1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

RESOLVED - bug 152846: ASTVisitor enhancement to enable bottom-up traversal

https://bugs.eclipse.org/bugs/show_bug.cgi?id=152846

Patch by Beth Tibbits
This commit is contained in:
Chris Recoskie 2007-01-23 16:06:41 +00:00
parent 98261e8d92
commit 45ba2b1b34
26 changed files with 41 additions and 32 deletions

View file

@ -39,6 +39,7 @@ public abstract class CASTVisitor extends ASTVisitor {
public int visit(ICASTDesignator designator) {
return PROCESS_CONTINUE;
}
/**
* Function to override if you wish to visit designators in your
* implementation: this does a bottom-up traversal.

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others.
* Copyright (c) 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -94,7 +94,7 @@ public class CASTFunctionDefinition extends CASTNode implements
if( declSpecifier != null ) if( !declSpecifier.accept( action ) ) return false;
if( declarator != null ) if( !declarator.accept( action ) ) return false;
if( bodyStatement != null ) if( !bodyStatement.accept( action ) ) return false;
//BRT is this an omission in original?
if( action.shouldVisitDeclarations ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -133,7 +133,7 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
IASTDeclaration [] decls = getMembers();
for( int i = 0; i < decls.length; i++ )
if( !decls[i].accept( action ) ) return false;
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -126,7 +126,7 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
}
if( nestedDeclarator != null ) if( !nestedDeclarator.accept( action ) ) return false;
if( action.shouldVisitDeclarators ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
@ -134,7 +134,7 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
default : break;
}
}
return postAccept( action );
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -81,9 +81,12 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default: break;
case ASTVisitor.PROCESS_ABORT:
return false;
case ASTVisitor.PROCESS_SKIP:
return true;
default:
break;
}
}
if (name != null)
@ -93,8 +96,8 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
for (int i = 0; i < enums.length; i++)
if (!enums[i].accept(action))
return false;
if( action.shouldVisitDeclSpecifiers ){
if( action.shouldVisitDeclSpecifiers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;

View file

@ -54,6 +54,7 @@ public class CPPASTInitializerList extends CPPASTNode implements
for ( int i = 0; i < list.length; i++ ) {
if( !list[i].accept( action ) ) return false;
}
if( action.shouldVisitInitializers ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;

View file

@ -118,6 +118,7 @@ public class CPPASTName extends CPPASTNode implements IASTName {
}
}
if (action.shouldVisitNames) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT:

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2007 IBM Corporation and others.
* Copyright (c) 2004, 20057 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at

View file

@ -85,9 +85,9 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
if( name != null ) if( !name.accept( action ) ) return false;
IASTDeclaration [] decls = getDeclarations();
for ( int i = 0; i < decls.length; i++ )
if( !decls[i].accept( action ) ) return false;
if( action instanceof CPPASTVisitor &&
if( !decls[i].accept( action ) ) return false;
if( action instanceof CPPASTVisitor &&
((CPPASTVisitor)action).shouldVisitNamespaces ){
switch( ((CPPASTVisitor)action).leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
@ -95,6 +95,7 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements
default : break;
}
}
return true;
}

View file

@ -185,6 +185,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements
} else if (!names[i].accept(action))
return false;
}
if (action.shouldVisitNames) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT:
@ -195,6 +196,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements
break;
}
}
return true;
}