From a4513baa305ef32348e8588bb6d4f0221780d1d2 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Thu, 28 Feb 2008 16:43:33 +0000 Subject: Introduce interfaces for c- and c++ specific visitors to allow for visitors that work for both c- and c++. --- .../org/eclipse/cdt/core/dom/ast/ASTVisitor.java | 110 ++++++++++++++------- .../eclipse/cdt/core/dom/ast/c/CASTVisitor.java | 33 ++----- .../eclipse/cdt/core/dom/ast/c/ICASTVisitor.java | 33 +++++++ .../cdt/core/dom/ast/cpp/CPPASTVisitor.java | 85 +++++----------- .../cdt/core/dom/ast/cpp/ICPPASTVisitor.java | 57 +++++++++++ .../core/dom/parser/c/CASTArrayDesignator.java | 20 ++-- .../dom/parser/c/CASTArrayRangeDesignator.java | 20 ++-- .../core/dom/parser/c/CASTFieldDesignator.java | 20 ++-- .../core/dom/parser/cpp/CPPASTBaseSpecifier.java | 22 ++--- .../dom/parser/cpp/CPPASTNamespaceDefinition.java | 21 ++-- .../cpp/CPPASTSimpleTypeTemplateParameter.java | 28 +++--- .../cpp/CPPASTTemplatedTypeTemplateParameter.java | 29 +++--- 12 files changed, 279 insertions(+), 199 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTVisitor.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisitor.java (limited to 'core/org.eclipse.cdt.core/parser') diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java index 5ede1617801..b4608b97e22 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTVisitor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 @@ -8,67 +8,113 @@ * Contributors: * IBM Corporation - initial API and implementation * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Mar 8, 2005 - */ package org.eclipse.cdt.core.dom.ast; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; +import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; /** - * Visitor allows traversal of AST.
+ * Abstract base class for all visitors to traverse ast nodes.
* visit() methods implement a top-down traversal, and
- * leave() methods implement a bottom-up traversal. - * + * leave() methods implement a bottom-up traversal.
+ * + * To visit c- or c++-specific nodes you need to implement {@link ICASTVisitor} + * and/or {@link ICPPASTVisitor} in addition to deriving from this class. */ public abstract class ASTVisitor { - /** - * These values should be overriden in the implementation subclass. + * Set this flag to visit names. */ public boolean shouldVisitNames = false; - + /** + * Set this flag to visit declarations. + */ public boolean shouldVisitDeclarations = false; - + /** + * Set this flag to visit initializers. + */ public boolean shouldVisitInitializers = false; - + /** + * Set this flag to visit parameter declarations. + */ public boolean shouldVisitParameterDeclarations = false; - + /** + * Set this flag to visit declarators. + */ public boolean shouldVisitDeclarators = false; - + /** + * Set this flag to visit declaration specifiers. + */ public boolean shouldVisitDeclSpecifiers = false; - + /** + * Set this flag to visit expressions. + */ public boolean shouldVisitExpressions = false; - + /** + * Set this flag to visit statements. + */ public boolean shouldVisitStatements = false; - + /** + * Set this flag to visit typeids. + */ public boolean shouldVisitTypeIds = false; - + /** + * Set this flag to visit enumerators. + */ public boolean shouldVisitEnumerators = false; - + /** + * Set this flag to visit translation units. + */ public boolean shouldVisitTranslationUnit = false; - + /** + * Set this flag to visit problem nodes. + */ public boolean shouldVisitProblems = false; - public boolean shouldVisitComments = false; + /** + * Set this flag to visit designators of initializers. + * Your visitor needs to implement {@link ICASTVisitor} to make this work. + */ + public boolean shouldVisitDesignators = false; /** - * @return continue to continue visiting, abort to stop, skip to not descend - * into this node. + * Set this flag to visit base specifiers off composite types. + * Your visitor needs to implement {@link ICPPASTVisitor} to make this work. + */ + public boolean shouldVisitBaseSpecifiers = false; + + /** + * Set this flag to visit to visit namespaces. + * Your visitor needs to implement {@link ICPPASTVisitor} to make this work. + */ + public boolean shouldVisitNamespaces = false; + + /** + * Set this flag to visit template parameters. + * Your visitor needs to implement {@link ICPPASTVisitor} to make this work. + */ + public boolean shouldVisitTemplateParameters = false; + + + /** + * Skip the traversal of children of this node, don't call leave on this node. */ public final static int PROCESS_SKIP = 1; + /** + * Abort the entire traversal. + */ public final static int PROCESS_ABORT = 2; - public final static int PROCESS_CONTINUE = 3; - /** - * - * visit methods - * + * Continue with traversing the children of this node. */ + public final static int PROCESS_CONTINUE = 3; + + // visit methods public int visit(IASTTranslationUnit tu) { return PROCESS_CONTINUE; } @@ -120,10 +166,8 @@ public abstract class ASTVisitor { public int visit( IASTComment comment){ return PROCESS_CONTINUE; } - - /** - * leave methods - implement a bottom-up traversal - */ + + // leave methods public int leave(IASTTranslationUnit tu) { return PROCESS_CONTINUE; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/CASTVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/CASTVisitor.java index d9f843b7542..e3a4ddd6f8f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/CASTVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/CASTVisitor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 @@ -8,43 +8,26 @@ * Contributors: * IBM Corporation - initial API and implementation * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Mar 8, 2005 - */ package org.eclipse.cdt.core.dom.ast.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; /** * This subclass of ASTVisitor that allows for better control in traversing C. - * - * @ref ASTVisitor - * @author jcamelon */ -public abstract class CASTVisitor extends ASTVisitor { - /** - * Override this value in your subclass if you do wish to visit designators. - */ - public boolean shouldVisitDesignators = false; +public abstract class CASTVisitor extends ASTVisitor implements ICASTVisitor { - /** - * Function to override if you wish to visit designators in your - * implementation. This does a top-down traversal. - * - * @param designator - * @return + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.c.ICASTVisitor#visit(org.eclipse.cdt.core.dom.ast.c.ICASTDesignator) */ 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. - * @param designator - * @return + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.c.ICASTVisitor#leave(org.eclipse.cdt.core.dom.ast.c.ICASTDesignator) */ public int leave(ICASTDesignator designator) { return PROCESS_CONTINUE; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTVisitor.java new file mode 100644 index 00000000000..47a334c0d1b --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/c/ICASTVisitor.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.c; + +import org.eclipse.cdt.core.dom.ast.ASTVisitor; + + +/** + * Interface for visitors to visit c-specific nodes. + * @since 5.0 + */ +public interface ICASTVisitor { + + /** + * Visits a designator. + * @return {@link ASTVisitor#PROCESS_CONTINUE}, {@link ASTVisitor#PROCESS_SKIP} or {@link ASTVisitor#PROCESS_ABORT} + */ + int visit(ICASTDesignator designator); + + /** + * Visits a designator. + * @return {@link ASTVisitor#PROCESS_CONTINUE} or {@link ASTVisitor#PROCESS_ABORT} + */ + int leave(ICASTDesignator designator); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/CPPASTVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/CPPASTVisitor.java index 58caee02671..95939af9ce2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/CPPASTVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/CPPASTVisitor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 @@ -7,11 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ - -/* - * Created on Mar 8, 2005 - */ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; @@ -21,86 +18,48 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas * C++ specific visitor class. *
The visit() methods implement a top-down traversal of the AST, * and the leave() methods implement a bottom-up traversal. - * - * @author jcamelon */ -public abstract class CPPASTVisitor extends ASTVisitor { +public abstract class CPPASTVisitor extends ASTVisitor implements ICPPASTVisitor { - /** - * Overide this value if you wish to visit base specifiers off composite - * types. + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier) */ - public boolean shouldVisitBaseSpecifiers = false; - - /** - * Overide this value if you wish to visit namespaces. - */ - public boolean shouldVisitNamespaces = false; - - /** - * Overide this value if you wish to visit template parameters. - */ - public boolean shouldVisitTemplateParameters = false; - - /** - * Visit BaseSpecifiers. - * - * @param specifier - * @return - */ - public int visit(ICPPASTBaseSpecifier specifier) { + public int visit(ICPPASTBaseSpecifier baseSpecifier) { return PROCESS_CONTINUE; } - /** - * Visit namespace definitions. - * - * @param namespace - * @return + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition) */ - public int visit(ICPPASTNamespaceDefinition namespace) { + public int visit(ICPPASTNamespaceDefinition namespaceDefinition) { return PROCESS_CONTINUE; } - /** - * Visit template parameter. - * - * @param parameter - * @return + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter) */ - public int visit(ICPPASTTemplateParameter parameter) { + public int visit(ICPPASTTemplateParameter templateParameter) { return PROCESS_CONTINUE; } - /** - * Visit BaseSpecifiers. - * Bottom-up traversal. - * - * @param specifier - * @return + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor#leave(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier) */ - public int leave(ICPPASTBaseSpecifier specifier) { + public int leave(ICPPASTBaseSpecifier baseSpecifier) { return PROCESS_CONTINUE; } - /** - * Visit namespace definitions. - * Bottom-up traversal. - * - * @param namespace - * @return + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor#leave(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition) */ - public int leave(ICPPASTNamespaceDefinition namespace) { + public int leave(ICPPASTNamespaceDefinition namespaceDefinition) { return PROCESS_CONTINUE; } - /** - * Visit template parameter. - * Bottom-up traversal. - * - * @param parameter - * @return + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor#leave(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter) */ - public int leave(ICPPASTTemplateParameter parameter) { + public int leave(ICPPASTTemplateParameter templateParameter) { return PROCESS_CONTINUE; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisitor.java new file mode 100644 index 00000000000..6f2231905ce --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisitor.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast.cpp; + +import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; + +/** + * Interface for visitors to visit c-specific nodes. + * @since 5.0 + */ +public interface ICPPASTVisitor { + + /** + * Visits a base class specifier of a composite type. + * @return {@link ASTVisitor#PROCESS_CONTINUE}, {@link ASTVisitor#PROCESS_SKIP} or {@link ASTVisitor#PROCESS_ABORT} + */ + int visit(ICPPASTBaseSpecifier baseSpecifier); + + /** + * Visits a base class specifier of a composite type. + * @return {@link ASTVisitor#PROCESS_CONTINUE} or {@link ASTVisitor#PROCESS_ABORT} + */ + int leave(ICPPASTBaseSpecifier baseSpecifier); + + /** + * Visits a namespace definition. + * @return {@link ASTVisitor#PROCESS_CONTINUE}, {@link ASTVisitor#PROCESS_SKIP} or {@link ASTVisitor#PROCESS_ABORT} + */ + int visit(ICPPASTNamespaceDefinition namespaceDefinition); + + /** + * Visits a namespace definition. + * @return {@link ASTVisitor#PROCESS_CONTINUE} or {@link ASTVisitor#PROCESS_ABORT} + */ + int leave(ICPPASTNamespaceDefinition namespaceDefinition); + + /** + * Visits a template parameter. + * @return {@link ASTVisitor#PROCESS_CONTINUE}, {@link ASTVisitor#PROCESS_SKIP} or {@link ASTVisitor#PROCESS_ABORT} + */ + int visit(ICPPASTTemplateParameter templateParameter); + + /** + * Visits a template parameter. + * @return {@link ASTVisitor#PROCESS_CONTINUE} or {@link ASTVisitor#PROCESS_ABORT} + */ + int leave(ICPPASTTemplateParameter templateParameter); +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java index dfd882b4478..67be1636741 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayDesignator.java @@ -1,21 +1,22 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator; +import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** @@ -47,9 +48,10 @@ public class CASTArrayDesignator extends CASTNode implements } } - public boolean accept( ASTVisitor action ){ - if( action instanceof CASTVisitor && ((CASTVisitor)action).shouldVisitDesignators ){ - switch( ((CASTVisitor)action).visit( this ) ){ + @Override + public boolean accept( ASTVisitor action ){ + if (action.shouldVisitDesignators && action instanceof ICASTVisitor) { + switch( ((ICASTVisitor)action).visit( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -57,8 +59,8 @@ public class CASTArrayDesignator extends CASTNode implements } if( exp != null ) if( !exp.accept( action ) ) return false; - if( action instanceof CASTVisitor && ((CASTVisitor)action).shouldVisitDesignators ){ - switch( ((CASTVisitor)action).leave( this ) ){ + if (action.shouldVisitDesignators && action instanceof ICASTVisitor) { + switch( ((ICASTVisitor)action).leave( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java index ebbc6c677d5..e0281ca4bc8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTArrayRangeDesignator.java @@ -1,20 +1,21 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; +import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor; import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; @@ -58,9 +59,10 @@ public class CASTArrayRangeDesignator extends CASTNode implements } } - public boolean accept( ASTVisitor action ){ - if( action instanceof CASTVisitor && ((CASTVisitor)action).shouldVisitDesignators ){ - switch( ((CASTVisitor)action).visit( this ) ){ + @Override + public boolean accept( ASTVisitor action ){ + if (action.shouldVisitDesignators && action instanceof ICASTVisitor) { + switch( ((ICASTVisitor)action).visit( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -69,8 +71,8 @@ public class CASTArrayRangeDesignator extends CASTNode implements if( floor != null ) if( !floor.accept( action ) ) return false; if( ceiling != null ) if( !ceiling.accept( action ) ) return false; - if( action instanceof CASTVisitor && ((CASTVisitor)action).shouldVisitDesignators ){ - switch( ((CASTVisitor)action).leave( this ) ){ + if (action.shouldVisitDesignators && action instanceof ICASTVisitor) { + switch( ((ICASTVisitor)action).leave( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java index 29a806208f5..6d16de821dc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java @@ -1,20 +1,21 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Yuan Zhang / Beth Tibbitts (IBM Research) + * IBM Rational Software - Initial API and implementation + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.c.CASTVisitor; import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator; +import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor; /** * @author jcamelon @@ -44,17 +45,18 @@ public class CASTFieldDesignator extends CASTNode implements } } - public boolean accept( ASTVisitor action ){ - if( action instanceof CASTVisitor && ((CASTVisitor)action).shouldVisitDesignators ){ - switch( ((CASTVisitor)action).visit( this ) ){ + @Override + public boolean accept( ASTVisitor action ){ + if (action.shouldVisitDesignators && action instanceof ICASTVisitor) { + switch( ((ICASTVisitor)action).visit( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; } } if( name != null ) if( !name.accept( action ) ) return false; - if( action instanceof CASTVisitor && ((CASTVisitor)action).shouldVisitDesignators ){ - switch( ((CASTVisitor)action).leave( this ) ){ + if (action.shouldVisitDesignators && action instanceof ICASTVisitor) { + switch( ((ICASTVisitor)action).leave( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java index e00e4d3c508..15380a0bb45 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java @@ -1,13 +1,14 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Bryan Wilkinson (QNX) + * IBM - Initial API and implementation + * Bryan Wilkinson (QNX) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -19,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -71,10 +72,10 @@ public class CPPASTBaseSpecifier extends CPPASTNode implements } } - public boolean accept(ASTVisitor action) { - if (action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitBaseSpecifiers) { - switch (((CPPASTVisitor)action).visit(this)) { + @Override + public boolean accept(ASTVisitor action) { + if (action.shouldVisitBaseSpecifiers && action instanceof ICPPASTVisitor) { + switch (((ICPPASTVisitor)action).visit(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -83,9 +84,8 @@ public class CPPASTBaseSpecifier extends CPPASTNode implements if (!name.accept(action)) return false; - if (action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitBaseSpecifiers) { - switch (((CPPASTVisitor)action).leave(this)) { + if (action.shouldVisitBaseSpecifiers && action instanceof ICPPASTVisitor) { + switch (((ICPPASTVisitor)action).leave(this)) { case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java index 69e7deffa86..1e2ade04400 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamespaceDefinition.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -17,8 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; @@ -73,10 +73,10 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements } } - public boolean accept( ASTVisitor action ){ - if( action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitNamespaces ){ - switch( ((CPPASTVisitor)action).visit( this ) ){ + @Override + public boolean accept( ASTVisitor action ){ + if (action.shouldVisitNamespaces && action instanceof ICPPASTVisitor) { + switch( ((ICPPASTVisitor)action).visit( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -88,9 +88,8 @@ public class CPPASTNamespaceDefinition extends CPPASTNode implements for ( int i = 0; i < decls.length; i++ ) if( !decls[i].accept( action ) ) return false; - if( action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitNamespaces ){ - switch( ((CPPASTVisitor)action).leave( this ) ){ + if (action.shouldVisitNamespaces && action instanceof ICPPASTVisitor) { + switch( ((ICPPASTVisitor)action).leave( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java index a2546480161..6078940eaf3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTSimpleTypeTemplateParameter.java @@ -1,20 +1,21 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTTypeId; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; /** * @author jcamelon @@ -68,10 +69,10 @@ public class CPPASTSimpleTypeTemplateParameter extends CPPASTNode implements } } - public boolean accept( ASTVisitor action ){ - if( action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitTemplateParameters ){ - switch( ((CPPASTVisitor)action).visit( this ) ){ + @Override + public boolean accept( ASTVisitor action ){ + if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) { + switch( ((ICPPASTVisitor)action).visit( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -81,14 +82,13 @@ public class CPPASTSimpleTypeTemplateParameter extends CPPASTNode implements if( name != null ) if( !name.accept( action ) ) return false; if( typeId != null ) if( !typeId.accept( action ) ) return false; - if( action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitTemplateParameters ){ - switch( ((CPPASTVisitor)action).leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } + if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) { + switch( ((ICPPASTVisitor)action).leave( this ) ){ + case ASTVisitor.PROCESS_ABORT : return false; + case ASTVisitor.PROCESS_SKIP : return true; + default : break; } + } return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java index aed92d31ade..44d5f304f1b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -15,9 +15,9 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; @@ -79,10 +79,10 @@ public class CPPASTTemplatedTypeTemplateParameter extends CPPASTNode implements } } - public boolean accept( ASTVisitor action ){ - if( action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitTemplateParameters ){ - switch( ((CPPASTVisitor)action).visit( this ) ){ + @Override + public boolean accept( ASTVisitor action ){ + if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) { + switch( ((ICPPASTVisitor)action).visit( this ) ){ case ASTVisitor.PROCESS_ABORT : return false; case ASTVisitor.PROCESS_SKIP : return true; default : break; @@ -96,14 +96,13 @@ public class CPPASTTemplatedTypeTemplateParameter extends CPPASTNode implements if( name != null ) if( !name.accept( action ) ) return false; if( defaultValue != null ) if( !defaultValue.accept( action ) ) return false; - if( action instanceof CPPASTVisitor && - ((CPPASTVisitor)action).shouldVisitTemplateParameters ){ - switch( ((CPPASTVisitor)action).leave( this ) ){ - case ASTVisitor.PROCESS_ABORT : return false; - case ASTVisitor.PROCESS_SKIP : return true; - default : break; - } + if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) { + switch( ((ICPPASTVisitor)action).leave( this ) ){ + case ASTVisitor.PROCESS_ABORT : return false; + case ASTVisitor.PROCESS_SKIP : return true; + default : break; } + } return true; } -- cgit v1.2.3