[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/model ModelUtils.java,1.5,1.6 Scope.java,1.
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2004-05-21 18:35:40
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19268/src/org/python/pydev/editor/model Modified Files: ModelUtils.java Scope.java Log Message: Sometimes class definitions where not being gotten. Index: Scope.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/Scope.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Scope.java 5 May 2004 02:05:08 -0000 1.5 --- Scope.java 21 May 2004 18:35:30 -0000 1.6 *************** *** 11,14 **** --- 11,15 ---- import java.util.Iterator; + import org.eclipse.core.runtime.IPath; import org.python.pydev.plugin.PydevPrefs; *************** *** 72,75 **** --- 73,77 ---- } + void addFunctionDefinition(FunctionNode newDef) { if (functions == null) *************** *** 120,136 **** public ArrayList findFunctionCalls(Object token, boolean recursive, Comparator c) { ArrayList retVal = new ArrayList(); ! // traverse our definitions ! if (functions != null) { ! Iterator i = functions.iterator(); ! while (i.hasNext()) { ! Object item = i.next(); ! if (c.compare(token, item) == 0) ! retVal.add(item); } } ! if (start != null && start instanceof ClassNode && c.compare(token, start) == 0) ! // class name can also be a function call ! retVal.add(start); ! // now traverse parents ArrayList ancestors = null; if (recursive) --- 122,143 ---- public ArrayList findFunctionCalls(Object token, boolean recursive, Comparator c) { ArrayList retVal = new ArrayList(); ! ! if (start != null){ ! if (start instanceof ClassNode && c.compare(token, start) == 0){ ! ! // class name can also be a function call ! retVal.add(start); ! // now traverse parents ! } ! for( Iterator itChildren = start.children.iterator(); itChildren.hasNext();){ ! Object item = itChildren.next(); ! if(item instanceof FunctionNode || item instanceof ClassNode){ ! if (c.compare(token, item) == 0){ ! retVal.add(item); ! } ! } } } ! ArrayList ancestors = null; if (recursive) *************** *** 184,186 **** --- 191,194 ---- return parent != null ? parent.findContainingClass() : null; } + } Index: ModelUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ModelUtils.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModelUtils.java 5 May 2004 02:05:08 -0000 1.5 --- ModelUtils.java 21 May 2004 18:35:30 -0000 1.6 *************** *** 196,210 **** // ex: simpleCall() if (node instanceof LocalNode && ! node.getParent() instanceof FunctionCallNode) { ! ArrayList funcCalls = node.getScope().findFunctionCalls(node.getName(), true, ! new Comparator() { ! public int compare(Object token, Object funcCall) { ! return ((String)token).compareTo(((AbstractNode)funcCall).getName()); ! } ! }); for (Iterator i = funcCalls.iterator(); i.hasNext();) { AbstractNode funcNode = (AbstractNode)i.next(); retVal.add(new ItemPointer(funcNode.getPath(), funcNode.getStart(), funcNode.getEnd())); } } else if (node instanceof ImportAlias || node instanceof ImportFromNode) { // imports: --- 196,221 ---- // ex: simpleCall() if (node instanceof LocalNode && ! node.getParent() instanceof FunctionCallNode) { ! ! //here we go for function calls... that is run(), Test() ! //Note: this can be functions or Class definitions. ! Comparator c = new Comparator() { ! public int compare(Object token, Object funcCall) { ! return ((String)token).compareTo(((AbstractNode)funcCall).getName()); ! } ! }; ! ! ! ArrayList funcCalls = new ArrayList(); ! funcCalls = node.getScope().findFunctionCalls(node.getName(), true, c ); ! ! for (Iterator i = funcCalls.iterator(); i.hasNext();) { AbstractNode funcNode = (AbstractNode)i.next(); retVal.add(new ItemPointer(funcNode.getPath(), funcNode.getStart(), funcNode.getEnd())); } + + + } else if (node instanceof ImportAlias || node instanceof ImportFromNode) { // imports: |