mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Visit method for pointer operators, bug 260461.
This commit is contained in:
parent
4e20a3afa8
commit
8d489aa58e
10 changed files with 135 additions and 64 deletions
|
@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
|
@ -5868,11 +5869,12 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertInstance(children[1], IASTDeclarator.class);
|
assertInstance(children[1], IASTDeclarator.class);
|
||||||
|
|
||||||
children= children[1].getChildren();
|
children= children[1].getChildren();
|
||||||
assertEquals(2, children.length);
|
assertEquals(3, children.length);
|
||||||
assertInstance(children[0], IASTName.class);
|
assertInstance(children[0], IASTPointerOperator.class);
|
||||||
assertInstance(children[1], IASTInitializer.class);
|
assertInstance(children[1], IASTName.class);
|
||||||
|
assertInstance(children[2], IASTInitializer.class);
|
||||||
|
|
||||||
children= children[1].getChildren()[0].getChildren(); // skip binary expression
|
children= children[2].getChildren()[0].getChildren(); // skip binary expression
|
||||||
assertEquals(2, children.length);
|
assertEquals(2, children.length);
|
||||||
assertInstance(children[0], IASTLiteralExpression.class);
|
assertInstance(children[0], IASTLiteralExpression.class);
|
||||||
assertInstance(children[1], IASTLiteralExpression.class);
|
assertInstance(children[1], IASTLiteralExpression.class);
|
||||||
|
@ -6007,4 +6009,17 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IVariable v= ba.assertNonProblem("y);", 1);
|
IVariable v= ba.assertNonProblem("y);", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int* v;
|
||||||
|
public void testPointerOperatorsAsChildren_260461() throws Exception {
|
||||||
|
final String code= getAboveComment();
|
||||||
|
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||||
|
IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
|
||||||
|
IASTSimpleDeclaration decl= getDeclaration(tu, 0);
|
||||||
|
IASTDeclarator dtor= decl.getDeclarators()[0];
|
||||||
|
IASTNode[] nodes = dtor.getChildren();
|
||||||
|
assertEquals(2, nodes.length);
|
||||||
|
assertInstance(nodes[0], IASTPointerOperator.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,11 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
|
||||||
return genericVisit(arrayModifier);
|
return genericVisit(arrayModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTPointerOperator ptrOperator) {
|
||||||
|
return genericVisit(ptrOperator);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclaration declaration) {
|
public int visit(IASTDeclaration declaration) {
|
||||||
return genericVisit(declaration);
|
return genericVisit(declaration);
|
||||||
|
@ -138,6 +143,11 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
|
||||||
return genericLeave(arrayModifier);
|
return genericLeave(arrayModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTPointerOperator ptrOperator) {
|
||||||
|
return genericLeave(ptrOperator);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int leave(IASTDeclaration declaration) {
|
public int leave(IASTDeclaration declaration) {
|
||||||
return genericLeave(declaration);
|
return genericLeave(declaration);
|
||||||
|
|
|
@ -70,6 +70,11 @@ public abstract class ASTVisitor {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public boolean shouldVisitArrayModifiers = false;
|
public boolean shouldVisitArrayModifiers = false;
|
||||||
|
/**
|
||||||
|
* Set this flag to visit pointer operators of declarators.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean shouldVisitPointerOperators = false;
|
||||||
/**
|
/**
|
||||||
* Set this flag to visit expressions.
|
* Set this flag to visit expressions.
|
||||||
*/
|
*/
|
||||||
|
@ -160,6 +165,7 @@ public abstract class ASTVisitor {
|
||||||
shouldVisitNames= visitNodes;
|
shouldVisitNames= visitNodes;
|
||||||
shouldVisitNamespaces= visitNodes;
|
shouldVisitNamespaces= visitNodes;
|
||||||
shouldVisitParameterDeclarations= visitNodes;
|
shouldVisitParameterDeclarations= visitNodes;
|
||||||
|
shouldVisitPointerOperators= visitNodes;
|
||||||
shouldVisitProblems= visitNodes;
|
shouldVisitProblems= visitNodes;
|
||||||
shouldVisitStatements= visitNodes;
|
shouldVisitStatements= visitNodes;
|
||||||
shouldVisitTemplateParameters= visitNodes;
|
shouldVisitTemplateParameters= visitNodes;
|
||||||
|
@ -203,6 +209,13 @@ public abstract class ASTVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public int visit(IASTPointerOperator ptrOperator) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +271,12 @@ public abstract class ASTVisitor {
|
||||||
public int leave(IASTArrayModifier arrayModifier) {
|
public int leave(IASTArrayModifier arrayModifier) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public int leave(IASTPointerOperator ptrOperator) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
public int leave(IASTExpression expression) {
|
public int leave(IASTExpression expression) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -131,6 +131,11 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i <= pointerOpsPos; i++) {
|
||||||
|
if (!pointerOps[i].accept(action))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) {
|
if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) {
|
||||||
if (getParent() instanceof IASTDeclarator) {
|
if (getParent() instanceof IASTDeclarator) {
|
||||||
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
||||||
|
@ -148,12 +153,6 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTPointerOperator[] ptrOps = getPointerOperators();
|
|
||||||
for (int i = 0; i < ptrOps.length; i++) {
|
|
||||||
if (!ptrOps[i].accept(action))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!postAccept(action))
|
if (!postAccept(action))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -14,9 +15,6 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public class CASTPointer extends ASTNode implements ICASTPointer {
|
public class CASTPointer extends ASTNode implements ICASTPointer {
|
||||||
|
|
||||||
private boolean isRestrict;
|
private boolean isRestrict;
|
||||||
|
@ -60,8 +58,15 @@ public class CASTPointer extends ASTNode implements ICASTPointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor visitor) {
|
public boolean accept(ASTVisitor action) {
|
||||||
return true;
|
if (action.shouldVisitPointerOperators) {
|
||||||
|
switch (action.visit(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
|
}
|
||||||
|
if (action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -53,25 +53,20 @@ public class CPPASTArrayModifier extends ASTNode implements IASTArrayModifier, I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (exp != null) {
|
if (action.shouldVisitArrayModifiers) {
|
||||||
if( action.shouldVisitArrayModifiers ){
|
switch (action.visit(this)) {
|
||||||
switch( action.visit( this ) ){
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
default : break;
|
||||||
default : break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!exp.accept(action))
|
}
|
||||||
return false;
|
if (exp != null && !exp.accept(action))
|
||||||
if( action.shouldVisitArrayModifiers ){
|
return false;
|
||||||
switch( action.leave( this ) ){
|
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
if (action.shouldVisitArrayModifiers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
return false;
|
||||||
default : break;
|
|
||||||
}
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -26,7 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C++ specific declarator.
|
* C++ specific declarator.
|
||||||
|
@ -130,13 +130,13 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTPointerOperator[] ptrOps = getPointerOperators();
|
for (int i = 0; i <= pointerOpsPos; i++) {
|
||||||
for (int i = 0; i < ptrOps.length; i++) {
|
if (!pointerOps[i].accept(action))
|
||||||
if (!ptrOps[i].accept(action)) return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nested == null && name != null) {
|
if (nested == null && name != null) {
|
||||||
IASTDeclarator outermost= CPPVisitor.findOutermostDeclarator(this);
|
IASTDeclarator outermost= ASTQueries.findOutermostDeclarator(this);
|
||||||
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
||||||
if (!name.accept(action)) return false;
|
if (!name.accept(action)) return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -15,14 +16,15 @@ import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* A pointer operator of a declarator
|
||||||
*/
|
*/
|
||||||
public class CPPASTPointer extends ASTNode implements IASTPointer {
|
public class CPPASTPointer extends ASTNode implements IASTPointer {
|
||||||
|
|
||||||
private boolean isConst;
|
private boolean isConst;
|
||||||
|
|
||||||
private boolean isVolatile;
|
private boolean isVolatile;
|
||||||
|
|
||||||
|
public CPPASTPointer() {
|
||||||
|
}
|
||||||
|
|
||||||
public CPPASTPointer copy() {
|
public CPPASTPointer copy() {
|
||||||
CPPASTPointer copy = new CPPASTPointer();
|
CPPASTPointer copy = new CPPASTPointer();
|
||||||
|
@ -52,6 +54,14 @@ public class CPPASTPointer extends ASTNode implements IASTPointer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
return true;
|
if (action.shouldVisitPointerOperators) {
|
||||||
|
switch (action.visit(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
|
}
|
||||||
|
if (action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -14,9 +15,6 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public class CPPASTPointerToMember extends CPPASTPointer implements ICPPASTPointerToMember {
|
public class CPPASTPointerToMember extends CPPASTPointer implements ICPPASTPointerToMember {
|
||||||
|
|
||||||
private IASTName n;
|
private IASTName n;
|
||||||
|
@ -52,11 +50,20 @@ public class CPPASTPointerToMember extends CPPASTPointer implements ICPPASTPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( n != null ) if( !n.accept( action ) ) return false;
|
if (action.shouldVisitPointerOperators) {
|
||||||
return true;
|
switch (action.visit(this)) {
|
||||||
}
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n != null && !n.accept(action))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (action.shouldVisitPointerOperators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRoleForName(IASTName name ) {
|
public int getRoleForName(IASTName name ) {
|
||||||
if( name == this.n )
|
if( name == this.n )
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -15,10 +16,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Reference operator for declarators.
|
||||||
*/
|
*/
|
||||||
public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReferenceOperator {
|
public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReferenceOperator {
|
||||||
|
|
||||||
|
public CPPASTReferenceOperator() {
|
||||||
|
}
|
||||||
|
|
||||||
public CPPASTReferenceOperator copy() {
|
public CPPASTReferenceOperator copy() {
|
||||||
CPPASTReferenceOperator copy = new CPPASTReferenceOperator();
|
CPPASTReferenceOperator copy = new CPPASTReferenceOperator();
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
|
@ -26,8 +30,15 @@ public class CPPASTReferenceOperator extends ASTNode implements ICPPASTReference
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
return true;
|
if (action.shouldVisitPointerOperators) {
|
||||||
|
switch (action.visit(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
|
}
|
||||||
|
if (action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue