@@ -86,7 +86,7 @@ static public Scope parseAST(final String code) {
8686 final mod m = ParserFacade .parse (code , CompileMode .exec , "<none>" , new CompilerFlags ());
8787 return parseNode (m .getChildren (), null , null );
8888 } catch (Throwable t ) {
89- if ( JythonAutocompletionProvider . debug >= 2 ) t . printStackTrace ( );
89+ JythonDev . printError ( t );
9090 return new Scope (null );
9191 }
9292 }
@@ -110,7 +110,7 @@ static public Scope parseNode(final List<PythonTree> children, final Scope paren
110110 static public void parseNode (final Scope scope , final List <PythonTree > children , final String className ) {
111111
112112 for (final PythonTree child : children ) {
113- print (child .getClass ());
113+ JythonDev . printTrace (child .getClass ());
114114
115115 if (child instanceof ImportFrom )
116116 scope .imports .putAll (parseImportFromStatement ( (ImportFrom )child ));
@@ -129,15 +129,15 @@ else if (child instanceof If || child instanceof For || child instanceof While
129129 // no new scope in if/for/while/with/try/ statements in python
130130 parseNode (scope , child .getChildren (), null );
131131 else
132- print ("IGNORING child: " + child + " -- " + (null != child .getChildren () ?
132+ JythonDev . printTrace ("IGNORING child: " + child + " -- " + (null != child .getChildren () ?
133133 String .join ("::" , child .getChildren ().stream ().map (c -> c .toString ()).collect (Collectors .toList ()))
134134 : "" ));
135135 }
136136 }
137137
138138 static public void parseExpr (final Expr child , final Scope scope ) {
139139 // child.getText() shows child is the base
140- print ("Expr: " + child .getText () + ", " + child .getInternalValue () + ", " + child .getValue () + ", children: " + String .join (", " , child .getChildren ().stream ().map (PythonTree ::toString ).collect (Collectors .toList ())));
140+ JythonDev . printTrace ("Expr: " + child .getText () + ", " + child .getInternalValue () + ", " + child .getValue () + ", children: " + String .join (", " , child .getChildren ().stream ().map (PythonTree ::toString ).collect (Collectors .toList ())));
141141 }
142142
143143 /**
@@ -169,7 +169,7 @@ static public Map<String, DotAutocompletions> parseImportStatement(final Import
169169 }
170170
171171 static private DotAutocompletions maybeStaticToDot (final PythonTree node , final DotAutocompletions da ) {
172- print ("children count:" + node .getChildCount () + ", children: " + (null != node .getChildren () ? node .getChildren ().stream ().map (c -> c .toString ()).collect (Collectors .toList ()) : "" ));
172+ JythonDev . printTrace ("children count:" + node .getChildCount () + ", children: " + (null != node .getChildren () ? node .getChildren ().stream ().map (c -> c .toString ()).collect (Collectors .toList ()) : "" ));
173173 if (node .getChildCount () > 0 && da instanceof StaticDotAutocompletions ) {
174174 // It's a right expression (a constructor invocation assigned to a variable on the left) so the left is an instance of the class
175175 return new VarDotAutocompletions (da .getClassname ());
@@ -196,7 +196,7 @@ static public Map<String, DotAutocompletions> parseAssignStatement(final Assign
196196 for (int i =0 ; i <right .getChildren ().size (); ++i ) {
197197 final CommonTree ct = left .getChildren ().get (i ).getNode ();
198198 if (null == ct ) {
199- print ("null for left: '" + left + "'" + " at child node " + i );
199+ JythonDev . printTrace ("null for left: '" + left + "'" + " at child node " + i );
200200 continue ;
201201 }
202202 final String name = ct .toString ();
@@ -303,7 +303,7 @@ static public void parseClassDef(final ClassDef c, final Scope parent) {
303303 for (final expr e : c .getInternalBases ()) {
304304 final DotAutocompletions da = parent .find (e .getText (), null );
305305 if (null == da || null == da .getClassname ())
306- print ("Could not find completions and className for " + e .getText ());
306+ JythonDev . print ("Could not find completions and className for " + e .getText ());
307307 else
308308 superclassNames .add (da .getClassname ());
309309 }
@@ -376,15 +376,15 @@ static public DotAutocompletions parseRight(final PyObject right, final Scope sc
376376 return new VarDotAutocompletions (m .getReturnType ().getName ());
377377 return new VarDotAutocompletions (c .getField (name ).getType ().getName ());
378378 } catch (Exception e ) {
379- print ("Could not find method or field " + name + " in class " + className );
379+ JythonDev . print ("Could not find method or field " + name + " in class " + className , e );
380380 }
381381 // Could also be a python module, e.g. attempting to autocomplete "os.path."
382382 try {
383383 final NModuleType module = Scope .indexer .loadModule (className + "." + name ); // overly expensive: any way to check it exists without loading it?
384384 if (null != module )
385385 return new StaticDotAutocompletions (className + "." + name );
386386 } catch (Exception e ) {
387- print ("Not a python module: " + className + "." + name );
387+ JythonDev . printTrace ("Not a python module: " + className + "." + name );
388388 }
389389 }
390390 if (right instanceof Call ) {
@@ -398,10 +398,8 @@ static public DotAutocompletions parseRight(final PyObject right, final Scope sc
398398 return parseRight (yield .getValue (), scope );
399399 }
400400
401+ JythonDev .printTrace ("Unsupported 'right' is: " + right + " " + (right != null ? right .getClass () : "" ));
402+
401403 return DotAutocompletions .EMPTY ;
402404 }
403-
404- static public final void print (Object s ) {
405- if (JythonAutocompletionProvider .debug >= 2 ) System .out .println (s );
406- }
407405}
0 commit comments