\r
- listener: if too many things popped off the stack, complain\r
- gracefully handle non-working cfactor\r
-- don't show listener on certain commands\r
- NPE in ErrorHighlight\r
- some way to not have previous definitions from a source file\r
clutter the namespace\r
objects\r
- worddef props\r
- prettyprint: when unparse called due to recursion, write a link\r
-- prettyprinter should output {{ ... }} syntax for hashtables\r
- FORGET: and forget\r
\r
+ httpd:\r
} //}}}
//{{{ getCompletions() method
- public void getCompletions(String vocab, String word, List completions,
+ public void getCompletions(String vocab, String word, Set completions,
boolean anywhere)
{
super.getCompletions(vocab,word,completions,anywhere);
while(moreCompletions != null)
{
Cons completion = (Cons)moreCompletions.car;
- completions.add(searchVocabulary(completion.next(),
- (String)completion.car));
+ FactorWord w = searchVocabulary(completion.next(),
+ (String)completion.car);
+ if(w != null)
+ completions.add(w);
moreCompletions = moreCompletions.next();
}
}
//{{{ updateList() method
private void updateList()
{
- List completions = FactorPlugin.getCompletions(
- field.getText(),true);
- FactorWord[] completionArray
- = (FactorWord[])completions.toArray(
- new FactorWord[completions.size()]);
- list.setListData(completionArray);
- if(completionArray.length != 0)
+ FactorWord[] completions = FactorPlugin.toWordArray(
+ FactorPlugin.getCompletions(
+ field.getText(),true));
+ list.setListData(completions);
+ if(completions.length != 0)
{
list.setSelectedIndex(0);
list.ensureIndexIsVisible(0);
private FactorParsedData data;
//{{{ FactorCompletion constructor
- public FactorCompletion(View view, List items,
+ public FactorCompletion(View view, FactorWord[] items,
String word, FactorParsedData data)
{
this.view = view;
textArea = view.getTextArea();
- this.items = items;
+ this.items = Arrays.asList(items);
this.word = word;
this.data = data;
} //}}}
evalInWire(word + " " + op);
} //}}}
+ //{{{ toWordArray() method
+ public static FactorWord[] toWordArray(Set completions)
+ {
+ FactorWord[] w = (FactorWord[])completions.toArray(new FactorWord[
+ completions.size()]);
+ Arrays.sort(w,new MiscUtilities.StringICaseCompare());
+
+ return w;
+ } //}}}
+
//{{{ getCompletions() method
/**
* Returns all words in all vocabularies.
* @param anywhere If true, matches anywhere in the word name are
* returned; otherwise, only matches from beginning.
*/
- public static List getCompletions(String word, boolean anywhere)
+ public static Set getCompletions(String word, boolean anywhere)
{
try
{
* @param anywhere If true, matches anywhere in the word name are
* returned; otherwise, only matches from beginning.
*/
- public static List getCompletions(Cons use, String word, boolean anywhere)
+ public static Set getCompletions(Cons use, String word, boolean anywhere)
{
try
{
- List completions = new ArrayList();
+ Set completions = new HashSet();
while(use != null)
{
vocab,word,completions,anywhere);
use = use.next();
}
-
- Collections.sort(completions,
- new MiscUtilities.StringICaseCompare());
-
+
return completions;
}
catch(Exception e)
if(word.length() == 0)
return null;
- List completions = FactorPlugin.getCompletions(
- data.use,word,false);
+ FactorWord[] completions = FactorPlugin.toWordArray(
+ FactorPlugin.getCompletions(
+ data.use,word,false));
- if(completions.size() == 0)
+ if(completions.length == 0)
return null;
else
{
USE: lists
USE: math
USE: namespaces
-USE: prettyprint
USE: stack
USE: stdio
USE: strings
USE: unparser
USE: vectors
USE: words
+USE: hashtables
: tab-size
#! Change this to suit your tastes.
] unless ;
: prettyprint-[ ( indent -- indent )
- "[" write <prettyprint ;
+ \ [ prettyprint-word <prettyprint ;
: prettyprint-] ( indent -- indent )
- prettyprint> "]" write ;
+ prettyprint> \ ] prettyprint-word ;
: prettyprint-list ( indent list -- indent )
#! Pretty-print a list, without [ and ].
swap prettyprint-[ swap prettyprint-list prettyprint-] ;
: prettyprint-{ ( indent -- indent )
- "{" write <prettyprint ;
+ \ { prettyprint-word <prettyprint ;
: prettyprint-} ( indent -- indent )
- prettyprint> "}" write ;
+ prettyprint> \ } prettyprint-word ;
: prettyprint-vector ( indent list -- indent )
#! Pretty-print a vector, without { and }.
: prettyprint-{} ( indent vector -- indent )
dup vector-length 0 = [
- drop "{ }" write
+ drop prettyprint-{ prettyprint-}
] [
swap prettyprint-{ swap prettyprint-vector prettyprint-}
] ifte ;
+: prettyprint-{{ ( indent -- indent )
+ \ {{ prettyprint-word <prettyprint ;
+
+: prettyprint-}} ( indent -- indent )
+ prettyprint> \ }} prettyprint-word ;
+
+: prettyprint-{{}} ( indent hashtable -- indent )
+ hash>alist dup length 0 = [
+ drop prettyprint-{{ prettyprint-}}
+ ] [
+ swap prettyprint-{{ swap prettyprint-list prettyprint-}}
+ ] ifte ;
+
: trim-newline ( str -- str )
dup ends-with-newline? dup [ nip ] [ drop ] ifte ;
unparse write
] [
[
- [ f = ] [ prettyprint-object ]
- [ cons? ] [ prettyprint-[] ]
- [ vector? ] [ prettyprint-{} ]
- [ word? ] [ prettyprint-word ]
- [ drop t ] [ prettyprint-object ]
+ [ f = ] [ prettyprint-object ]
+ [ cons? ] [ prettyprint-[] ]
+ [ hashtable? ] [ prettyprint-{{}} ]
+ [ vector? ] [ prettyprint-{} ]
+ [ word? ] [ prettyprint-word ]
+ [ drop t ] [ prettyprint-object ]
] cond
] ifte ;
USE: namespaces
USE: stack
USE: test
+USE: lists
[ f ] [ [ ] [ ] catch ] unit-test
global [ "error" get ] bind
"Hello" =
] unit-test
+
+[ ] [ [ ] print-error ] unit-test
+[ ] [ [ 2 car ] print-error ] unit-test
: print-error ( quot -- )
#! Execute a quotation, and if it throws an error, print it
#! and return to the caller.
- [ [ default-error-handler drop ] when* ] catch ;
+ [ [ default-error-handler ] when* ] catch ;