2
* Created on Jun 10, 2006
5
package org.python.pydev.parser.visitors.scope;
7
import java.util.ArrayList;
9
public class EasyASTIteratorWithChildrenVisitor extends EasyAstIteratorBase{
12
* Overriden because we deal only with the nodes with children in this iterator
14
* @see org.python.pydev.parser.visitors.scope.EasyAstIteratorBase#createEntry()
17
protected ASTEntry createEntry() {
19
if(parents.size() > 0){
20
entry = new ASTEntryWithChildren((ASTEntryWithChildren) parents.peek());
22
entry = new ASTEntryWithChildren(null);
28
* This implementation only adds it to the flattened list (nodes) if there is no parent.
29
* Otherwise (if there is a parent), this implementation will add it to the parents children.
31
* @see org.python.pydev.parser.visitors.scope.EasyAstIteratorBase#doAddNode(org.python.pydev.parser.visitors.scope.ASTEntry)
34
protected void doAddNode(ASTEntry entry) {
35
if(entry.parent == null){
36
super.doAddNode(entry);
38
ASTEntryWithChildren parent = (ASTEntryWithChildren)entry.parent;
39
if(parent.children == null){
40
parent.children = new ArrayList<ASTEntryWithChildren>();
42
parent.children.add((ASTEntryWithChildren) entry);