Skip to content

Commit 7f00a1a

Browse files
committed
Add Str (literal string) as a knonw type, so that it appears as so in parsed vars
rather than the latter appearing as an empty.
1 parent eab3fa0 commit 7f00a1a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/scijava/plugins/scripteditor/jython/JythonScriptParser.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.python.antlr.ast.Name;
5252
import org.python.antlr.ast.Num;
5353
import org.python.antlr.ast.Return;
54+
import org.python.antlr.ast.Str;
5455
import org.python.antlr.ast.TryExcept;
5556
import org.python.antlr.ast.TryFinally;
5657
import org.python.antlr.ast.Tuple;
@@ -352,9 +353,13 @@ static public DotAutocompletions parseRight(final PyObject right, final Scope sc
352353
if (right instanceof Num) {
353354
// e.g. return 10
354355
// e.g. n = 42
355-
final Class<?> c = ((Num)right).getInternalN().getClass() == PyInteger.class ? Long.TYPE : Double.TYPE;
356+
final Class<?> c = ((Num)right).getInternalN().getClass() == PyInteger.class ? Long.TYPE : Double.TYPE; // TODO this creates trouble for Scope.findVarsByType and would be perhaps easier as Long and Double (non-primitive).
356357
return new VarDotAutocompletions(c.toString());
357358
}
359+
if (right instanceof Str) {
360+
// Literal String
361+
return new VarDotAutocompletions(String.class.getCanonicalName());
362+
}
358363
if (right instanceof Attribute) {
359364
// e.g. a field or a method
360365
// gray8 = IJ.getImage().GRAY8

0 commit comments

Comments
 (0)