Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30535/src/org/python/pydev/parser/visitors/scope
Modified Files:
OutlineCreatorVisitor.java EasyAstIteratorBase.java
Log Message:
Index: EasyAstIteratorBase.java
===================================================================
RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope/EasyAstIteratorBase.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** EasyAstIteratorBase.java 27 Jan 2007 14:18:48 -0000 1.18
--- EasyAstIteratorBase.java 19 Jun 2007 00:30:43 -0000 1.19
***************
*** 23,27 ****
public abstract class EasyAstIteratorBase extends VisitorBase{
! private List<ASTEntry> nodes = new ArrayList<ASTEntry>();
protected final FastStack<SimpleNode> stack = new FastStack<SimpleNode>();
--- 23,27 ----
public abstract class EasyAstIteratorBase extends VisitorBase{
! protected List<ASTEntry> nodes = new ArrayList<ASTEntry>();
protected final FastStack<SimpleNode> stack = new FastStack<SimpleNode>();
Index: OutlineCreatorVisitor.java
===================================================================
RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope/OutlineCreatorVisitor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** OutlineCreatorVisitor.java 11 Jun 2006 20:04:00 -0000 1.2
--- OutlineCreatorVisitor.java 19 Jun 2007 00:30:43 -0000 1.3
***************
*** 16,19 ****
--- 16,20 ----
public class OutlineCreatorVisitor extends EasyASTIteratorWithChildrenVisitor{
+
public static OutlineCreatorVisitor create(SimpleNode ast) {
OutlineCreatorVisitor visitor = new OutlineCreatorVisitor();
***************
*** 77,81 ****
}
!
@Override
protected void doAddNode(ASTEntry entry) {
--- 78,83 ----
}
!
!
@Override
protected void doAddNode(ASTEntry entry) {
***************
*** 86,89 ****
--- 88,125 ----
if(type.beginColumn == 1){
entry.parent = null; //top-level
+ }else{
+
+ //try to match it to some other indentation already set.
+ ASTEntryWithChildren lastAdded = null;
+ if(nodes != null && nodes.size() > 0){
+ lastAdded = (ASTEntryWithChildren) nodes.get(nodes.size()-1);
+ }
+
+ while(lastAdded != null){
+ if(lastAdded.node == null){
+ break;
+ }
+
+ //if it is equal to the indentation of this node, it's parent is the same, if it is higher
+ //it is a child or a child's child...
+ if(lastAdded.node.beginColumn == node.beginColumn){
+ entry.parent = lastAdded.parent;
+ break;
+
+ }else if(node.beginColumn > lastAdded.node.beginColumn ){
+ //it's higher, so, check the last children of lastAdded for a possible parent...
+ entry.parent = lastAdded;
+ List<ASTEntryWithChildren> children = lastAdded.children;
+ if(children != null && children.size() > 0){
+ lastAdded = children.get(children.size()-1);
+ }else{
+ break;
+ }
+
+ }else{
+ //it's less, so, the parent is already set...
+ break;
+ }
+ }
}
}
***************
*** 99,103 ****
if(object instanceof commentType){
commentType type = (commentType) object;
! if(type.id.trim().startsWith("#---")){
atomic(type);
}
--- 135,141 ----
if(object instanceof commentType){
commentType type = (commentType) object;
! String trimmed = type.id.trim();
!
! if(trimmed.startsWith("#---") || trimmed.endsWith("---")){
atomic(type);
}
|