mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 16:55:38 +02:00
Bug 316307: [C++0x] Syntax for lambda expressions.
This commit is contained in:
parent
04b85fcd5b
commit
7a22acef41
26 changed files with 863 additions and 589 deletions
|
@ -8820,4 +8820,44 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
IFunction f2= bh.assertNonProblem("f() {", 1);
|
||||
assertSame(f1, f2);
|
||||
}
|
||||
|
||||
// struct C {
|
||||
// void test() {
|
||||
// int a;
|
||||
// []{};
|
||||
// [=]{};
|
||||
// [&]{};
|
||||
// [this]{};
|
||||
// [=, this]{};
|
||||
// [&, this]{};
|
||||
// [a]{};
|
||||
// [=, a]{};
|
||||
// [&, a]{};
|
||||
// [a ...]{};
|
||||
// [](int p){};
|
||||
// [](int p) mutable {};
|
||||
// [](int p) mutable throw(int) {};
|
||||
// [](int p) mutable throw(int) -> char {};
|
||||
// [](int p) throw(int) {};
|
||||
// [](int p) -> char {};
|
||||
// }
|
||||
// };
|
||||
public void testLambdaExpression_316307a() throws Exception {
|
||||
String code= getAboveComment();
|
||||
parseAndCheckBindings(code);
|
||||
}
|
||||
|
||||
|
||||
// template <typename T, typename C> void sort(T from, T to, C compare) {}
|
||||
// float abs(float f);
|
||||
//
|
||||
// void abssort(float *x, unsigned N) {
|
||||
// sort(x, x + N, [](float a, float b) {
|
||||
// return abs(a) < abs(b);
|
||||
// });
|
||||
// }
|
||||
public void _testLambdaExpression_316307b() throws Exception {
|
||||
String code= getAboveComment();
|
||||
parseAndCheckBindings(code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2010 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
|
||||
|
@ -13,10 +13,11 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
|
||||
/**
|
||||
* Generic visitor for ast-nodes.
|
||||
|
@ -36,17 +37,25 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return genericVisit(baseSpecifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return genericVisit(namespaceDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
||||
return genericVisit(templateParameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTCapture capture) {
|
||||
return genericVisit(capture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTArrayModifier arrayModifier) {
|
||||
|
@ -118,26 +127,36 @@ public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVis
|
|||
return genericVisit(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICASTDesignator designator) {
|
||||
return genericVisit(designator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int leave(ICASTDesignator designator) {
|
||||
return genericLeave(designator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int leave(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return genericLeave(baseSpecifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return genericLeave(namespaceDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int leave(ICPPASTTemplateParameter templateParameter) {
|
||||
return genericLeave(templateParameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int leave(ICPPASTCapture capture) {
|
||||
return genericLeave(capture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int leave(IASTArrayModifier arrayModifier) {
|
||||
return genericLeave(arrayModifier);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -14,8 +14,11 @@
|
|||
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;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
|
||||
|
||||
/**
|
||||
|
@ -23,9 +26,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
|
|||
* visit() methods implement a top-down traversal, and <br>
|
||||
* leave() methods implement a bottom-up traversal. <br>
|
||||
*
|
||||
* To visit c- or c++-specific nodes you need to implement {@link ICASTVisitor}
|
||||
* and/or {@link ICPPASTVisitor} in addition to deriving from this class.
|
||||
*
|
||||
* <p> Clients may subclass. </p>
|
||||
*/
|
||||
public abstract class ASTVisitor {
|
||||
|
@ -103,28 +103,30 @@ public abstract class ASTVisitor {
|
|||
|
||||
/**
|
||||
* Set this flag to visit designators of initializers.
|
||||
* Your visitor needs to implement {@link ICASTVisitor} to make this work.
|
||||
*/
|
||||
public boolean shouldVisitDesignators = false;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Set this flag to visit captures
|
||||
* @since 5.3
|
||||
*/
|
||||
public boolean shouldVisitCaptures= false;
|
||||
|
||||
/**
|
||||
* Per default inactive nodes are not visited. You can change that by setting
|
||||
* this flag to <code>true</code>.
|
||||
|
@ -175,6 +177,7 @@ public abstract class ASTVisitor {
|
|||
public ASTVisitor(boolean visitNodes) {
|
||||
shouldVisitArrayModifiers= visitNodes;
|
||||
shouldVisitBaseSpecifiers= visitNodes;
|
||||
shouldVisitCaptures= visitNodes;
|
||||
shouldVisitDeclarations= visitNodes;
|
||||
shouldVisitDeclarators= visitNodes;
|
||||
shouldVisitDeclSpecifiers= visitNodes;
|
||||
|
@ -256,6 +259,41 @@ public abstract class ASTVisitor {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int visit(ICPPASTCapture capture) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int visit(ICASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
// leave methods
|
||||
public int leave(IASTTranslationUnit tu) {
|
||||
return PROCESS_CONTINUE;
|
||||
|
@ -318,6 +356,41 @@ public abstract class ASTVisitor {
|
|||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int leave(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int leave(ICPPASTTemplateParameter templateParameter) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int leave(ICPPASTCapture capture) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public int leave(ICASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link IASTTranslationUnit#getComments()}, instead.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -15,17 +15,9 @@ 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.
|
||||
* @deprecated you can use {@link ASTVisitor}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CASTVisitor extends ASTVisitor implements ICASTVisitor {
|
||||
|
||||
|
||||
public int visit(ICASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
public int leave(ICASTDesignator designator) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -12,13 +12,11 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* C++ specific visitor class.
|
||||
* <br>The visit() methods implement a top-down traversal of the AST,
|
||||
* and the leave() methods implement a bottom-up traversal.
|
||||
* @deprecated you can use {@link ASTVisitor}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CPPASTVisitor extends ASTVisitor implements ICPPASTVisitor {
|
||||
|
||||
/**
|
||||
|
@ -34,28 +32,4 @@ public abstract class CPPASTVisitor extends ASTVisitor implements ICPPASTVisitor
|
|||
public CPPASTVisitor(boolean visitNodes) {
|
||||
super(visitNodes);
|
||||
}
|
||||
|
||||
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int leave(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public int leave(ICPPASTTemplateParameter templateParameter) {
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 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.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
||||
/**
|
||||
* Capture for a lambda expression, introduced in C++0x.
|
||||
*
|
||||
* @since 5.3
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTCapture extends IASTNode, ICPPASTPackExpandable {
|
||||
ASTNodeProperty IDENTIFIER = new ASTNodeProperty("ICPPASTCapture - IDENTIFIER [IASTName]"); //$NON-NLS-1$
|
||||
|
||||
ICPPASTCapture copy();
|
||||
|
||||
/**
|
||||
* Returns whether the capture uses a leading ampersand.
|
||||
*/
|
||||
boolean isByReference();
|
||||
|
||||
/**
|
||||
* Returns whether this capture is for the this pointer.
|
||||
*/
|
||||
boolean capturesThisPointer();
|
||||
|
||||
/**
|
||||
* Returns the identifier for this capture or <code>null</code>, when
|
||||
* <code>this<code> is captured.
|
||||
*/
|
||||
IASTName getIdentifier();
|
||||
|
||||
/**
|
||||
* Not allowed on frozen AST.
|
||||
* @see #isByReference()
|
||||
*/
|
||||
void setIsByReference(boolean value);
|
||||
|
||||
/**
|
||||
* Not allowed on frozen AST. Providing a <code>null</code> identifier indicates
|
||||
* that this capture is for the this pointer.
|
||||
* @see #getIdentifier()
|
||||
*/
|
||||
void setIdentifier(IASTName identifier);
|
||||
}
|
|
@ -55,6 +55,18 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
|
|||
*/
|
||||
public void setVolatile(boolean value);
|
||||
|
||||
/**
|
||||
* When used as a lambda declarator, it can be mutable.
|
||||
* @since 5.3
|
||||
*/
|
||||
public boolean isMutable();
|
||||
|
||||
/**
|
||||
* When used as a lambda declarator, it can be mutable.
|
||||
* @since 5.3
|
||||
*/
|
||||
public void setMutable(boolean value);
|
||||
|
||||
/**
|
||||
* Is the method pure virtual?
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 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.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
|
||||
/**
|
||||
* Lambda expression, introduced in C++0x.
|
||||
*
|
||||
* @since 5.3
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTLambdaExpression extends IASTExpression {
|
||||
ASTNodeProperty CAPTURE = new ASTNodeProperty("ICPPASTLambdaExpression - CAPTURE [ICPPASTCapture]"); //$NON-NLS-1$
|
||||
ASTNodeProperty DECLARATOR = new ASTNodeProperty("ICPPASTLambdaExpression - DECLARATOR [ICPPASTFunctionDeclarator]"); //$NON-NLS-1$
|
||||
ASTNodeProperty BODY = new ASTNodeProperty("ICPPASTLambdaExpression - BODY [IASTCompoundStatement]"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The capture default can be by copy, by reference or unspecified.
|
||||
*/
|
||||
enum CaptureDefault {UNSPECIFIED, BY_COPY, BY_REFERENCE}
|
||||
|
||||
/**
|
||||
* Returns the capture default for this lambda expression.
|
||||
*/
|
||||
CaptureDefault getCaptureDefault();
|
||||
|
||||
/**
|
||||
* Returns the array of captures for this lambda expression.
|
||||
*/
|
||||
ICPPASTCapture[] getCaptures();
|
||||
|
||||
/**
|
||||
* Returns the lambda declarator for this lambda expression, or <code>null</code>
|
||||
* in case it was not specified.
|
||||
*/
|
||||
ICPPASTFunctionDeclarator getDeclarator();
|
||||
|
||||
/**
|
||||
* Returns the compound statement of this lambda expression. Can be <code>null</code>
|
||||
* when creating AST for content assist.
|
||||
*/
|
||||
IASTCompoundStatement getBody();
|
||||
|
||||
|
||||
/**
|
||||
* Not allowed on frozen AST.
|
||||
* @see #getCaptureDefault()
|
||||
*/
|
||||
void setCaptureDefault(CaptureDefault value);
|
||||
|
||||
/**
|
||||
* Not allowed on frozen AST.
|
||||
* @see #getCaptures()
|
||||
*/
|
||||
void addCapture(ICPPASTCapture capture);
|
||||
|
||||
/**
|
||||
* Not allowed on frozen AST.
|
||||
* @see #getDeclarator()
|
||||
*/
|
||||
void setDeclarator(ICPPASTFunctionDeclarator dtor);
|
||||
|
||||
/**
|
||||
* Not allowed on frozen AST.
|
||||
* @see #getBody()
|
||||
*/
|
||||
void setBody(IASTCompoundStatement body);
|
||||
}
|
|
@ -60,18 +60,23 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
public ICPPASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTInitializerClause expr2);
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public ICPPASTCapture newCapture();
|
||||
|
||||
public ICPPASTCastExpression newCastExpression(int operator, IASTTypeId typeId, IASTExpression operand);
|
||||
|
||||
public ICPPASTCatchHandler newCatchHandler(IASTDeclaration decl, IASTStatement body);
|
||||
|
||||
public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
|
||||
|
||||
public ICPPASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newConstructorChainInitializer(IASTName, IASTInitializer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ICPPASTConstructorChainInitializer newConstructorChainInitializer(IASTName memberInitializerId, IASTExpression initializerValue);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -82,30 +87,30 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Deprecated
|
||||
public ICPPASTConstructorInitializer newConstructorInitializer(IASTExpression exp);
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTConstructorInitializer newConstructorInitializer(IASTInitializerClause[] args);
|
||||
|
||||
|
||||
public ICPPASTConversionName newConversionName(IASTTypeId typeId);
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTDeclarator newDeclarator(IASTName name);
|
||||
|
||||
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
|
||||
|
||||
public ICPPASTDeleteExpression newDeleteExpression(IASTExpression operand);
|
||||
|
||||
public ICPPASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name);
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTEnumerationSpecifier newEnumerationSpecifier(boolean isScoped, IASTName name, ICPPASTDeclSpecifier baseType);
|
||||
|
||||
public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
|
||||
|
||||
public ICPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiation(IASTDeclaration declaration);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newExplicitTemplateInstantiation(IASTDeclaration)}.
|
||||
*/
|
||||
|
@ -113,7 +118,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration);
|
||||
|
||||
public ICPPASTExpressionList newExpressionList();
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -122,10 +127,10 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner);
|
||||
|
||||
public ICPPASTForStatement newForStatement();
|
||||
|
||||
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTDeclaration condition,
|
||||
IASTExpression iterationExpression, IASTStatement body);
|
||||
|
||||
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
|
||||
IASTExpression iterationExpression, IASTStatement body);
|
||||
|
||||
|
@ -151,22 +156,27 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public ICPPASTIfStatement newIfStatement();
|
||||
|
||||
public ICPPASTIfStatement newIfStatement(IASTDeclaration condition, IASTStatement then, IASTStatement elseClause);
|
||||
|
||||
|
||||
public ICPPASTIfStatement newIfStatement(IASTExpression condition, IASTStatement then, IASTStatement elseClause);
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTInitializerList newInitializerList();
|
||||
|
||||
/**
|
||||
* @since 5.3
|
||||
*/
|
||||
public ICPPASTLambdaExpression newLambdaExpression();
|
||||
|
||||
public ICPPASTLinkageSpecification newLinkageSpecification(String literal);
|
||||
|
||||
|
||||
public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep);
|
||||
|
||||
public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
|
||||
|
||||
public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
|
||||
|
||||
public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName);
|
||||
|
||||
public ICPPASTNamespaceDefinition newNamespaceDefinition(IASTName name);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newNewExpression(IASTInitializerClause[], IASTInitializer, IASTTypeId)}
|
||||
*/
|
||||
|
@ -179,21 +189,21 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public ICPPASTNewExpression newNewExpression(IASTInitializerClause[] placement, IASTInitializer initializer, IASTTypeId typeId);
|
||||
|
||||
public ICPPASTOperatorName newOperatorName(char[] name);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new pack expansion expression for the given pattern.
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTPackExpansionExpression newPackExpansionExpression(IASTExpression pattern);
|
||||
|
||||
|
||||
public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator);
|
||||
|
||||
public IGPPASTPointer newPointerGPP();
|
||||
|
||||
|
||||
public ICPPASTPointerToMember newPointerToMember(IASTName name);
|
||||
|
||||
|
||||
public IGPPASTPointerToMember newPointerToMemberGPP(IASTName name);
|
||||
|
||||
|
||||
public IASTProblemTypeId newProblemTypeId(IASTProblem problem);
|
||||
|
||||
public ICPPASTQualifiedName newQualifiedName();
|
||||
|
@ -213,26 +223,26 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.2
|
||||
*/
|
||||
public IASTReturnStatement newReturnStatement(IASTInitializerClause retValue);
|
||||
|
||||
|
||||
public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newSimpleDeclSpecifier()}
|
||||
*/
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP();
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer initializer);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier, IASTInitializer)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(int type, IASTExpression expression);
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(ICPPASTDeclSpecifier declSpec, IASTInitializer initializer);
|
||||
|
||||
public ICPPASTSimpleTypeTemplateParameter newSimpleTypeTemplateParameter(int type, IASTName name, IASTTypeId typeId);
|
||||
|
||||
/**
|
||||
|
@ -242,19 +252,19 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public ICPPASTStaticAssertDeclaration newStaticAssertion(IASTExpression condition, ICPPASTLiteralExpression message);
|
||||
|
||||
public ICPPASTSwitchStatement newSwitchStatement();
|
||||
|
||||
|
||||
public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body);
|
||||
|
||||
public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controlloer, IASTStatement body);
|
||||
|
||||
|
||||
public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration);
|
||||
|
||||
|
||||
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue);
|
||||
|
||||
public ICPPASTTemplateId newTemplateId(IASTName templateName);
|
||||
|
||||
|
||||
public ICPPASTTemplateSpecialization newTemplateSpecialization(IASTDeclaration declaration);
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
|
||||
*/
|
||||
|
@ -268,11 +278,11 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
* @since 5.2
|
||||
*/
|
||||
public ICPPASTTranslationUnit newTranslationUnit(IScanner scanner);
|
||||
|
||||
public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
|
||||
|
||||
public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
|
||||
|
||||
public ICPPASTTryBlockStatement newTryBlockStatement(IASTStatement body);
|
||||
|
||||
public ICPPASTNamedTypeSpecifier newTypedefNameSpecifier(IASTName name);
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
@ -285,7 +295,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
*/
|
||||
@Deprecated
|
||||
public ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate);
|
||||
|
||||
|
||||
public ICPPASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand);
|
||||
|
||||
public ICPPASTUsingDeclaration newUsingDeclaration(IASTName name);
|
||||
|
@ -293,11 +303,10 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
public ICPPASTUsingDirective newUsingDirective(IASTName name);
|
||||
|
||||
public ICPPASTVisibilityLabel newVisibilityLabel(int visibility);
|
||||
|
||||
|
||||
public ICPPASTWhileStatement newWhileStatement();
|
||||
|
||||
public ICPPASTWhileStatement newWhileStatement(IASTDeclaration condition, IASTStatement body);
|
||||
|
||||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
|
||||
|
||||
}
|
||||
|
|
|
@ -1425,7 +1425,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
* @throws BacktrackException
|
||||
* request a backtrack
|
||||
*/
|
||||
protected IASTStatement functionBody() throws EndOfFileException, BacktrackException {
|
||||
protected IASTCompoundStatement functionBody() throws EndOfFileException, BacktrackException {
|
||||
return compoundStatement();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2010 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
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -16,12 +16,11 @@ 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.ICASTArrayDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* Implementation of array designators
|
||||
*/
|
||||
public class CASTArrayDesignator extends ASTNode implements
|
||||
ICASTArrayDesignator, IASTAmbiguityParent {
|
||||
|
@ -57,23 +56,20 @@ public class CASTArrayDesignator extends ASTNode implements
|
|||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if (action.shouldVisitDesignators && action instanceof ICASTVisitor) {
|
||||
switch( ((ICASTVisitor)action).visit( this ) ){
|
||||
if (action.shouldVisitDesignators) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
if( exp != null ) if( !exp.accept( action ) ) return false;
|
||||
if (exp != null && !exp.accept(action))
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2010 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
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -15,13 +15,12 @@ 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.ICASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* Implementation of array range designators.
|
||||
*/
|
||||
public class CASTArrayRangeDesignator extends ASTNode implements
|
||||
IGCCASTArrayRangeDesignator, IASTAmbiguityParent {
|
||||
|
@ -72,23 +71,21 @@ public class CASTArrayRangeDesignator extends ASTNode implements
|
|||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if (action.shouldVisitDesignators && action instanceof ICASTVisitor) {
|
||||
switch( ((ICASTVisitor)action).visit( this ) ){
|
||||
if (action.shouldVisitDesignators ) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
if( floor != null ) if( !floor.accept( action ) ) return false;
|
||||
if( ceiling != null ) if( !ceiling.accept( action ) ) return false;
|
||||
if (floor != null && !floor.accept(action))
|
||||
return false;
|
||||
if (ceiling != null && !ceiling.accept(action))
|
||||
return false;
|
||||
|
||||
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2010 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
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
@ -15,11 +15,10 @@ 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.ICASTFieldDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
* Implementation of field designators
|
||||
*/
|
||||
public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator {
|
||||
|
||||
|
@ -54,21 +53,18 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator
|
|||
|
||||
@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.shouldVisitDesignators && action instanceof ICASTVisitor) {
|
||||
switch( ((ICASTVisitor)action).leave( this ) ){
|
||||
if (action.shouldVisitDesignators ) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
if (name != null && !name.accept(action))
|
||||
return false;
|
||||
if (action.shouldVisitDesignators && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICPPASTCompletionContext;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
|
@ -92,23 +91,20 @@ public class CPPASTBaseSpecifier extends ASTNode implements ICPPASTBaseSpecifier
|
|||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitBaseSpecifiers && action instanceof ICPPASTVisitor) {
|
||||
switch (((ICPPASTVisitor)action).visit(this)) {
|
||||
if (action.shouldVisitBaseSpecifiers) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name.accept(action)) return false;
|
||||
if (name != null && !name.accept(action))
|
||||
return false;
|
||||
|
||||
if (action.shouldVisitBaseSpecifiers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 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.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.cpp.ICPPASTCapture;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
||||
/**
|
||||
* Implementation for captures.
|
||||
*/
|
||||
public class CPPASTCapture extends ASTNode implements ICPPASTCapture {
|
||||
private boolean fByReference;
|
||||
private boolean fPackExpansion;
|
||||
private IASTName fIdentifier;
|
||||
|
||||
public CPPASTCapture() {
|
||||
}
|
||||
|
||||
public CPPASTCapture copy() {
|
||||
final CPPASTCapture result= new CPPASTCapture();
|
||||
if (fIdentifier != null)
|
||||
result.setIdentifier(fIdentifier.copy());
|
||||
result.fByReference= fByReference;
|
||||
result.fPackExpansion= fPackExpansion;
|
||||
result.setOffsetAndLength(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean capturesThisPointer() {
|
||||
return fIdentifier == null;
|
||||
}
|
||||
|
||||
public boolean isByReference() {
|
||||
return fByReference;
|
||||
}
|
||||
|
||||
public boolean isPackExpansion() {
|
||||
return fPackExpansion;
|
||||
}
|
||||
|
||||
public IASTName getIdentifier() {
|
||||
return fIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor visitor) {
|
||||
if (visitor.shouldVisitCaptures) {
|
||||
switch (visitor.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fIdentifier != null && !fIdentifier.accept(visitor))
|
||||
return false;
|
||||
|
||||
if (visitor.shouldVisitCaptures && visitor.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setIdentifier(IASTName identifier) {
|
||||
assertNotFrozen();
|
||||
if (identifier != null) {
|
||||
identifier.setParent(this);
|
||||
identifier.setPropertyInParent(IDENTIFIER);
|
||||
}
|
||||
fIdentifier= identifier;
|
||||
}
|
||||
|
||||
public void setIsByReference(boolean value) {
|
||||
assertNotFrozen();
|
||||
fByReference= value;
|
||||
}
|
||||
|
||||
public void setIsPackExpansion(boolean val) {
|
||||
assertNotFrozen();
|
||||
fPackExpansion= val;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
|||
private boolean pureVirtual;
|
||||
private boolean isVolatile;
|
||||
private boolean isConst;
|
||||
private boolean isMutable;
|
||||
|
||||
private ICPPFunctionScope scope = null;
|
||||
|
||||
|
@ -56,6 +57,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
|||
copy.pureVirtual = pureVirtual;
|
||||
copy.isVolatile = isVolatile;
|
||||
copy.isConst = isConst;
|
||||
copy.isMutable= isMutable;
|
||||
|
||||
for(IASTParameterDeclaration param : getParameters())
|
||||
copy.addParameterDeclaration(param == null ? null : param.copy());
|
||||
|
@ -110,6 +112,15 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
|||
this.isVolatile = value;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return isMutable;
|
||||
}
|
||||
|
||||
public void setMutable(boolean value) {
|
||||
assertNotFrozen();
|
||||
this.isMutable = value;
|
||||
}
|
||||
|
||||
public IASTTypeId[] getExceptionSpecification() {
|
||||
return typeIds= ArrayUtil.trim(typeIds);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 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.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
||||
/**
|
||||
* Implementation for lambda expressions.
|
||||
*/
|
||||
public class CPPASTLambdaExpression extends ASTNode implements ICPPASTLambdaExpression {
|
||||
private static final ICPPASTCapture[] NO_CAPTURES = {};
|
||||
|
||||
private CaptureDefault fCaptureDefault;
|
||||
private ICPPASTCapture[] fCaptures;
|
||||
private ICPPASTFunctionDeclarator fDeclarator;
|
||||
private IASTCompoundStatement fBody;
|
||||
|
||||
public CPPASTLambdaExpression() {
|
||||
fCaptureDefault= CaptureDefault.UNSPECIFIED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTExpression#copy()
|
||||
*/
|
||||
public IASTExpression copy() {
|
||||
CPPASTLambdaExpression result= new CPPASTLambdaExpression();
|
||||
result.fCaptureDefault= fCaptureDefault;
|
||||
if (fCaptures != null) {
|
||||
for (ICPPASTCapture capture : fCaptures) {
|
||||
if (capture != null) {
|
||||
result.addCapture(capture.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fDeclarator != null) {
|
||||
result.setDeclarator(fDeclarator.copy());
|
||||
}
|
||||
if (fBody != null) {
|
||||
result.setBody(fBody.copy());
|
||||
}
|
||||
|
||||
result.setOffsetAndLength(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor visitor) {
|
||||
if (visitor.shouldVisitExpressions) {
|
||||
switch (visitor.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fCaptures != null) {
|
||||
for (ICPPASTCapture cap : fCaptures) {
|
||||
if (cap != null && !cap.accept(visitor))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (fDeclarator != null && !fDeclarator.accept(visitor))
|
||||
return false;
|
||||
if (fBody != null && !fBody.accept(visitor))
|
||||
return false;
|
||||
|
||||
if (visitor.shouldVisitExpressions && visitor.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public IASTCompoundStatement getBody() {
|
||||
return fBody;
|
||||
}
|
||||
|
||||
public CaptureDefault getCaptureDefault() {
|
||||
return fCaptureDefault;
|
||||
}
|
||||
|
||||
public ICPPASTCapture[] getCaptures() {
|
||||
if (fCaptures == null)
|
||||
return NO_CAPTURES;
|
||||
return fCaptures= ArrayUtil.trim(fCaptures);
|
||||
}
|
||||
|
||||
public ICPPASTFunctionDeclarator getDeclarator() {
|
||||
return fDeclarator;
|
||||
}
|
||||
|
||||
public void addCapture(ICPPASTCapture capture) {
|
||||
assertNotFrozen();
|
||||
capture.setParent(this);
|
||||
capture.setPropertyInParent(CAPTURE);
|
||||
if (fCaptures == null) {
|
||||
fCaptures= new ICPPASTCapture[] {capture, null};
|
||||
} else {
|
||||
fCaptures= ArrayUtil.append(fCaptures, capture);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBody(IASTCompoundStatement body) {
|
||||
assertNotFrozen();
|
||||
body.setParent(this);
|
||||
body.setPropertyInParent(BODY);
|
||||
fBody= body;
|
||||
}
|
||||
|
||||
public void setCaptureDefault(CaptureDefault value) {
|
||||
fCaptureDefault= value;
|
||||
}
|
||||
|
||||
public void setDeclarator(ICPPASTFunctionDeclarator dtor) {
|
||||
assertNotFrozen();
|
||||
dtor.setParent(this);
|
||||
dtor.setPropertyInParent(DECLARATOR);
|
||||
fDeclarator= dtor;
|
||||
}
|
||||
|
||||
public IType getExpressionType() {
|
||||
// mstodo type for lambda expressions
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isLValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@ 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.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.ASTNode;
|
||||
|
@ -111,8 +110,8 @@ public class CPPASTNamespaceDefinition extends ASTNode implements
|
|||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitNamespaces && action instanceof ICPPASTVisitor) {
|
||||
switch (((ICPPASTVisitor) action).visit(this)) {
|
||||
if (action.shouldVisitNamespaces) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
|
@ -127,8 +126,7 @@ public class CPPASTNamespaceDefinition extends ASTNode implements
|
|||
if (!decl.accept(action)) return false;
|
||||
}
|
||||
|
||||
if (action.shouldVisitNamespaces && action instanceof ICPPASTVisitor &&
|
||||
((ICPPASTVisitor) action).leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
if (action.shouldVisitNamespaces && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
@ -79,23 +80,22 @@ public class CPPASTParameterDeclaration extends ASTNode implements ICPPASTParame
|
|||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if( action.shouldVisitParameterDeclarations ){
|
||||
switch( action.visit( this ) ){
|
||||
if (action.shouldVisitParameterDeclarations) {
|
||||
switch (action.visit((IASTParameterDeclaration) this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if( fDeclSpec != null ) if( !fDeclSpec.accept( action ) ) return false;
|
||||
if( fDeclarator != null ) if( !fDeclarator.accept( action ) ) return false;
|
||||
if (fDeclSpec != null && !fDeclSpec.accept(action))
|
||||
return false;
|
||||
if (fDeclarator != null && !fDeclarator.accept(action))
|
||||
return false;
|
||||
|
||||
if( action.shouldVisitParameterDeclarations ){
|
||||
switch( action.leave( this ) ){
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
}
|
||||
if (action.shouldVisitParameterDeclarations &&
|
||||
action.leave((IASTParameterDeclaration) this) == ASTVisitor.PROCESS_ABORT) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -15,7 +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.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
||||
/**
|
||||
|
@ -94,25 +93,23 @@ public class CPPASTSimpleTypeTemplateParameter extends ASTNode implements ICPPAS
|
|||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) {
|
||||
switch (((ICPPASTVisitor) action).visit(this)) {
|
||||
if (action.shouldVisitTemplateParameters) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fName != null) if (!fName.accept(action)) return false;
|
||||
if (fTypeId != null) if (!fTypeId.accept(action)) return false;
|
||||
if (fName != null && !fName.accept(action))
|
||||
return false;
|
||||
if (fTypeId != null && !fTypeId.accept(action))
|
||||
return false;
|
||||
|
||||
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;
|
||||
if (action.shouldVisitTemplateParameters && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRoleForName(IASTName n) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2010 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
|
||||
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
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.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
@ -112,8 +111,8 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
|
|||
|
||||
@Override
|
||||
public boolean accept( ASTVisitor action ){
|
||||
if (action.shouldVisitTemplateParameters && action instanceof ICPPASTVisitor) {
|
||||
switch( ((ICPPASTVisitor)action).visit( this ) ){
|
||||
if (action.shouldVisitTemplateParameters) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT : return false;
|
||||
case ASTVisitor.PROCESS_SKIP : return true;
|
||||
default : break;
|
||||
|
@ -121,20 +120,19 @@ public class CPPASTTemplatedTypeTemplateParameter extends ASTNode implements
|
|||
}
|
||||
|
||||
ICPPASTTemplateParameter [] ps = getTemplateParameters();
|
||||
for ( int i = 0; i < ps.length; i++ ) {
|
||||
if( !ps[i].accept( action ) ) return false;
|
||||
}
|
||||
if( fName != null ) if( !fName.accept( action ) ) return false;
|
||||
if( fDefaultValue != null ) if( !fDefaultValue.accept( action ) ) return false;
|
||||
for (int i = 0; i < ps.length; i++) {
|
||||
if (!ps[i].accept(action))
|
||||
return false;
|
||||
}
|
||||
if (fName != null && !fName.accept(action))
|
||||
return false;
|
||||
if (fDefaultValue != null && !fDefaultValue.accept(action))
|
||||
return false;
|
||||
|
||||
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;
|
||||
if (action.shouldVisitTemplateParameters && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRoleForName(IASTName n) {
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
|
@ -73,6 +74,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
|
@ -160,6 +162,10 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
return new CPPASTBreakStatement();
|
||||
}
|
||||
|
||||
public ICPPASTCapture newCapture() {
|
||||
return new CPPASTCapture();
|
||||
}
|
||||
|
||||
public IASTCaseStatement newCaseStatement(IASTExpression expr) {
|
||||
return new CPPASTCaseStatement(expr);
|
||||
}
|
||||
|
@ -209,19 +215,19 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTContinueStatement newContinueStatement() {
|
||||
return new CPPASTContinueStatement();
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTConversionName newConversionName(IASTTypeId typeId) {
|
||||
return new CPPASTConversionName(typeId);
|
||||
}
|
||||
|
||||
|
||||
public IASTDeclarationStatement newDeclarationStatement(IASTDeclaration declaration) {
|
||||
return new CPPASTDeclarationStatement(declaration);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTDeclarator newDeclarator(IASTName name) {
|
||||
return new CPPASTDeclarator(name);
|
||||
}
|
||||
|
||||
|
||||
public IASTDefaultStatement newDefaultStatement() {
|
||||
return new CPPASTDefaultStatement();
|
||||
}
|
||||
|
@ -263,7 +269,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation newExplicitTemplateInstantiationGPP(IASTDeclaration declaration) {
|
||||
return new GPPASTExplicitTemplateInstantiation(declaration);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTExpressionList newExpressionList() {
|
||||
return new CPPASTExpressionList();
|
||||
}
|
||||
|
@ -271,15 +277,15 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTExpressionStatement newExpressionStatement(IASTExpression expression) {
|
||||
return new CPPASTExpressionStatement(expression);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTFieldDeclarator newFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
|
||||
return new CPPASTFieldDeclarator(name, bitFieldSize);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTFieldReference newFieldReference(IASTName name, IASTExpression owner) {
|
||||
return new CPPASTFieldReference(name, owner);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTForStatement newForStatement() {
|
||||
return new CPPASTForStatement();
|
||||
}
|
||||
|
@ -288,12 +294,12 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
IASTExpression iterationExpression, IASTStatement body) {
|
||||
return new CPPASTForStatement(init, condition, iterationExpression, body);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTForStatement newForStatement(IASTStatement init, IASTExpression condition,
|
||||
IASTExpression iterationExpr, IASTStatement body) {
|
||||
return new CPPASTForStatement(init, condition, iterationExpr, body);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public ICPPASTFunctionCallExpression newFunctionCallExpression(IASTExpression idExpr, IASTExpression argList) {
|
||||
CPPASTFunctionCallExpression result = new CPPASTFunctionCallExpression(idExpr, null);
|
||||
|
@ -318,7 +324,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
IASTStatement bodyStatement) {
|
||||
return new CPPASTFunctionWithTryBlock(declSpecifier, declarator, bodyStatement);
|
||||
}
|
||||
|
||||
|
||||
public IGNUASTCompoundStatementExpression newGNUCompoundStatementExpression(IASTCompoundStatement compoundStatement) {
|
||||
return new CPPASTCompoundStatementExpression(compoundStatement);
|
||||
}
|
||||
|
@ -326,7 +332,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTGotoStatement newGotoStatement(IASTName name) {
|
||||
return new CPPASTGotoStatement(name);
|
||||
}
|
||||
|
||||
|
||||
public IASTIdExpression newIdExpression(IASTName name) {
|
||||
return new CPPASTIdExpression(name);
|
||||
}
|
||||
|
@ -351,10 +357,14 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTInitializerList newInitializerList() {
|
||||
return new CPPASTInitializerList();
|
||||
}
|
||||
|
||||
|
||||
public IASTLabelStatement newLabelStatement(IASTName name, IASTStatement nestedStatement) {
|
||||
return new CPPASTLabelStatement(name, nestedStatement);
|
||||
}
|
||||
|
||||
public ICPPASTLambdaExpression newLambdaExpression() {
|
||||
return new CPPASTLambdaExpression();
|
||||
}
|
||||
|
||||
public ICPPASTLinkageSpecification newLinkageSpecification(String literal) {
|
||||
return new CPPASTLinkageSpecification(literal);
|
||||
|
@ -363,7 +373,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTLiteralExpression newLiteralExpression(int kind, String rep) {
|
||||
return new CPPASTLiteralExpression(kind, rep.toCharArray());
|
||||
}
|
||||
|
||||
|
||||
public IASTName newName() {
|
||||
return new CPPASTName();
|
||||
}
|
||||
|
@ -407,7 +417,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||
return new CPPASTParameterDeclaration(declSpec, declarator);
|
||||
}
|
||||
|
||||
|
||||
public IASTPointer newPointer() {
|
||||
return new CPPASTPointer();
|
||||
}
|
||||
|
@ -415,7 +425,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IGPPASTPointer newPointerGPP() {
|
||||
return new GPPASTPointer();
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTPointerToMember newPointerToMember(IASTName name) {
|
||||
return new CPPASTPointerToMember(name);
|
||||
}
|
||||
|
@ -455,7 +465,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTReferenceOperator newReferenceOperator(boolean isRValueReference) {
|
||||
return new CPPASTReferenceOperator(isRValueReference);
|
||||
}
|
||||
|
||||
|
||||
public IASTReturnStatement newReturnStatement(IASTExpression retValue) {
|
||||
return new CPPASTReturnStatement(retValue);
|
||||
}
|
||||
|
@ -463,11 +473,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTReturnStatement newReturnStatement(IASTInitializerClause retValue) {
|
||||
return new CPPASTReturnStatement(retValue);
|
||||
}
|
||||
|
||||
|
||||
public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
|
||||
return new CPPASTSimpleDeclaration(declSpecifier);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
|
||||
return new CPPASTSimpleDeclSpecifier();
|
||||
}
|
||||
|
@ -476,7 +486,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier newSimpleDeclSpecifierGPP() {
|
||||
return new GPPASTSimpleDeclSpecifier();
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTSimpleTypeConstructorExpression newSimpleTypeConstructorExpression(
|
||||
ICPPASTDeclSpecifier declSpec, IASTInitializer initializer) {
|
||||
return new CPPASTSimpleTypeConstructorExpression(declSpec, initializer);
|
||||
|
@ -506,7 +516,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTSwitchStatement newSwitchStatement(IASTDeclaration controller, IASTStatement body) {
|
||||
return new CPPASTSwitchStatement(controller, body);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
|
||||
return new CPPASTSwitchStatement(controller, body);
|
||||
}
|
||||
|
@ -514,7 +524,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTTemplateDeclaration newTemplateDeclaration(IASTDeclaration declaration) {
|
||||
return new CPPASTTemplateDeclaration(declaration);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTTemplatedTypeTemplateParameter newTemplatedTypeTemplateParameter(IASTName name, IASTExpression defaultValue) {
|
||||
return new CPPASTTemplatedTypeTemplateParameter(name, defaultValue);
|
||||
}
|
||||
|
@ -555,7 +565,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTTypeId newTypeId(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||
return new CPPASTTypeId(declSpecifier, declarator);
|
||||
}
|
||||
|
||||
|
||||
public ICPPASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
|
||||
return new CPPASTTypeIdExpression(operator, typeId);
|
||||
}
|
||||
|
@ -563,7 +573,7 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public IASTTypeIdInitializerExpression newTypeIdInitializerExpression(IASTTypeId typeId, IASTInitializer initializer) {
|
||||
return new CPPASTTypeIdInitializerExpression(typeId, initializer);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression newTypenameExpression(IASTName qualifiedName, IASTExpression expr, boolean isTemplate) {
|
||||
return new CPPASTTypenameExpression(qualifiedName, expr);
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
|
@ -82,6 +83,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression.CaptureDefault;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
|
@ -1414,6 +1417,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
+ ((ASTNode) name).getLength() - ((ASTNode) name).getOffset());
|
||||
return idExpression;
|
||||
}
|
||||
case IToken.tLBRACKET:
|
||||
return lambdaExpression();
|
||||
|
||||
default:
|
||||
IToken la = LA(1);
|
||||
int startingOffset = la.getOffset();
|
||||
|
@ -1435,11 +1441,87 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
IToken t= consume();
|
||||
ICPPASTLiteralExpression r= nodeFactory.newLiteralExpression(IASTLiteralExpression.lk_string_literal, t.getImage());
|
||||
setRange(r, t.getOffset(), t.getEndOffset());
|
||||
return r;
|
||||
return setRange(r, t.getOffset(), t.getEndOffset());
|
||||
}
|
||||
|
||||
protected IASTExpression specialCastExpression(int kind) throws EndOfFileException, BacktrackException {
|
||||
private IASTExpression lambdaExpression() throws EndOfFileException, BacktrackException {
|
||||
final int offset= LA().getOffset();
|
||||
|
||||
ICPPASTLambdaExpression lambdaExpr= nodeFactory.newLambdaExpression();
|
||||
|
||||
// Lambda introducer
|
||||
consume(IToken.tLBRACKET);
|
||||
boolean needComma= false;
|
||||
switch(LT(1)) {
|
||||
case IToken.tASSIGN:
|
||||
lambdaExpr.setCaptureDefault(CaptureDefault.BY_COPY);
|
||||
consume();
|
||||
needComma= true;
|
||||
break;
|
||||
case IToken.tAMPER:
|
||||
final int lt2 = LT(2);
|
||||
if (lt2 == IToken.tCOMMA || lt2 == IToken.tRBRACKET) {
|
||||
lambdaExpr.setCaptureDefault(CaptureDefault.BY_REFERENCE);
|
||||
consume();
|
||||
needComma= true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
loop: for(;;) {
|
||||
switch (LT(1)) {
|
||||
case IToken.tEOC:
|
||||
return setRange(lambdaExpr, offset, LA().getEndOffset());
|
||||
case IToken.tRBRACKET:
|
||||
consume();
|
||||
break loop;
|
||||
}
|
||||
|
||||
if (needComma) {
|
||||
consume(IToken.tCOMMA);
|
||||
}
|
||||
|
||||
ICPPASTCapture cap= capture();
|
||||
lambdaExpr.addCapture(cap);
|
||||
needComma= true;
|
||||
}
|
||||
|
||||
if (LT(1) == IToken.tLPAREN) {
|
||||
ICPPASTFunctionDeclarator dtor = functionDeclarator(true);
|
||||
lambdaExpr.setDeclarator(dtor);
|
||||
if (LT(1) == IToken.tEOC)
|
||||
return setRange(lambdaExpr, offset, calculateEndOffset(dtor));
|
||||
}
|
||||
|
||||
IASTCompoundStatement body = functionBody();
|
||||
lambdaExpr.setBody(body);
|
||||
return setRange(lambdaExpr, offset, calculateEndOffset(body));
|
||||
}
|
||||
|
||||
private ICPPASTCapture capture() throws EndOfFileException, BacktrackException {
|
||||
final int offset= LA().getOffset();
|
||||
final ICPPASTCapture result = nodeFactory.newCapture();
|
||||
|
||||
switch (LT(1)) {
|
||||
case IToken.t_this:
|
||||
return setRange(result, offset, consume().getEndOffset());
|
||||
case IToken.tAMPER:
|
||||
consume();
|
||||
result.setIsByReference(true);
|
||||
break;
|
||||
}
|
||||
|
||||
final IASTName identifier= identifier();
|
||||
result.setIdentifier(identifier);
|
||||
|
||||
if (LT(1) == IToken.tELLIPSIS) {
|
||||
result.setIsPackExpansion(true);
|
||||
return setRange(result, offset, consume().getEndOffset());
|
||||
}
|
||||
|
||||
return setRange(result, offset, calculateEndOffset(identifier));
|
||||
}
|
||||
|
||||
protected IASTExpression specialCastExpression(int kind) throws EndOfFileException, BacktrackException {
|
||||
final int offset = LA(1).getOffset();
|
||||
final int optype= consume().getType();
|
||||
consume(IToken.tLT);
|
||||
|
@ -3342,7 +3424,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
switch (lt1) {
|
||||
case IToken.tLPAREN:
|
||||
if (option.fAllowFunctions && strategy == DtorStrategy.PREFER_FUNCTION) {
|
||||
result= functionDeclarator();
|
||||
result= functionDeclarator(false);
|
||||
setDeclaratorID(result, hasEllipsis, declaratorName, nestedDeclarator);
|
||||
}
|
||||
break loop;
|
||||
|
@ -3413,9 +3495,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
/**
|
||||
* Parse a function declarator starting with the left parenthesis.
|
||||
*/
|
||||
private ICPPASTDeclarator functionDeclarator() throws EndOfFileException, BacktrackException {
|
||||
private ICPPASTFunctionDeclarator functionDeclarator(boolean isLambdaDeclarator) throws EndOfFileException, BacktrackException {
|
||||
IToken last = consume(IToken.tLPAREN);
|
||||
int startOffset= last.getOffset();
|
||||
final int startOffset= last.getOffset();
|
||||
int endOffset= last.getEndOffset();
|
||||
|
||||
final ICPPASTFunctionDeclarator fc = nodeFactory.newFunctionDeclarator(null);
|
||||
|
@ -3462,18 +3544,25 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
__attribute_decl_seq(supportAttributeSpecifiers, false);
|
||||
|
||||
// cv-qualifiers
|
||||
cvloop: while(true) {
|
||||
switch (LT(1)) {
|
||||
case IToken.t_const:
|
||||
fc.setConst(true);
|
||||
if (isLambdaDeclarator) {
|
||||
if (LT(1) == IToken.t_mutable) {
|
||||
fc.setMutable(true);
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
case IToken.t_volatile:
|
||||
fc.setVolatile(true);
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
default:
|
||||
break cvloop;
|
||||
}
|
||||
} else {
|
||||
cvloop: while(true) {
|
||||
switch (LT(1)) {
|
||||
case IToken.t_const:
|
||||
fc.setConst(true);
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
case IToken.t_volatile:
|
||||
fc.setVolatile(true);
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
default:
|
||||
break cvloop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3524,10 +3613,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
IASTTypeId typeId= typeId(DeclarationOptions.TYPEID_TRAILING_RETURN_TYPE);
|
||||
fc.setTrailingReturnType(typeId);
|
||||
endOffset= calculateEndOffset(typeId);
|
||||
}
|
||||
}
|
||||
|
||||
setRange(fc, startOffset, endOffset);
|
||||
return fc;
|
||||
return setRange(fc, startOffset, endOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4110,11 +4198,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
|
||||
|
||||
@Override
|
||||
protected IASTStatement functionBody() throws EndOfFileException, BacktrackException {
|
||||
protected IASTCompoundStatement functionBody() throws EndOfFileException, BacktrackException {
|
||||
++functionBodyCount;
|
||||
IASTStatement s = super.functionBody();
|
||||
--functionBodyCount;
|
||||
return s;
|
||||
try {
|
||||
return super.functionBody();
|
||||
} finally {
|
||||
--functionBodyCount;
|
||||
}
|
||||
}
|
||||
|
||||
protected IASTStatement parseSwitchStatement() throws EndOfFileException, BacktrackException {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2010 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
|
||||
|
@ -10,26 +10,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImageLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor;
|
||||
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.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNodeSpecification;
|
||||
|
||||
|
@ -37,36 +22,27 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNodeSpecification;
|
|||
* Visitor to select nodes by image-location.
|
||||
* @since 5.0
|
||||
*/
|
||||
public class FindNodeByImageLocation extends CPPASTVisitor implements ICASTVisitor {
|
||||
public class FindNodeByImageLocation extends ASTGenericVisitor {
|
||||
private final int fOffset;
|
||||
private final int fLength;
|
||||
private final ASTNodeSpecification<?> fNodeSpec;
|
||||
|
||||
public FindNodeByImageLocation(int offset, int length, ASTNodeSpecification<?> nodeSpec) {
|
||||
super(!nodeSpec.requiresClass(IASTName.class));
|
||||
fNodeSpec= nodeSpec;
|
||||
fOffset = offset;
|
||||
fLength = length;
|
||||
|
||||
shouldVisitNames = true;
|
||||
shouldVisitDeclarations= true;
|
||||
|
||||
shouldVisitInitializers=
|
||||
shouldVisitParameterDeclarations=
|
||||
shouldVisitDeclarators=
|
||||
shouldVisitDeclSpecifiers=
|
||||
shouldVisitDesignators=
|
||||
shouldVisitEnumerators=
|
||||
shouldVisitExpressions=
|
||||
shouldVisitStatements=
|
||||
shouldVisitTypeIds=
|
||||
shouldVisitEnumerators=
|
||||
shouldVisitBaseSpecifiers=
|
||||
shouldVisitNamespaces=
|
||||
shouldVisitTemplateParameters=
|
||||
shouldVisitTranslationUnit= !nodeSpec.requiresClass(IASTName.class);
|
||||
}
|
||||
|
||||
public int processNode(IASTNode node) {
|
||||
@Override
|
||||
protected int genericVisit(IASTNode node) {
|
||||
return processNode(node);
|
||||
}
|
||||
|
||||
private int processNode(IASTNode node) {
|
||||
if (node instanceof ASTNode) {
|
||||
final ASTNode astNode = (ASTNode) node;
|
||||
if (astNode.getOffset() > fOffset+fLength || astNode.getOffset() + astNode.getLength() < fOffset) {
|
||||
|
@ -93,89 +69,10 @@ public class FindNodeByImageLocation extends CPPASTVisitor implements ICASTVisit
|
|||
return processNode(declaration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTDeclarator declarator) {
|
||||
return processNode(declarator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTDeclSpecifier declSpec) {
|
||||
return processNode(declSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTEnumerator enumerator) {
|
||||
return processNode(enumerator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTExpression expression) {
|
||||
return processNode(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTInitializer initializer) {
|
||||
return processNode(initializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
if (name.toString() != null)
|
||||
return processNode(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTParameterDeclaration parameterDeclaration) {
|
||||
return processNode(parameterDeclaration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTStatement statement) {
|
||||
return processNode(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTTypeId typeId) {
|
||||
return processNode(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTBaseSpecifier baseSpecifier) {
|
||||
return processNode(baseSpecifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||
return processNode(namespaceDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
||||
return processNode(templateParameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTProblem problem) {
|
||||
return processNode(problem);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDesignator(org.eclipse.cdt.core.dom.ast.c.ICASTDesignator)
|
||||
*/
|
||||
public int visit(ICASTDesignator designator) {
|
||||
return processNode(designator);
|
||||
}
|
||||
|
||||
/* (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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int visit(IASTTranslationUnit tu) {
|
||||
return processNode(tu);
|
||||
}
|
||||
}
|
|
@ -12,28 +12,15 @@ package org.eclipse.cdt.ui.tests.DOMAST;
|
|||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
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.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
@ -41,29 +28,16 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulateDOMASTAction {
|
||||
public class CPPPopulateASTViewAction extends ASTGenericVisitor implements IPopulateDOMASTAction {
|
||||
private static final int INITIAL_PROBLEM_SIZE = 4;
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
shouldVisitDeclarations = true;
|
||||
shouldVisitInitializers = true;
|
||||
shouldVisitParameterDeclarations = true;
|
||||
shouldVisitDeclarators = true;
|
||||
shouldVisitDeclSpecifiers = true;
|
||||
shouldVisitExpressions = true;
|
||||
shouldVisitStatements = true;
|
||||
shouldVisitTypeIds = true;
|
||||
shouldVisitEnumerators = true;
|
||||
shouldVisitBaseSpecifiers = true;
|
||||
shouldVisitNamespaces = true;
|
||||
shouldVisitTemplateParameters= true;
|
||||
}
|
||||
|
||||
DOMASTNodeParent root = null;
|
||||
IProgressMonitor monitor = null;
|
||||
IASTProblem[] astProblems = new IASTProblem[INITIAL_PROBLEM_SIZE];
|
||||
|
||||
public CPPPopulateASTViewAction(IASTTranslationUnit tu, IProgressMonitor monitor) {
|
||||
super(true);
|
||||
shouldVisitTranslationUnit= false;
|
||||
root = new DOMASTNodeParent(tu);
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
@ -131,199 +105,22 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
|
|||
return tree;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTDeclaration declaration) {
|
||||
DOMASTNodeLeaf temp = addRoot(declaration);
|
||||
if (temp == null)
|
||||
public int genericVisit(IASTNode declaration) {
|
||||
if (addRoot(declaration) == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processDeclarator(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTDeclarator declarator) {
|
||||
DOMASTNodeLeaf temp = addRoot(declarator);
|
||||
|
||||
IASTPointerOperator[] ops = declarator.getPointerOperators();
|
||||
for (IASTPointerOperator op : ops)
|
||||
addRoot(op);
|
||||
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processBaseSpecifier(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier)
|
||||
*/
|
||||
@Override
|
||||
public int visit(ICPPASTBaseSpecifier specifier) {
|
||||
DOMASTNodeLeaf temp = addRoot(specifier);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTDeclSpecifier declSpec) {
|
||||
DOMASTNodeLeaf temp = addRoot(declSpec);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTEnumerator enumerator) {
|
||||
DOMASTNodeLeaf temp = addRoot(enumerator);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processExpression(org.eclipse.cdt.core.dom.ast.IASTExpression)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTExpression expression) {
|
||||
DOMASTNodeLeaf temp = addRoot(expression);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processInitializer(org.eclipse.cdt.core.dom.ast.IASTInitializer)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTInitializer initializer) {
|
||||
DOMASTNodeLeaf temp = addRoot(initializer);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processName(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
DOMASTNodeLeaf temp = null;
|
||||
if (name.toString() != null)
|
||||
temp = addRoot(name);
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
if (name.toString() != null) {
|
||||
return genericVisit(name);
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processNamespace(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
|
||||
*/
|
||||
@Override
|
||||
public int visit(ICPPASTNamespaceDefinition namespace) {
|
||||
DOMASTNodeLeaf temp = addRoot(namespace);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processParameterDeclaration(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration)
|
||||
*/
|
||||
@Override
|
||||
public int visit(
|
||||
IASTParameterDeclaration parameterDeclaration) {
|
||||
DOMASTNodeLeaf temp = addRoot(parameterDeclaration);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processStatement(org.eclipse.cdt.core.dom.ast.IASTStatement)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTStatement statement) {
|
||||
DOMASTNodeLeaf temp = addRoot(statement);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId)
|
||||
*/
|
||||
@Override
|
||||
public int visit(IASTTypeId typeId) {
|
||||
DOMASTNodeLeaf temp = addRoot(typeId);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter)
|
||||
*/
|
||||
@Override
|
||||
public int visit(ICPPASTTemplateParameter templateParameter) {
|
||||
DOMASTNodeLeaf temp = addRoot(templateParameter);
|
||||
if (temp == null)
|
||||
return PROCESS_ABORT;
|
||||
else if (temp instanceof DOMASTNodeLeafContinue)
|
||||
return PROCESS_CONTINUE;
|
||||
else
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
private DOMASTNodeLeaf mergeNode(ASTNode node) {
|
||||
DOMASTNodeLeaf leaf = addRoot(node);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2010 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
|
||||
|
@ -97,7 +97,7 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
public static final int FLAG_INCLUDE_STATEMENTS = 1<<2;
|
||||
static {
|
||||
ignoreInterfaces.addAll(Arrays.asList(new String[] {
|
||||
"IASTCompletionContext", "IASTNode"
|
||||
"IASTCompletionContext", "ICPPASTCompletionContext", "IASTNode"
|
||||
}));
|
||||
}
|
||||
public DOMASTNodeLeaf(IASTNode node) {
|
||||
|
@ -332,8 +332,7 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
return name;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class key) {
|
||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class key) {
|
||||
if (key == IPropertySource.class)
|
||||
return new ASTPropertySource(getNode());
|
||||
|
||||
|
@ -424,18 +423,18 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
if (node instanceof IASTName) {
|
||||
IPropertyDescriptor[] desc = getPropertyDescriptors(((IASTName)node).resolveBinding());
|
||||
if (desc != null)
|
||||
for(int i=0; i<desc.length; i++)
|
||||
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, desc[i]);
|
||||
for (IPropertyDescriptor element : desc)
|
||||
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, element);
|
||||
desc = getPropertyDescriptors(node);
|
||||
if (desc != null)
|
||||
for(int i=0; i<desc.length; i++)
|
||||
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, desc[i]);
|
||||
for (IPropertyDescriptor element : desc)
|
||||
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, element);
|
||||
|
||||
} else {
|
||||
IPropertyDescriptor[] desc = getPropertyDescriptors(node);
|
||||
if (desc != null)
|
||||
for(int i=0; i<desc.length; i++)
|
||||
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, desc[i]);
|
||||
for (IPropertyDescriptor element : desc)
|
||||
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, element);
|
||||
}
|
||||
|
||||
return (IPropertyDescriptor[])ArrayUtil.trim(IPropertyDescriptor.class, descriptors);
|
||||
|
@ -447,8 +446,8 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
Class<?> objClass = obj.getClass();
|
||||
Class<?>[] interfaces = objClass.getInterfaces();
|
||||
|
||||
for(int i=0; i<interfaces.length; i++) {
|
||||
Method[] methods = interfaces[i].getMethods();
|
||||
for (Class<?> interface1 : interfaces) {
|
||||
Method[] methods = interface1.getMethods();
|
||||
for(int j=0; j<methods.length; j++) {
|
||||
// multiple interfaces can have the same method, so don't duplicate that method in the property view
|
||||
// which causes an ArrayIndexOutOfBoundsException elsewhere
|
||||
|
@ -478,14 +477,14 @@ public class DOMASTNodeLeaf implements IAdaptable {
|
|||
|
||||
private boolean alreadyEncountered(Method method, IPropertyDescriptor[] desc) {
|
||||
StringBuffer name = null;
|
||||
for(int i=0; i<desc.length; i++) {
|
||||
if (desc[i] == null) // reached the end of the array
|
||||
for (IPropertyDescriptor element : desc) {
|
||||
if (element == null) // reached the end of the array
|
||||
break;
|
||||
|
||||
name = new StringBuffer();
|
||||
name.append(method.getName());
|
||||
name.append(EMPTY_PARAMETER);
|
||||
if (name.toString().equals(desc[i].getDisplayName()))
|
||||
if (name.toString().equals(element.getDisplayName()))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue