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