plugin fixes
parent
790b6132a3
commit
5b26116784
|
@ -37,14 +37,9 @@
|
|||
+ listener/plugin:
|
||||
|
||||
- faster completion
|
||||
- word added >1 if external instance dies
|
||||
- sidekick: still parsing too much
|
||||
- errors don't always disappear
|
||||
- console: wrong history
|
||||
- listener: if too many things popped off the stack, complain
|
||||
- NPE in ErrorHighlight
|
||||
- some way to not have previous definitions from a source file
|
||||
clutter the namespace
|
||||
- maple-like: press enter at old commands to evaluate there
|
||||
- completion in the listener
|
||||
- special completion for USE:/IN:
|
||||
|
|
|
@ -188,6 +188,14 @@ public class DefaultVocabularyLookup implements VocabularyLookup
|
|||
}
|
||||
} //}}}
|
||||
|
||||
//{{{ forget() method
|
||||
public void forget(FactorWord word)
|
||||
{
|
||||
Map vocab = (Map)vocabularies.get(word.vocabulary);
|
||||
if(vocab != null)
|
||||
vocab.remove(word.name);
|
||||
} //}}}
|
||||
|
||||
//{{{ getVocabularies() method
|
||||
public Cons getVocabularies()
|
||||
{
|
||||
|
|
|
@ -185,34 +185,34 @@ public class ExternalFactor extends DefaultVocabularyLookup
|
|||
public synchronized FactorWord searchVocabulary(Cons vocabulary, String name)
|
||||
{
|
||||
FactorWord w = super.searchVocabulary(vocabulary,name);
|
||||
|
||||
if(w != null)
|
||||
return w;
|
||||
|
||||
if(closed)
|
||||
return define("#<unknown>",name);
|
||||
|
||||
try
|
||||
{
|
||||
if(!closed)
|
||||
{
|
||||
Cons result = parseObject(eval(FactorReader.unparseObject(name)
|
||||
+ " "
|
||||
+ FactorReader.unparseObject(vocabulary)
|
||||
+ " jedit-lookup ."));
|
||||
if(result.car == null)
|
||||
return null;
|
||||
|
||||
result = (Cons)result.car;
|
||||
w = new FactorWord(
|
||||
(String)result.car,
|
||||
(String)result.next().car);
|
||||
w.stackEffect = (String)result.next().next().car;
|
||||
return w;
|
||||
}
|
||||
Cons result = parseObject(eval(FactorReader.unparseObject(name)
|
||||
+ " "
|
||||
+ FactorReader.unparseObject(vocabulary)
|
||||
+ " jedit-lookup ."));
|
||||
if(result.car == null)
|
||||
return null;
|
||||
|
||||
result = (Cons)result.car;
|
||||
w = new FactorWord(
|
||||
(String)result.car,
|
||||
(String)result.next().car);
|
||||
w.stackEffect = (String)result.next().next().car;
|
||||
return w;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.log(Log.ERROR,this,e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new FactorWord("unknown",name);
|
||||
} //}}}
|
||||
|
||||
//{{{ getCompletions() method
|
||||
|
|
|
@ -36,9 +36,12 @@ public interface VocabularyLookup
|
|||
{
|
||||
public FactorWord define(String in, String word)
|
||||
throws Exception;
|
||||
|
||||
public FactorWord searchVocabulary(Cons use, String word)
|
||||
throws Exception;
|
||||
|
||||
public void forget(FactorWord word);
|
||||
|
||||
/**
|
||||
* @param vocab The vocabulary name
|
||||
* @param word A substring of the word name to complete
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FactorParsedData extends SideKickParsedData
|
|||
public FactorSideKickParser parser;
|
||||
public String in;
|
||||
public Cons use;
|
||||
|
||||
|
||||
FactorParsedData(FactorSideKickParser parser, String fileName)
|
||||
{
|
||||
super(fileName);
|
||||
|
|
|
@ -40,14 +40,12 @@ import sidekick.*;
|
|||
|
||||
public class FactorSideKickParser extends SideKickParser
|
||||
{
|
||||
private Map previewMap;
|
||||
|
||||
/**
|
||||
* When we parse a file, we store the <word,worddef> pairs in this
|
||||
* map, so that completion popups show the latest stack effects,
|
||||
* and not whatever they were the last time the source was run-file'd.
|
||||
* We store the file's parse tree in this property.
|
||||
*/
|
||||
private Map worddefs;
|
||||
public static String PARSED_PROPERTY = "factor-parsed";
|
||||
|
||||
private Map previewMap;
|
||||
|
||||
//{{{ FactorSideKickParser constructor
|
||||
public FactorSideKickParser()
|
||||
|
@ -100,6 +98,9 @@ public class FactorSideKickParser extends SideKickParser
|
|||
public SideKickParsedData parse(Buffer buffer,
|
||||
DefaultErrorSource errorSource)
|
||||
{
|
||||
Cons parsed = (Cons)buffer.getProperty(PARSED_PROPERTY);
|
||||
removeWordDefinitions(parsed);
|
||||
|
||||
FactorParsedData d = new FactorParsedData(
|
||||
this,buffer.getPath());
|
||||
|
||||
|
@ -126,12 +127,14 @@ public class FactorSideKickParser extends SideKickParser
|
|||
errorSource);
|
||||
FactorReader r = new FactorReader(scanner,
|
||||
false,FactorPlugin.getExternalInstance());
|
||||
|
||||
Cons parsed = r.parse();
|
||||
|
||||
|
||||
parsed = r.parse();
|
||||
|
||||
d.in = r.getIn();
|
||||
d.use = r.getUse();
|
||||
|
||||
buffer.setProperty(PARSED_PROPERTY,parsed);
|
||||
|
||||
addWordDefNodes(d,parsed,buffer);
|
||||
}
|
||||
catch(FactorParseException pe)
|
||||
|
@ -151,9 +154,23 @@ public class FactorSideKickParser extends SideKickParser
|
|||
return d;
|
||||
} //}}}
|
||||
|
||||
//{{{ removeWordDefinitions() method
|
||||
private void removeWordDefinitions(Cons parsed)
|
||||
{
|
||||
while(parsed != null)
|
||||
{
|
||||
Object obj = parsed.car;
|
||||
if(obj instanceof FactorWordDefinition)
|
||||
{
|
||||
FactorPlugin.getExternalInstance().forget(
|
||||
((FactorWordDefinition)obj).word);
|
||||
}
|
||||
parsed = parsed.next();
|
||||
}
|
||||
} //}}}
|
||||
|
||||
//{{{ addWordDefNodes() method
|
||||
private void addWordDefNodes(SideKickParsedData d, Cons parsed,
|
||||
Buffer buffer)
|
||||
private void addWordDefNodes(FactorParsedData d, Cons parsed, Buffer buffer)
|
||||
{
|
||||
FactorAsset last = null;
|
||||
|
||||
|
@ -171,10 +188,8 @@ public class FactorSideKickParser extends SideKickParser
|
|||
int startLine = Math.min(
|
||||
buffer.getLineCount() - 1,
|
||||
word.line - 1);
|
||||
int startLineLength = buffer.getLineLength(
|
||||
startLine);
|
||||
int startCol = Math.min(word.col,
|
||||
startLineLength);
|
||||
int startLineLength = buffer.getLineLength(startLine);
|
||||
int startCol = Math.min(word.col,startLineLength);
|
||||
|
||||
int start = buffer.getLineStartOffset(startLine)
|
||||
+ startCol;
|
||||
|
|
|
@ -40,6 +40,9 @@ USE: math-internals
|
|||
|
||||
! A simple single-dispatch generic word system.
|
||||
|
||||
! "if I say I'd rather eat cheese than shit... doesn't mean
|
||||
! those are the only two things I can eat." - Tac
|
||||
|
||||
: predicate-word ( word -- word )
|
||||
word-name "?" cat2 "in" get create ;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ USE: kernel
|
|||
USE: math
|
||||
USE: math-internals
|
||||
|
||||
: >rect ( x -- xr xi ) dup real swap imaginary ;
|
||||
: >rect ( x -- xr xi ) dup real swap imaginary ; inline
|
||||
|
||||
: conjugate ( z -- z* )
|
||||
>rect neg rect> ;
|
||||
|
@ -53,7 +53,7 @@ IN: math-internals
|
|||
|
||||
: 2>rect ( x y -- xr yr xi yi )
|
||||
[ swap real swap real ] 2keep
|
||||
swap imaginary swap imaginary ;
|
||||
swap imaginary swap imaginary ; inline
|
||||
|
||||
M: complex number= ( x y -- ? )
|
||||
2>rect number= [ number= ] [ 2drop f ] ifte ;
|
||||
|
|
|
@ -62,7 +62,7 @@ global [
|
|||
: (read-multiline) ( quot depth -- quot ? )
|
||||
#! Flag indicates EOF.
|
||||
>r read dup [
|
||||
(parse) depth r> dup >r = [
|
||||
(parse) depth r> dup >r <= [
|
||||
( we're done ) r> drop t
|
||||
] [
|
||||
( more input needed ) r> cont-prompt get prompt.
|
||||
|
|
Loading…
Reference in New Issue