File tree Expand file tree Collapse file tree
src/main/java/org/scijava/plugins/scripteditor/jython Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -196,6 +196,31 @@ public List<String> findStartsWith(final String name) {
196196 return completions ;
197197 }
198198
199+ /** Return a table of names vs classnames, with classnames being null for python builtins.
200+ *
201+ * @param name
202+ * @return
203+ */
204+ public Map <String , String > findStartsWith2 (final String name ) {
205+ final Map <String , String > completions = new HashMap <>();
206+ Scope scope = this ;
207+ while (null != scope ) {
208+ for (final Map .Entry <String , DotAutocompletions > e : scope .vars .entrySet ()) {
209+ if (e .getKey ().startsWith (name )) completions .put (e .getKey (), e .getValue ().getClassname ());
210+ }
211+ for (final Map .Entry <String , DotAutocompletions > e : scope .imports .entrySet ()) {
212+ if (e .getKey ().startsWith (name )) completions .put (e .getKey (), e .getValue ().getClassname ());
213+ }
214+ for (String builtinName : indexer .getBindings ().keySet ()) {
215+ if (builtinName .startsWith ("__builtin__." ))
216+ builtinName = builtinName .substring (12 ); // without the "__builtin__." prefix
217+ if (builtinName .startsWith (name )) completions .put (builtinName , null );
218+ }
219+ scope = scope .parent ;
220+ }
221+ return completions ;
222+ }
223+
199224
200225 /** Find vars by type, recursively upstream the nested scopes, listing first those of the innermost scope.
201226 *
You can’t perform that action at this time.
0 commit comments