mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 02:15:31 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
7a10d644c5
132 changed files with 2570 additions and 1385 deletions
|
@ -58,7 +58,6 @@ import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
@ -359,7 +358,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
isExecuted = true;
|
isExecuted = true;
|
||||||
|
|
||||||
Job job = new Job(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobNam")) { //$NON-NLS-1$
|
Job job = new Job(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName")) { //$NON-NLS-1$
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
IStatus status;
|
IStatus status;
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
* of methods that are working with their value.
|
* of methods that are working with their value.
|
||||||
*
|
*
|
||||||
* @author Anton Gorenkov
|
* @author Anton Gorenkov
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization"; //$NON-NLS-1$
|
public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization"; //$NON-NLS-1$
|
||||||
|
@ -65,7 +64,6 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
class OnEachClass extends ASTVisitor {
|
class OnEachClass extends ASTVisitor {
|
||||||
|
|
||||||
// NOTE: Classes can be nested and even can be declared in constructors of the other classes
|
// NOTE: Classes can be nested and even can be declared in constructors of the other classes
|
||||||
private final Stack< Set<IField> > constructorsStack = new Stack< Set<IField> >();
|
private final Stack< Set<IField> > constructorsStack = new Stack< Set<IField> >();
|
||||||
private boolean skipConstructorsWithFCalls = skipConstructorsWithFCalls();
|
private boolean skipConstructorsWithFCalls = skipConstructorsWithFCalls();
|
||||||
|
@ -133,21 +131,21 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bug 368420 - Skip constructor if pattern is *this = toBeCopied;
|
// Bug 368420 - Skip constructor if pattern is *this = toBeCopied;
|
||||||
if(expression instanceof IASTBinaryExpression) {
|
if (expression instanceof IASTBinaryExpression) {
|
||||||
IASTBinaryExpression binaryExpression = (IASTBinaryExpression) expression;
|
IASTBinaryExpression binaryExpression = (IASTBinaryExpression) expression;
|
||||||
if(referencesThis(binaryExpression.getOperand1()) && binaryExpression.getOperand1().isLValue()) {
|
if (referencesThis(binaryExpression.getOperand1()) && binaryExpression.getOperand1().isLValue()) {
|
||||||
skipCurrentConstructor = true;
|
skipCurrentConstructor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipCurrentConstructor) {
|
if (skipCurrentConstructor && !constructorsStack.empty()) {
|
||||||
constructorsStack.peek().clear();
|
constructorsStack.peek().clear();
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks whether expression references this (directly, by pointer or by reference)
|
/**
|
||||||
*
|
* Checks whether expression references this (directly, by pointer or by reference)
|
||||||
*/
|
*/
|
||||||
public boolean referencesThis(IASTNode expr) {
|
public boolean referencesThis(IASTNode expr) {
|
||||||
if (expr instanceof IASTLiteralExpression) {
|
if (expr instanceof IASTLiteralExpression) {
|
||||||
|
@ -224,7 +222,6 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -236,5 +233,4 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
public boolean skipConstructorsWithFCalls() {
|
public boolean skipConstructorsWithFCalls() {
|
||||||
return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_SKIP);
|
return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_SKIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.util.AttributeUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checker looking for unused function or variable declarations.
|
* Checker looking for unused function or variable declarations.
|
||||||
|
@ -58,6 +59,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
public static final String ER_UNUSED_STATIC_FUNCTION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem"; //$NON-NLS-1$
|
public static final String ER_UNUSED_STATIC_FUNCTION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem"; //$NON-NLS-1$
|
||||||
public static final String PARAM_MACRO_ID = "macro"; //$NON-NLS-1$
|
public static final String PARAM_MACRO_ID = "macro"; //$NON-NLS-1$
|
||||||
public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
|
public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
|
||||||
|
private static final String[] ATTRIBUTE_UNUSED = new String[] { "__unused__", "unused" }; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
private Map<IBinding, IASTDeclarator> externFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
private Map<IBinding, IASTDeclarator> externFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
||||||
private Map<IBinding, IASTDeclarator> staticFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
private Map<IBinding, IASTDeclarator> staticFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
|
||||||
|
@ -130,6 +132,8 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
|
|
||||||
IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
|
IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
|
||||||
for (IASTDeclarator decl : declarators) {
|
for (IASTDeclarator decl : declarators) {
|
||||||
|
if (AttributeUtil.hasAttribute(decl, ATTRIBUTE_UNUSED))
|
||||||
|
continue;
|
||||||
IASTName astName = decl.getName();
|
IASTName astName = decl.getName();
|
||||||
if (astName != null) {
|
if (astName != null) {
|
||||||
IBinding binding = astName.resolveBinding();
|
IBinding binding = astName.resolveBinding();
|
||||||
|
@ -191,14 +195,15 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
|
||||||
// definitions
|
// definitions
|
||||||
IASTFunctionDefinition definition = (IASTFunctionDefinition) element;
|
IASTFunctionDefinition definition = (IASTFunctionDefinition) element;
|
||||||
|
|
||||||
IASTName astName = definition.getDeclarator().getName();
|
IASTFunctionDeclarator declarator = definition.getDeclarator();
|
||||||
|
IASTName astName = declarator.getName();
|
||||||
if (astName != null) {
|
if (astName != null) {
|
||||||
IBinding binding = astName.resolveBinding();
|
IBinding binding = astName.resolveBinding();
|
||||||
|
|
||||||
if (definition.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_static) {
|
if (definition.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_static &&
|
||||||
if (!(astName instanceof ICPPASTQualifiedName)) {
|
!(astName instanceof ICPPASTQualifiedName) &&
|
||||||
staticFunctionDefinitions.put(binding, definition.getDeclarator());
|
!AttributeUtil.hasAttribute(declarator, ATTRIBUTE_UNUSED)) {
|
||||||
}
|
staticFunctionDefinitions.put(binding, declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
// externFunctionDeclarators filter out
|
// externFunctionDeclarators filter out
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2011, 2012 Andrew Gvozdev and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -307,4 +307,14 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
|
||||||
checkNoErrors();
|
checkNoErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static int v1 __attribute__((unused));
|
||||||
|
// int f1() __attribute__((__unused__));
|
||||||
|
// extern int f2() __attribute__((unused));
|
||||||
|
// static void f3() __attribute__((unused));
|
||||||
|
// static void f4() __attribute__((unused));
|
||||||
|
// static void f4() __attribute__((unused)) {}
|
||||||
|
public void testAttributeUnused() throws IOException {
|
||||||
|
loadCodeAndRun(getAboveComment());
|
||||||
|
checkNoErrors();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,12 +107,14 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
map.put("__GNUC__", "4");
|
map.put("__GNUC__", "4");
|
||||||
map.put("__GNUC_MINOR__", "5");
|
map.put("__GNUC_MINOR__", "5");
|
||||||
map.put("__SIZEOF_INT__", "4");
|
map.put("__SIZEOF_INT__", "4");
|
||||||
|
map.put("__SIZEOF_LONG__", "8");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, String> getStdMap() {
|
private static Map<String, String> getStdMap() {
|
||||||
Map<String, String> map= new HashMap<String, String>();
|
Map<String, String> map= new HashMap<String, String>();
|
||||||
map.put("__SIZEOF_INT__", "4");
|
map.put("__SIZEOF_INT__", "4");
|
||||||
|
map.put("__SIZEOF_LONG__", "8");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,11 +191,11 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertDefinition(ICPPBinding b) {
|
private void assertDefinition(ICPPBinding b) {
|
||||||
assertTrue(((IASTName)((ICPPInternalBinding) b).getDefinition()).isDefinition());
|
assertTrue(((IASTName) ((ICPPInternalBinding) b).getDefinition()).isDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertDeclaration(ICPPBinding b) {
|
private void assertDeclaration(ICPPBinding b) {
|
||||||
assertTrue(((IASTName)((ICPPInternalBinding) b).getDeclarations()[0]).isDeclaration());
|
assertTrue(((IASTName) ((ICPPInternalBinding) b).getDeclarations()[0]).isDeclaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPMethod extractSingleMethod(IBinding[] bindings) {
|
private ICPPMethod extractSingleMethod(IBinding[] bindings) {
|
||||||
|
@ -4682,10 +4682,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
|
||||||
IASTDeclaration[] decls = tu.getDeclarations();
|
IASTDeclaration[] decls = tu.getDeclarations();
|
||||||
|
|
||||||
assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
|
assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
|
||||||
assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
|
assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
|
||||||
assertTrue(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
|
assertTrue(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
|
||||||
assertEquals(((IASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
|
assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class _A {
|
// class _A {
|
||||||
|
@ -5396,7 +5396,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
ICPPASTFunctionDeclarator fdecl2= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2]).getDeclarators()[0];
|
ICPPASTFunctionDeclarator fdecl2= (ICPPASTFunctionDeclarator) ((IASTSimpleDeclaration) nsdecls[2]).getDeclarators()[0];
|
||||||
|
|
||||||
IASTStatement[] stmts= ((IASTCompoundStatement) fdef.getBody()).getStatements();
|
IASTStatement[] stmts= ((IASTCompoundStatement) fdef.getBody()).getStatements();
|
||||||
IASTName clname= ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration)((IASTDeclarationStatement) stmts[0]).getDeclaration()).getDeclSpecifier()).getName();
|
IASTName clname= ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) stmts[0]).getDeclaration()).getDeclSpecifier()).getName();
|
||||||
IASTName fnname1= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1]).getExpression()).getFunctionNameExpression()).getName();
|
IASTName fnname1= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[1]).getExpression()).getFunctionNameExpression()).getName();
|
||||||
IASTName fnname2= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2]).getExpression()).getFunctionNameExpression()).getName();
|
IASTName fnname2= ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTExpressionStatement) stmts[2]).getExpression()).getFunctionNameExpression()).getName();
|
||||||
|
|
||||||
|
@ -5906,8 +5906,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
|
|
||||||
IType t1= ((IPointerType)pt1.getType().getParameterTypes()[0]).getType();
|
IType t1= ((IPointerType)pt1.getType().getParameterTypes()[0]).getType();
|
||||||
IQualifierType t2= (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
|
IQualifierType t2= (IQualifierType) ((IPointerType) pt2.getType().getParameterTypes()[0]).getType();
|
||||||
IQualifierType t3= (IQualifierType)((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
|
IQualifierType t3= (IQualifierType) ((IPointerType) pt3.getType().getParameterTypes()[0]).getType();
|
||||||
IQualifierType t4= (IQualifierType)((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
|
IQualifierType t4= (IQualifierType) ((IPointerType) pt4.getType().getParameterTypes()[0]).getType();
|
||||||
|
|
||||||
assertTrue(!(t1 instanceof IQualifierType));
|
assertTrue(!(t1 instanceof IQualifierType));
|
||||||
assertTrue(t2.isConst()); assertTrue(!t2.isVolatile());
|
assertTrue(t2.isConst()); assertTrue(!t2.isVolatile());
|
||||||
|
@ -9559,4 +9559,37 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
p= getDeclaration(S, 2);
|
p= getDeclaration(S, 2);
|
||||||
p= getDeclaration(S, 3);
|
p= getDeclaration(S, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// typedef int int8_t __attribute__ ((__mode__ (__QI__)));
|
||||||
|
// typedef int int16_t __attribute__ ((__mode__ (__HI__)));
|
||||||
|
// typedef int int32_t __attribute__ ((__mode__ (__SI__)));
|
||||||
|
// typedef int int64_t __attribute__ ((__mode__ (__DI__)));
|
||||||
|
// typedef int word_t __attribute__ ((__mode__ (__word__)));
|
||||||
|
// void f(int8_t*) {}
|
||||||
|
// void f(int16_t*) {}
|
||||||
|
// void f(int32_t*) {}
|
||||||
|
// void f(int64_t*) {}
|
||||||
|
// void test(signed char* i8, short* i16, int* i32, long* i64, word_t* word) {
|
||||||
|
// f(i8);
|
||||||
|
// f(i16);
|
||||||
|
// f(i32);
|
||||||
|
// f(i64);
|
||||||
|
// f(word);
|
||||||
|
// }
|
||||||
|
public void testModeAttribute_330635() throws Exception {
|
||||||
|
BindingAssertionHelper bh= getAssertionHelper();
|
||||||
|
String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" };
|
||||||
|
ICPPFunction[] functions = new ICPPFunction[calls.length];
|
||||||
|
for (int i = 0; i < calls.length; i++) {
|
||||||
|
functions[i] = bh.assertNonProblem(calls[i], 1, ICPPFunction.class);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < functions.length - 1; i++) {
|
||||||
|
for (int j = 0; j < i ; j++) {
|
||||||
|
assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function",
|
||||||
|
functions[i], functions[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions",
|
||||||
|
functions[calls.length - 1], functions[calls.length - 2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 IBM Corporation.
|
* Copyright (c) 2006, 2012 IBM Corporation.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
@ -74,6 +75,12 @@ public class CFunctionTests extends PDOMTestBase {
|
||||||
assertTrue(((IFunction) bindings[0]).takesVarArgs());
|
assertTrue(((IFunction) bindings[0]).takesVarArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNoReturnCFunction() throws Exception {
|
||||||
|
IBinding[] bindings = findQualifiedName(pdom, "noReturnCFunction");
|
||||||
|
assertEquals(1, bindings.length);
|
||||||
|
assertTrue(((IFunction) bindings[0]).isNoReturn());
|
||||||
|
}
|
||||||
|
|
||||||
public void testKnRStyleFunctionWithProblemParameters() throws Exception {
|
public void testKnRStyleFunctionWithProblemParameters() throws Exception {
|
||||||
IBinding[] bindings = findQualifiedName(pdom, "KnRfunctionWithProblemParameters");
|
IBinding[] bindings = findQualifiedName(pdom, "KnRfunctionWithProblemParameters");
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 IBM Corporation.
|
* Copyright (c) 2006, 2012 IBM Corporation.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
@ -38,7 +39,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public class CPPFunctionTests extends PDOMTestBase {
|
public class CPPFunctionTests extends PDOMTestBase {
|
||||||
protected ICProject project;
|
protected ICProject project;
|
||||||
|
|
||||||
protected PDOM pdom;
|
protected PDOM pdom;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
@ -137,13 +137,19 @@ public class CPPFunctionTests extends PDOMTestBase {
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertTrue(((ICPPFunction) bindings[0]).isInline());
|
assertTrue(((ICPPFunction) bindings[0]).isInline());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVarArgsCPPFunction() throws Exception {
|
public void testVarArgsCPPFunction() throws Exception {
|
||||||
IBinding[] bindings = findQualifiedName(pdom, "varArgsCPPFunction");
|
IBinding[] bindings = findQualifiedName(pdom, "varArgsCPPFunction");
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertTrue(((ICPPFunction) bindings[0]).takesVarArgs());
|
assertTrue(((ICPPFunction) bindings[0]).takesVarArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNoReturnCPPFunction() throws Exception {
|
||||||
|
IBinding[] bindings = findQualifiedName(pdom, "noReturnCPPFunction");
|
||||||
|
assertEquals(1, bindings.length);
|
||||||
|
assertTrue(((ICPPFunction) bindings[0]).isNoReturn());
|
||||||
|
}
|
||||||
|
|
||||||
public void testForwardDeclarationType() throws Exception {
|
public void testForwardDeclarationType() throws Exception {
|
||||||
assertType(pdom, "forwardDeclaration", ICPPFunction.class);
|
assertType(pdom, "forwardDeclaration", ICPPFunction.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ void varArgsCFunction(int p1, ...);
|
||||||
const void constCFunction();
|
const void constCFunction();
|
||||||
volatile void volatileCFunction();
|
volatile void volatileCFunction();
|
||||||
void storageClassCFunction(register int p1, int p2);
|
void storageClassCFunction(register int p1, int p2);
|
||||||
|
void noReturnCFunction() __attribute__((noreturn));
|
||||||
|
|
||||||
void voidCFunction();
|
void voidCFunction();
|
||||||
int intCFunction();
|
int intCFunction();
|
||||||
|
|
|
@ -4,6 +4,7 @@ static int staticCPPFunction(double p1);
|
||||||
extern float externCPPFunction(int p1);
|
extern float externCPPFunction(int p1);
|
||||||
inline void inlineCPPFunction(long p1);
|
inline void inlineCPPFunction(long p1);
|
||||||
void varArgsCPPFunction(int p1, ...);
|
void varArgsCPPFunction(int p1, ...);
|
||||||
|
void noReturnCPPFunction() __attribute__((noreturn));
|
||||||
|
|
||||||
void voidCPPFunction();
|
void voidCPPFunction();
|
||||||
int intCPPFunction();
|
int intCPPFunction();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Mike Kucera (IBM) - implicit names
|
* Mike Kucera (IBM) - implicit names
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -76,6 +77,16 @@ public abstract class ASTVisitor {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public boolean shouldVisitPointerOperators = false;
|
public boolean shouldVisitPointerOperators = false;
|
||||||
|
/**
|
||||||
|
* Set this flag to visit attributes.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public boolean shouldVisitAttributes = false;
|
||||||
|
/**
|
||||||
|
* Set this flag to visit token nodes.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public boolean shouldVisitTokens = false;
|
||||||
/**
|
/**
|
||||||
* Set this flag to visit expressions.
|
* Set this flag to visit expressions.
|
||||||
*/
|
*/
|
||||||
|
@ -168,7 +179,8 @@ public abstract class ASTVisitor {
|
||||||
* @param visitNodes whether visitor is setup to visit all nodes per default, except
|
* @param visitNodes whether visitor is setup to visit all nodes per default, except
|
||||||
* ambiguous nodes ({@link #shouldVisitAmbiguousNodes}),
|
* ambiguous nodes ({@link #shouldVisitAmbiguousNodes}),
|
||||||
* inactive nodes ({@link #includeInactiveNodes}),
|
* inactive nodes ({@link #includeInactiveNodes}),
|
||||||
* and implicit names (@link {@link #shouldVisitImplicitNames}).
|
* implicit names ({@link #shouldVisitImplicitNames}),
|
||||||
|
* and tokens ({@link #shouldVisitTokens}).
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
public ASTVisitor(boolean visitNodes) {
|
public ASTVisitor(boolean visitNodes) {
|
||||||
|
@ -186,6 +198,7 @@ public abstract class ASTVisitor {
|
||||||
shouldVisitNamespaces= visitNodes;
|
shouldVisitNamespaces= visitNodes;
|
||||||
shouldVisitParameterDeclarations= visitNodes;
|
shouldVisitParameterDeclarations= visitNodes;
|
||||||
shouldVisitPointerOperators= visitNodes;
|
shouldVisitPointerOperators= visitNodes;
|
||||||
|
shouldVisitAttributes= visitNodes;
|
||||||
shouldVisitProblems= visitNodes;
|
shouldVisitProblems= visitNodes;
|
||||||
shouldVisitStatements= visitNodes;
|
shouldVisitStatements= visitNodes;
|
||||||
shouldVisitTemplateParameters= visitNodes;
|
shouldVisitTemplateParameters= visitNodes;
|
||||||
|
@ -222,20 +235,26 @@ public abstract class ASTVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @since 5.1 */
|
||||||
* @since 5.1
|
|
||||||
*/
|
|
||||||
public int visit(IASTArrayModifier arrayModifier) {
|
public int visit(IASTArrayModifier arrayModifier) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @since 5.1 */
|
||||||
* @since 5.1
|
|
||||||
*/
|
|
||||||
public int visit(IASTPointerOperator ptrOperator) {
|
public int visit(IASTPointerOperator ptrOperator) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public int visit(IASTAttribute attribute) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public int visit(IASTToken token) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -320,20 +339,26 @@ public abstract class ASTVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @since 5.1 */
|
||||||
* @since 5.1
|
|
||||||
*/
|
|
||||||
public int leave(IASTArrayModifier arrayModifier) {
|
public int leave(IASTArrayModifier arrayModifier) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @since 5.1 */
|
||||||
* @since 5.1
|
|
||||||
*/
|
|
||||||
public int leave(IASTPointerOperator ptrOperator) {
|
public int leave(IASTPointerOperator ptrOperator) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public int leave(IASTAttribute attribute) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public int leave(IASTToken token) {
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
public int leave(IASTExpression expression) {
|
public int leave(IASTExpression expression) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a C++11 (ISO/IEC 14882:2011 7.6)
|
||||||
|
* or a GCC attribute (http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html).
|
||||||
|
*
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public interface IASTAttribute extends IASTNode {
|
||||||
|
public static final IASTAttribute[] EMPTY_ATTRIBUTE_ARRAY = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>ATTRIBUTE_ARGUMENT</code> represents the relationship between an
|
||||||
|
* <code>IASTAttribute</code> and an <code>IASTExpression</code>.
|
||||||
|
*/
|
||||||
|
public static final ASTNodeProperty ARGUMENT_CLAUSE = new ASTNodeProperty(
|
||||||
|
"IASTAttribute.ARGUMENT_CLAUSE - IASTToken, argument clause for IASTAttribute"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the attribute.
|
||||||
|
*/
|
||||||
|
public char[] getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns arguments of this attribute, or {@code null} if the attribute doesn't have arguments.
|
||||||
|
*/
|
||||||
|
public IASTToken getArgumentClause();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the argument clause.
|
||||||
|
*/
|
||||||
|
public void setArgumentClause(IASTToken argumentClause);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute copy();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute copy(CopyStyle style);
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 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:
|
||||||
|
* Sergey Prigogin (Google) - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An AST node that may have attributes.
|
||||||
|
* @since 5.4
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
*/
|
||||||
|
public interface IASTAttributeOwner extends IASTNode {
|
||||||
|
public static final ASTNodeProperty ATTRIBUTE =
|
||||||
|
new ASTNodeProperty("IASTAttributeOwner.ATTRIBUTE"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the array of attributes.
|
||||||
|
*/
|
||||||
|
public IASTAttribute[] getAttributes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an attribute to the node.
|
||||||
|
*/
|
||||||
|
public void addAttribute(IASTAttribute attribute);
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
public interface IASTDeclarator extends IASTNameOwner, IASTAttributeOwner {
|
||||||
/**
|
/**
|
||||||
* Constant - empty declarator array
|
* Constant - empty declarator array
|
||||||
*/
|
*/
|
||||||
|
@ -51,8 +51,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
"IASTDeclarator.DECLARATOR_NAME - IASTName for IASTDeclarator"); //$NON-NLS-1$
|
"IASTDeclarator.DECLARATOR_NAME - IASTName for IASTDeclarator"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the list of pointer operators applied to the type for the
|
* This is the list of pointer operators applied to the type for the declarator.
|
||||||
* declarator.
|
|
||||||
*
|
*
|
||||||
* @return array of IASTPointerOperator
|
* @return array of IASTPointerOperator
|
||||||
*/
|
*/
|
||||||
|
@ -61,8 +60,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
/**
|
/**
|
||||||
* Adds a pointer operator to the declarator.
|
* Adds a pointer operator to the declarator.
|
||||||
*
|
*
|
||||||
* @param operator
|
* @param operator a <code>IASTPointerOperator</code> to be added.
|
||||||
* <code>IASTPointerOperator</code> to be added.
|
|
||||||
*/
|
*/
|
||||||
public void addPointerOperator(IASTPointerOperator operator);
|
public void addPointerOperator(IASTPointerOperator operator);
|
||||||
|
|
||||||
|
@ -106,7 +104,7 @@ public interface IASTDeclarator extends IASTNode, IASTNameOwner {
|
||||||
* <code>IASTInitializer</code>
|
* <code>IASTInitializer</code>
|
||||||
*/
|
*/
|
||||||
public void setInitializer(IASTInitializer initializer);
|
public void setInitializer(IASTInitializer initializer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -17,8 +18,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTSimpleDeclaration extends IASTDeclaration {
|
public interface IASTSimpleDeclaration extends IASTDeclaration, IASTAttributeOwner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>DECL_SPECIFIER</code> represents the relationship between an
|
* <code>DECL_SPECIFIER</code> represents the relationship between an
|
||||||
* <code>IASTSimpleDeclaration</code> and it's nested
|
* <code>IASTSimpleDeclaration</code> and it's nested
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -16,10 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTStatement extends IASTNode {
|
public interface IASTStatement extends IASTAttributeOwner {
|
||||||
/**
|
|
||||||
* Constant.
|
|
||||||
*/
|
|
||||||
public static final IASTStatement[] EMPTY_STATEMENT_ARRAY = {};
|
public static final IASTStatement[] EMPTY_STATEMENT_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an arbitrary code token.
|
||||||
|
*
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public interface IASTToken extends IASTNode {
|
||||||
|
public static final IASTToken[] EMPTY_TOKEN_ARRAY = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the token type.
|
||||||
|
* @see org.eclipse.cdt.core.parser.IToken#getType()
|
||||||
|
*/
|
||||||
|
public int getTokenType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the token text.
|
||||||
|
* @see org.eclipse.cdt.core.parser.IToken#getCharImage()
|
||||||
|
*/
|
||||||
|
public char[] getTokenCharImage();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTToken copy();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTToken copy(CopyStyle style);
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a sequence of code tokens.
|
||||||
|
*
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public interface IASTTokenList extends IASTToken {
|
||||||
|
/**
|
||||||
|
* {@code NESTED_TOKEN} describes the relationship between
|
||||||
|
* {@code IASTTokenList} and the nested {@code IASTToken}s.
|
||||||
|
*/
|
||||||
|
public static final ASTNodeProperty NESTED_TOKEN = new ASTNodeProperty(
|
||||||
|
"IASTTokenList.NESTED_TOKEN - Nested IASTToken for IASTTokenList"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns nested tokens.
|
||||||
|
*/
|
||||||
|
public IASTToken[] getTokens();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a nested token.
|
||||||
|
*
|
||||||
|
* @param token a token to be added to the list
|
||||||
|
*/
|
||||||
|
public void addToken(IASTToken token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the list contains a single token, returns its type. Otherwise returns 0.
|
||||||
|
* @see org.eclipse.cdt.core.parser.IToken#getType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getTokenType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the list contains a single token, returns its text. Otherwise returns {@code null}.
|
||||||
|
* @see org.eclipse.cdt.core.parser.IToken#getCharImage()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public char[] getTokenCharImage();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTTokenList copy();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTTokenList copy(CopyStyle style);
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -51,4 +52,11 @@ public interface IFunction extends IBinding {
|
||||||
* Returns {@code true} if this function takes variable arguments.
|
* Returns {@code true} if this function takes variable arguments.
|
||||||
*/
|
*/
|
||||||
public boolean takesVarArgs();
|
public boolean takesVarArgs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if this function never returns. Based on 'noreturn' attribute in
|
||||||
|
* the function declaration.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public boolean isNoReturn();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 IBM Corporation and others.
|
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Mike Kucera (IBM Corporation) - initial API and implementation
|
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -47,6 +48,9 @@ public interface INodeFactory {
|
||||||
|
|
||||||
public IASTASMDeclaration newASMDeclaration(String assembly);
|
public IASTASMDeclaration newASMDeclaration(String assembly);
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public IASTAttribute newAttribute(char[] name, IASTToken argumentClause);
|
||||||
|
|
||||||
public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
|
public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2);
|
||||||
|
|
||||||
public IASTBreakStatement newBreakStatement();
|
public IASTBreakStatement newBreakStatement();
|
||||||
|
@ -158,6 +162,12 @@ public interface INodeFactory {
|
||||||
|
|
||||||
public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body);
|
public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body);
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public IASTToken newToken(int tokenType, char[] tokenImage);
|
||||||
|
|
||||||
|
/** @since 5.4 */
|
||||||
|
public IASTTokenList newTokenList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
|
* @deprecated Replaced by {@link #newTranslationUnit(IScanner)}.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -16,14 +16,13 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a namespace alias in C++. e.g. namespace ABC { int
|
* This interface represents a namespace alias in C++,
|
||||||
* x; } namspace DEF = ABC;
|
* e.g. namespace ABC { int* x; } namespace DEF = ABC;
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner {
|
public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ALIAS_NAME</code> represents the new namespace name being
|
* <code>ALIAS_NAME</code> represents the new namespace name being
|
||||||
* introduced.
|
* introduced.
|
||||||
|
@ -68,7 +67,6 @@ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner {
|
||||||
*/
|
*/
|
||||||
public void setMappingName(IASTName qualifiedName);
|
public void setMappingName(IASTName qualifiedName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@ -80,5 +78,4 @@ public interface ICPPASTNamespaceAlias extends IASTDeclaration, IASTNameOwner {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTNamespaceAlias copy(CopyStyle style);
|
public ICPPASTNamespaceAlias copy(CopyStyle style);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,13 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
|
@ -21,8 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTUsingDeclaration extends IASTDeclaration, IASTNameOwner {
|
public interface ICPPASTUsingDeclaration extends IASTDeclaration, IASTNameOwner, IASTAttributeOwner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>NAME</code> is the qualified name brought into scope.
|
* <code>NAME</code> is the qualified name brought into scope.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
|
@ -21,10 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner {
|
public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner, IASTAttributeOwner {
|
||||||
/**
|
|
||||||
* Constant.
|
|
||||||
*/
|
|
||||||
public static final ICPPASTUsingDirective[] EMPTY_USINGDIRECTIVE_ARRAY = new ICPPASTUsingDirective[0];
|
public static final ICPPASTUsingDirective[] EMPTY_USINGDIRECTIVE_ARRAY = new ICPPASTUsingDirective[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,5 +59,4 @@ public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICPPASTUsingDirective copy(CopyStyle style);
|
public ICPPASTUsingDirective copy(CopyStyle style);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.parser.IScanner;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPNodeFactory extends INodeFactory {
|
public interface ICPPNodeFactory extends INodeFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +50,7 @@ public interface ICPPNodeFactory extends INodeFactory {
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTInitializerClause subscript);
|
public ICPPASTArraySubscriptExpression newArraySubscriptExpression(IASTExpression arrayExpr, IASTInitializerClause subscript);
|
||||||
|
|
||||||
public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
|
public ICPPASTBaseSpecifier newBaseSpecifier(IASTName name, int visibility, boolean isVirtual);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser.util;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of static methods for dealing with attributes.
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTAttribute
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.IASTAttributeOwner
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public class AttributeUtil {
|
||||||
|
private static final String[] ATTRIBUTE_NORETURN = new String[] { "__noreturn__", "noreturn" }; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
||||||
|
// Not instantiatable.
|
||||||
|
private AttributeUtil() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if a declarator has an attribute with one of the given names.
|
||||||
|
* The {@code names} array is assumed to be small.
|
||||||
|
*/
|
||||||
|
public static boolean hasAttribute(IASTAttributeOwner node, String[] names) {
|
||||||
|
IASTAttribute[] attributes = node.getAttributes();
|
||||||
|
for (IASTAttribute attribute : attributes) {
|
||||||
|
char[] name = attribute.getName();
|
||||||
|
for (int i = 0; i < names.length; i++) {
|
||||||
|
if (CharArrayUtils.equals(name, names[i]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the node has a "noreturn" or "__noreturn__" attribute.
|
||||||
|
*/
|
||||||
|
public static boolean hasNoreturnAttribute(IASTAttributeOwner node) {
|
||||||
|
return hasAttribute(node, ATTRIBUTE_NORETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns character representation of the attribute argument, or {@code null} if the attribute
|
||||||
|
* has zero or more than one argument.
|
||||||
|
*/
|
||||||
|
public static char[] getSimpleArgument(IASTAttribute attribute) {
|
||||||
|
IASTToken argumentClause = attribute.getArgumentClause();
|
||||||
|
return argumentClause == null ? null : argumentClause.getTokenCharImage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.util;
|
package org.eclipse.cdt.core.parser.util;
|
||||||
|
|
||||||
|
@ -19,7 +20,9 @@ import java.util.Arrays;
|
||||||
* @author dschaefe
|
* @author dschaefe
|
||||||
*/
|
*/
|
||||||
public class CharArrayUtils {
|
public class CharArrayUtils {
|
||||||
public static final char[] EMPTY = {};
|
/** @since 5.4 */
|
||||||
|
public static final char[] EMPTY_CHAR_ARRAY = {};
|
||||||
|
public static final char[] EMPTY = EMPTY_CHAR_ARRAY;
|
||||||
|
|
||||||
private CharArrayUtils() {}
|
private CharArrayUtils() {}
|
||||||
|
|
||||||
|
@ -54,6 +57,40 @@ public class CharArrayUtils {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if the contents of a character array are the same as contents
|
||||||
|
* of a string.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public static final boolean equals(char[] str1, String str2) {
|
||||||
|
int length = str1.length;
|
||||||
|
if (str2.length() != length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (str1[i] != str2.charAt(i))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@code true} if a prefix of the character array is the same as contents
|
||||||
|
* of a string.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public static final boolean startsWith(char[] str1, String str2) {
|
||||||
|
int len = str2.length();
|
||||||
|
if (str1.length < len)
|
||||||
|
return false;
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
if (str1[i] != str2.charAt(i)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a lexicographical comparator for char arrays. Comparison is done
|
* Implements a lexicographical comparator for char arrays. Comparison is done
|
||||||
* on a per char basis, not a code-point basis.
|
* on a per char basis, not a code-point basis.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 IBM Corporation and others.
|
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,9 +7,11 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Mike Kucera (IBM Corporation) - initial API and implementation
|
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.util;
|
package org.eclipse.cdt.core.parser.util;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
@ -110,4 +112,25 @@ public final class CollectionUtils {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combines two collections into one.
|
||||||
|
* @param c1 The first collection. May be modified as a result of the call. May be {@code null}.
|
||||||
|
* @param c2 The second collection. May be {@code null}.
|
||||||
|
* @return A collection containing elements from both input collections,
|
||||||
|
* or {@code null} if both, {@code c1} and {@code c2} are {@code null}.
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public static <T, U extends Collection<T>> U merge(U c1, U c2) {
|
||||||
|
if (c1 == null)
|
||||||
|
return c2;
|
||||||
|
if (c2 == null)
|
||||||
|
return c1;
|
||||||
|
if (c1.isEmpty())
|
||||||
|
return c2;
|
||||||
|
if (c2.isEmpty())
|
||||||
|
return c1;
|
||||||
|
c1.addAll(c2);
|
||||||
|
return c1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for C and C++ attributes.
|
||||||
|
*/
|
||||||
|
public abstract class ASTAttribute extends ASTNode implements IASTAttribute {
|
||||||
|
private final char[] name;
|
||||||
|
private final IASTToken argumentClause;
|
||||||
|
|
||||||
|
public ASTAttribute(char[] name, IASTToken arguments) {
|
||||||
|
this.name = name;
|
||||||
|
this.argumentClause = arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char[] getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTToken getArgumentClause() {
|
||||||
|
return argumentClause;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setArgumentClause(IASTToken argumentClause) {
|
||||||
|
assertNotFrozen();
|
||||||
|
if (argumentClause != null) {
|
||||||
|
argumentClause.setParent(this);
|
||||||
|
argumentClause.setPropertyInParent(ARGUMENT_CLAUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(ASTVisitor action) {
|
||||||
|
if (action.shouldVisitAttributes) {
|
||||||
|
switch (action.visit(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argumentClause != null && !argumentClause.accept(action)) return false;
|
||||||
|
|
||||||
|
if (action.shouldVisitAttributes && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classes that implement IASTAttributeOwner interface may extend this class.
|
||||||
|
*/
|
||||||
|
public abstract class ASTAttributeOwner extends ASTNode implements IASTAttributeOwner {
|
||||||
|
private IASTAttribute[] attributes = IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
attributes = ArrayUtil.trim(attributes);
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
assertNotFrozen();
|
||||||
|
if (attribute != null) {
|
||||||
|
attribute.setParent(this);
|
||||||
|
attribute.setPropertyInParent(ATTRIBUTE);
|
||||||
|
attributes = ArrayUtil.append(attributes, attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <T extends ASTAttributeOwner> T copy(T copy, CopyStyle style) {
|
||||||
|
for (IASTAttribute attribute : getAttributes()) {
|
||||||
|
copy.addAttribute(attribute.copy(style));
|
||||||
|
}
|
||||||
|
return super.copy(copy, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean acceptByAttributes(ASTVisitor action) {
|
||||||
|
for (IASTAttribute attribute : attributes) {
|
||||||
|
if (attribute == null)
|
||||||
|
break;
|
||||||
|
if (!attribute.accept(action))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -370,6 +370,14 @@ public abstract class ASTNode implements IASTNode {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected <T extends ASTNode> T copy(T copy, CopyStyle style) {
|
||||||
|
copy.setOffsetAndLength(this);
|
||||||
|
if (style == CopyStyle.withLocations) {
|
||||||
|
copy.setCopyLocation(this);
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setCopyLocation(IASTNode originalNode) {
|
protected void setCopyLocation(IASTNode originalNode) {
|
||||||
locations = new IASTNodeLocation[] { new ASTCopyLocation(originalNode) };
|
locations = new IASTNodeLocation[] { new ASTCopyLocation(originalNode) };
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a code token.
|
||||||
|
*/
|
||||||
|
public class ASTToken extends ASTNode implements IASTToken {
|
||||||
|
private final int tokenType;
|
||||||
|
private final char[] tokenImage;
|
||||||
|
|
||||||
|
public ASTToken(int tokenType, char[] tokenImage) {
|
||||||
|
this.tokenType = tokenType;
|
||||||
|
this.tokenImage = tokenImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTokenType() {
|
||||||
|
return tokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char[] getTokenCharImage() {
|
||||||
|
return tokenImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ASTToken copy() {
|
||||||
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ASTToken copy(CopyStyle style) {
|
||||||
|
return copy(new ASTToken(tokenType, tokenImage), style);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(ASTVisitor action) {
|
||||||
|
if (action.shouldVisitTokens) {
|
||||||
|
switch (action.visit(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action.shouldVisitTokens) {
|
||||||
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTokenList;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a sequence of code tokens.
|
||||||
|
*/
|
||||||
|
public class ASTTokenList extends ASTNode implements IASTTokenList {
|
||||||
|
private IASTToken[] tokens = IASTToken.EMPTY_TOKEN_ARRAY;
|
||||||
|
|
||||||
|
public ASTTokenList() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ASTTokenList copy() {
|
||||||
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ASTTokenList copy(CopyStyle style) {
|
||||||
|
ASTTokenList copy = new ASTTokenList();
|
||||||
|
for (IASTToken token : tokens) {
|
||||||
|
if (token == null)
|
||||||
|
break;
|
||||||
|
copy.addToken(token.copy(style));
|
||||||
|
}
|
||||||
|
return copy(copy, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTToken[] getTokens() {
|
||||||
|
tokens = ArrayUtil.trim(tokens);
|
||||||
|
return tokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addToken(IASTToken token) {
|
||||||
|
tokens = ArrayUtil.append(tokens, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTokenType() {
|
||||||
|
IASTToken[] tok = getTokens();
|
||||||
|
return tok != null && tok.length == 1 ? tok[0].getTokenType() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char[] getTokenCharImage() {
|
||||||
|
IASTToken[] tok = getTokens();
|
||||||
|
return tok != null && tok.length == 1 ? tok[0].getTokenCharImage() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(ASTVisitor action) {
|
||||||
|
if (action.shouldVisitTokens) {
|
||||||
|
switch (action.visit(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (IASTToken token : tokens) {
|
||||||
|
if (token == null)
|
||||||
|
break;
|
||||||
|
if (!token.accept(action)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action.shouldVisitTokens && action.leave(this) == ASTVisitor.PROCESS_ABORT)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,13 +10,18 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||||
|
@ -60,6 +65,8 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTokenList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
|
@ -83,6 +90,7 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||||
import org.eclipse.cdt.core.parser.ParseError;
|
import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CollectionUtils;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -484,8 +492,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume the next token available only if the type is as specified. In case we reached the end of
|
* Consume the next token available only if the type is as specified. In case we reached
|
||||||
* completion, no token is consumed and the eoc-token returned.
|
* the end of completion, no token is consumed and the eoc-token returned.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* The type of token that you are expecting.
|
* The type of token that you are expecting.
|
||||||
|
@ -2314,26 +2322,38 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
*
|
*
|
||||||
* @param allowAttrib if true accept any number of __attribute__
|
* @param allowAttrib if true accept any number of __attribute__
|
||||||
* @param allowDeclspec if true accept any number of __declspec
|
* @param allowDeclspec if true accept any number of __declspec
|
||||||
|
* @return the list of attributes, or {@code null} if there are none
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* @throws EndOfFileException
|
* @throws EndOfFileException
|
||||||
*/
|
*/
|
||||||
protected void __attribute_decl_seq(boolean allowAttrib, boolean allowDeclspec) throws BacktrackException, EndOfFileException {
|
protected List<IASTAttribute> __attribute_decl_seq(boolean allowAttrib, boolean allowDeclspec)
|
||||||
|
throws BacktrackException, EndOfFileException {
|
||||||
|
List<IASTAttribute> result = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
final int lt = LTcatchEOF(1);
|
final int lt = LTcatchEOF(1);
|
||||||
if (allowAttrib && (lt == IGCCToken.t__attribute__)) {
|
if (allowAttrib && (lt == IGCCToken.t__attribute__)) {
|
||||||
__attribute__();
|
result = CollectionUtils.merge(result, __attribute__());
|
||||||
} else if (allowDeclspec && (lt == IGCCToken.t__declspec)) {
|
} else if (allowDeclspec && (lt == IGCCToken.t__declspec)) {
|
||||||
__declspec();
|
__declspec();
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void __attribute__() throws BacktrackException, EndOfFileException {
|
/**
|
||||||
|
* Parses an __attribute__ clause.
|
||||||
|
* @return the list of attributes, or {@code null} if the __attribute__ clause contained
|
||||||
|
* no attributes
|
||||||
|
* @throws BacktrackException
|
||||||
|
* @throws EndOfFileException
|
||||||
|
*/
|
||||||
|
protected List<IASTAttribute> __attribute__() throws BacktrackException, EndOfFileException {
|
||||||
if (LT(1) != IGCCToken.t__attribute__)
|
if (LT(1) != IGCCToken.t__attribute__)
|
||||||
return;
|
return null;
|
||||||
|
|
||||||
|
List<IASTAttribute> result = null;
|
||||||
consume();
|
consume();
|
||||||
if (LT(1) == IToken.tLPAREN) {
|
if (LT(1) == IToken.tLPAREN) {
|
||||||
consume();
|
consume();
|
||||||
|
@ -2346,7 +2366,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
// Allow empty attribute
|
// Allow empty attribute
|
||||||
if (lt1 != IToken.tCOMMA) {
|
if (lt1 != IToken.tCOMMA) {
|
||||||
singleAttribute();
|
IASTAttribute attribute = singleAttribute();
|
||||||
|
if (result == null)
|
||||||
|
result = new ArrayList<IASTAttribute>();
|
||||||
|
result.add(attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require comma
|
// Require comma
|
||||||
|
@ -2358,41 +2381,100 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
consumeOrEOC(IToken.tRPAREN);
|
consumeOrEOC(IToken.tRPAREN);
|
||||||
consumeOrEOC(IToken.tRPAREN);
|
consumeOrEOC(IToken.tRPAREN);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void singleAttribute() throws EndOfFileException, BacktrackException {
|
private IASTAttribute singleAttribute() throws EndOfFileException, BacktrackException {
|
||||||
// Check if we have an identifier including keywords
|
// Get an identifier including keywords
|
||||||
if (!isIdentifier(LA(1)))
|
IToken attributeName = identifierOrKeyword();
|
||||||
throw backtrack;
|
IASTToken argumentClause = null;
|
||||||
consume();
|
// Check for arguments
|
||||||
|
|
||||||
// Check for parameters
|
|
||||||
if (LT(1) == IToken.tLPAREN) {
|
if (LT(1) == IToken.tLPAREN) {
|
||||||
consume();
|
consume();
|
||||||
for(;;) {
|
argumentClause = balancedTokenSeq(IToken.tRPAREN);
|
||||||
final int lt2= LT(1);
|
|
||||||
if (lt2 == IToken.tRPAREN || lt2 == IToken.tEOC)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Allow empty parameter
|
|
||||||
if (lt2 != IToken.tCOMMA) {
|
|
||||||
expression();
|
|
||||||
}
|
|
||||||
// Require comma
|
|
||||||
if (LT(1) != IToken.tCOMMA)
|
|
||||||
break;
|
|
||||||
consume();
|
|
||||||
}
|
|
||||||
consumeOrEOC(IToken.tRPAREN);
|
consumeOrEOC(IToken.tRPAREN);
|
||||||
}
|
}
|
||||||
|
IASTAttribute result = nodeFactory.newAttribute(attributeName.getCharImage(), argumentClause);
|
||||||
|
setRange(result, attributeName.getOffset(), getEndOffset());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIdentifier(IToken t) {
|
private IToken identifierOrKeyword() throws EndOfFileException, BacktrackException {
|
||||||
|
IToken t = LA(1);
|
||||||
char[] image= t.getCharImage();
|
char[] image= t.getCharImage();
|
||||||
if (image.length == 0)
|
if (image.length == 0)
|
||||||
return false;
|
throw backtrack;
|
||||||
char firstChar= image[0];
|
char firstChar= image[0];
|
||||||
return Character.isLetter(firstChar) || firstChar == '_';
|
if (!Character.isLetter(firstChar) && firstChar != '_')
|
||||||
|
throw backtrack;
|
||||||
|
consume();
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IASTToken balancedTokenSeq(int endType) throws EndOfFileException, BacktrackException {
|
||||||
|
IASTToken result = null;
|
||||||
|
IToken t;
|
||||||
|
while ((t = LA(1)).getType() != endType) {
|
||||||
|
consume();
|
||||||
|
IASTToken token;
|
||||||
|
switch (LT(1)) {
|
||||||
|
case IToken.tLPAREN:
|
||||||
|
token = balancedTokenSeq(t.getOffset(), IToken.tRPAREN);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IToken.tLBRACKET:
|
||||||
|
token = balancedTokenSeq(t.getOffset(), IToken.tRBRACKET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
token = balancedTokenSeq(t.getOffset(), IToken.tRBRACE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
token = nodeFactory.newToken(t.getType(), t.getCharImage());
|
||||||
|
setRange(token, t.getOffset(), t.getEndOffset());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result = addTokenToSequence(result, token);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses sequence of tokens until encountering a token of a given type
|
||||||
|
* @param offset the offset for the returned token node.
|
||||||
|
* @param endType the type of the token to stop before
|
||||||
|
* @return a token sequence, possibly empty but never {@code null}
|
||||||
|
*/
|
||||||
|
private IASTToken balancedTokenSeq(int offset, int endType) throws EndOfFileException, BacktrackException {
|
||||||
|
IASTToken token = balancedTokenSeq(endType);
|
||||||
|
if (token == null)
|
||||||
|
token = nodeFactory.newTokenList();
|
||||||
|
int endOffset = consumeOrEOC(endType).getEndOffset();
|
||||||
|
setRange(token, offset, endOffset);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a token to a token sequence.
|
||||||
|
*
|
||||||
|
* @param sequence the token sequence, may be {@code null}
|
||||||
|
* @param token the token to add
|
||||||
|
* @return the modified token sequence that is never {@code null}
|
||||||
|
*/
|
||||||
|
private IASTToken addTokenToSequence(IASTToken sequence, IASTToken token) {
|
||||||
|
if (sequence == null) {
|
||||||
|
sequence = token;
|
||||||
|
} else if (sequence instanceof IASTTokenList) {
|
||||||
|
((IASTTokenList) sequence).addToken(token);
|
||||||
|
adjustLength(sequence, token);
|
||||||
|
} else {
|
||||||
|
IASTTokenList list = nodeFactory.newTokenList();
|
||||||
|
list.addToken(token);
|
||||||
|
setRange(list, token);
|
||||||
|
sequence = list;
|
||||||
|
}
|
||||||
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void __declspec() throws BacktrackException, EndOfFileException {
|
protected void __declspec() throws BacktrackException, EndOfFileException {
|
||||||
|
|
|
@ -6,15 +6,13 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
|
||||||
|
|
||||||
public interface IASTAmbiguityParent {
|
public interface IASTAmbiguityParent {
|
||||||
|
|
||||||
public void replace( IASTNode child, IASTNode other );
|
public void replace(IASTNode child, IASTNode other);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
|
|
||||||
public interface IASTAmbiguousStatement extends IASTStatement {
|
public interface IASTAmbiguousStatement extends IASTStatement {
|
||||||
|
public static final ASTNodeProperty STATEMENT = new ASTNodeProperty("IASTAmbiguousStatement.STATEMENT - Ambiguous statement."); //$NON-NLS-1$
|
||||||
|
|
||||||
public static final ASTNodeProperty STATEMENT = new ASTNodeProperty( "IASTAmbiguousStatement.STATEMENT - Ambiguous statement." ); //$NON-NLS-1$
|
public void addStatement(IASTStatement s);
|
||||||
public void addStatement( IASTStatement s );
|
|
||||||
public IASTStatement [] getStatements();
|
public IASTStatement[] getStatements();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,22 +50,22 @@ public class SizeofCalculator {
|
||||||
|
|
||||||
private static final SizeAndAlignment SIZE_1 = new SizeAndAlignment(1, 1);
|
private static final SizeAndAlignment SIZE_1 = new SizeAndAlignment(1, 1);
|
||||||
|
|
||||||
private final SizeAndAlignment size_2;
|
public final SizeAndAlignment size_2;
|
||||||
private final SizeAndAlignment size_4;
|
public final SizeAndAlignment size_4;
|
||||||
private final SizeAndAlignment size_8;
|
public final SizeAndAlignment size_8;
|
||||||
private final SizeAndAlignment sizeof_pointer;
|
public final SizeAndAlignment sizeof_pointer;
|
||||||
private final SizeAndAlignment sizeof_int;
|
public final SizeAndAlignment sizeof_int;
|
||||||
private final SizeAndAlignment sizeof_long;
|
public final SizeAndAlignment sizeof_long;
|
||||||
private final SizeAndAlignment sizeof_long_long;
|
public final SizeAndAlignment sizeof_long_long;
|
||||||
private final SizeAndAlignment sizeof_short;
|
public final SizeAndAlignment sizeof_short;
|
||||||
private final SizeAndAlignment sizeof_bool;
|
public final SizeAndAlignment sizeof_bool;
|
||||||
private final SizeAndAlignment sizeof_wchar_t;
|
public final SizeAndAlignment sizeof_wchar_t;
|
||||||
private final SizeAndAlignment sizeof_float;
|
public final SizeAndAlignment sizeof_float;
|
||||||
private final SizeAndAlignment sizeof_complex_float;
|
public final SizeAndAlignment sizeof_complex_float;
|
||||||
private final SizeAndAlignment sizeof_double;
|
public final SizeAndAlignment sizeof_double;
|
||||||
private final SizeAndAlignment sizeof_complex_double;
|
public final SizeAndAlignment sizeof_complex_double;
|
||||||
private final SizeAndAlignment sizeof_long_double;
|
public final SizeAndAlignment sizeof_long_double;
|
||||||
private final SizeAndAlignment sizeof_complex_long_double;
|
public final SizeAndAlignment sizeof_complex_long_double;
|
||||||
|
|
||||||
public SizeofCalculator(IASTTranslationUnit ast) {
|
public SizeofCalculator(IASTTranslationUnit ast) {
|
||||||
int maxAlignment = 32;
|
int maxAlignment = 32;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2012 IBM Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -89,7 +91,18 @@ public class CASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTAmb
|
||||||
public IASTPointerOperator[] getPointerOperators() {
|
public IASTPointerOperator[] getPointerOperators() {
|
||||||
return dtors[0].getPointerOperators();
|
return dtors[0].getPointerOperators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return dtors[0].getAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
assertNotFrozen();
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRoleForName(IASTName name) {
|
public int getRoleForName(IASTName name) {
|
||||||
return dtors[0].getRoleForName(name);
|
return dtors[0].getRoleForName(name);
|
||||||
|
|
|
@ -6,11 +6,13 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -31,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
* @since 5.0.1
|
* @since 5.0.1
|
||||||
*/
|
*/
|
||||||
public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
|
public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
|
||||||
|
|
||||||
private IASTSimpleDeclaration fSimpleDecl;
|
private IASTSimpleDeclaration fSimpleDecl;
|
||||||
private IASTDeclSpecifier fAltDeclSpec;
|
private IASTDeclSpecifier fAltDeclSpec;
|
||||||
private IASTDeclarator fAltDtor;
|
private IASTDeclarator fAltDtor;
|
||||||
|
@ -85,7 +86,17 @@ public class CASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements
|
||||||
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
|
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
|
||||||
fSimpleDecl.setDeclSpecifier(declSpec);
|
fSimpleDecl.setDeclSpecifier(declSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return fSimpleDecl.getAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
fSimpleDecl.addAttribute(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) {
|
protected final IASTNode doResolveAmbiguity(ASTVisitor resolver) {
|
||||||
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
|
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -24,14 +26,13 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope;
|
||||||
|
|
||||||
public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbiguousStatement {
|
public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbiguousStatement {
|
||||||
|
private IASTStatement[] stmts = new IASTStatement[2];
|
||||||
private IASTStatement [] stmts = new IASTStatement[2];
|
private int stmtsPos= -1;
|
||||||
private int stmtsPos=-1;
|
|
||||||
private IScope fScope;
|
private IScope fScope;
|
||||||
private IASTDeclaration fDeclaration;
|
private IASTDeclaration fDeclaration;
|
||||||
|
|
||||||
public CASTAmbiguousStatement(IASTStatement... statements) {
|
public CASTAmbiguousStatement(IASTStatement... statements) {
|
||||||
for(IASTStatement s : statements)
|
for (IASTStatement s : statements)
|
||||||
addStatement(s);
|
addStatement(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi
|
||||||
((ICPPASTInternalScope) fScope).populateCache();
|
((ICPPASTInternalScope) fScope).populateCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeAlternative(IASTNode alternative) {
|
protected void beforeAlternative(IASTNode alternative) {
|
||||||
cleanupScope();
|
cleanupScope();
|
||||||
|
@ -73,7 +74,7 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi
|
||||||
public void addStatement(IASTStatement s) {
|
public void addStatement(IASTStatement s) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
stmts = ArrayUtil.appendAt( IASTStatement.class, stmts, ++stmtsPos, s );
|
stmts = ArrayUtil.appendAt(IASTStatement.class, stmts, ++stmtsPos, s);
|
||||||
s.setParent(this);
|
s.setParent(this);
|
||||||
s.setPropertyInParent(STATEMENT);
|
s.setPropertyInParent(STATEMENT);
|
||||||
}
|
}
|
||||||
|
@ -81,16 +82,25 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTStatement[] getStatements() {
|
public IASTStatement[] getStatements() {
|
||||||
stmts = ArrayUtil.trimAt( IASTStatement.class, stmts, stmtsPos );
|
stmts = ArrayUtil.trimAt(IASTStatement.class, stmts, stmtsPos);
|
||||||
return stmts;
|
return stmts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode[] getNodes() {
|
public IASTNode[] getNodes() {
|
||||||
return getStatements();
|
return getStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTStatement copy() {
|
public IASTStatement copy() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
@ -100,5 +110,4 @@ public class CASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbi
|
||||||
public IASTStatement copy(CopyStyle style) {
|
public IASTStatement copy(CopyStyle style) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDeclarator {
|
public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDeclarator {
|
||||||
private IASTArrayModifier[] arrayMods = null;
|
private IASTArrayModifier[] arrayMods;
|
||||||
private int arrayModsPos = -1;
|
private int arrayModsPos = -1;
|
||||||
|
|
||||||
public CASTArrayDeclarator() {
|
public CASTArrayDeclarator() {
|
||||||
|
@ -44,23 +45,18 @@ public class CASTArrayDeclarator extends CASTDeclarator implements IASTArrayDecl
|
||||||
@Override
|
@Override
|
||||||
public CASTArrayDeclarator copy(CopyStyle style) {
|
public CASTArrayDeclarator copy(CopyStyle style) {
|
||||||
CASTArrayDeclarator copy = new CASTArrayDeclarator();
|
CASTArrayDeclarator copy = new CASTArrayDeclarator();
|
||||||
copyBaseDeclarator(copy, style);
|
for (IASTArrayModifier modifier : getArrayModifiers()) {
|
||||||
for (IASTArrayModifier modifier : getArrayModifiers())
|
|
||||||
copy.addArrayModifier(modifier == null ? null : modifier.copy(style));
|
copy.addArrayModifier(modifier == null ? null : modifier.copy(style));
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
}
|
||||||
return copy;
|
return copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTArrayModifier[] getArrayModifiers() {
|
public IASTArrayModifier[] getArrayModifiers() {
|
||||||
if (arrayMods == null)
|
if (arrayMods == null)
|
||||||
return IASTArrayModifier.EMPTY_ARRAY;
|
return IASTArrayModifier.EMPTY_ARRAY;
|
||||||
arrayMods = ArrayUtil.trimAt(IASTArrayModifier.class,
|
arrayMods = ArrayUtil.trimAt(IASTArrayModifier.class, arrayMods, arrayModsPos);
|
||||||
arrayMods, arrayModsPos);
|
|
||||||
return arrayMods;
|
return arrayMods;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C-specific attribute.
|
||||||
|
*/
|
||||||
|
public class CASTAttribute extends ASTAttribute {
|
||||||
|
|
||||||
|
public CASTAttribute(char[] name, IASTToken argumentClause) {
|
||||||
|
super(name, argumentClause);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CASTAttribute copy() {
|
||||||
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CASTAttribute copy(CopyStyle style) {
|
||||||
|
IASTToken argumentClause = getArgumentClause();
|
||||||
|
if (argumentClause != null)
|
||||||
|
argumentClause = argumentClause.copy(style);
|
||||||
|
return copy(new CASTAttribute(getName(), argumentClause), style);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,35 +6,37 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTBreakStatement extends ASTNode implements IASTBreakStatement {
|
public class CASTBreakStatement extends ASTAttributeOwner implements IASTBreakStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
if (action.shouldVisitStatements) {
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
switch (action.leave(this)) {
|
||||||
default : break;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,10 +51,6 @@ public class CASTBreakStatement extends ASTNode implements IASTBreakStatement {
|
||||||
@Override
|
@Override
|
||||||
public CASTBreakStatement copy(CopyStyle style) {
|
public CASTBreakStatement copy(CopyStyle style) {
|
||||||
CASTBreakStatement copy = new CASTBreakStatement();
|
CASTBreakStatement copy = new CASTBreakStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -15,17 +16,15 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IASTAmbiguityParent {
|
public class CASTCaseStatement extends ASTAttributeOwner implements IASTCaseStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTExpression expression;
|
private IASTExpression expression;
|
||||||
|
|
||||||
|
|
||||||
public CASTCaseStatement() {
|
public CASTCaseStatement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +40,7 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS
|
||||||
@Override
|
@Override
|
||||||
public CASTCaseStatement copy(CopyStyle style) {
|
public CASTCaseStatement copy(CopyStyle style) {
|
||||||
CASTCaseStatement copy = new CASTCaseStatement(expression == null ? null : expression.copy(style));
|
CASTCaseStatement copy = new CASTCaseStatement(expression == null ? null : expression.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,20 +59,20 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( expression != null ) if( !expression.accept( action ) ) return false;
|
if (expression != null) if (!expression.accept(action)) return false;
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,10 +81,9 @@ public class CASTCaseStatement extends ASTNode implements IASTCaseStatement, IAS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == expression )
|
if (child == expression) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
expression = (IASTExpression) other;
|
expression = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -18,13 +19,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTCompoundStatement extends ASTNode implements IASTCompoundStatement, IASTAmbiguityParent {
|
public class CASTCompoundStatement extends ASTAttributeOwner implements IASTCompoundStatement, IASTAmbiguityParent {
|
||||||
private IASTStatement[] statements;
|
private IASTStatement[] statements;
|
||||||
private IScope scope;
|
private IScope scope;
|
||||||
|
|
||||||
|
@ -38,11 +39,7 @@ public class CASTCompoundStatement extends ASTNode implements IASTCompoundStatem
|
||||||
CASTCompoundStatement copy = new CASTCompoundStatement();
|
CASTCompoundStatement copy = new CASTCompoundStatement();
|
||||||
for (IASTStatement statement : getStatements())
|
for (IASTStatement statement : getStatements())
|
||||||
copy.addStatement(statement == null ? null : statement.copy(style));
|
copy.addStatement(statement == null ? null : statement.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,10 +74,13 @@ public class CASTCompoundStatement extends ASTNode implements IASTCompoundStatem
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
IASTStatement[] s = getStatements();
|
IASTStatement[] s = getStatements();
|
||||||
for (int i = 0; i < s.length; i++) {
|
for (int i = 0; i < s.length; i++) {
|
||||||
if (!s[i].accept(action)) return false;
|
if (!s[i].accept(action)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,17 +8,18 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTContinueStatement extends ASTNode implements IASTContinueStatement {
|
public class CASTContinueStatement extends ASTAttributeOwner implements IASTContinueStatement {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
|
@ -28,6 +29,9 @@ public class CASTContinueStatement extends ASTNode implements IASTContinueStatem
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -46,10 +50,6 @@ public class CASTContinueStatement extends ASTNode implements IASTContinueStatem
|
||||||
@Override
|
@Override
|
||||||
public CASTContinueStatement copy(CopyStyle style) {
|
public CASTContinueStatement copy(CopyStyle style) {
|
||||||
CASTContinueStatement copy = new CASTContinueStatement();
|
CASTContinueStatement copy = new CASTContinueStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,10 +9,12 @@
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -22,7 +24,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
/**
|
/**
|
||||||
* A declaration statement.
|
* A declaration statement.
|
||||||
*/
|
*/
|
||||||
public class CASTDeclarationStatement extends ASTNode implements IASTDeclarationStatement, IASTAmbiguityParent {
|
public class CASTDeclarationStatement extends ASTNode
|
||||||
|
implements IASTDeclarationStatement, IASTAmbiguityParent {
|
||||||
private IASTDeclaration declaration;
|
private IASTDeclaration declaration;
|
||||||
|
|
||||||
public CASTDeclarationStatement() {
|
public CASTDeclarationStatement() {
|
||||||
|
@ -41,11 +44,7 @@ public class CASTDeclarationStatement extends ASTNode implements IASTDeclaration
|
||||||
public CASTDeclarationStatement copy(CopyStyle style) {
|
public CASTDeclarationStatement copy(CopyStyle style) {
|
||||||
CASTDeclarationStatement copy = new CASTDeclarationStatement();
|
CASTDeclarationStatement copy = new CASTDeclarationStatement();
|
||||||
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +71,9 @@ public class CASTDeclarationStatement extends ASTNode implements IASTDeclaration
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaration != null && !declaration.accept(action)) return false;
|
if (declaration != null && !declaration.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -91,4 +92,16 @@ public class CASTDeclarationStatement extends ASTNode implements IASTDeclaration
|
||||||
declaration = (IASTDeclaration) other;
|
declaration = (IASTDeclaration) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
// Declaration statements don't have attributes.
|
||||||
|
return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
// Declaration statements don't have attributes.
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -26,17 +27,17 @@ import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbiguityParent {
|
public class CASTDeclarator extends ASTAttributeOwner implements IASTDeclarator, IASTAmbiguityParent {
|
||||||
private IASTInitializer initializer;
|
private IASTInitializer initializer;
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
private IASTDeclarator nestedDeclarator;
|
private IASTDeclarator nestedDeclarator;
|
||||||
private IASTPointerOperator[] pointerOps = null;
|
private IASTPointerOperator[] pointerOps;
|
||||||
private int pointerOpsPos= -1;
|
private int pointerOpsPos= -1;
|
||||||
|
|
||||||
public CASTDeclarator() {
|
public CASTDeclarator() {
|
||||||
|
@ -58,24 +59,19 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CASTDeclarator copy(CopyStyle style) {
|
public CASTDeclarator copy(CopyStyle style) {
|
||||||
CASTDeclarator copy = new CASTDeclarator();
|
return copy(new CASTDeclarator(), style);
|
||||||
copyBaseDeclarator(copy, style);
|
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyBaseDeclarator(CASTDeclarator copy, CopyStyle style) {
|
protected <T extends CASTDeclarator> T copy(T copy, CopyStyle style) {
|
||||||
copy.setName(name == null ? null : name.copy(style));
|
copy.setName(name == null ? null : name.copy(style));
|
||||||
copy.setInitializer(initializer == null ? null : initializer.copy(style));
|
copy.setInitializer(initializer == null ? null : initializer.copy(style));
|
||||||
copy.setNestedDeclarator(nestedDeclarator == null ? null : nestedDeclarator.copy(style));
|
copy.setNestedDeclarator(nestedDeclarator == null ? null : nestedDeclarator.copy(style));
|
||||||
for(IASTPointerOperator pointer : getPointerOperators())
|
for (IASTPointerOperator pointer : getPointerOperators()) {
|
||||||
copy.addPointerOperator(pointer == null ? null : pointer.copy(style));
|
copy.addPointerOperator(pointer == null ? null : pointer.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
}
|
||||||
|
return super.copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTPointerOperator[] getPointerOperators() {
|
public IASTPointerOperator[] getPointerOperators() {
|
||||||
if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY;
|
if (pointerOps == null) return IASTPointerOperator.EMPTY_ARRAY;
|
||||||
|
@ -141,10 +137,10 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitDeclarators) {
|
if (action.shouldVisitDeclarators) {
|
||||||
switch(action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +149,8 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) {
|
if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) {
|
||||||
if (getParent() instanceof IASTDeclarator) {
|
if (getParent() instanceof IASTDeclarator) {
|
||||||
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
||||||
|
|
|
@ -1,44 +1,47 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTDefaultStatement extends ASTNode implements IASTDefaultStatement {
|
public class CASTDefaultStatement extends ASTAttributeOwner implements IASTDefaultStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( action.shouldVisitStatements ){
|
|
||||||
switch( action.leave( this ) ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
if (action.shouldVisitStatements) {
|
||||||
default : break;
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CASTDefaultStatement copy() {
|
public CASTDefaultStatement copy() {
|
||||||
return copy(CopyStyle.withoutLocations);
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
@ -47,10 +50,6 @@ public class CASTDefaultStatement extends ASTNode implements IASTDefaultStatemen
|
||||||
@Override
|
@Override
|
||||||
public CASTDefaultStatement copy(CopyStyle style) {
|
public CASTDefaultStatement copy(CopyStyle style) {
|
||||||
CASTDefaultStatement copy = new CASTDefaultStatement();
|
CASTDefaultStatement copy = new CASTDefaultStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -16,18 +17,16 @@ import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmbiguityParent {
|
public class CASTDoStatement extends ASTAttributeOwner implements IASTDoStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTStatement body;
|
private IASTStatement body;
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
|
|
||||||
|
|
||||||
public CASTDoStatement() {
|
public CASTDoStatement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +45,7 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb
|
||||||
CASTDoStatement copy = new CASTDoStatement();
|
CASTDoStatement copy = new CASTDoStatement();
|
||||||
copy.setBody(body == null ? null : body.copy(style));
|
copy.setBody(body == null ? null : body.copy(style));
|
||||||
copy.setCondition(condition == null ? null : condition.copy(style));
|
copy.setCondition(condition == null ? null : condition.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,13 +63,11 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTExpression getCondition() {
|
public IASTExpression getCondition() {
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCondition(IASTExpression condition) {
|
public void setCondition(IASTExpression condition) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
|
@ -86,21 +79,24 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( body != null ) if( !body.accept( action ) ) return false;
|
|
||||||
if( condition != null ) if( !condition.accept( action ) ) return false;
|
if (!acceptByAttributes(action)) return false;
|
||||||
if( action.shouldVisitStatements ){
|
if (body != null && !body.accept(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
if (condition != null && !condition.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
if (action.shouldVisitStatements) {
|
||||||
default : break;
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -108,16 +104,14 @@ public class CASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmb
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( body == child )
|
if (body == child) {
|
||||||
{
|
other.setPropertyInParent(body.getPropertyInParent());
|
||||||
other.setPropertyInParent( body.getPropertyInParent() );
|
other.setParent(body.getParent());
|
||||||
other.setParent( body.getParent() );
|
|
||||||
body = (IASTStatement) other;
|
body = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( child == condition )
|
if (child == condition) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
condition = (IASTExpression) other;
|
condition = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -15,18 +16,16 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTExpressionStatement extends ASTNode implements
|
public class CASTExpressionStatement extends ASTAttributeOwner
|
||||||
IASTExpressionStatement, IASTAmbiguityParent {
|
implements IASTExpressionStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTExpression expression;
|
private IASTExpression expression;
|
||||||
|
|
||||||
|
|
||||||
public CASTExpressionStatement() {
|
public CASTExpressionStatement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +42,7 @@ public class CASTExpressionStatement extends ASTNode implements
|
||||||
public CASTExpressionStatement copy(CopyStyle style) {
|
public CASTExpressionStatement copy(CopyStyle style) {
|
||||||
CASTExpressionStatement copy = new CASTExpressionStatement();
|
CASTExpressionStatement copy = new CASTExpressionStatement();
|
||||||
copy.setExpression(expression == null ? null : expression.copy(style));
|
copy.setExpression(expression == null ? null : expression.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,29 +64,22 @@ public class CASTExpressionStatement extends ASTNode implements
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT:
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
return false;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
case ASTVisitor.PROCESS_SKIP:
|
default: break;
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (expression != null)
|
|
||||||
if (!expression.accept(action))
|
if (!acceptByAttributes(action)) return false;
|
||||||
return false;
|
if (expression != null && !expression.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT:
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
return false;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
case ASTVisitor.PROCESS_SKIP:
|
default: break;
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,5 +91,4 @@ public class CASTExpressionStatement extends ASTNode implements
|
||||||
expression = (IASTExpression) other;
|
expression = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -39,12 +40,8 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl
|
||||||
@Override
|
@Override
|
||||||
public CASTFieldDeclarator copy(CopyStyle style) {
|
public CASTFieldDeclarator copy(CopyStyle style) {
|
||||||
CASTFieldDeclarator copy = new CASTFieldDeclarator();
|
CASTFieldDeclarator copy = new CASTFieldDeclarator();
|
||||||
copyBaseDeclarator(copy, style);
|
|
||||||
copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy(style));
|
copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy(style));
|
||||||
if (style == CopyStyle.withLocations) {
|
return copy(copy, style);
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +49,6 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl
|
||||||
return bitFieldSize;
|
return bitFieldSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBitFieldSize(IASTExpression size) {
|
public void setBitFieldSize(IASTExpression size) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
|
@ -81,6 +77,4 @@ public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDecl
|
||||||
super.replace(child, other);
|
super.replace(child, other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -18,19 +19,18 @@ import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTForStatement extends ASTNode implements IASTForStatement, IASTAmbiguityParent {
|
public class CASTForStatement extends ASTAttributeOwner implements IASTForStatement, IASTAmbiguityParent {
|
||||||
private IScope scope = null;
|
private IScope scope;
|
||||||
|
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
private IASTExpression iterationExpression;
|
private IASTExpression iterationExpression;
|
||||||
private IASTStatement body, init;
|
private IASTStatement body;
|
||||||
|
private IASTStatement init;
|
||||||
|
|
||||||
public CASTForStatement() {
|
public CASTForStatement() {
|
||||||
}
|
}
|
||||||
|
@ -51,20 +51,16 @@ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTA
|
||||||
@Override
|
@Override
|
||||||
public CASTForStatement copy(CopyStyle style) {
|
public CASTForStatement copy(CopyStyle style) {
|
||||||
CASTForStatement copy = new CASTForStatement();
|
CASTForStatement copy = new CASTForStatement();
|
||||||
copyForStatement(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyForStatement(CASTForStatement copy, CopyStyle style) {
|
protected <T extends CASTForStatement> T copy(T copy, CopyStyle style) {
|
||||||
copy.setInitializerStatement(init == null ? null : init.copy(style));
|
copy.setInitializerStatement(init == null ? null : init.copy(style));
|
||||||
copy.setConditionExpression(condition == null ? null : condition.copy(style));
|
copy.setConditionExpression(condition == null ? null : condition.copy(style));
|
||||||
copy.setIterationExpression(iterationExpression == null ? null : iterationExpression
|
copy.setIterationExpression(iterationExpression == null ?
|
||||||
.copy(style));
|
null : iterationExpression.copy(style));
|
||||||
copy.setBody(body == null ? null : body.copy(style));
|
copy.setBody(body == null ? null : body.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return super.copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,62 +124,58 @@ public class CASTForStatement extends ASTNode implements IASTForStatement, IASTA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
if( scope == null )
|
if (scope == null)
|
||||||
scope = new CScope( this, EScopeKind.eLocal);
|
scope = new CScope(this, EScopeKind.eLocal);
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( init != null ) if( !init.accept( action ) ) return false;
|
|
||||||
if( condition != null ) if( !condition.accept( action ) ) return false;
|
|
||||||
if( iterationExpression != null ) if( !iterationExpression.accept( action ) ) return false;
|
|
||||||
if( body != null ) if( !body.accept( action ) ) return false;
|
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
if (init != null && !init.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
if (condition != null && !condition.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
if (iterationExpression != null && !iterationExpression.accept(action)) return false;
|
||||||
default : break;
|
if (body != null && !body.accept(action)) return false;
|
||||||
|
|
||||||
|
if (action.shouldVisitStatements) {
|
||||||
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( body == child )
|
if (body == child) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
body = (IASTStatement) other;
|
body = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( child == init )
|
if (child == init) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
init = (IASTStatement) other;
|
init = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( child == iterationExpression)
|
if (child == iterationExpression) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
iterationExpression = (IASTExpression) other;
|
iterationExpression = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
if( child == condition)
|
if (child == condition) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
condition = (IASTExpression) other;
|
condition = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -47,17 +48,11 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
|
||||||
@Override
|
@Override
|
||||||
public CASTFunctionDeclarator copy(CopyStyle style) {
|
public CASTFunctionDeclarator copy(CopyStyle style) {
|
||||||
CASTFunctionDeclarator copy = new CASTFunctionDeclarator();
|
CASTFunctionDeclarator copy = new CASTFunctionDeclarator();
|
||||||
copyBaseDeclarator(copy, style);
|
|
||||||
copy.varArgs = varArgs;
|
copy.varArgs = varArgs;
|
||||||
|
|
||||||
for (IASTParameterDeclaration param : getParameters()) {
|
for (IASTParameterDeclaration param : getParameters()) {
|
||||||
copy.addParameterDeclaration(param == null ? null : param.copy(style));
|
copy.addParameterDeclaration(param == null ? null : param.copy(style));
|
||||||
}
|
}
|
||||||
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,21 +6,21 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
public class CASTGotoStatement extends ASTAttributeOwner implements IASTGotoStatement {
|
||||||
|
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
|
|
||||||
public CASTGotoStatement() {
|
public CASTGotoStatement() {
|
||||||
|
@ -38,11 +38,7 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
||||||
@Override
|
@Override
|
||||||
public CASTGotoStatement copy(CopyStyle style) {
|
public CASTGotoStatement copy(CopyStyle style) {
|
||||||
CASTGotoStatement copy = new CASTGotoStatement(name == null ? null : name.copy(style));
|
CASTGotoStatement copy = new CASTGotoStatement(name == null ? null : name.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,31 +47,33 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(IASTName name) {
|
public void setName(IASTName name) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
name.setParent(this);
|
name.setParent(this);
|
||||||
name.setPropertyInParent(NAME);
|
name.setPropertyInParent(NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
if (name != null && !name.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
if (action.shouldVisitStatements) {
|
||||||
default : break;
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -83,7 +81,7 @@ public class CASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
if( n == name ) return r_reference;
|
if (n == name) return r_reference;
|
||||||
return r_unclear;
|
return r_unclear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -17,19 +18,16 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If statements for C.
|
* If statements for C.
|
||||||
*/
|
*/
|
||||||
public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmbiguityParent {
|
public class CASTIfStatement extends ASTAttributeOwner implements IASTIfStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
private IASTStatement thenClause;
|
private IASTStatement thenClause;
|
||||||
private IASTStatement elseClause;
|
private IASTStatement elseClause;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CASTIfStatement() {
|
public CASTIfStatement() {
|
||||||
}
|
}
|
||||||
|
@ -39,7 +37,6 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb
|
||||||
setThenClause(thenClause);
|
setThenClause(thenClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CASTIfStatement(IASTExpression condition, IASTStatement thenClause, IASTStatement elseClause) {
|
public CASTIfStatement(IASTExpression condition, IASTStatement thenClause, IASTStatement elseClause) {
|
||||||
this(condition, thenClause);
|
this(condition, thenClause);
|
||||||
setElseClause(elseClause);
|
setElseClause(elseClause);
|
||||||
|
@ -56,11 +53,7 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb
|
||||||
copy.setConditionExpression(condition == null ? null : condition.copy(style));
|
copy.setConditionExpression(condition == null ? null : condition.copy(style));
|
||||||
copy.setThenClause(thenClause == null ? null : thenClause.copy(style));
|
copy.setThenClause(thenClause == null ? null : thenClause.copy(style));
|
||||||
copy.setElseClause(elseClause == null ? null : elseClause.copy(style));
|
copy.setElseClause(elseClause == null ? null : elseClause.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,16 +114,19 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
N stack= null;
|
N stack= null;
|
||||||
IASTIfStatement stmt= this;
|
IASTIfStatement stmt= this;
|
||||||
loop: for(;;) {
|
loop: for (;;) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.visit(stmt)) {
|
switch (action.visit(stmt)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP:
|
case ASTVisitor.PROCESS_SKIP:
|
||||||
stmt= null;
|
stmt= null;
|
||||||
break loop;
|
break loop;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!((CASTIfStatement) stmt).acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
IASTNode child = stmt.getConditionExpression();
|
IASTNode child = stmt.getConditionExpression();
|
||||||
if (child != null && !child.accept(action))
|
if (child != null && !child.accept(action))
|
||||||
return false;
|
return false;
|
||||||
|
@ -165,22 +161,19 @@ public class CASTIfStatement extends ASTNode implements IASTIfStatement, IASTAmb
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( thenClause == child )
|
if (thenClause == child) {
|
||||||
{
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
|
||||||
thenClause = (IASTStatement) other;
|
thenClause = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( elseClause == child )
|
if (elseClause == child) {
|
||||||
{
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
|
||||||
elseClause = (IASTStatement) other;
|
elseClause = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( child == condition )
|
if (child == condition) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
condition = (IASTExpression) other;
|
condition = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -25,10 +26,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKnRFunctionDeclarator {
|
public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKnRFunctionDeclarator {
|
||||||
|
|
||||||
IASTName[] parameterNames = IASTName.EMPTY_NAME_ARRAY;
|
IASTName[] parameterNames = IASTName.EMPTY_NAME_ARRAY;
|
||||||
IASTDeclaration[] parameterDeclarations = IASTDeclaration.EMPTY_DECLARATION_ARRAY;
|
IASTDeclaration[] parameterDeclarations = IASTDeclaration.EMPTY_DECLARATION_ARRAY;
|
||||||
|
|
||||||
|
|
||||||
public CASTKnRFunctionDeclarator() {
|
public CASTKnRFunctionDeclarator() {
|
||||||
}
|
}
|
||||||
|
@ -46,7 +45,6 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
|
||||||
@Override
|
@Override
|
||||||
public CASTKnRFunctionDeclarator copy(CopyStyle style) {
|
public CASTKnRFunctionDeclarator copy(CopyStyle style) {
|
||||||
CASTKnRFunctionDeclarator copy = new CASTKnRFunctionDeclarator();
|
CASTKnRFunctionDeclarator copy = new CASTKnRFunctionDeclarator();
|
||||||
copyBaseDeclarator(copy, style);
|
|
||||||
|
|
||||||
copy.parameterNames = new IASTName[parameterNames.length];
|
copy.parameterNames = new IASTName[parameterNames.length];
|
||||||
for (int i = 0; i < parameterNames.length; i++) {
|
for (int i = 0; i < parameterNames.length; i++) {
|
||||||
|
@ -65,10 +63,7 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
|
||||||
copy.parameterDeclarations[i].setPropertyInParent(FUNCTION_PARAMETER);
|
copy.parameterDeclarations[i].setPropertyInParent(FUNCTION_PARAMETER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (style == CopyStyle.withLocations) {
|
return copy(copy, style);
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,13 +80,11 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTName[] getParameterNames() {
|
public IASTName[] getParameterNames() {
|
||||||
return parameterNames;
|
return parameterNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParameterDeclarations(IASTDeclaration[] decls) {
|
public void setParameterDeclarations(IASTDeclaration[] decls) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
|
@ -106,7 +99,6 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDeclaration[] getParameterDeclarations() {
|
public IASTDeclaration[] getParameterDeclarations() {
|
||||||
return parameterDeclarations;
|
return parameterDeclarations;
|
||||||
|
@ -131,17 +123,19 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDeclarator getDeclaratorForParameterName(IASTName name) {
|
public IASTDeclarator getDeclaratorForParameterName(IASTName name) {
|
||||||
boolean found=false;
|
boolean found= false;
|
||||||
for(int i=0; i<parameterNames.length; i++) {
|
for (int i= 0; i < parameterNames.length; i++) {
|
||||||
if (parameterNames[i] == name) found = true;
|
if (parameterNames[i] == name)
|
||||||
|
found = true;
|
||||||
}
|
}
|
||||||
if(!found) return null;
|
if (!found)
|
||||||
|
return null;
|
||||||
|
|
||||||
for(int i=0; i<parameterDeclarations.length; i++) {
|
for (int i= 0; i < parameterDeclarations.length; i++) {
|
||||||
if (parameterDeclarations[i] instanceof IASTSimpleDeclaration) {
|
if (parameterDeclarations[i] instanceof IASTSimpleDeclaration) {
|
||||||
IASTDeclarator[] decltors = ((IASTSimpleDeclaration)parameterDeclarations[i]).getDeclarators();
|
IASTDeclarator[] decltors = ((IASTSimpleDeclaration) parameterDeclarations[i]).getDeclarators();
|
||||||
for(int j=0; j<decltors.length; j++) {
|
for (int j= 0; j < decltors.length; j++) {
|
||||||
if(decltors[j].getName().toString().equals(name.toString()))
|
if (decltors[j].getName().toString().equals(name.toString()))
|
||||||
return decltors[j];
|
return decltors[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,8 +147,10 @@ public class CASTKnRFunctionDeclarator extends CASTDeclarator implements ICASTKn
|
||||||
@Override
|
@Override
|
||||||
public int getRoleForName(IASTName name) {
|
public int getRoleForName(IASTName name) {
|
||||||
IASTName [] n = getParameterNames();
|
IASTName [] n = getParameterNames();
|
||||||
for( int i = 0; i < n.length; ++i )
|
for (int i = 0; i < n.length; ++i) {
|
||||||
if( n[i] == name ) return r_unclear;
|
if (n[i] == name)
|
||||||
|
return r_unclear;
|
||||||
|
}
|
||||||
return super.getRoleForName(name);
|
return super.getRoleForName(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -16,13 +17,13 @@ import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTLabelStatement extends ASTNode implements IASTLabelStatement, IASTAmbiguityParent {
|
public class CASTLabelStatement extends ASTAttributeOwner implements IASTLabelStatement, IASTAmbiguityParent {
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
private IASTStatement nestedStatement;
|
private IASTStatement nestedStatement;
|
||||||
|
|
||||||
|
@ -44,11 +45,7 @@ public class CASTLabelStatement extends ASTNode implements IASTLabelStatement, I
|
||||||
CASTLabelStatement copy = new CASTLabelStatement();
|
CASTLabelStatement copy = new CASTLabelStatement();
|
||||||
copy.setName(name == null ? null : name.copy(style));
|
copy.setName(name == null ? null : name.copy(style));
|
||||||
copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy(style));
|
copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,8 +72,11 @@ public class CASTLabelStatement extends ASTNode implements IASTLabelStatement, I
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (name != null && !name.accept(action)) return false;
|
if (name != null && !name.accept(action)) return false;
|
||||||
if (nestedStatement != null && !nestedStatement.accept(action)) return false;
|
if (nestedStatement != null && !nestedStatement.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
|
||||||
|
@ -33,8 +34,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
|
||||||
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
|
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
|
||||||
private final char[] name;
|
private final char[] name;
|
||||||
|
|
||||||
private static final char[] EMPTY_CHAR_ARRAY = {};
|
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private IBinding binding;
|
private IBinding binding;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
|
||||||
}
|
}
|
||||||
|
|
||||||
public CASTName() {
|
public CASTName() {
|
||||||
name = EMPTY_CHAR_ARRAY;
|
name = CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,7 +107,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (name == EMPTY_CHAR_ARRAY)
|
if (name == CharArrayUtils.EMPTY_CHAR_ARRAY)
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
return new String(name);
|
return new String(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,42 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
*******************************************************************************/
|
* Sergey Prigogin (Google)
|
||||||
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTNullStatement extends ASTNode implements IASTNullStatement {
|
public class CASTNullStatement extends ASTAttributeOwner implements IASTNullStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( action.shouldVisitStatements ){
|
|
||||||
switch( action.leave( this ) ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
if (action.shouldVisitStatements) {
|
||||||
default : break;
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -47,10 +50,6 @@ public class CASTNullStatement extends ASTNode implements IASTNullStatement {
|
||||||
@Override
|
@Override
|
||||||
public CASTNullStatement copy(CopyStyle style) {
|
public CASTNullStatement copy(CopyStyle style) {
|
||||||
CASTNullStatement copy = new CASTNullStatement();
|
CASTNullStatement copy = new CASTNullStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTProblemDeclaration extends CASTProblemOwner implements
|
public class CASTProblemDeclaration extends CASTProblemOwner implements IASTProblemDeclaration {
|
||||||
IASTProblemDeclaration {
|
|
||||||
|
|
||||||
public CASTProblemDeclaration() {
|
public CASTProblemDeclaration() {
|
||||||
super();
|
super();
|
||||||
|
@ -38,28 +37,26 @@ public class CASTProblemDeclaration extends CASTProblemOwner implements
|
||||||
@Override
|
@Override
|
||||||
public CASTProblemDeclaration copy(CopyStyle style) {
|
public CASTProblemDeclaration copy(CopyStyle style) {
|
||||||
CASTProblemDeclaration copy = new CASTProblemDeclaration();
|
CASTProblemDeclaration copy = new CASTProblemDeclaration();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitDeclarations ){
|
if (action.shouldVisitDeclarations) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.accept(action); // visits the problem
|
super.accept(action); // visits the problem
|
||||||
if( action.shouldVisitDeclarations ){
|
|
||||||
switch( action.leave( this ) ){
|
if (action.shouldVisitDeclarations) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
default : break;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -37,28 +37,26 @@ public class CASTProblemExpression extends CASTProblemOwner implements IASTProbl
|
||||||
@Override
|
@Override
|
||||||
public CASTProblemExpression copy(CopyStyle style) {
|
public CASTProblemExpression copy(CopyStyle style) {
|
||||||
CASTProblemExpression copy = new CASTProblemExpression();
|
CASTProblemExpression copy = new CASTProblemExpression();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.accept(action); // visits the problem
|
super.accept(action); // visits the problem
|
||||||
if( action.shouldVisitExpressions ){
|
|
||||||
switch( action.leave( this ) ){
|
if (action.shouldVisitExpressions) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
default : break;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
||||||
|
|
||||||
private IASTProblem problem;
|
private IASTProblem problem;
|
||||||
|
|
||||||
public CASTProblemOwner() {
|
public CASTProblemOwner() {
|
||||||
|
@ -30,9 +29,9 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
||||||
setProblem(problem);
|
setProblem(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyBaseProblem(CASTProblemOwner copy, CopyStyle style) {
|
protected <T extends CASTProblemOwner> T copy(T copy, CopyStyle style) {
|
||||||
copy.setProblem(problem == null ? null : problem.copy(style));
|
copy.setProblem(problem == null ? null : problem.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return super.copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,17 +50,17 @@ abstract class CASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action){
|
||||||
if( action.shouldVisitProblems ){
|
if (action.shouldVisitProblems) {
|
||||||
switch( action.visit( getProblem() ) ){
|
switch (action.visit(getProblem())) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
switch( action.leave( getProblem() ) ){
|
switch (action.leave(getProblem())) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,13 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
|
|
||||||
|
@ -36,30 +38,39 @@ public class CASTProblemStatement extends CASTProblemOwner implements IASTProble
|
||||||
@Override
|
@Override
|
||||||
public CASTProblemStatement copy(CopyStyle style) {
|
public CASTProblemStatement copy(CopyStyle style) {
|
||||||
CASTProblemStatement copy = new CASTProblemStatement();
|
CASTProblemStatement copy = new CASTProblemStatement();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.accept(action); // visits the problem
|
super.accept(action); // visits the problem
|
||||||
if( action.shouldVisitStatements ){
|
|
||||||
switch( action.leave( this ) ){
|
if (action.shouldVisitStatements) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
default : break;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
assertNotFrozen();
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -17,10 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
public class CASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent {
|
public class CASTReturnStatement extends ASTAttributeOwner implements IASTReturnStatement, IASTAmbiguityParent {
|
||||||
private IASTExpression retValue;
|
private IASTExpression retValue;
|
||||||
|
|
||||||
public CASTReturnStatement() {
|
public CASTReturnStatement() {
|
||||||
|
@ -39,11 +40,7 @@ public class CASTReturnStatement extends ASTNode implements IASTReturnStatement,
|
||||||
public CASTReturnStatement copy(CopyStyle style) {
|
public CASTReturnStatement copy(CopyStyle style) {
|
||||||
CASTReturnStatement copy =
|
CASTReturnStatement copy =
|
||||||
new CASTReturnStatement(retValue == null ? null : retValue.copy(style));
|
new CASTReturnStatement(retValue == null ? null : retValue.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,7 +81,10 @@ public class CASTReturnStatement extends ASTNode implements IASTReturnStatement,
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (retValue != null && !retValue.accept(action)) return false;
|
if (retValue != null && !retValue.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -18,13 +19,13 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models a simple declaration.
|
* Models a simple declaration.
|
||||||
*/
|
*/
|
||||||
public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
public class CASTSimpleDeclaration extends ASTAttributeOwner implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
||||||
private IASTDeclarator[] declarators;
|
private IASTDeclarator[] declarators;
|
||||||
private int declaratorsPos = -1;
|
private int declaratorsPos = -1;
|
||||||
private IASTDeclSpecifier declSpecifier;
|
private IASTDeclSpecifier declSpecifier;
|
||||||
|
@ -45,15 +46,10 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
public CASTSimpleDeclaration copy(CopyStyle style) {
|
public CASTSimpleDeclaration copy(CopyStyle style) {
|
||||||
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
CASTSimpleDeclaration copy = new CASTSimpleDeclaration();
|
||||||
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
||||||
|
for (IASTDeclarator declarator : getDeclarators()) {
|
||||||
for (IASTDeclarator declarator : getDeclarators())
|
|
||||||
copy.addDeclarator(declarator == null ? null : declarator.copy(style));
|
copy.addDeclarator(declarator == null ? null : declarator.copy(style));
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
}
|
||||||
return copy;
|
return copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,9 +94,10 @@ public class CASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclarat
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declSpecifier != null && !declSpecifier.accept(action))
|
if (!acceptByAttributes(action)) return false;
|
||||||
return false;
|
if (declSpecifier != null && !declSpecifier.accept(action)) return false;
|
||||||
|
|
||||||
IASTDeclarator[] dtors = getDeclarators();
|
IASTDeclarator[] dtors = getDeclarators();
|
||||||
for (int i = 0; i < dtors.length; i++) {
|
for (int i = 0; i < dtors.length; i++) {
|
||||||
if (!dtors[i].accept(action))
|
if (!dtors[i].accept(action))
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -16,15 +17,14 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTSwitchStatement extends ASTNode implements
|
public class CASTSwitchStatement extends ASTAttributeOwner
|
||||||
IASTSwitchStatement, IASTAmbiguityParent {
|
implements IASTSwitchStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTExpression controller;
|
private IASTExpression controller;
|
||||||
private IASTStatement body;
|
private IASTStatement body;
|
||||||
|
|
||||||
|
@ -46,11 +46,7 @@ public class CASTSwitchStatement extends ASTNode implements
|
||||||
CASTSwitchStatement copy = new CASTSwitchStatement();
|
CASTSwitchStatement copy = new CASTSwitchStatement();
|
||||||
copy.setControllerExpression(controller == null ? null : controller.copy(style));
|
copy.setControllerExpression(controller == null ? null : controller.copy(style));
|
||||||
copy.setBody(body == null ? null : body.copy(style));
|
copy.setBody(body == null ? null : body.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,22 +80,24 @@ public class CASTSwitchStatement extends ASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( controller != null ) if( !controller.accept( action ) ) return false;
|
|
||||||
if( body != null ) if( !body.accept( action ) ) return false;
|
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
if (controller != null && !controller.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
if (body != null && !body.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
|
||||||
default : break;
|
if (action.shouldVisitStatements) {
|
||||||
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,16 +105,14 @@ public class CASTSwitchStatement extends ASTNode implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( body == child )
|
if (body == child) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
body = (IASTStatement) other;
|
body = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( child == controller )
|
if (child == controller) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
controller = (IASTExpression) other;
|
controller = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -16,13 +17,14 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTWhileStatement extends ASTNode implements IASTWhileStatement, IASTAmbiguityParent {
|
public class CASTWhileStatement extends ASTAttributeOwner
|
||||||
|
implements IASTWhileStatement, IASTAmbiguityParent {
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
private IASTStatement body;
|
private IASTStatement body;
|
||||||
|
|
||||||
|
@ -44,11 +46,7 @@ public class CASTWhileStatement extends ASTNode implements IASTWhileStatement, I
|
||||||
CASTWhileStatement copy = new CASTWhileStatement();
|
CASTWhileStatement copy = new CASTWhileStatement();
|
||||||
copy.setCondition(condition == null ? null : condition.copy(style));
|
copy.setCondition(condition == null ? null : condition.copy(style));
|
||||||
copy.setBody(body == null ? null : body.copy(style));
|
copy.setBody(body == null ? null : body.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,6 +88,8 @@ public class CASTWhileStatement extends ASTNode implements IASTWhileStatement, I
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (condition != null && !condition.accept(action)) return false;
|
if (condition != null && !condition.accept(action)) return false;
|
||||||
if (body != null && !body.accept(action)) return false;
|
if (body != null && !body.accept(action)) return false;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -32,8 +33,10 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.AttributeUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
|
@ -48,7 +51,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
private static final int RESOLUTION_IN_PROGRESS = 1 << 1;
|
private static final int RESOLUTION_IN_PROGRESS = 1 << 1;
|
||||||
private int bits = 0;
|
private int bits = 0;
|
||||||
|
|
||||||
protected IFunctionType type = null;
|
protected IFunctionType type;
|
||||||
|
|
||||||
public CFunction(IASTDeclarator declarator) {
|
public CFunction(IASTDeclarator declarator) {
|
||||||
storeDeclarator(declarator);
|
storeDeclarator(declarator);
|
||||||
|
@ -469,12 +472,12 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTDeclarator[] getDeclarations() {
|
||||||
return declarators;
|
return declarators;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTFunctionDeclarator getDefinition() {
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,4 +485,25 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNoReturn() {
|
||||||
|
IASTFunctionDeclarator dtor = getPreferredDtor();
|
||||||
|
return dtor != null && AttributeUtil.hasNoreturnAttribute(dtor);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IASTFunctionDeclarator getPreferredDtor() {
|
||||||
|
IASTFunctionDeclarator dtor = getDefinition();
|
||||||
|
if (dtor != null)
|
||||||
|
return dtor;
|
||||||
|
|
||||||
|
IASTDeclarator[] dtors = getDeclarations();
|
||||||
|
if (dtors != null) {
|
||||||
|
for (IASTDeclarator declarator : dtors) {
|
||||||
|
if (declarator instanceof IASTFunctionDeclarator)
|
||||||
|
return (IASTFunctionDeclarator) declarator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 IBM Corporation and others.
|
* Copyright (c) 2006, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||||
|
@ -58,6 +59,8 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTokenList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
|
||||||
|
@ -79,6 +82,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTToken;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTTokenList;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
|
import org.eclipse.cdt.internal.core.dom.parser.NodeFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||||
|
|
||||||
|
@ -88,7 +93,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||||
* implementations of the nodes.
|
* implementations of the nodes.
|
||||||
*/
|
*/
|
||||||
public class CNodeFactory extends NodeFactory implements ICNodeFactory {
|
public class CNodeFactory extends NodeFactory implements ICNodeFactory {
|
||||||
|
|
||||||
private static final CNodeFactory DEFAULT_INSTANCE = new CNodeFactory();
|
private static final CNodeFactory DEFAULT_INSTANCE = new CNodeFactory();
|
||||||
|
|
||||||
public static CNodeFactory getDefault() {
|
public static CNodeFactory getDefault() {
|
||||||
|
@ -125,6 +129,10 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
|
||||||
return new CASTASMDeclaration(assembly);
|
return new CASTASMDeclaration(assembly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute newAttribute(char[] name, IASTToken argumentClause) {
|
||||||
|
return new CASTAttribute(name, argumentClause);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
|
public IASTBinaryExpression newBinaryExpression(int op, IASTExpression expr1, IASTExpression expr2) {
|
||||||
return new CASTBinaryExpression(op, expr1, expr2);
|
return new CASTBinaryExpression(op, expr1, expr2);
|
||||||
|
@ -392,7 +400,17 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory {
|
||||||
public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
|
public IASTSwitchStatement newSwitchStatement(IASTExpression controller, IASTStatement body) {
|
||||||
return new CASTSwitchStatement(controller, body);
|
return new CASTSwitchStatement(controller, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTToken newToken(int tokenType, char[] tokenImage) {
|
||||||
|
return new ASTToken(tokenType, tokenImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTTokenList newTokenList() {
|
||||||
|
return new ASTTokenList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTTranslationUnit newTranslationUnit() {
|
public IASTTranslationUnit newTranslationUnit() {
|
||||||
return newTranslationUnit(null);
|
return newTranslationUnit(null);
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
@ -88,7 +89,7 @@ public class CParameter extends PlatformObject implements IParameter {
|
||||||
IASTName name = getPrimaryDeclaration();
|
IASTName name = getPrimaryDeclaration();
|
||||||
if (name != null)
|
if (name != null)
|
||||||
return name.toCharArray();
|
return name.toCharArray();
|
||||||
return CVisitor.EMPTY_CHAR_ARRAY;
|
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
|
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
|
@ -88,6 +90,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.AttributeUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.IContentAssistMatcher;
|
import org.eclipse.cdt.core.parser.util.IContentAssistMatcher;
|
||||||
|
@ -98,15 +101,13 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
|
import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of methods to find information in an AST.
|
* Collection of methods to find information in an AST.
|
||||||
*/
|
*/
|
||||||
public class CVisitor extends ASTQueries {
|
public class CVisitor extends ASTQueries {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final CBasicType UNSIGNED_LONG_INT = new CBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
private static final CBasicType UNSIGNED_LONG_INT = new CBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
||||||
|
|
||||||
public static class CollectProblemsAction extends ASTVisitor {
|
public static class CollectProblemsAction extends ASTVisitor {
|
||||||
|
@ -443,9 +444,7 @@ public class CVisitor extends ASTQueries {
|
||||||
private static final String SIZE_T = "size_t"; //$NON-NLS-1$
|
private static final String SIZE_T = "size_t"; //$NON-NLS-1$
|
||||||
private static final String PTRDIFF_T = "ptrdiff_t"; //$NON-NLS-1$
|
private static final String PTRDIFF_T = "ptrdiff_t"; //$NON-NLS-1$
|
||||||
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
public static final char[] EMPTY_CHAR_ARRAY = "".toCharArray(); //$NON-NLS-1$
|
// Definition lookup start location
|
||||||
|
|
||||||
// definition lookup start location
|
|
||||||
protected static final int AT_BEGINNING = 1;
|
protected static final int AT_BEGINNING = 1;
|
||||||
protected static final int AT_NEXT = 2;
|
protected static final int AT_NEXT = 2;
|
||||||
|
|
||||||
|
@ -1255,6 +1254,7 @@ public class CVisitor extends ASTQueries {
|
||||||
return createType(baseType, (IASTFunctionDeclarator) declarator);
|
return createType(baseType, (IASTFunctionDeclarator) declarator);
|
||||||
|
|
||||||
IType type = baseType;
|
IType type = baseType;
|
||||||
|
type = applyAttributes(type, declarator);
|
||||||
type = setupPointerChain(declarator.getPointerOperators(), type);
|
type = setupPointerChain(declarator.getPointerOperators(), type);
|
||||||
type = setupArrayChain(declarator, type);
|
type = setupArrayChain(declarator, type);
|
||||||
|
|
||||||
|
@ -1265,6 +1265,49 @@ public class CVisitor extends ASTQueries {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IType applyAttributes(IType type, IASTDeclarator declarator) {
|
||||||
|
if (type instanceof IBasicType) {
|
||||||
|
IBasicType basicType = (IBasicType) type;
|
||||||
|
if (basicType.getKind() == IBasicType.Kind.eInt) {
|
||||||
|
IASTAttribute[] attributes = declarator.getAttributes();
|
||||||
|
for (IASTAttribute attribute : attributes) {
|
||||||
|
char[] name = attribute.getName();
|
||||||
|
if (CharArrayUtils.equals(name, "__mode__") || CharArrayUtils.equals(name, "mode")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
char[] mode = AttributeUtil.getSimpleArgument(attribute);
|
||||||
|
if (CharArrayUtils.equals(mode, "__QI__") || CharArrayUtils.equals(mode, "QI")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
type = new CBasicType(IBasicType.Kind.eChar,
|
||||||
|
basicType.isUnsigned() ? IBasicType.IS_UNSIGNED : IBasicType.IS_SIGNED);
|
||||||
|
} else if (CharArrayUtils.equals(mode, "__HI__") || CharArrayUtils.equals(mode, "HI")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
type = new CBasicType(IBasicType.Kind.eInt,
|
||||||
|
IBasicType.IS_SHORT | getSignModifiers(basicType));
|
||||||
|
} else if (CharArrayUtils.equals(mode, "__SI__") || CharArrayUtils.equals(mode, "SI")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
type = new CBasicType(IBasicType.Kind.eInt, getSignModifiers(basicType));
|
||||||
|
} else if (CharArrayUtils.equals(mode, "__DI__") || CharArrayUtils.equals(mode, "DI")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
SizeofCalculator sizeofs = new SizeofCalculator(declarator.getTranslationUnit());
|
||||||
|
int modifier;
|
||||||
|
if (sizeofs.sizeof_long != null && sizeofs.sizeof_int != null &&
|
||||||
|
sizeofs.sizeof_long.size == 2 * sizeofs.sizeof_int.size) {
|
||||||
|
modifier = IBasicType.IS_LONG;
|
||||||
|
} else {
|
||||||
|
modifier = IBasicType.IS_LONG_LONG;
|
||||||
|
}
|
||||||
|
type = new CBasicType(IBasicType.Kind.eInt,
|
||||||
|
modifier | getSignModifiers(basicType));
|
||||||
|
} else if (CharArrayUtils.equals(mode, "__word__") || CharArrayUtils.equals(mode, "word")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
type = new CBasicType(IBasicType.Kind.eInt,
|
||||||
|
IBasicType.IS_LONG | getSignModifiers(basicType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getSignModifiers(IBasicType type) {
|
||||||
|
return type.getModifiers() & (IBasicType.IS_SIGNED | IBasicType.IS_UNSIGNED);
|
||||||
|
}
|
||||||
|
|
||||||
public static IType createType(IType returnType, IASTFunctionDeclarator declarator) {
|
public static IType createType(IType returnType, IASTFunctionDeclarator declarator) {
|
||||||
IType[] pTypes = getParmTypes(declarator);
|
IType[] pTypes = getParmTypes(declarator);
|
||||||
returnType = setupPointerChain(declarator.getPointerOperators(), returnType);
|
returnType = setupPointerChain(declarator.getPointerOperators(), returnType);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
@ -85,6 +87,7 @@ import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CollectionUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
|
@ -1272,7 +1275,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTElaboratedTypeSpecifier elaboratedTypeSpecifier() throws BacktrackException, EndOfFileException {
|
protected IASTElaboratedTypeSpecifier elaboratedTypeSpecifier() throws BacktrackException, EndOfFileException {
|
||||||
// this is an elaborated class specifier
|
// this is an elaborated class specifier
|
||||||
IToken t = consume();
|
IToken t = consume();
|
||||||
|
@ -1302,7 +1304,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, final DeclarationOptions option)
|
protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, final DeclarationOptions option)
|
||||||
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
|
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
|
||||||
|
@ -1337,7 +1338,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accept __attribute__ or __declspec between pointer operators and declarator.
|
// Accept __attribute__ or __declspec between pointer operators and declarator.
|
||||||
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
|
List<IASTAttribute> attributes =
|
||||||
|
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
|
||||||
|
|
||||||
// Look for identifier or nested declarator
|
// Look for identifier or nested declarator
|
||||||
final int lt1= LT(1);
|
final int lt1= LT(1);
|
||||||
|
@ -1347,7 +1349,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
final IASTName declaratorName = identifier();
|
final IASTName declaratorName = identifier();
|
||||||
endOffset= calculateEndOffset(declaratorName);
|
endOffset= calculateEndOffset(declaratorName);
|
||||||
return declarator(pointerOps, declaratorName, null, startingOffset, endOffset, option);
|
return declarator(pointerOps, attributes, declaratorName, null, startingOffset,
|
||||||
|
endOffset, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lt1 == IToken.tLPAREN) {
|
if (lt1 == IToken.tLPAREN) {
|
||||||
|
@ -1357,7 +1360,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (option.fAllowAbstract) {
|
if (option.fAllowAbstract) {
|
||||||
final IToken mark= mark();
|
final IToken mark= mark();
|
||||||
try {
|
try {
|
||||||
cand1= declarator(pointerOps, nodeFactory.newName(), null, startingOffset, endOffset, option);
|
cand1= declarator(pointerOps, attributes, nodeFactory.newName(), null,
|
||||||
|
startingOffset, endOffset, option);
|
||||||
if (option.fRequireAbstract)
|
if (option.fRequireAbstract)
|
||||||
return cand1;
|
return cand1;
|
||||||
|
|
||||||
|
@ -1374,7 +1378,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
final IASTDeclarator nested= declarator(declSpec, option);
|
final IASTDeclarator nested= declarator(declSpec, option);
|
||||||
endOffset= consume(IToken.tRPAREN).getEndOffset();
|
endOffset= consume(IToken.tRPAREN).getEndOffset();
|
||||||
final IASTDeclarator cand2= declarator(pointerOps, null, nested, startingOffset, endOffset, option);
|
final IASTDeclarator cand2= declarator(pointerOps, attributes, null, nested,
|
||||||
|
startingOffset, endOffset, option);
|
||||||
if (cand1 == null || cand1End == null)
|
if (cand1 == null || cand1End == null)
|
||||||
return cand2;
|
return cand2;
|
||||||
final IToken cand2End= LA(1);
|
final IToken cand2End= LA(1);
|
||||||
|
@ -1399,12 +1404,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (!option.fAllowAbstract) {
|
if (!option.fAllowAbstract) {
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
}
|
}
|
||||||
return declarator(pointerOps, nodeFactory.newName(), null, startingOffset, endOffset, option);
|
return declarator(pointerOps, attributes, nodeFactory.newName(), null, startingOffset,
|
||||||
|
endOffset, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTDeclarator declarator(final List<IASTPointerOperator> pointerOps,
|
private IASTDeclarator declarator(final List<IASTPointerOperator> pointerOps,
|
||||||
final IASTName declaratorName, final IASTDeclarator nestedDeclarator,
|
List<IASTAttribute> attributes, final IASTName declaratorName,
|
||||||
final int startingOffset, int endOffset,
|
final IASTDeclarator nestedDeclarator, final int startingOffset, int endOffset,
|
||||||
final DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
final DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
IASTDeclarator result= null;
|
IASTDeclarator result= null;
|
||||||
int lt1;
|
int lt1;
|
||||||
|
@ -1433,19 +1439,23 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IGCCToken.t__attribute__: // if __attribute__ is after a declarator
|
case IGCCToken.t__attribute__: // if __attribute__ is after a declarator
|
||||||
if (!supportAttributeSpecifiers)
|
if (!supportAttributeSpecifiers)
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
__attribute_decl_seq(true, supportDeclspecSpecifiers);
|
attributes = CollectionUtils.merge(attributes,
|
||||||
|
__attribute_decl_seq(true, supportDeclspecSpecifiers));
|
||||||
break;
|
break;
|
||||||
case IGCCToken.t__declspec:
|
case IGCCToken.t__declspec:
|
||||||
if (!supportDeclspecSpecifiers)
|
if (!supportDeclspecSpecifiers)
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
__attribute_decl_seq(supportAttributeSpecifiers, true);
|
attributes = CollectionUtils.merge(attributes,
|
||||||
|
__attribute_decl_seq(supportAttributeSpecifiers, true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lt1 != 0)
|
if (lt1 != 0) {
|
||||||
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
|
attributes = CollectionUtils.merge(attributes,
|
||||||
|
__attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers));
|
||||||
|
}
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result= nodeFactory.newDeclarator(null);
|
result= nodeFactory.newDeclarator(null);
|
||||||
|
@ -1465,6 +1475,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
result.addPointerOperator(po);
|
result.addPointerOperator(po);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attributes != null) {
|
||||||
|
for (IASTAttribute attribute : attributes) {
|
||||||
|
result.addAttribute(attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
((ASTNode) result).setOffsetAndLength(startingOffset, endOffset - startingOffset);
|
((ASTNode) result).setOffsetAndLength(startingOffset, endOffset - startingOffset);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2011 IBM Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2012 IBM Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -84,7 +86,7 @@ public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDeclarator[] getDeclarators() {
|
public IASTDeclarator[] getDeclarators() {
|
||||||
dtors = ArrayUtil.trimAt(IASTDeclarator.class, dtors, dtorPos );
|
dtors = ArrayUtil.trimAt(IASTDeclarator.class, dtors, dtorPos);
|
||||||
return dtors;
|
return dtors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,17 +115,28 @@ public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode
|
||||||
return dtors[0].getPointerOperators();
|
return dtors[0].getPointerOperators();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRoleForName(IASTName name) {
|
|
||||||
return dtors[0].getRoleForName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPointerOperator(IASTPointerOperator operator) {
|
public void addPointerOperator(IASTPointerOperator operator) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
Assert.isLegal(false);
|
Assert.isLegal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return dtors[0].getAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
assertNotFrozen();
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRoleForName(IASTName name) {
|
||||||
|
return dtors[0].getRoleForName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInitializer(IASTInitializer initializer) {
|
public void setInitializer(IASTInitializer initializer) {
|
||||||
// store the initializer until the ambiguity is resolved
|
// store the initializer until the ambiguity is resolved
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 IBM Wind River Systems, Inc. and others.
|
* Copyright (c) 2009, 2012 IBM Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -33,7 +35,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
* };
|
* };
|
||||||
*/
|
*/
|
||||||
public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
|
public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
|
||||||
|
|
||||||
private IASTSimpleDeclaration fSimpleDecl;
|
private IASTSimpleDeclaration fSimpleDecl;
|
||||||
private IASTDeclSpecifier fAltDeclSpec;
|
private IASTDeclSpecifier fAltDeclSpec;
|
||||||
private IASTDeclarator fAltDtor;
|
private IASTDeclarator fAltDtor;
|
||||||
|
@ -55,7 +56,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode[] getNodes() {
|
public IASTNode[] getNodes() {
|
||||||
return new IASTNode[] {fSimpleDecl, fAltDeclSpec, fAltDtor};
|
return new IASTNode[] { fSimpleDecl, fAltDeclSpec, fAltDtor };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,7 +98,6 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
||||||
owner.replace(nodeToReplace, fSimpleDecl);
|
owner.replace(nodeToReplace, fSimpleDecl);
|
||||||
IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0];
|
IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0];
|
||||||
dtor.accept(resolver);
|
dtor.accept(resolver);
|
||||||
|
|
||||||
|
|
||||||
// find nested names
|
// find nested names
|
||||||
final NameCollector nameCollector= new NameCollector();
|
final NameCollector nameCollector= new NameCollector();
|
||||||
|
@ -129,4 +129,14 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
||||||
fSimpleDecl.accept(resolver);
|
fSimpleDecl.accept(resolver);
|
||||||
return fSimpleDecl;
|
return fSimpleDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return fSimpleDecl.getAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
fSimpleDecl.addAttribute(attribute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -23,16 +25,14 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements
|
public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements IASTAmbiguousStatement {
|
||||||
IASTAmbiguousStatement {
|
private IASTStatement[] stmts = new IASTStatement[2];
|
||||||
|
private int stmtsPos= -1;
|
||||||
private IASTStatement [] stmts = new IASTStatement[2];
|
|
||||||
private int stmtsPos=-1;
|
|
||||||
private IScope fScope;
|
private IScope fScope;
|
||||||
private IASTDeclaration fDeclaration;
|
private IASTDeclaration fDeclaration;
|
||||||
|
|
||||||
public CPPASTAmbiguousStatement(IASTStatement... statements) {
|
public CPPASTAmbiguousStatement(IASTStatement... statements) {
|
||||||
for(IASTStatement s : statements)
|
for (IASTStatement s : statements)
|
||||||
addStatement(s);
|
addStatement(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements
|
||||||
public void addStatement(IASTStatement s) {
|
public void addStatement(IASTStatement s) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
stmts = ArrayUtil.appendAt( IASTStatement.class, stmts, ++stmtsPos, s );
|
stmts = ArrayUtil.appendAt(IASTStatement.class, stmts, ++stmtsPos, s);
|
||||||
s.setParent(this);
|
s.setParent(this);
|
||||||
s.setPropertyInParent(STATEMENT);
|
s.setPropertyInParent(STATEMENT);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTStatement[] getStatements() {
|
public IASTStatement[] getStatements() {
|
||||||
stmts = ArrayUtil.trimAt( IASTStatement.class, stmts, stmtsPos );
|
stmts = ArrayUtil.trimAt(IASTStatement.class, stmts, stmtsPos);
|
||||||
return stmts;
|
return stmts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,4 +100,14 @@ public class CPPASTAmbiguousStatement extends ASTAmbiguousNode implements
|
||||||
public IASTNode[] getNodes() {
|
public IASTNode[] getNodes() {
|
||||||
return getStatements();
|
return getStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 Google, 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:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTToken;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C++-specific attribute.
|
||||||
|
*/
|
||||||
|
public class CPPASTAttribute extends ASTAttribute {
|
||||||
|
|
||||||
|
public CPPASTAttribute(char[] name, IASTToken argumentsClause) {
|
||||||
|
super(name, argumentsClause);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CPPASTAttribute copy() {
|
||||||
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CPPASTAttribute copy(CopyStyle style) {
|
||||||
|
IASTToken argumentClause = getArgumentClause();
|
||||||
|
if (argumentClause != null)
|
||||||
|
argumentClause = argumentClause.copy(style);
|
||||||
|
return copy(new CPPASTAttribute(getName(), argumentClause), style);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,17 +7,18 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement {
|
public class CPPASTBreakStatement extends ASTAttributeOwner implements IASTBreakStatement {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
|
@ -27,6 +28,9 @@ public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -45,10 +49,6 @@ public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement
|
||||||
@Override
|
@Override
|
||||||
public CPPASTBreakStatement copy(CopyStyle style) {
|
public CPPASTBreakStatement copy(CopyStyle style) {
|
||||||
CPPASTBreakStatement copy = new CPPASTBreakStatement();
|
CPPASTBreakStatement copy = new CPPASTBreakStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -14,14 +15,14 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, IASTAmbiguityParent {
|
public class CPPASTCaseStatement extends ASTAttributeOwner
|
||||||
|
implements IASTCaseStatement, IASTAmbiguityParent {
|
||||||
private IASTExpression expression;
|
private IASTExpression expression;
|
||||||
|
|
||||||
public CPPASTCaseStatement() {
|
public CPPASTCaseStatement() {
|
||||||
|
@ -38,13 +39,9 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CPPASTCaseStatement copy(CopyStyle style) {
|
public CPPASTCaseStatement copy(CopyStyle style) {
|
||||||
CPPASTCaseStatement copy = new CPPASTCaseStatement(expression == null ? null
|
CPPASTCaseStatement copy =
|
||||||
: expression.copy(style));
|
new CPPASTCaseStatement(expression == null ? null : expression.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,18 +60,20 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch(action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( expression != null ) if( !expression.accept( action ) ) return false;
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
if (expression != null && !expression.accept(action)) return false;
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.leave( this ) ){
|
switch(action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
default : break;
|
default : break;
|
||||||
|
@ -85,12 +84,10 @@ public class CPPASTCaseStatement extends ASTNode implements IASTCaseStatement, I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == expression )
|
if (child == expression) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
expression = (IASTExpression) other;
|
expression = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -17,13 +18,14 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent {
|
public class CPPASTCatchHandler extends ASTAttributeOwner
|
||||||
|
implements ICPPASTCatchHandler, IASTAmbiguityParent {
|
||||||
private boolean isCatchAll;
|
private boolean isCatchAll;
|
||||||
private IASTStatement body;
|
private IASTStatement body;
|
||||||
private IASTDeclaration declaration;
|
private IASTDeclaration declaration;
|
||||||
|
@ -48,11 +50,7 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
|
||||||
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
||||||
copy.setCatchBody(body == null ? null : body.copy(style));
|
copy.setCatchBody(body == null ? null : body.copy(style));
|
||||||
copy.setIsCatchAll(isCatchAll);
|
copy.setIsCatchAll(isCatchAll);
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,6 +103,8 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (declaration != null && !declaration.accept(action)) return false;
|
if (declaration != null && !declaration.accept(action)) return false;
|
||||||
if (body != null && !body.accept(action)) return false;
|
if (body != null && !body.accept(action)) return false;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -17,13 +18,13 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTCompoundStatement extends ASTNode
|
public class CPPASTCompoundStatement extends ASTAttributeOwner
|
||||||
implements IASTCompoundStatement, IASTAmbiguityParent {
|
implements IASTCompoundStatement, IASTAmbiguityParent {
|
||||||
private IASTStatement[] statements = new IASTStatement[2];
|
private IASTStatement[] statements = new IASTStatement[2];
|
||||||
private ICPPScope scope;
|
private ICPPScope scope;
|
||||||
|
@ -36,26 +37,24 @@ public class CPPASTCompoundStatement extends ASTNode
|
||||||
@Override
|
@Override
|
||||||
public CPPASTCompoundStatement copy(CopyStyle style) {
|
public CPPASTCompoundStatement copy(CopyStyle style) {
|
||||||
CPPASTCompoundStatement copy = new CPPASTCompoundStatement();
|
CPPASTCompoundStatement copy = new CPPASTCompoundStatement();
|
||||||
for (IASTStatement statement : getStatements())
|
for (IASTStatement statement : getStatements()) {
|
||||||
copy.addStatement(statement == null ? null : statement.copy(style));
|
if (statement == null)
|
||||||
copy.setOffsetAndLength(this);
|
break;
|
||||||
if (style == CopyStyle.withLocations) {
|
copy.addStatement(statement.copy(style));
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
}
|
||||||
return copy;
|
return copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTStatement[] getStatements() {
|
public IASTStatement[] getStatements() {
|
||||||
if (statements == null)
|
statements = ArrayUtil.trim(statements);
|
||||||
return IASTStatement.EMPTY_STATEMENT_ARRAY;
|
return statements;
|
||||||
return ArrayUtil.trim(IASTStatement.class, statements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatement(IASTStatement statement) {
|
public void addStatement(IASTStatement statement) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
statements = ArrayUtil.append(IASTStatement.class, statements, statement);
|
statements = ArrayUtil.append(statements, statement);
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
statement.setParent(this);
|
statement.setParent(this);
|
||||||
statement.setPropertyInParent(NESTED_STATEMENT);
|
statement.setPropertyInParent(NESTED_STATEMENT);
|
||||||
|
@ -78,11 +77,15 @@ public class CPPASTCompoundStatement extends ASTNode
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IASTStatement[] s = getStatements();
|
|
||||||
for (int i = 0; i < s.length; i++) {
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (!s[i].accept(action))
|
for (IASTStatement statement : statements) {
|
||||||
|
if (statement == null)
|
||||||
|
break;
|
||||||
|
if (!statement.accept(action))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -95,7 +98,6 @@ public class CPPASTCompoundStatement extends ASTNode
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if (statements == null) return;
|
|
||||||
for (int i = 0; i < statements.length; ++i) {
|
for (int i = 0; i < statements.length; ++i) {
|
||||||
if (statements[i] == child) {
|
if (statements[i] == child) {
|
||||||
other.setParent(statements[i].getParent());
|
other.setParent(statements[i].getParent());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,17 +7,18 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTContinueStatement extends ASTNode implements IASTContinueStatement {
|
public class CPPASTContinueStatement extends ASTAttributeOwner implements IASTContinueStatement {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
|
@ -27,6 +28,9 @@ public class CPPASTContinueStatement extends ASTNode implements IASTContinueStat
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -45,10 +49,6 @@ public class CPPASTContinueStatement extends ASTNode implements IASTContinueStat
|
||||||
@Override
|
@Override
|
||||||
public CPPASTContinueStatement copy(CopyStyle style) {
|
public CPPASTContinueStatement copy(CopyStyle style) {
|
||||||
CPPASTContinueStatement copy = new CPPASTContinueStatement();
|
CPPASTContinueStatement copy = new CPPASTContinueStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -40,11 +42,7 @@ public class CPPASTDeclarationStatement extends ASTNode
|
||||||
public CPPASTDeclarationStatement copy(CopyStyle style) {
|
public CPPASTDeclarationStatement copy(CopyStyle style) {
|
||||||
CPPASTDeclarationStatement copy = new CPPASTDeclarationStatement();
|
CPPASTDeclarationStatement copy = new CPPASTDeclarationStatement();
|
||||||
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,7 +69,9 @@ public class CPPASTDeclarationStatement extends ASTNode
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaration != null && !declaration.accept(action)) return false;
|
if (declaration != null && !declaration.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -90,4 +90,16 @@ public class CPPASTDeclarationStatement extends ASTNode
|
||||||
declaration = (IASTDeclaration) other;
|
declaration = (IASTDeclaration) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
// Declaration statements don't have attributes.
|
||||||
|
return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
// Declaration statements don't have attributes.
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
@ -47,6 +48,7 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IAST
|
||||||
private IASTImplicitName[] implicitNames;
|
private IASTImplicitName[] implicitNames;
|
||||||
private IASTDeclarator nested;
|
private IASTDeclarator nested;
|
||||||
private IASTPointerOperator[] pointerOps;
|
private IASTPointerOperator[] pointerOps;
|
||||||
|
private IASTAttribute[] attributes;
|
||||||
private boolean isPackExpansion;
|
private boolean isPackExpansion;
|
||||||
|
|
||||||
public CPPASTDeclarator() {
|
public CPPASTDeclarator() {
|
||||||
|
@ -81,8 +83,12 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IAST
|
||||||
copy.setInitializer(initializer == null ? null : initializer.copy(style));
|
copy.setInitializer(initializer == null ? null : initializer.copy(style));
|
||||||
copy.setNestedDeclarator(nested == null ? null : nested.copy(style));
|
copy.setNestedDeclarator(nested == null ? null : nested.copy(style));
|
||||||
copy.isPackExpansion= isPackExpansion;
|
copy.isPackExpansion= isPackExpansion;
|
||||||
for (IASTPointerOperator pointer : getPointerOperators())
|
for (IASTPointerOperator pointer : getPointerOperators()) {
|
||||||
copy.addPointerOperator(pointer == null ? null : pointer.copy(style));
|
copy.addPointerOperator(pointer.copy(style));
|
||||||
|
}
|
||||||
|
for (IASTAttribute attribute : getAttributes()) {
|
||||||
|
copy.addAttribute(attribute.copy(style));
|
||||||
|
}
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +104,23 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IAST
|
||||||
return pointerOps;
|
return pointerOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
if (attributes == null) return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
attributes = ArrayUtil.trim(IASTAttribute.class, attributes);
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
assertNotFrozen();
|
||||||
|
if (attribute != null) {
|
||||||
|
attribute.setParent(this);
|
||||||
|
attribute.setPropertyInParent(ATTRIBUTE);
|
||||||
|
attributes = ArrayUtil.append(IASTAttribute.class, attributes, attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTDeclarator getNestedDeclarator() {
|
public IASTDeclarator getNestedDeclarator() {
|
||||||
return nested;
|
return nested;
|
||||||
|
@ -178,6 +201,15 @@ public class CPPASTDeclarator extends ASTNode implements ICPPASTDeclarator, IAST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attributes != null) {
|
||||||
|
for (IASTAttribute attribute : attributes) {
|
||||||
|
if (attribute == null)
|
||||||
|
break;
|
||||||
|
if (!attribute.accept(action))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nested == null && name != null) {
|
if (nested == null && name != null) {
|
||||||
IASTDeclarator outermost= ASTQueries.findOutermostDeclarator(this);
|
IASTDeclarator outermost= ASTQueries.findOutermostDeclarator(this);
|
||||||
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,18 +7,18 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTDefaultStatement extends ASTNode implements IASTDefaultStatement {
|
public class CPPASTDefaultStatement extends ASTAttributeOwner implements IASTDefaultStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
|
@ -28,6 +28,9 @@ public class CPPASTDefaultStatement extends ASTNode implements IASTDefaultStatem
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -46,10 +49,6 @@ public class CPPASTDefaultStatement extends ASTNode implements IASTDefaultStatem
|
||||||
@Override
|
@Override
|
||||||
public CPPASTDefaultStatement copy(CopyStyle style) {
|
public CPPASTDefaultStatement copy(CopyStyle style) {
|
||||||
CPPASTDefaultStatement copy = new CPPASTDefaultStatement();
|
CPPASTDefaultStatement copy = new CPPASTDefaultStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -15,18 +16,17 @@ import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTAmbiguityParent {
|
public class CPPASTDoStatement extends ASTAttributeOwner
|
||||||
|
implements IASTDoStatement, IASTAmbiguityParent {
|
||||||
private IASTStatement body;
|
private IASTStatement body;
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTDoStatement() {
|
public CPPASTDoStatement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,7 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA
|
||||||
CPPASTDoStatement copy = new CPPASTDoStatement();
|
CPPASTDoStatement copy = new CPPASTDoStatement();
|
||||||
copy.setBody(body == null ? null : body.copy(style));
|
copy.setBody(body == null ? null : body.copy(style));
|
||||||
copy.setCondition(condition == null ? null : condition.copy(style));
|
copy.setCondition(condition == null ? null : condition.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,21 +79,24 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( body != null ) if( !body.accept( action ) ) return false;
|
|
||||||
if( condition != null ) if( !condition.accept( action ) ) return false;
|
if (!acceptByAttributes(action)) return false;
|
||||||
if( action.shouldVisitStatements ){
|
if (body != null && !body.accept(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
if (condition != null && !condition.accept(action)) return false;
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
if (action.shouldVisitStatements) {
|
||||||
default : break;
|
switch (action.leave(this)) {
|
||||||
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -105,16 +104,14 @@ public class CPPASTDoStatement extends ASTNode implements IASTDoStatement, IASTA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( body == child )
|
if (body == child) {
|
||||||
{
|
other.setPropertyInParent(body.getPropertyInParent());
|
||||||
other.setPropertyInParent( body.getPropertyInParent() );
|
other.setParent(body.getParent());
|
||||||
other.setParent( body.getParent() );
|
|
||||||
body = (IASTStatement) other;
|
body = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( child == condition )
|
if (child == condition) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
condition = (IASTExpression) other;
|
condition = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -14,15 +15,14 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTExpressionStatement extends ASTNode implements
|
public class CPPASTExpressionStatement extends ASTAttributeOwner
|
||||||
IASTExpressionStatement, IASTAmbiguityParent {
|
implements IASTExpressionStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTExpression expression;
|
private IASTExpression expression;
|
||||||
|
|
||||||
public CPPASTExpressionStatement() {
|
public CPPASTExpressionStatement() {
|
||||||
|
@ -41,11 +41,7 @@ public class CPPASTExpressionStatement extends ASTNode implements
|
||||||
public CPPASTExpressionStatement copy(CopyStyle style) {
|
public CPPASTExpressionStatement copy(CopyStyle style) {
|
||||||
CPPASTExpressionStatement copy = new CPPASTExpressionStatement();
|
CPPASTExpressionStatement copy = new CPPASTExpressionStatement();
|
||||||
copy.setExpression(expression == null ? null : expression.copy(style));
|
copy.setExpression(expression == null ? null : expression.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +68,10 @@ public class CPPASTExpressionStatement extends ASTNode implements
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (expression != null && !expression.accept(action)) return false;
|
if (expression != null && !expression.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Emanuel Graf IFS - Bug 198269
|
* Emanuel Graf IFS - Bug 198269
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -19,14 +20,15 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For statement in C++
|
* For statement in C++
|
||||||
*/
|
*/
|
||||||
public class CPPASTForStatement extends ASTNode implements ICPPASTForStatement, IASTAmbiguityParent {
|
public class CPPASTForStatement extends ASTAttributeOwner
|
||||||
private IScope scope = null;
|
implements ICPPASTForStatement, IASTAmbiguityParent {
|
||||||
|
private IScope scope;
|
||||||
|
|
||||||
private IASTStatement init;
|
private IASTStatement init;
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
|
@ -67,11 +69,7 @@ public class CPPASTForStatement extends ASTNode implements ICPPASTForStatement,
|
||||||
copy.setIterationExpression(iterationExpression == null ?
|
copy.setIterationExpression(iterationExpression == null ?
|
||||||
null : iterationExpression.copy(style));
|
null : iterationExpression.copy(style));
|
||||||
copy.setBody(body == null ? null : body.copy(style));
|
copy.setBody(body == null ? null : body.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,6 +134,8 @@ public class CPPASTForStatement extends ASTNode implements ICPPASTForStatement,
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (init != null && !init.accept(action)) return false;
|
if (init != null && !init.accept(action)) return false;
|
||||||
if (condition != null && !condition.accept(action)) return false;
|
if (condition != null && !condition.accept(action)) return false;
|
||||||
if (condDeclaration != null && !condDeclaration.accept(action)) return false;
|
if (condDeclaration != null && !condDeclaration.accept(action)) return false;
|
||||||
|
|
|
@ -1,27 +1,26 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
public class CPPASTGotoStatement extends ASTAttributeOwner implements IASTGotoStatement {
|
||||||
|
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTGotoStatement() {
|
public CPPASTGotoStatement() {
|
||||||
}
|
}
|
||||||
|
@ -38,11 +37,7 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
||||||
@Override
|
@Override
|
||||||
public CPPASTGotoStatement copy(CopyStyle style) {
|
public CPPASTGotoStatement copy(CopyStyle style) {
|
||||||
CPPASTGotoStatement copy = new CPPASTGotoStatement(name == null ? null : name.copy(style));
|
CPPASTGotoStatement copy = new CPPASTGotoStatement(name == null ? null : name.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,28 +46,30 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(IASTName name) {
|
public void setName(IASTName name) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
name.setParent(this);
|
name.setParent(this);
|
||||||
name.setPropertyInParent(NAME);
|
name.setPropertyInParent(NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (!acceptByAttributes(action)) return false;
|
||||||
switch( action.leave( this ) ){
|
if (name != null && !name.accept(action)) return false;
|
||||||
|
|
||||||
|
if (action.shouldVisitStatements) {
|
||||||
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT : return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP : return true;
|
||||||
default : break;
|
default : break;
|
||||||
|
@ -83,7 +80,7 @@ public class CPPASTGotoStatement extends ASTNode implements IASTGotoStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
if( name == n ) return r_reference;
|
if (name == n) return r_reference;
|
||||||
return r_unclear;
|
return r_unclear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -19,13 +20,13 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If statement in C++
|
* If statement in C++
|
||||||
*/
|
*/
|
||||||
public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IASTAmbiguityParent {
|
public class CPPASTIfStatement extends ASTAttributeOwner implements ICPPASTIfStatement, IASTAmbiguityParent {
|
||||||
private IASTExpression condition;
|
private IASTExpression condition;
|
||||||
private IASTStatement thenClause;
|
private IASTStatement thenClause;
|
||||||
private IASTStatement elseClause;
|
private IASTStatement elseClause;
|
||||||
|
@ -59,11 +60,7 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA
|
||||||
copy.setConditionExpression(condition == null ? null : condition.copy(style));
|
copy.setConditionExpression(condition == null ? null : condition.copy(style));
|
||||||
copy.setThenClause(thenClause == null ? null : thenClause.copy(style));
|
copy.setThenClause(thenClause == null ? null : thenClause.copy(style));
|
||||||
copy.setElseClause(elseClause == null ? null : elseClause.copy(style));
|
copy.setElseClause(elseClause == null ? null : elseClause.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,6 +132,9 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!((CPPASTIfStatement) stmt).acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
IASTNode child = stmt.getConditionExpression();
|
IASTNode child = stmt.getConditionExpression();
|
||||||
if (child != null && !child.accept(action))
|
if (child != null && !child.accept(action))
|
||||||
return false;
|
return false;
|
||||||
|
@ -158,6 +158,7 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
if (stmt != null && action.leave(stmt) == ASTVisitor.PROCESS_ABORT)
|
if (stmt != null && action.leave(stmt) == ASTVisitor.PROCESS_ABORT)
|
||||||
return false;
|
return false;
|
||||||
|
@ -207,8 +208,8 @@ public class CPPASTIfStatement extends ASTNode implements ICPPASTIfStatement, IA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
if( scope == null )
|
if (scope == null)
|
||||||
scope = new CPPBlockScope( this );
|
scope = new CPPBlockScope(this);
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -26,9 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
* e.g.: int a[]= {1,2,3};
|
* e.g.: int a[]= {1,2,3};
|
||||||
*/
|
*/
|
||||||
public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList, IASTAmbiguityParent {
|
public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializerList, IASTAmbiguityParent {
|
||||||
|
private IASTInitializerClause [] initializers;
|
||||||
private IASTInitializerClause [] initializers = null;
|
private int initializersPos= -1;
|
||||||
private int initializersPos=-1;
|
|
||||||
private int actualSize;
|
private int actualSize;
|
||||||
private boolean fIsPackExpansion;
|
private boolean fIsPackExpansion;
|
||||||
|
|
||||||
|
@ -40,8 +39,9 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer
|
||||||
@Override
|
@Override
|
||||||
public CPPASTInitializerList copy(CopyStyle style) {
|
public CPPASTInitializerList copy(CopyStyle style) {
|
||||||
CPPASTInitializerList copy = new CPPASTInitializerList();
|
CPPASTInitializerList copy = new CPPASTInitializerList();
|
||||||
for (IASTInitializerClause initializer : getClauses())
|
for (IASTInitializerClause initializer : getClauses()) {
|
||||||
copy.addClause(initializer == null ? null : initializer.copy(style));
|
copy.addClause(initializer == null ? null : initializer.copy(style));
|
||||||
|
}
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
copy.actualSize = getSize();
|
copy.actualSize = getSize();
|
||||||
copy.fIsPackExpansion = fIsPackExpansion;
|
copy.fIsPackExpansion = fIsPackExpansion;
|
||||||
|
@ -114,9 +114,9 @@ public class CPPASTInitializerList extends ASTNode implements ICPPASTInitializer
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept( ASTVisitor action ){
|
||||||
if (action.shouldVisitInitializers) {
|
if (action.shouldVisitInitializers) {
|
||||||
switch (action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IASTInitializerClause[] list = getClauses();
|
IASTInitializerClause[] list = getClauses();
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -15,18 +16,16 @@ import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTLabelStatement extends ASTNode implements
|
public class CPPASTLabelStatement extends ASTAttributeOwner
|
||||||
IASTLabelStatement, IASTAmbiguityParent {
|
implements IASTLabelStatement, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
private IASTStatement nestedStatement;
|
private IASTStatement nestedStatement;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTLabelStatement() {
|
public CPPASTLabelStatement() {
|
||||||
}
|
}
|
||||||
|
@ -46,11 +45,7 @@ public class CPPASTLabelStatement extends ASTNode implements
|
||||||
CPPASTLabelStatement copy = new CPPASTLabelStatement();
|
CPPASTLabelStatement copy = new CPPASTLabelStatement();
|
||||||
copy.setName(name == null ? null : name.copy(style));
|
copy.setName(name == null ? null : name.copy(style));
|
||||||
copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy(style));
|
copy.setNestedStatement(nestedStatement == null ? null : nestedStatement.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,22 +64,24 @@ public class CPPASTLabelStatement extends ASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
|
||||||
if( nestedStatement != null ) if( !nestedStatement.accept( action ) ) return false;
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
if (name != null && !name.accept(action)) return false;
|
||||||
|
if (nestedStatement != null && !nestedStatement.accept(action)) return false;
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,7 +89,7 @@ public class CPPASTLabelStatement extends ASTNode implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
if( n == name ) return r_declaration;
|
if (n == name) return r_declaration;
|
||||||
return r_unclear;
|
return r_unclear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,12 +110,10 @@ public class CPPASTLabelStatement extends ASTNode implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == nestedStatement )
|
if (child == nestedStatement) {
|
||||||
{
|
other.setParent(this);
|
||||||
other.setParent( this );
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
|
||||||
setNestedStatement((IASTStatement) other);
|
setNestedStatement((IASTStatement) other);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,18 +7,18 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTNullStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTNullStatement extends ASTNode implements IASTNullStatement {
|
public class CPPASTNullStatement extends ASTAttributeOwner implements IASTNullStatement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
|
@ -28,6 +28,9 @@ public class CPPASTNullStatement extends ASTNode implements IASTNullStatement {
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT: return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
|
@ -46,10 +49,6 @@ public class CPPASTNullStatement extends ASTNode implements IASTNullStatement {
|
||||||
@Override
|
@Override
|
||||||
public CPPASTNullStatement copy(CopyStyle style) {
|
public CPPASTNullStatement copy(CopyStyle style) {
|
||||||
CPPASTNullStatement copy = new CPPASTNullStatement();
|
CPPASTNullStatement copy = new CPPASTNullStatement();
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -32,35 +32,30 @@ public class CPPASTProblemDeclaration extends CPPASTProblemOwner implements IAST
|
||||||
public CPPASTProblemDeclaration copy() {
|
public CPPASTProblemDeclaration copy() {
|
||||||
return copy(CopyStyle.withoutLocations);
|
return copy(CopyStyle.withoutLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CPPASTProblemDeclaration copy(CopyStyle style) {
|
public CPPASTProblemDeclaration copy(CopyStyle style) {
|
||||||
CPPASTProblemDeclaration copy = new CPPASTProblemDeclaration();
|
CPPASTProblemDeclaration copy = new CPPASTProblemDeclaration();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitDeclarations ){
|
if (action.shouldVisitDeclarations) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.accept(action); // visits the problem
|
super.accept(action); // visits the problem
|
||||||
if( action.shouldVisitDeclarations ){
|
if (action.shouldVisitDeclarations) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -36,28 +36,24 @@ public class CPPASTProblemExpression extends CPPASTProblemOwner implements IASTP
|
||||||
@Override
|
@Override
|
||||||
public CPPASTProblemExpression copy(CopyStyle style) {
|
public CPPASTProblemExpression copy(CopyStyle style) {
|
||||||
CPPASTProblemExpression copy = new CPPASTProblemExpression();
|
CPPASTProblemExpression copy = new CPPASTProblemExpression();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.accept(action); // visits the problem
|
super.accept(action); // visits the problem
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -20,27 +21,25 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
||||||
|
|
||||||
private IASTProblem problem;
|
private IASTProblem problem;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTProblemOwner() {
|
public CPPASTProblemOwner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPASTProblemOwner(IASTProblem problem) {
|
public CPPASTProblemOwner(IASTProblem problem) {
|
||||||
setProblem(problem);
|
setProblem(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyBaseProblem(CPPASTProblemOwner copy, CopyStyle style) {
|
protected <T extends CPPASTProblemOwner> T copy(T copy, CopyStyle style) {
|
||||||
copy.setProblem(problem == null ? null : problem.copy(style));
|
copy.setProblem(problem == null ? null : problem.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return super.copy(copy, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IASTProblem getProblem() {
|
public IASTProblem getProblem() {
|
||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProblem(IASTProblem p) {
|
public void setProblem(IASTProblem p) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
|
@ -50,19 +49,19 @@ abstract class CPPASTProblemOwner extends ASTNode implements IASTProblemHolder {
|
||||||
p.setPropertyInParent(PROBLEM);
|
p.setPropertyInParent(PROBLEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitProblems ){
|
if (action.shouldVisitProblems) {
|
||||||
switch( action.visit( getProblem() ) ){
|
switch (action.visit(getProblem())) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
switch( action.leave( getProblem() ) ){
|
switch (action.leave(getProblem())) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTAttribute;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ public class CPPASTProblemStatement extends CPPASTProblemOwner implements IASTPr
|
||||||
public CPPASTProblemStatement(IASTProblem problem) {
|
public CPPASTProblemStatement(IASTProblem problem) {
|
||||||
super(problem);
|
super(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CPPASTProblemStatement copy() {
|
public CPPASTProblemStatement copy() {
|
||||||
return copy(CopyStyle.withoutLocations);
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
@ -36,30 +38,37 @@ public class CPPASTProblemStatement extends CPPASTProblemOwner implements IASTPr
|
||||||
@Override
|
@Override
|
||||||
public CPPASTProblemStatement copy(CopyStyle style) {
|
public CPPASTProblemStatement copy(CopyStyle style) {
|
||||||
CPPASTProblemStatement copy = new CPPASTProblemStatement();
|
CPPASTProblemStatement copy = new CPPASTProblemStatement();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.accept(action); // visits the problem
|
super.accept(action); // visits the problem
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IASTAttribute[] getAttributes() {
|
||||||
|
return IASTAttribute.EMPTY_ATTRIBUTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttribute(IASTAttribute attribute) {
|
||||||
|
assertNotFrozen();
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProblemTypeId {
|
public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProblemTypeId {
|
||||||
|
|
||||||
public CPPASTProblemTypeId() {
|
public CPPASTProblemTypeId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,11 +37,7 @@ public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProbl
|
||||||
@Override
|
@Override
|
||||||
public CPPASTProblemTypeId copy(CopyStyle style) {
|
public CPPASTProblemTypeId copy(CopyStyle style) {
|
||||||
CPPASTProblemTypeId copy = new CPPASTProblemTypeId();
|
CPPASTProblemTypeId copy = new CPPASTProblemTypeId();
|
||||||
copyBaseProblem(copy, style);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +49,7 @@ public class CPPASTProblemTypeId extends CPPASTProblemOwner implements IASTProbl
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visits the problem
|
// Visit the problem
|
||||||
if (!super.accept(action))
|
if (!super.accept(action))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010, 2011 Wind River Systems, Inc. and others.
|
* Copyright (c) 2010, 2012 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - Initial API and implementation
|
* Markus Schorn - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||||
|
@ -34,7 +36,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
/**
|
/**
|
||||||
* Range based for loop in c++.
|
* Range based for loop in c++.
|
||||||
*/
|
*/
|
||||||
public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRangeBasedForStatement, IASTAmbiguityParent {
|
public class CPPASTRangeBasedForStatement extends ASTAttributeOwner
|
||||||
|
implements ICPPASTRangeBasedForStatement, IASTAmbiguityParent {
|
||||||
private IScope fScope;
|
private IScope fScope;
|
||||||
private IASTDeclaration fDeclaration;
|
private IASTDeclaration fDeclaration;
|
||||||
private IASTInitializerClause fInitClause;
|
private IASTInitializerClause fInitClause;
|
||||||
|
@ -55,11 +58,7 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
|
||||||
copy.setDeclaration(fDeclaration == null ? null : fDeclaration.copy(style));
|
copy.setDeclaration(fDeclaration == null ? null : fDeclaration.copy(style));
|
||||||
copy.setInitializerClause(fInitClause == null ? null : fInitClause.copy(style));
|
copy.setInitializerClause(fInitClause == null ? null : fInitClause.copy(style));
|
||||||
copy.setBody(fBody == null ? null : fBody.copy(style));
|
copy.setBody(fBody == null ? null : fBody.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,11 +177,13 @@ public class CPPASTRangeBasedForStatement extends ASTNode implements ICPPASTRang
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept( ASTVisitor action ){
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!acceptByAttributes(action)) return false;
|
||||||
if (fDeclaration != null && !fDeclaration.accept(action))
|
if (fDeclaration != null && !fDeclaration.accept(action))
|
||||||
return false;
|
return false;
|
||||||
if (fInitClause != null && !fInitClause.accept(action))
|
if (fInitClause != null && !fInitClause.accept(action))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -16,10 +17,10 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent {
|
public class CPPASTReturnStatement extends ASTAttributeOwner implements IASTReturnStatement, IASTAmbiguityParent {
|
||||||
private IASTInitializerClause retValue;
|
private IASTInitializerClause retValue;
|
||||||
|
|
||||||
public CPPASTReturnStatement() {
|
public CPPASTReturnStatement() {
|
||||||
|
@ -38,11 +39,7 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
|
||||||
public CPPASTReturnStatement copy(CopyStyle style) {
|
public CPPASTReturnStatement copy(CopyStyle style) {
|
||||||
CPPASTReturnStatement copy =
|
CPPASTReturnStatement copy =
|
||||||
new CPPASTReturnStatement(retValue == null ? null : retValue.copy(style));
|
new CPPASTReturnStatement(retValue == null ? null : retValue.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,16 +74,14 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
|
||||||
public boolean accept(ASTVisitor action) {
|
public boolean accept(ASTVisitor action) {
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT:
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
return false;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
case ASTVisitor.PROCESS_SKIP:
|
default: break;
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (retValue != null && !retValue.accept(action))
|
|
||||||
return false;
|
if (!acceptByAttributes(action)) return false;
|
||||||
|
if (retValue != null && !retValue.accept(action)) return false;
|
||||||
|
|
||||||
if (action.shouldVisitStatements) {
|
if (action.shouldVisitStatements) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue