mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixes parsing of declarations and new expressions, bug 84242+236856.
This commit is contained in:
parent
03a4e6e5aa
commit
4e28c73769
70 changed files with 3030 additions and 2492 deletions
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
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.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
@ -35,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
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.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;
|
||||||
|
@ -544,23 +546,35 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
assertEquals(count, sum);
|
assertEquals(count, sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected IASTFunctionDefinition getFunctionDefinition(IASTTranslationUnit tu, int i_decl) {
|
final protected <T extends IASTDeclaration> T getDeclaration(IASTTranslationUnit tu, int i_decl) {
|
||||||
|
Class<T> tclass;
|
||||||
IASTDeclaration[] decls= tu.getDeclarations();
|
IASTDeclaration[] decls= tu.getDeclarations();
|
||||||
assertTrue(decls.length > i_decl);
|
assertTrue(decls.length > i_decl);
|
||||||
assertInstance(decls[i_decl], IASTFunctionDefinition.class);
|
return (T) decls[i_decl];
|
||||||
return (IASTFunctionDefinition) decls[i_decl];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected IASTStatement getStatement(IASTFunctionDefinition fdef, int i_stmt) {
|
final protected <T extends IASTDeclaration> T getDeclaration(IASTCompositeTypeSpecifier ct, int i_decl) {
|
||||||
|
Class<T> tclass;
|
||||||
|
IASTDeclaration[] decls= ct.getMembers();
|
||||||
|
assertTrue(decls.length > i_decl);
|
||||||
|
return (T) decls[i_decl];
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected <T extends IASTCompositeTypeSpecifier> T getCompositeType(IASTTranslationUnit tu, int i_decl) {
|
||||||
|
IASTSimpleDeclaration sdecl= getDeclaration(tu, i_decl);
|
||||||
|
return (T) sdecl.getDeclSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected <T extends IASTStatement> T getStatement(IASTFunctionDefinition fdef, int i_stmt) {
|
||||||
IASTCompoundStatement compound= (IASTCompoundStatement) fdef.getBody();
|
IASTCompoundStatement compound= (IASTCompoundStatement) fdef.getBody();
|
||||||
IASTStatement[] stmts= compound.getStatements();
|
IASTStatement[] stmts= compound.getStatements();
|
||||||
assertTrue(stmts.length > i_stmt);
|
assertTrue(stmts.length > i_stmt);
|
||||||
return stmts[i_stmt];
|
return (T) stmts[i_stmt];
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected IASTExpression getExpressionOfStatement(IASTFunctionDefinition fdef, int i) {
|
final protected <T extends IASTExpression> T getExpressionOfStatement(IASTFunctionDefinition fdef, int i) {
|
||||||
IASTStatement stmt= getStatement(fdef, i);
|
IASTStatement stmt= getStatement(fdef, i);
|
||||||
assertInstance(stmt, IASTExpressionStatement.class);
|
assertInstance(stmt, IASTExpressionStatement.class);
|
||||||
return ((IASTExpressionStatement) stmt).getExpression();
|
return (T) ((IASTExpressionStatement) stmt).getExpression();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,18 +90,6 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class C { };
|
|
||||||
// void f(int(C)) { } // void f(int (*fp)(C c)) { }
|
|
||||||
// // not: void f(int C);
|
|
||||||
// int g(C);
|
|
||||||
// void foo() {
|
|
||||||
// f(1); //error: cannot convert 1 to function pointer
|
|
||||||
// f(g); //OK
|
|
||||||
// }
|
|
||||||
public void _test8_2s7a() throws Exception { // TODO raised bug 90633
|
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// char msg[] = "Syntax error on line %s
|
// char msg[] = "Syntax error on line %s
|
||||||
// ";
|
// ";
|
||||||
public void _test8_5_2s1() throws Exception { // TODO raised bug 90647
|
public void _test8_5_2s1() throws Exception { // TODO raised bug 90647
|
||||||
|
|
|
@ -13,14 +13,18 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||||
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.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
|
@ -776,14 +780,13 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
// };
|
// };
|
||||||
public void test5_3_4s3() throws Exception {
|
public void test5_3_4s3() throws Exception {
|
||||||
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
IASTFunctionDefinition fdef= getFunctionDefinition(tu, 0);
|
IASTFunctionDefinition fdef= getDeclaration(tu, 0);
|
||||||
IASTExpression expr= getExpressionOfStatement(fdef, 0);
|
IASTExpression expr= getExpressionOfStatement(fdef, 0);
|
||||||
assertInstance(expr, ICPPASTNewExpression.class);
|
assertInstance(expr, ICPPASTNewExpression.class);
|
||||||
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
|
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
|
||||||
|
|
||||||
assertNull(newExpr.getNewPlacement());
|
assertNull(newExpr.getNewPlacement());
|
||||||
assertNull(newExpr.getNewInitializer());
|
assertNull(newExpr.getNewInitializer());
|
||||||
assertEquals(0, newExpr.getNewTypeIdArrayExpressions().length);
|
|
||||||
IASTTypeId typeid= newExpr.getTypeId();
|
IASTTypeId typeid= newExpr.getTypeId();
|
||||||
isTypeEqual(CPPVisitor.createType(typeid), "int () * []");
|
isTypeEqual(CPPVisitor.createType(typeid), "int () * []");
|
||||||
}
|
}
|
||||||
|
@ -795,11 +798,11 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
// new T[5];
|
// new T[5];
|
||||||
// new (2,f) T[5];
|
// new (2,f) T[5];
|
||||||
// };
|
// };
|
||||||
public void _test5_3_4s12() throws Exception {
|
public void test5_3_4s12() throws Exception {
|
||||||
// failing see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
|
||||||
|
|
||||||
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
IASTFunctionDefinition fdef= getFunctionDefinition(tu, 1);
|
IASTFunctionDefinition fdef= getDeclaration(tu, 1);
|
||||||
|
|
||||||
// new T;
|
// new T;
|
||||||
IASTExpression expr= getExpressionOfStatement(fdef, 0);
|
IASTExpression expr= getExpressionOfStatement(fdef, 0);
|
||||||
|
@ -807,7 +810,6 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
|
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
|
||||||
assertNull(newExpr.getNewPlacement());
|
assertNull(newExpr.getNewPlacement());
|
||||||
assertNull(newExpr.getNewInitializer());
|
assertNull(newExpr.getNewInitializer());
|
||||||
assertEquals(0, newExpr.getNewTypeIdArrayExpressions().length);
|
|
||||||
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
|
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
|
||||||
|
|
||||||
// new(2,f) T;
|
// new(2,f) T;
|
||||||
|
@ -816,7 +818,6 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
newExpr= (ICPPASTNewExpression) expr;
|
newExpr= (ICPPASTNewExpression) expr;
|
||||||
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
|
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
|
||||||
assertNull(newExpr.getNewInitializer());
|
assertNull(newExpr.getNewInitializer());
|
||||||
assertEquals(0, newExpr.getNewTypeIdArrayExpressions().length);
|
|
||||||
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
|
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
|
||||||
|
|
||||||
// new T[5];
|
// new T[5];
|
||||||
|
@ -825,7 +826,6 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
newExpr= (ICPPASTNewExpression) expr;
|
newExpr= (ICPPASTNewExpression) expr;
|
||||||
assertNull(newExpr.getNewPlacement());
|
assertNull(newExpr.getNewPlacement());
|
||||||
assertNull(newExpr.getNewInitializer());
|
assertNull(newExpr.getNewInitializer());
|
||||||
assertEquals(1, newExpr.getNewTypeIdArrayExpressions().length);
|
|
||||||
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []");
|
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []");
|
||||||
|
|
||||||
// new (2,f) T[5];
|
// new (2,f) T[5];
|
||||||
|
@ -834,7 +834,6 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
newExpr= (ICPPASTNewExpression) expr;
|
newExpr= (ICPPASTNewExpression) expr;
|
||||||
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
|
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
|
||||||
assertNull(newExpr.getNewInitializer());
|
assertNull(newExpr.getNewInitializer());
|
||||||
assertEquals(1, newExpr.getNewTypeIdArrayExpressions().length);
|
|
||||||
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []");
|
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1133,7 +1132,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
// // an ordinary member function, not a constructor
|
// // an ordinary member function, not a constructor
|
||||||
// } S;
|
// } S;
|
||||||
public void test7_1_3s5b() throws Exception {
|
public void test7_1_3s5b() throws Exception {
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
IASTTranslationUnit tu= parseWithErrors(getAboveComment(), ParserLanguage.CPP);
|
||||||
|
IASTCompositeTypeSpecifier comp= getCompositeType(tu, 0);
|
||||||
|
IASTDeclaration d= getDeclaration(comp, 0);
|
||||||
|
assertInstance(d, IASTProblemDeclaration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int foo() {
|
// int foo() {
|
||||||
|
@ -1776,10 +1778,27 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class C { };
|
||||||
|
// void f(int(C)) { } // void f(int (*fp)(C c)) { }
|
||||||
|
// // not: void f(int C);
|
||||||
|
// int g(C);
|
||||||
|
// void foo() {
|
||||||
|
// f(1); //error: cannot convert 1 to function pointer
|
||||||
|
// f(g); //OK
|
||||||
|
// }
|
||||||
|
public void test8_2s7a() throws Exception { // TODO raised bug 90633
|
||||||
|
final String code = getAboveComment();
|
||||||
|
parse(code, ParserLanguage.CPP, true, 1);
|
||||||
|
|
||||||
|
BindingAssertionHelper ba= new BindingAssertionHelper(code, true);
|
||||||
|
IFunction f= ba.assertNonProblem("f", 1, IFunction.class);
|
||||||
|
isTypeEqual(f.getType(), "void (int (C) *)");
|
||||||
|
}
|
||||||
|
|
||||||
// class C { };
|
// class C { };
|
||||||
// void h(int *(C[10])); // void h(int *(*_fp)(C _parm[10]));
|
// void h(int *(C[10])); // void h(int *(*_fp)(C _parm[10]));
|
||||||
// // not: void h(int *C[10]);
|
// // not: void h(int *C[10]);
|
||||||
public void _test8_2s7b() throws Exception {
|
public void test8_2s7b() throws Exception {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
parse(code, ParserLanguage.CPP, true, 0);
|
parse(code, ParserLanguage.CPP, true, 0);
|
||||||
BindingAssertionHelper ba= new BindingAssertionHelper(code, true);
|
BindingAssertionHelper ba= new BindingAssertionHelper(code, true);
|
||||||
|
@ -3958,7 +3977,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
// int f(char*);
|
// int f(char*);
|
||||||
// void g()
|
// void g()
|
||||||
// {
|
// {
|
||||||
// extern f(int);
|
// extern int f(int);
|
||||||
// f("asdf"); //error: f(int) hides f(char*)
|
// f("asdf"); //error: f(int) hides f(char*)
|
||||||
// // so there is no f(char*) in this scope
|
// // so there is no f(char*) in this scope
|
||||||
// }
|
// }
|
||||||
|
@ -5634,7 +5653,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class Matherr { virtual vf(); };
|
// class Matherr { virtual void vf(); };
|
||||||
// class Overflow: public Matherr { };
|
// class Overflow: public Matherr { };
|
||||||
// class Underflow: public Matherr { };
|
// class Underflow: public Matherr { };
|
||||||
// class Zerodivide: public Matherr { };
|
// class Zerodivide: public Matherr { };
|
||||||
|
@ -6185,7 +6204,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
// int ef(D&);
|
// int ef(D&);
|
||||||
// int ff(X&);
|
// int ff(X&);
|
||||||
public void test11_3s2() throws Exception { //bug 92793
|
public void test11_3s2() throws Exception { //bug 92793
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
|
IASTCompositeTypeSpecifier D= getCompositeType(tu, 2);
|
||||||
|
IASTDeclaration accessDecl= getDeclaration(D, 2);
|
||||||
|
assertInstance(accessDecl, ICPPASTUsingDeclaration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int z() {
|
// int z() {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
|
@ -83,6 +84,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||||
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.ICPPASTSimpleTypeConstructorExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
|
@ -1621,7 +1623,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace Y { void f(float); }
|
// namespace Y { void f(float); }
|
||||||
// namespace A { using namespace Y; f(int); }
|
// namespace A { using namespace Y; void f(int); }
|
||||||
// namespace B { void f(char); }
|
// namespace B { void f(char); }
|
||||||
// namespace AB { using namespace A; using namespace B; }
|
// namespace AB { using namespace A; using namespace B; }
|
||||||
// void h(){
|
// void h(){
|
||||||
|
@ -3562,32 +3564,38 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// 1,4,12,21 - conversion
|
// 1,4,12,21 - conversion
|
||||||
// 2, 16 .isConversion
|
// 2, 16 .isConversion
|
||||||
|
|
||||||
assertEquals(col.size(), 22);
|
final IASTName int1 = col.getName(1);
|
||||||
|
assertNotNull(int1);
|
||||||
|
assertTrue(int1 instanceof ICPPASTConversionName);
|
||||||
|
assertNotNull(((ICPPASTConversionName) int1).getTypeId());
|
||||||
|
|
||||||
assertNotNull(col.getName(1));
|
IASTFunctionDefinition fdef= getDeclaration(tu, 1);
|
||||||
assertNotNull(col.getName(4));
|
final IASTName x_int = fdef.getDeclarator().getName();
|
||||||
assertNotNull(col.getName(12));
|
assertNotNull(x_int);
|
||||||
assertNotNull(col.getName(21));
|
assertTrue(x_int instanceof ICPPASTQualifiedName);
|
||||||
assertNotNull(col.getName(2));
|
assertTrue(((ICPPASTQualifiedName) x_int).isConversionOrOperator());
|
||||||
assertNotNull(col.getName(16));
|
|
||||||
|
|
||||||
// ensure the conversions are conversions
|
final IASTName int2= ((ICPPASTQualifiedName)x_int).getLastName();
|
||||||
assertTrue(col.getName(1) instanceof ICPPASTConversionName);
|
assertNotNull(int2);
|
||||||
assertTrue(col.getName(4) instanceof ICPPASTConversionName);
|
assertTrue(int2 instanceof ICPPASTConversionName);
|
||||||
assertTrue(col.getName(12) instanceof ICPPASTConversionName);
|
assertNotNull(((ICPPASTConversionName) int2).getTypeId());
|
||||||
assertTrue(col.getName(21) instanceof ICPPASTConversionName);
|
|
||||||
assertNotNull(((ICPPASTConversionName) col.getName(1)).getTypeId());
|
|
||||||
assertNotNull(((ICPPASTConversionName) col.getName(4)).getTypeId());
|
|
||||||
assertNotNull(((ICPPASTConversionName) col.getName(12)).getTypeId());
|
|
||||||
assertNotNull(((ICPPASTConversionName) col.getName(21)).getTypeId());
|
|
||||||
|
|
||||||
// ensure qualified name isConversionOrOperator
|
final IASTName int3 = col.getName(12);
|
||||||
assertTrue(col.getName(2) instanceof ICPPASTQualifiedName);
|
assertNotNull(int3);
|
||||||
assertTrue(col.getName(16) instanceof ICPPASTQualifiedName);
|
assertTrue(int3 instanceof ICPPASTConversionName);
|
||||||
assertTrue(((ICPPASTQualifiedName) col.getName(2))
|
assertNotNull(((ICPPASTConversionName) int3).getTypeId());
|
||||||
.isConversionOrOperator());
|
|
||||||
assertTrue(((ICPPASTQualifiedName) col.getName(16))
|
ICPPASTTemplateDeclaration tdef= getDeclaration(tu, 3);
|
||||||
.isConversionOrOperator());
|
fdef= (IASTFunctionDefinition) tdef.getDeclaration();
|
||||||
|
final IASTName x_ac_int = fdef.getDeclarator().getName();
|
||||||
|
assertNotNull(x_ac_int);
|
||||||
|
assertTrue(x_ac_int instanceof ICPPASTQualifiedName);
|
||||||
|
assertTrue(((ICPPASTQualifiedName) x_ac_int).isConversionOrOperator());
|
||||||
|
|
||||||
|
final IASTName int4= ((ICPPASTQualifiedName)x_ac_int).getLastName();
|
||||||
|
assertNotNull(int4);
|
||||||
|
assertTrue(int4 instanceof ICPPASTConversionName);
|
||||||
|
assertNotNull(((ICPPASTConversionName) int4).getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug88662() throws Exception {
|
public void testBug88662() throws Exception {
|
||||||
|
@ -4066,7 +4074,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame(d2, r);
|
assertSame(d2, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class P {
|
// class Point {
|
||||||
// Point() : xCoord(0) {}
|
// Point() : xCoord(0) {}
|
||||||
// int xCoord;
|
// int xCoord;
|
||||||
// };
|
// };
|
||||||
|
@ -5021,10 +5029,6 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame( blah, col.getName(6).resolveBinding() );
|
assertSame( blah, col.getName(6).resolveBinding() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug80171() throws Exception {
|
|
||||||
parseAndCheckBindings( "static var;"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug78800() throws Exception {
|
public void testBug78800() throws Exception {
|
||||||
parseAndCheckBindings( "class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;" ); //$NON-NLS-1$
|
parseAndCheckBindings( "class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -5658,7 +5662,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// X::~X() {}
|
// X::~X() {}
|
||||||
// X::operator int() {}
|
// X::operator int() {}
|
||||||
// X::xtint(a); // 2
|
// X::xtint(a); // 2
|
||||||
public void _testEmptyDeclSpecifier() throws Exception {
|
public void testEmptyDeclSpecifier() throws Exception {
|
||||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
ba.assertNonProblem("X {", 1, ICPPClassType.class);
|
ba.assertNonProblem("X {", 1, ICPPClassType.class);
|
||||||
ba.assertNonProblem("X()", 1, ICPPConstructor.class);
|
ba.assertNonProblem("X()", 1, ICPPConstructor.class);
|
||||||
|
@ -5677,46 +5681,46 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// int p[100];
|
// int p[100];
|
||||||
// void test(int f) {
|
// void test(int f) {
|
||||||
// new T;
|
// new T;
|
||||||
|
// new T();
|
||||||
// new T(f);
|
// new T(f);
|
||||||
// new (p) T;
|
// new (p) T;
|
||||||
|
// new (p) T();
|
||||||
// new (p) T(f);
|
// new (p) T(f);
|
||||||
// new (T);
|
// new (T);
|
||||||
|
// new (T)();
|
||||||
// new (T)(f);
|
// new (T)(f);
|
||||||
// new (p) (T);
|
// new (p) (T);
|
||||||
|
// new (p) (T)();
|
||||||
// new (p) (T)(f);
|
// new (p) (T)(f);
|
||||||
// new T[f][f];
|
// new T[f][f];
|
||||||
// new T[f][f](f);
|
|
||||||
// new (p) T[f][f];
|
// new (p) T[f][f];
|
||||||
// new (p) T[f][f](f);
|
|
||||||
// new (T[f][f]);
|
// new (T[f][f]);
|
||||||
// new (T[f][f])(f);
|
|
||||||
// new (p) (T[f][f]);
|
// new (p) (T[f][f]);
|
||||||
// new (p) (T[f][f])(f);
|
|
||||||
// };
|
// };
|
||||||
public void _testNewPlacement_Bug236856() throws Exception {
|
public void testNewPlacement() throws Exception {
|
||||||
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
|
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
|
||||||
IASTFunctionDefinition fdef= getFunctionDefinition(tu, 3);
|
IASTFunctionDefinition fdef= getDeclaration(tu, 3);
|
||||||
|
|
||||||
checkNewExpression(fdef, 0, null, "int", 0, null);
|
checkNewExpression(fdef, 0, null, "int", null);
|
||||||
checkNewExpression(fdef, 1, null, "int", 0, IASTIdExpression.class);
|
checkNewExpression(fdef, 1, null, "int", IASTExpressionList.class);
|
||||||
checkNewExpression(fdef, 2, IASTIdExpression.class, "int", 0, null);
|
checkNewExpression(fdef, 2, null, "int", IASTIdExpression.class);
|
||||||
checkNewExpression(fdef, 3, IASTIdExpression.class, "int", 0, IASTIdExpression.class);
|
checkNewExpression(fdef, 3, IASTIdExpression.class, "int", null);
|
||||||
checkNewExpression(fdef, 4, null, "int", 0, null);
|
checkNewExpression(fdef, 4, IASTIdExpression.class, "int", IASTExpressionList.class);
|
||||||
checkNewExpression(fdef, 5, null, "int", 0, IASTIdExpression.class);
|
checkNewExpression(fdef, 5, IASTIdExpression.class, "int", IASTIdExpression.class);
|
||||||
checkNewExpression(fdef, 6, IASTIdExpression.class, "int", 0, null);
|
checkNewExpression(fdef, 6, null, "int", null);
|
||||||
checkNewExpression(fdef, 7, IASTIdExpression.class, "int", 0, IASTIdExpression.class);
|
checkNewExpression(fdef, 7, null, "int", IASTExpressionList.class);
|
||||||
|
checkNewExpression(fdef, 8, null, "int", IASTIdExpression.class);
|
||||||
|
checkNewExpression(fdef, 9, IASTIdExpression.class, "int", null);
|
||||||
|
checkNewExpression(fdef, 10, IASTIdExpression.class, "int", IASTExpressionList.class);
|
||||||
|
checkNewExpression(fdef, 11, IASTIdExpression.class, "int", IASTIdExpression.class);
|
||||||
|
|
||||||
checkNewExpression(fdef, 8, null, "int [] []", 2, null);
|
checkNewExpression(fdef, 12, null, "int [] []", null);
|
||||||
checkNewExpression(fdef, 9, null, "int [] []", 2, IASTIdExpression.class);
|
checkNewExpression(fdef, 13, IASTIdExpression.class, "int [] []", null);
|
||||||
checkNewExpression(fdef, 10, IASTIdExpression.class, "int [] []", 2, null);
|
checkNewExpression(fdef, 14, null, "int [] []", null);
|
||||||
checkNewExpression(fdef, 11, IASTIdExpression.class, "int [] []", 2, IASTIdExpression.class);
|
checkNewExpression(fdef, 15, IASTIdExpression.class, "int [] []", null);
|
||||||
checkNewExpression(fdef, 12, null, "int [] []", 2, null);
|
|
||||||
checkNewExpression(fdef, 13, null, "int [] []", 2, IASTIdExpression.class);
|
|
||||||
checkNewExpression(fdef, 14, IASTIdExpression.class, "int [] []", 2, null);
|
|
||||||
checkNewExpression(fdef, 15, IASTIdExpression.class, "int [] []", 2, IASTIdExpression.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type, int array, Class<?> init) {
|
private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type, Class<?> init) {
|
||||||
IASTExpression expr;
|
IASTExpression expr;
|
||||||
ICPPASTNewExpression newExpr;
|
ICPPASTNewExpression newExpr;
|
||||||
expr= getExpressionOfStatement(fdef, i_expr);
|
expr= getExpressionOfStatement(fdef, i_expr);
|
||||||
|
@ -5732,8 +5736,6 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
} else {
|
} else {
|
||||||
assertInstance(newExpr.getNewInitializer(), init);
|
assertInstance(newExpr.getNewInitializer(), init);
|
||||||
}
|
}
|
||||||
assertEquals(array, newExpr.getNewTypeIdArrayExpressions().length);
|
|
||||||
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), type);
|
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 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,10 +10,11 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
|
* mstodo the class should be removed
|
||||||
*/
|
*/
|
||||||
public class AST2CSpecFailingTest extends AST2SpecBaseTest {
|
public class AST2CSpecFailingTest extends AST2SpecBaseTest {
|
||||||
|
|
||||||
|
@ -38,19 +39,20 @@ public class AST2CSpecFailingTest extends AST2SpecBaseTest {
|
||||||
--End Example]
|
--End Example]
|
||||||
*/
|
*/
|
||||||
public void test6_7_7s6() throws Exception {
|
public void test6_7_7s6() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
// test is no longer failing, was moved to AST2CSpecTest
|
||||||
buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
// StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
// buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
||||||
buffer.append("struct tag {\n"); //$NON-NLS-1$
|
// buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
||||||
buffer.append("unsigned t:4;\n"); //$NON-NLS-1$
|
// buffer.append("struct tag {\n"); //$NON-NLS-1$
|
||||||
buffer.append("const t:5;\n"); //$NON-NLS-1$
|
// buffer.append("unsigned t:4;\n"); //$NON-NLS-1$
|
||||||
buffer.append("plain r:5;\n"); //$NON-NLS-1$
|
// buffer.append("const t:5;\n"); //$NON-NLS-1$
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
// buffer.append("plain r:5;\n"); //$NON-NLS-1$
|
||||||
buffer.append("t f(t (t));\n"); //$NON-NLS-1$
|
// buffer.append("};\n"); //$NON-NLS-1$
|
||||||
buffer.append("long t;\n"); //$NON-NLS-1$
|
// buffer.append("t f(t (t));\n"); //$NON-NLS-1$
|
||||||
try {
|
// buffer.append("long t;\n"); //$NON-NLS-1$
|
||||||
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
// try {
|
||||||
assertTrue(false);
|
// parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||||
} catch (Exception e) {}
|
// assertTrue(false);
|
||||||
|
// } catch (Exception e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2078,4 +2078,32 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||||
|
|
||||||
parseCandCPP(buffer.toString(), false, 0);
|
parseCandCPP(buffer.toString(), false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
[--Start Example(C 6.7.7-6):
|
||||||
|
typedef signed int t;
|
||||||
|
typedef int plain;
|
||||||
|
struct tag {
|
||||||
|
unsigned t:4;
|
||||||
|
const t:5;
|
||||||
|
plain r:5;
|
||||||
|
};
|
||||||
|
t f(t (t));
|
||||||
|
long t;
|
||||||
|
--End Example]
|
||||||
|
*/
|
||||||
|
public void test6_7_7s6() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("typedef signed int t;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("typedef int plain;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct tag {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("unsigned t:4;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("const t:5;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("plain r:5;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("t f(t (t));\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("long t;\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
parse(buffer.toString(), ParserLanguage.C, true, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,10 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
||||||
parse( code, ParserLanguage.CPP, false, true, checkBindings, expectedProblemBindings, null );
|
parse( code, ParserLanguage.CPP, false, true, checkBindings, expectedProblemBindings, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTTranslationUnit parseWithErrors( String code, ParserLanguage lang) throws ParserException {
|
||||||
|
return parse(code, lang, false, false, false, 0, null );
|
||||||
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
|
||||||
return parse(code, lang, false, true, checkBindings, expectedProblemBindings, null );
|
return parse(code, lang, false, true, checkBindings, expectedProblemBindings, null );
|
||||||
}
|
}
|
||||||
|
@ -134,7 +138,7 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
||||||
NameResolver res = new NameResolver();
|
NameResolver res = new NameResolver();
|
||||||
tu.accept( res );
|
tu.accept( res );
|
||||||
if (res.problemBindings.size() != expectedProblemBindings )
|
if (res.problemBindings.size() != expectedProblemBindings )
|
||||||
throw new ParserException("Expected " + expectedProblemBindings + " problems, encountered " + res.problemBindings.size() ); //$NON-NLS-1$ //$NON-NLS-2$
|
throw new ParserException("Expected " + expectedProblemBindings + " problems, encountered " + res.problemBindings.size() );
|
||||||
if (problems != null) {
|
if (problems != null) {
|
||||||
for (int i = 0; i < problems.length; i++) {
|
for (int i = 0; i < problems.length; i++) {
|
||||||
assertEquals(problems[i], res.problemBindings.get(i));
|
assertEquals(problems[i], res.problemBindings.get(i));
|
||||||
|
@ -143,24 +147,24 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if( parser2.encounteredError() && expectNoProblems )
|
if( parser2.encounteredError() && expectNoProblems )
|
||||||
throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
throw new ParserException( "FAILURE");
|
||||||
|
|
||||||
if( lang == ParserLanguage.C && expectNoProblems )
|
if( lang == ParserLanguage.C && expectNoProblems )
|
||||||
{
|
{
|
||||||
if (CVisitor.getProblems(tu).length != 0) {
|
if (CVisitor.getProblems(tu).length != 0) {
|
||||||
throw new ParserException (" CVisitor has AST Problems " ); //$NON-NLS-1$
|
throw new ParserException (" CVisitor has AST Problems " );
|
||||||
}
|
}
|
||||||
if (tu.getPreprocessorProblems().length != 0) {
|
if (tu.getPreprocessorProblems().length != 0) {
|
||||||
throw new ParserException (" C TranslationUnit has Preprocessor Problems " ); //$NON-NLS-1$
|
throw new ParserException (" C TranslationUnit has Preprocessor Problems " );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( lang == ParserLanguage.CPP && expectNoProblems )
|
else if ( lang == ParserLanguage.CPP && expectNoProblems )
|
||||||
{
|
{
|
||||||
if (CPPVisitor.getProblems(tu).length != 0) {
|
if (CPPVisitor.getProblems(tu).length != 0) {
|
||||||
throw new ParserException (" CPPVisitor has AST Problems " ); //$NON-NLS-1$
|
throw new ParserException (" CPPVisitor has AST Problems " );
|
||||||
}
|
}
|
||||||
if (tu.getPreprocessorProblems().length != 0) {
|
if (tu.getPreprocessorProblems().length != 0) {
|
||||||
throw new ParserException (" CPP TranslationUnit has Preprocessor Problems " ); //$NON-NLS-1$
|
throw new ParserException (" CPP TranslationUnit has Preprocessor Problems " );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +183,7 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
||||||
public int numNullBindings = 0;
|
public int numNullBindings = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public int visit(IASTName name) {
|
public int visit(IASTName name) {
|
||||||
nameList.add(name);
|
nameList.add(name);
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
|
|
|
@ -3746,8 +3746,17 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertInstance(col.getName(11).resolveBinding(), ITypedef.class);
|
assertInstance(col.getName(11).resolveBinding(), ITypedef.class);
|
||||||
|
|
||||||
// function ptr
|
// function ptr
|
||||||
assertInstance(col.getName(12).resolveBinding(), ITypedef.class);
|
final IBinding typedef = col.getName(12).resolveBinding();
|
||||||
assertInstance(col.getName(13).resolveBinding(), IProblemBinding.class);
|
final IBinding secondJ = col.getName(13).resolveBinding();
|
||||||
|
assertInstance(typedef, ITypedef.class);
|
||||||
|
if (lang == ParserLanguage.CPP) {
|
||||||
|
assertInstance(secondJ, IProblemBinding.class);
|
||||||
|
} else {
|
||||||
|
// for plain C this is actually not a problem, the second J has to be interpreted as a (useless)
|
||||||
|
// parameter name.
|
||||||
|
assertInstance(typedef, ITypedef.class);
|
||||||
|
isTypeEqual(((ITypedef) typedef).getType(), "int (int) *");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4817,9 +4826,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// int f3(int (tint));
|
// int f3(int (tint));
|
||||||
// int f4(int (identifier));
|
// int f4(int (identifier));
|
||||||
// int f5(int *(tint[10]));
|
// int f5(int *(tint[10]));
|
||||||
public void _testParamWithFunctionType_Bug84242() throws Exception {
|
public void testParamWithFunctionType_Bug84242() throws Exception {
|
||||||
// works for plain-c, see testcase below.
|
|
||||||
// mstodo also check related failure AST2CPPSpecFailingTest._test8_2s7a()
|
|
||||||
final String comment= getAboveComment();
|
final String comment= getAboveComment();
|
||||||
final boolean[] isCpps= {false, true};
|
final boolean[] isCpps= {false, true};
|
||||||
for (boolean isCpp : isCpps) {
|
for (boolean isCpp : isCpps) {
|
||||||
|
@ -4844,7 +4851,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
// class C { };
|
// class C { };
|
||||||
// void f1(int(C)) { }
|
// void f1(int(C)) { }
|
||||||
public void _testParamWithFunctionTypeCpp_Bug84242() throws Exception {
|
public void testParamWithFunctionTypeCpp_Bug84242() throws Exception {
|
||||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
|
||||||
IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
|
IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
|
||||||
|
|
|
@ -120,17 +120,17 @@ public class CommentTests extends AST2BaseTest {
|
||||||
|
|
||||||
private String getCppSource() {
|
private String getCppSource() {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("CppClass()\n");
|
buffer.append("void CppClass()\n");
|
||||||
buffer.append("{\n");
|
buffer.append("{\n");
|
||||||
buffer.append(" // Comment in cpp\n");
|
buffer.append(" // Comment in cpp\n");
|
||||||
buffer.append(" value = 1 + /*The magic 5 */5 * 6;\n");
|
buffer.append(" int value = 1 + /*The magic 5 */5 * 6;\n");
|
||||||
buffer.append(" // Another comment\n");
|
buffer.append(" // Another comment\n");
|
||||||
buffer.append(" value++;\n");
|
buffer.append(" value++;\n");
|
||||||
buffer.append("}\n");
|
buffer.append("}\n");
|
||||||
buffer.append("/* A blockcomment \n");
|
buffer.append("/* A blockcomment \n");
|
||||||
buffer.append("* over multiple lines */\n");
|
buffer.append("* over multiple lines */\n");
|
||||||
buffer.append("//Toplevel comment\n");
|
buffer.append("//Toplevel comment\n");
|
||||||
buffer.append("doIrgendwas(){\n");
|
buffer.append("void doIrgendwas(){\n");
|
||||||
buffer.append(" //A little bit code\n");
|
buffer.append(" //A little bit code\n");
|
||||||
buffer.append(" int i = 3; //Trailing comment\n");
|
buffer.append(" int i = 3; //Trailing comment\n");
|
||||||
buffer.append(" ;\n");
|
buffer.append(" ;\n");
|
||||||
|
@ -152,7 +152,7 @@ public class CommentTests extends AST2BaseTest {
|
||||||
buffer.append(" int n = i++ +5;\n");
|
buffer.append(" int n = i++ +5;\n");
|
||||||
buffer.append(" //Last comment in cpp\n");
|
buffer.append(" //Last comment in cpp\n");
|
||||||
buffer.append("}\n");
|
buffer.append("}\n");
|
||||||
buffer.append("globaleFuntktion(){\n");
|
buffer.append("int globaleFuntktion(){\n");
|
||||||
buffer.append("//An integer\n");
|
buffer.append("//An integer\n");
|
||||||
buffer.append("int i;\n");
|
buffer.append("int i;\n");
|
||||||
buffer.append("}\n");
|
buffer.append("}\n");
|
||||||
|
@ -243,8 +243,7 @@ public class CommentTests extends AST2BaseTest {
|
||||||
assertEquals(5, comments.length);
|
assertEquals(5, comments.length);
|
||||||
assertNotNull(comments[0].getFileLocation());
|
assertNotNull(comments[0].getFileLocation());
|
||||||
assertNotNull(comments[0].getNodeLocations());
|
assertNotNull(comments[0].getNodeLocations());
|
||||||
for (int i = 0; i < comments.length; i++) {
|
for (IASTComment comment : comments) {
|
||||||
IASTComment comment = comments[i];
|
|
||||||
IASTFileLocation loc= comment.getFileLocation();
|
IASTFileLocation loc= comment.getFileLocation();
|
||||||
int idx= loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO");
|
int idx= loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO");
|
||||||
assertEquals("TODO", code.substring(idx, idx+4));
|
assertEquals("TODO", code.substring(idx, idx+4));
|
||||||
|
|
|
@ -854,8 +854,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
assertInstances( col, A, 2 );
|
assertInstances( col, A, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
|
public void testNewExpressions() throws Exception {
|
||||||
public void _testNewExpressions() throws Exception {
|
|
||||||
IASTTranslationUnit tu = parse( "typedef int A; int B; int C; int D; int P; int*p = new (P) (A[B][C][D]);" ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse( "typedef int A; int B; int C; int D; int P; int*p = new (P) (A[B][C][D]);" ); //$NON-NLS-1$
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept( col );
|
tu.accept( col );
|
||||||
|
|
|
@ -98,9 +98,9 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
|
||||||
|
|
||||||
public void testBaseCase_FunctionDeclaration() throws Exception
|
public void testBaseCase_FunctionDeclaration() throws Exception
|
||||||
{
|
{
|
||||||
String code = "int x(); x( );"; //$NON-NLS-1$
|
String code = "int x(); void test() {x( );}"; //$NON-NLS-1$
|
||||||
int offset1 = code.indexOf( "x()" ); //$NON-NLS-1$
|
int offset1 = code.indexOf( "x( )" ); //$NON-NLS-1$
|
||||||
int offset2 = code.indexOf( "()"); //$NON-NLS-1$
|
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
|
||||||
IASTNode node = parse( code, offset1, offset2 );
|
IASTNode node = parse( code, offset1, offset2 );
|
||||||
assertTrue( node instanceof IASTName );
|
assertTrue( node instanceof IASTName );
|
||||||
assertTrue( ((IASTName)node).resolveBinding() instanceof IFunction );
|
assertTrue( ((IASTName)node).resolveBinding() instanceof IFunction );
|
||||||
|
|
|
@ -521,7 +521,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testBug36769A() throws Exception {
|
public void testBug36769A() throws Exception {
|
||||||
|
|
||||||
parse("template <class A, B> cls<A, C>::operator &() const {}\n");
|
parse("template <class A, B> cls<A, C>::operator otherType() const {}\n");
|
||||||
parse("template <class A, B> cls<A, C>::cls() {}\n");
|
parse("template <class A, B> cls<A, C>::cls() {}\n");
|
||||||
parse("template <class A, B> cls<A, C>::~cls() {}\n");
|
parse("template <class A, B> cls<A, C>::~cls() {}\n");
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBugFunctor758() throws Exception {
|
public void testBugFunctor758() throws Exception {
|
||||||
parse("template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}");
|
parse(
|
||||||
|
"class Functor {"+
|
||||||
|
"template <typename Fun> Functor(Fun fun) : spImpl_(new FunctorHandler<Functor, Fun>(fun)){}" +
|
||||||
|
"};"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36932() throws Exception {
|
public void testBug36932() throws Exception {
|
||||||
|
@ -642,10 +646,10 @@ public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
public void testBug36696() throws Exception {
|
public void testBug36696() throws Exception {
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
code
|
code.write("template<typename T> class RefCounted {");
|
||||||
.write("template <typename P1> RefCounted(const RefCounted<P1>& rhs)\n");
|
code.write("template <typename P1> RefCounted(const RefCounted<P1>& rhs)\n");
|
||||||
code
|
code.write(": pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_) {}\n");
|
||||||
.write(": pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_) {}\n");
|
code.write("};");
|
||||||
parse(code.toString());
|
parse(code.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,7 +843,11 @@ public class QuickParser2Tests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36690() throws Exception {
|
public void testBug36690() throws Exception {
|
||||||
parse("Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}");
|
parse(
|
||||||
|
"class Functor {" +
|
||||||
|
"Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get())){}" +
|
||||||
|
"}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36703() throws Exception {
|
public void testBug36703() throws Exception {
|
||||||
|
|
|
@ -78,22 +78,22 @@ public class BasicCompletionTest extends CompletionTestBase {
|
||||||
|
|
||||||
public void testTypedef() throws Exception {
|
public void testTypedef() throws Exception {
|
||||||
String code =
|
String code =
|
||||||
"typedef int blah;" +
|
"void test() {typedef int blah;" +
|
||||||
"bl";
|
"bl";
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
IASTCompletionNode node = getGPPCompletionNode(code);
|
IASTCompletionNode node = getGPPCompletionNode(code);
|
||||||
IASTName[] names = node.getNames();
|
IASTName[] names = node.getNames();
|
||||||
assertEquals(2, names.length);
|
assertEquals(2, names.length);
|
||||||
assertNull(names[0].getTranslationUnit());
|
assertNull(names[1].getTranslationUnit());
|
||||||
IBinding[] bindings = names[1].getCompletionContext().findBindings(names[1], true);
|
IBinding[] bindings = names[0].getCompletionContext().findBindings(names[0], true);
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertEquals("blah", ((ITypedef)bindings[0]).getName());
|
assertEquals("blah", ((ITypedef)bindings[0]).getName());
|
||||||
|
|
||||||
// C
|
// C
|
||||||
node = getGCCCompletionNode(code);
|
node = getGCCCompletionNode(code);
|
||||||
names = node.getNames();
|
names = node.getNames();
|
||||||
assertEquals(1, names.length);
|
assert(names.length > 0);
|
||||||
bindings = names[0].getCompletionContext().findBindings(names[0], true);
|
bindings = names[0].getCompletionContext().findBindings(names[0], true);
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertEquals("blah", ((ITypedef)bindings[0]).getName());
|
assertEquals("blah", ((ITypedef)bindings[0]).getName());
|
||||||
|
|
|
@ -13,10 +13,14 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.append;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
@ -47,8 +51,11 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
if (expression instanceof ICPPASTNewExpression) {
|
if (expression instanceof ICPPASTNewExpression) {
|
||||||
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
||||||
newExpression.getNewTypeIdArrayExpressions();
|
IASTTypeId id= newExpression.getTypeId();
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, newExpression, new CPPASTLiteralExpression(0, "5"), null); //$NON-NLS-1$
|
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
|
||||||
|
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
||||||
|
IASTArrayModifier add= new CPPASTArrayModifier(new CPPASTLiteralExpression(0, "5"));
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, dtor, add, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -13,10 +13,14 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
@ -49,8 +53,11 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
if (expression instanceof ICPPASTNewExpression) {
|
if (expression instanceof ICPPASTNewExpression) {
|
||||||
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
||||||
IASTExpression[] arraySizeExpressions = newExpression.getNewTypeIdArrayExpressions();
|
IASTTypeId id= newExpression.getTypeId();
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE, arraySizeExpressions[0], new CPPASTLiteralExpression(0, "6"), null); //$NON-NLS-1$
|
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
|
||||||
|
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
||||||
|
IASTArrayModifier add= new CPPASTArrayModifier(new CPPASTLiteralExpression(0, "6"));
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE, mods[0], add, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -13,7 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.remove;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
|
@ -47,8 +50,10 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
if (expression instanceof ICPPASTNewExpression) {
|
if (expression instanceof ICPPASTNewExpression) {
|
||||||
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
||||||
IASTExpression[] arraySizeExpressions = newExpression.getNewTypeIdArrayExpressions();
|
IASTTypeId id= newExpression.getTypeId();
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, arraySizeExpressions[1], null, null);
|
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
|
||||||
|
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, mods[1], null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -13,7 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
|
||||||
|
@ -54,8 +57,11 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
if (expression instanceof ICPPASTNewExpression) {
|
if (expression instanceof ICPPASTNewExpression) {
|
||||||
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
||||||
IASTExpression[] arraySizeExpressions = newExpression.getNewTypeIdArrayExpressions();
|
IASTTypeId id= newExpression.getTypeId();
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, arraySizeExpressions[1], new CPPASTLiteralExpression(0, "7"), null); //$NON-NLS-1$
|
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
|
||||||
|
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
||||||
|
IASTExpression expr= mods[1].getConstantExpression();
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, expr, new CPPASTLiteralExpression(0, "7"), null); //$NON-NLS-1$
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2008 Symbian Software Systems 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:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -46,6 +48,7 @@ public class PDOMCBugsTest extends BaseTestCase {
|
||||||
return suite(PDOMCBugsTest.class);
|
return suite(PDOMCBugsTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
cproject= CProjectHelper.createCProject("PDOMCBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
cproject= CProjectHelper.createCProject("PDOMCBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
Bundle b = CTestPlugin.getDefault().getBundle();
|
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||||
|
@ -59,6 +62,7 @@ public class PDOMCBugsTest extends BaseTestCase {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if (cproject != null) {
|
if (cproject != null) {
|
||||||
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||||
|
@ -79,16 +83,16 @@ public class PDOMCBugsTest extends BaseTestCase {
|
||||||
IBinding[] bindings= pdom.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, NPM);
|
IBinding[] bindings= pdom.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, NPM);
|
||||||
assertEquals(7, bindings.length);
|
assertEquals(7, bindings.length);
|
||||||
Set bnames= new HashSet();
|
Set bnames= new HashSet();
|
||||||
for(int i=0; i<bindings.length; i++) {
|
for (IBinding binding : bindings) {
|
||||||
assertTrue("expected typedef, got "+bindings[i], bindings[i] instanceof ITypedef);
|
assertTrue("expected typedef, got "+binding, binding instanceof ITypedef);
|
||||||
bnames.add(bindings[i].getName());
|
bnames.add(binding.getName());
|
||||||
IType type= SemanticUtil.getUltimateType((IType)bindings[i], false);
|
IType type= SemanticUtil.getUltimateType((IType)binding, false);
|
||||||
|
|
||||||
if(bindings[i].getName().equals("J")) {
|
if(binding.getName().equals("J")) {
|
||||||
|
// for plain C the second J has to be interpreted as a (useless) parameter name.
|
||||||
assertTrue(type instanceof IFunctionType);
|
assertTrue(type instanceof IFunctionType);
|
||||||
IFunctionType ft= (IFunctionType) type;
|
IFunctionType ft= (IFunctionType) type;
|
||||||
assertEquals(1, ft.getParameterTypes().length);
|
assertEquals("int (int)", ASTTypeUtil.getType(ft));
|
||||||
assertNull(ft.getParameterTypes()[0]);
|
|
||||||
} else {
|
} else {
|
||||||
assertNull("expected null, got "+type, type);
|
assertNull("expected null, got "+type, type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
//!Commented NameTest1
|
//!Commented NameTest1
|
||||||
//%CPP
|
//%CPP
|
||||||
//Test
|
//Test
|
||||||
Hallo;
|
int Hallo;
|
||||||
|
|
||||||
//!Commented NameTest2
|
//!Commented NameTest2
|
||||||
//%CPP
|
//%CPP
|
||||||
Hallo; //Test
|
int Hallo; //Test
|
||||||
|
|
||||||
//!Commented NameTest2
|
//!Commented NameTest2
|
||||||
//%CPP
|
//%CPP
|
||||||
Hallo /*Test*/;
|
int Hallo /*Test*/;
|
||||||
|
|
||||||
//!Commented QualifiedName1
|
//!Commented QualifiedName1
|
||||||
//%CPP
|
//%CPP
|
||||||
//TEST
|
//TEST
|
||||||
TestClass::Hallo;
|
int TestClass::Hallo;
|
||||||
|
|
||||||
//!Commented QualifiedName1
|
//!Commented QualifiedName1
|
||||||
//%CPP
|
//%CPP
|
||||||
TestClass::Hallo; //TEST
|
int TestClass::Hallo; //TEST
|
||||||
|
|
||||||
//!Commented QualifiedName1
|
//!Commented QualifiedName1
|
||||||
//%CPP
|
//%CPP
|
||||||
TestClass::Hallo /*Test*/;
|
int TestClass::Hallo /*Test*/;
|
||||||
|
|
||||||
//!Commented OperatorName1
|
//!Commented OperatorName1
|
||||||
//%CPP
|
//%CPP
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Klasse0
|
class Klasse0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Klasse1(); /*
|
Klasse0(); /*
|
||||||
* Comment
|
* Comment
|
||||||
*/
|
*/
|
||||||
std::string toString();
|
std::string toString();
|
||||||
|
@ -15,7 +15,7 @@ private:
|
||||||
class Klasse0
|
class Klasse0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Klasse1(); /*
|
Klasse0(); /*
|
||||||
* Comment
|
* Comment
|
||||||
*/
|
*/
|
||||||
std::string toString();
|
std::string toString();
|
||||||
|
@ -28,7 +28,7 @@ private:
|
||||||
class Klasse0
|
class Klasse0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Klasse1(); //Comment
|
Klasse0(); //Comment
|
||||||
std::string toString();
|
std::string toString();
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
|
@ -38,7 +38,7 @@ private:
|
||||||
class Klasse0
|
class Klasse0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Klasse1(); //Comment
|
Klasse0(); //Comment
|
||||||
std::string toString();
|
std::string toString();
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
|
@ -51,7 +51,7 @@ class Klasse0
|
||||||
{
|
{
|
||||||
//Comment2
|
//Comment2
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse0();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
|
@ -524,7 +524,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -541,7 +541,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0; //TEST
|
int i = 0; //TEST
|
||||||
i++;
|
i++;
|
||||||
|
@ -557,7 +557,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -575,7 +575,7 @@ public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
//KommentarDavor
|
//KommentarDavor
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -592,7 +592,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -609,7 +609,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -627,7 +627,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -646,7 +646,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -663,7 +663,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -681,7 +681,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -701,7 +701,7 @@ public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
//TEST
|
//TEST
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -719,7 +719,7 @@ public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
/*TEST*/
|
/*TEST*/
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -737,7 +737,7 @@ class Klasse1 //Nachher
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -755,7 +755,7 @@ class Klasse1 /*Nachher*/
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -774,7 +774,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -793,7 +793,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -814,7 +814,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -831,7 +831,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -848,7 +848,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -865,7 +865,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -884,7 +884,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -904,7 +904,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -922,7 +922,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//!NameTest
|
//!NameTest
|
||||||
//%CPP
|
//%CPP
|
||||||
Hallo;
|
int Hallo;
|
||||||
|
|
||||||
//!QualifiedName
|
//!QualifiedName
|
||||||
//%CPP
|
//%CPP
|
||||||
TestClass::Hallo;
|
int TestClass::Hallo;
|
||||||
|
|
||||||
//!OperatorName
|
//!OperatorName
|
||||||
//%CPP
|
//%CPP
|
||||||
|
|
|
@ -10,7 +10,7 @@ void foo()
|
||||||
|
|
||||||
//!CaseDefaultStatementTest
|
//!CaseDefaultStatementTest
|
||||||
//%CPP
|
//%CPP
|
||||||
foo()
|
void foo()
|
||||||
{
|
{
|
||||||
switch (1){
|
switch (1){
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -146,7 +146,7 @@ public: = //Klasse...
|
||||||
class Klasse0
|
class Klasse0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Klasse1(); //Comment
|
Klasse0(); //Comment
|
||||||
std::string toString();
|
std::string toString();
|
||||||
private:
|
private:
|
||||||
int i;
|
int i;
|
||||||
|
@ -156,7 +156,7 @@ private:
|
||||||
=>leading
|
=>leading
|
||||||
|
|
||||||
=>trailing
|
=>trailing
|
||||||
Klasse1(); = //Comment
|
Klasse0(); = //Comment
|
||||||
|
|
||||||
=>freestanding
|
=>freestanding
|
||||||
|
|
||||||
|
@ -760,7 +760,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -785,7 +785,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0; //TEST
|
int i = 0; //TEST
|
||||||
i++;
|
i++;
|
||||||
|
@ -810,7 +810,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -840,7 +840,7 @@ public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
//KommentarDavor
|
//KommentarDavor
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -852,7 +852,7 @@ private:
|
||||||
|
|
||||||
//=
|
//=
|
||||||
=>leading
|
=>leading
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -874,7 +874,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -893,7 +893,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -913,7 +913,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -933,7 +933,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -949,7 +949,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -967,7 +967,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -990,7 +990,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1008,7 +1008,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1027,7 +1027,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1047,7 +1047,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1069,7 +1069,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1087,7 +1087,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1108,7 +1108,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1131,7 +1131,7 @@ public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
//TEST
|
//TEST
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1143,7 +1143,7 @@ private:
|
||||||
|
|
||||||
//=
|
//=
|
||||||
=>leading
|
=>leading
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1162,7 +1162,7 @@ public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
/*TEST*/
|
/*TEST*/
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1174,7 +1174,7 @@ private:
|
||||||
|
|
||||||
//=
|
//=
|
||||||
=>leading
|
=>leading
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1193,7 +1193,7 @@ class Klasse1 //Nachher
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1210,7 +1210,7 @@ class Klasse1 //Nachher
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1234,7 +1234,7 @@ class Klasse1 /*Nachher*/
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1251,7 +1251,7 @@ class Klasse1 /*Nachher*/
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1276,7 +1276,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1294,7 +1294,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1319,7 +1319,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1337,7 +1337,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1364,7 +1364,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1382,7 +1382,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1407,7 +1407,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1433,7 +1433,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1459,7 +1459,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1489,7 +1489,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1520,7 +1520,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1547,7 +1547,7 @@ class Klasse1
|
||||||
public:
|
public:
|
||||||
Klasse1();
|
Klasse1();
|
||||||
std::string toString();
|
std::string toString();
|
||||||
inlineMethode()
|
void inlineMethode()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.testplugin;
|
package org.eclipse.cdt.core.testplugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -30,36 +30,37 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
*/
|
*/
|
||||||
public class FileManager {
|
public class FileManager {
|
||||||
ArrayList fileHandles;
|
HashSet<IFile> fileHandles;
|
||||||
|
|
||||||
public FileManager(){
|
public FileManager(){
|
||||||
fileHandles = new ArrayList();
|
fileHandles = new HashSet<IFile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFile(IFile file){
|
public void addFile(IFile file){
|
||||||
fileHandles.add(file);
|
fileHandles.add(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeAllFiles() throws CoreException{
|
public void closeAllFiles() throws CoreException, InterruptedException{
|
||||||
Iterator iter = fileHandles.iterator();
|
int wait= 1;
|
||||||
while (iter.hasNext()){
|
for (int i = 0; i < 11; i++) {
|
||||||
|
for (Iterator iter= fileHandles.iterator(); iter.hasNext();) {
|
||||||
IFile tempFile = (IFile) iter.next();
|
IFile tempFile = (IFile) iter.next();
|
||||||
|
try {
|
||||||
|
if (i==1) {
|
||||||
tempFile.refreshLocal(IResource.DEPTH_INFINITE,null);
|
tempFile.refreshLocal(IResource.DEPTH_INFINITE,null);
|
||||||
|
}
|
||||||
try {
|
|
||||||
tempFile.delete(true,null);
|
tempFile.delete(true,null);
|
||||||
|
iter.remove();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
try {
|
if (wait > 2000)
|
||||||
Thread.sleep(2000);
|
throw e;
|
||||||
} catch (InterruptedException e1) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
finally{
|
|
||||||
tempFile.delete(true,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fileHandles.isEmpty())
|
||||||
|
return;
|
||||||
|
Thread.sleep(wait);
|
||||||
|
wait*=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 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
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -81,8 +82,7 @@ public interface ICPPASTNewExpression extends IASTExpression {
|
||||||
public static final ASTNodeProperty TYPE_ID = new ASTNodeProperty("ICPPASTNewExpression.TYPE_ID - The type being 'newed'"); //$NON-NLS-1$
|
public static final ASTNodeProperty TYPE_ID = new ASTNodeProperty("ICPPASTNewExpression.TYPE_ID - The type being 'newed'"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type Id.
|
* Get the type Id. The type-id includes the optional array modifications.
|
||||||
*
|
|
||||||
* @return <code>IASTTypeId</code>
|
* @return <code>IASTTypeId</code>
|
||||||
*/
|
*/
|
||||||
public IASTTypeId getTypeId();
|
public IASTTypeId getTypeId();
|
||||||
|
@ -96,9 +96,8 @@ public interface ICPPASTNewExpression extends IASTExpression {
|
||||||
public void setTypeId(IASTTypeId typeId);
|
public void setTypeId(IASTTypeId typeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the typeID a new type ID?
|
* Returns whether the the typeID a new type ID, which is the case when
|
||||||
*
|
* the type-id is provided without parenthesis.
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
public boolean isNewTypeId();
|
public boolean isNewTypeId();
|
||||||
|
|
||||||
|
@ -117,18 +116,15 @@ public interface ICPPASTNewExpression extends IASTExpression {
|
||||||
"ICPPASTNewExpression.NEW_TYPEID_ARRAY_EXPRESSION - Expressions inside array brackets"); //$NON-NLS-1$
|
"ICPPASTNewExpression.NEW_TYPEID_ARRAY_EXPRESSION - Expressions inside array brackets"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the new array size expressions.
|
* @deprecated the id-expressions are part of the type-id.
|
||||||
*
|
|
||||||
* @return <code>IASTExpression []</code>
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public IASTExpression[] getNewTypeIdArrayExpressions();
|
public IASTExpression[] getNewTypeIdArrayExpressions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add another array size expression.
|
* @deprecated the id-expressions are part of the type-id
|
||||||
*
|
|
||||||
* @param expression
|
|
||||||
* <code>IASTExpression</code>
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void addNewTypeIdArrayExpression(IASTExpression expression);
|
public void addNewTypeIdArrayExpression(IASTExpression expression);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
|
@ -78,7 +79,6 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected final AbstractParserLogService log;
|
protected final AbstractParserLogService log;
|
||||||
protected final IScanner scanner;
|
protected final IScanner scanner;
|
||||||
protected final ParserMode mode;
|
protected final ParserMode mode;
|
||||||
|
@ -193,6 +193,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return node.getOffset() + node.getLength();
|
return node.getOffset() + node.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void adjustLength(IASTNode n, IASTNode endNode) {
|
||||||
|
final int endOffset= calculateEndOffset(endNode);
|
||||||
|
final ASTNode node = (ASTNode) n;
|
||||||
|
node.setLength(endOffset-node.getOffset());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume the next token available, regardless of the type.
|
* Consume the next token available, regardless of the type.
|
||||||
*
|
*
|
||||||
|
@ -201,13 +207,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* If there is no token to consume.
|
* If there is no token to consume.
|
||||||
*/
|
*/
|
||||||
protected IToken consume() throws EndOfFileException {
|
protected IToken consume() throws EndOfFileException {
|
||||||
|
if (currToken == null) {
|
||||||
if (currToken == null)
|
|
||||||
currToken = fetchToken();
|
currToken = fetchToken();
|
||||||
IToken lastToken = null;
|
}
|
||||||
if (currToken != null)
|
|
||||||
lastToken = currToken;
|
final IToken lastToken = currToken;
|
||||||
currToken = currToken.getNext();
|
currToken= lastToken.getNext();
|
||||||
return lastToken;
|
return lastToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,13 +225,33 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* If LT(1) != type
|
* If LT(1) != type
|
||||||
*/
|
*/
|
||||||
protected IToken consume(int type) throws EndOfFileException,
|
protected IToken consume(int type) throws EndOfFileException, BacktrackException {
|
||||||
BacktrackException {
|
final IToken la1= LA(1);
|
||||||
if (LT(1) == type)
|
if (la1.getType() != type)
|
||||||
|
throwBacktrack(la1);
|
||||||
|
|
||||||
|
return consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the next token available only if the type is as specified. In case we
|
||||||
|
* reached the end of completion, no token is consumed and the eoc-token returned.
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* The type of token that you are expecting.
|
||||||
|
* @return the token that was consumed and removed from our buffer.
|
||||||
|
* @throws BacktrackException
|
||||||
|
* If LT(1) != type
|
||||||
|
*/
|
||||||
|
protected IToken consumeOrEOC(int type) throws EndOfFileException, BacktrackException {
|
||||||
|
final IToken la1= LA(1);
|
||||||
|
final int lt1 = la1.getType();
|
||||||
|
if (lt1 != type) {
|
||||||
|
if (lt1 == IToken.tEOC)
|
||||||
|
return la1;
|
||||||
|
throwBacktrack(la1);
|
||||||
|
}
|
||||||
return consume();
|
return consume();
|
||||||
IToken la = LA(1);
|
|
||||||
throwBacktrack(la.getOffset(), la.getLength());
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -560,6 +585,16 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected abstract IGNUASTCompoundStatementExpression createCompoundStatementExpression();
|
protected abstract IGNUASTCompoundStatementExpression createCompoundStatementExpression();
|
||||||
|
|
||||||
|
protected IASTExpression possiblyEmptyExpressionList(int endToken) throws BacktrackException, EndOfFileException {
|
||||||
|
IToken la1= LA(1);
|
||||||
|
if (la1.getType() == endToken) {
|
||||||
|
IASTExpressionList expressionList = createExpressionList();
|
||||||
|
((ASTNode) expressionList).setOffsetAndLength(la1.getOffset(), 0);
|
||||||
|
return expressionList;
|
||||||
|
}
|
||||||
|
return expression();
|
||||||
|
}
|
||||||
|
|
||||||
protected IASTExpression expression() throws BacktrackException, EndOfFileException {
|
protected IASTExpression expression() throws BacktrackException, EndOfFileException {
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
int startingOffset = la.getOffset();
|
int startingOffset = la.getOffset();
|
||||||
|
@ -593,14 +628,11 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected abstract IASTExpression multiplicativeExpression()
|
protected abstract IASTExpression multiplicativeExpression()
|
||||||
throws BacktrackException, EndOfFileException;
|
throws BacktrackException, EndOfFileException;
|
||||||
|
|
||||||
protected abstract IASTTypeId typeId(boolean forNewExpression)
|
protected abstract IASTTypeId typeId(DeclarationOptions option) throws EndOfFileException;
|
||||||
throws EndOfFileException;
|
|
||||||
|
|
||||||
protected abstract IASTExpression castExpression()
|
protected abstract IASTExpression castExpression() throws BacktrackException, EndOfFileException;
|
||||||
throws BacktrackException, EndOfFileException;
|
|
||||||
|
|
||||||
protected abstract IASTExpression unaryExpression()
|
protected abstract IASTExpression unaryExpression() throws BacktrackException, EndOfFileException;
|
||||||
throws BacktrackException, EndOfFileException;
|
|
||||||
|
|
||||||
protected abstract IASTExpression buildTypeIdExpression(int op,
|
protected abstract IASTExpression buildTypeIdExpression(int op,
|
||||||
IASTTypeId typeId, int startingOffset, int endingOffset);
|
IASTTypeId typeId, int startingOffset, int endingOffset);
|
||||||
|
@ -818,7 +850,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
boolean needBack = false;
|
boolean needBack = false;
|
||||||
try {
|
try {
|
||||||
consume();
|
consume();
|
||||||
d = typeId(false);
|
d = typeId(DeclarationOptions.TYPEID);
|
||||||
if (d == null)
|
if (d == null)
|
||||||
needBack = true;
|
needBack = true;
|
||||||
else
|
else
|
||||||
|
@ -862,7 +894,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
catch (BacktrackException e) {
|
catch (BacktrackException e) {
|
||||||
backup(m);
|
backup(m);
|
||||||
d = typeId(false);
|
d = typeId(DeclarationOptions.TYPEID);
|
||||||
if (d == null)
|
if (d == null)
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -874,14 +906,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
if (d != null)
|
if (d != null)
|
||||||
return buildTypeIdExpression(IGNUASTTypeIdExpression.op_typeof, d, offset, lastOffset);
|
return buildTypeIdExpression(IGNUASTTypeIdExpression.op_typeof, d, offset, lastOffset);
|
||||||
|
|
||||||
if (expression != null)
|
|
||||||
return buildUnaryExpression(IGNUASTUnaryExpression.op_typeof, expression, offset, lastOffset);
|
return buildUnaryExpression(IGNUASTUnaryExpression.op_typeof, expression, offset, lastOffset);
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTStatement handleFunctionBody() throws BacktrackException,
|
protected IASTStatement handleFunctionBody() throws BacktrackException, EndOfFileException {
|
||||||
EndOfFileException {
|
|
||||||
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE) {
|
if (mode == ParserMode.QUICK_PARSE || mode == ParserMode.STRUCTURAL_PARSE) {
|
||||||
IToken curr = LA(1);
|
IToken curr = LA(1);
|
||||||
IToken last = skipOverCompoundStatement();
|
IToken last = skipOverCompoundStatement();
|
||||||
|
@ -896,9 +924,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
IASTCompoundStatement cs = createCompoundStatement();
|
IASTCompoundStatement cs = createCompoundStatement();
|
||||||
((ASTNode) cs).setOffsetAndLength(curr.getOffset(), last.getEndOffset() - curr.getOffset());
|
((ASTNode) cs).setOffsetAndLength(curr.getOffset(), last.getEndOffset() - curr.getOffset());
|
||||||
return cs;
|
return cs;
|
||||||
} else if (mode == ParserMode.COMPLETE_PARSE)
|
}
|
||||||
|
|
||||||
|
// full parse
|
||||||
return functionBody();
|
return functionBody();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -912,184 +941,50 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return compoundStatement();
|
return compoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IASTDeclarator initDeclarator()
|
protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException;
|
||||||
throws EndOfFileException, BacktrackException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param flags input flags that are used to make our decision
|
* @param option the options with which to parse the declaration
|
||||||
* @throws FoundDeclaratorException encountered EOF while looking ahead
|
* @throws FoundDeclaratorException encountered EOF while looking ahead
|
||||||
*/
|
*/
|
||||||
protected void lookAheadForDeclarator(Flags flags) throws FoundDeclaratorException {
|
protected void lookAheadForDeclarator(final DeclarationOptions option) throws FoundDeclaratorException {
|
||||||
if (flags.typeId)
|
|
||||||
return;
|
|
||||||
IToken mark = null;
|
IToken mark = null;
|
||||||
try {
|
try {
|
||||||
mark = mark();
|
mark = mark();
|
||||||
} catch (EndOfFileException eof) {
|
final IASTDeclarator dtor= initDeclarator(option);
|
||||||
|
final IToken la = LA(1);
|
||||||
|
if (la == null || la == mark)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tIDENTIFIER )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch( EndOfFileException eof )
|
|
||||||
{
|
|
||||||
backup( mark );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
IASTDeclarator d = initDeclarator();
|
|
||||||
IToken la = LA(1);
|
|
||||||
backup(mark);
|
|
||||||
if (la == null || la.getType() == IToken.tEOC)
|
|
||||||
return;
|
|
||||||
final ASTNode n = ((ASTNode) d);
|
|
||||||
final int length = n.getLength();
|
|
||||||
final int offset = n.getOffset();
|
|
||||||
if (length == 0)
|
|
||||||
return;
|
|
||||||
if (flags.parm) {
|
|
||||||
ASTNode name = (ASTNode) d.getName();
|
|
||||||
if (name.getOffset() == offset) {
|
|
||||||
// fix for bugs 147903 and 179493
|
|
||||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147903
|
|
||||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=179493
|
|
||||||
if (name.getLength() == length || d instanceof IASTArrayDeclarator) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (d.getInitializer() != null) {
|
|
||||||
ASTNode init = (ASTNode) d.getInitializer();
|
|
||||||
if (name.getOffset() == offset
|
|
||||||
&& n.getOffset() + n.getLength() == init
|
|
||||||
.getOffset()
|
|
||||||
+ init.getLength())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (la.getType()) {
|
if (verifyLookaheadDeclarator(option, dtor, la))
|
||||||
case IToken.tCOMMA:
|
throw new FoundDeclaratorException(dtor, la);
|
||||||
case IToken.tRPAREN:
|
|
||||||
throw new FoundDeclaratorException( d, la );
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkTokenVsDeclarator(la, d);
|
|
||||||
return;
|
|
||||||
} catch (BacktrackException bte) {
|
} catch (BacktrackException bte) {
|
||||||
backup(mark);
|
|
||||||
return;
|
|
||||||
} catch (EndOfFileException e) {
|
} catch (EndOfFileException e) {
|
||||||
|
} finally {
|
||||||
|
if (mark != null)
|
||||||
backup(mark);
|
backup(mark);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkTokenVsDeclarator(IToken la, IASTDeclarator d) throws FoundDeclaratorException {
|
protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken);
|
||||||
switch (la.getType()) {
|
|
||||||
case IToken.tCOMMA:
|
|
||||||
case IToken.tLBRACE:
|
|
||||||
throw new FoundDeclaratorException( d, la );
|
|
||||||
case IToken.tSEMI:
|
|
||||||
if (d instanceof IASTFieldDeclarator)
|
|
||||||
return;
|
|
||||||
throw new FoundDeclaratorException( d, la );
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class FoundDeclaratorException extends Exception
|
public static class FoundDeclaratorException extends Exception {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 0;
|
private static final long serialVersionUID = 0;
|
||||||
|
|
||||||
public final IASTDeclarator declarator;
|
|
||||||
public final IToken currToken;
|
|
||||||
public IASTDeclSpecifier declSpec;
|
public IASTDeclSpecifier declSpec;
|
||||||
|
public IASTDeclarator declarator;
|
||||||
|
|
||||||
public FoundDeclaratorException( IASTDeclarator d, IToken t )
|
public IASTDeclSpecifier altSpec;
|
||||||
{
|
public IASTDeclarator altDeclarator;
|
||||||
|
|
||||||
|
public IToken currToken;
|
||||||
|
|
||||||
|
public FoundDeclaratorException(IASTDeclarator d, IToken t) {
|
||||||
this.declarator = d;
|
this.declarator = d;
|
||||||
this.currToken =t;
|
this.currToken =t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Flags {
|
|
||||||
private boolean encounteredTypename = false;
|
|
||||||
|
|
||||||
// have we encountered a typeName yet?
|
|
||||||
private boolean encounteredRawType = false;
|
|
||||||
|
|
||||||
// have we encountered a raw type yet?
|
|
||||||
boolean parm = false;
|
|
||||||
|
|
||||||
// is this for a simpleDeclaration or parameterDeclaration?
|
|
||||||
boolean constructor = false;
|
|
||||||
|
|
||||||
boolean typeId = false;
|
|
||||||
|
|
||||||
// are we attempting the constructor strategy?
|
|
||||||
public Flags(boolean parm, boolean c, boolean t) {
|
|
||||||
this.parm = parm;
|
|
||||||
constructor = c;
|
|
||||||
typeId = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Flags(boolean parm, boolean typeId) {
|
|
||||||
this(parm, false, typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if we have encountered a simple type up to this point,
|
|
||||||
* false otherwise
|
|
||||||
*/
|
|
||||||
public boolean haveEncounteredRawType() {
|
|
||||||
return encounteredRawType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if we have encountered a typename up to this point,
|
|
||||||
* false otherwise
|
|
||||||
*/
|
|
||||||
public boolean haveEncounteredTypename() {
|
|
||||||
return encounteredTypename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param b -
|
|
||||||
* set to true if we encounter a raw type (int, short, etc.)
|
|
||||||
*/
|
|
||||||
public void setEncounteredRawType(boolean b) {
|
|
||||||
encounteredRawType = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param b -
|
|
||||||
* set to true if we encounter a typename
|
|
||||||
*/
|
|
||||||
public void setEncounteredTypename(boolean b) {
|
|
||||||
encounteredTypename = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if we are parsing for a ParameterDeclaration
|
|
||||||
*/
|
|
||||||
public boolean isForParameterDeclaration() {
|
|
||||||
return parm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return whether or not we are attempting the constructor strategy or
|
|
||||||
* not
|
|
||||||
*/
|
|
||||||
public boolean isForConstructor() {
|
|
||||||
return constructor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an enumeration specifier, as according to the ANSI specs in C &
|
* Parse an enumeration specifier, as according to the ANSI specs in C &
|
||||||
* C++. enumSpecifier: "enum" (name)? "{" (enumerator-list) "}"
|
* C++. enumSpecifier: "enum" (name)? "{" (enumerator-list) "}"
|
||||||
|
@ -1246,8 +1141,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected abstract IASTCaseStatement createCaseStatement();
|
protected abstract IASTCaseStatement createCaseStatement();
|
||||||
|
|
||||||
protected abstract IASTDeclaration declaration() throws BacktrackException,
|
protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
|
||||||
EndOfFileException;
|
|
||||||
|
|
||||||
|
|
||||||
protected IASTDeclaration asmDeclaration() throws EndOfFileException,
|
protected IASTDeclaration asmDeclaration() throws EndOfFileException,
|
||||||
|
@ -1330,7 +1224,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
* This method will attempt to parse a statement as both an expression and a declaration,
|
* This method will attempt to parse a statement as both an expression and a declaration,
|
||||||
* if both parses succeed then an ambiguity node is returned.
|
* if both parses succeed then an ambiguity node is returned.
|
||||||
*/
|
*/
|
||||||
protected IASTStatement parseDeclarationOrExpressionStatement() throws EndOfFileException, BacktrackException {
|
protected IASTStatement parseDeclarationOrExpressionStatement(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
// First attempt to parse an expressionStatement
|
// First attempt to parse an expressionStatement
|
||||||
// Note: the function style cast ambiguity is handled in expression
|
// Note: the function style cast ambiguity is handled in expression
|
||||||
// Since it only happens when we are in a statement
|
// Since it only happens when we are in a statement
|
||||||
|
@ -1354,7 +1248,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
// Now attempt to parse a declarationStatement
|
// Now attempt to parse a declarationStatement
|
||||||
IASTDeclarationStatement ds = null;
|
IASTDeclarationStatement ds = null;
|
||||||
try {
|
try {
|
||||||
IASTDeclaration d = declaration();
|
IASTDeclaration d = declaration(option);
|
||||||
ds = createDeclarationStatement();
|
ds = createDeclarationStatement();
|
||||||
ds.setDeclaration(d);
|
ds.setDeclaration(d);
|
||||||
((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
|
((ASTNode) ds).setOffsetAndLength(((ASTNode) d).getOffset(), ((ASTNode) d).getLength());
|
||||||
|
@ -1369,10 +1263,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
if (ds == null) {
|
if (ds == null) {
|
||||||
while (true) {
|
backup(lastTokenOfExpression); consume();
|
||||||
if (consume() == lastTokenOfExpression)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return expressionStatement;
|
return expressionStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1396,61 +1287,49 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// x = y; // implicit int
|
final IASTDeclaration declaration = ds.getDeclaration();
|
||||||
// valid at Translation Unit scope but not valid as a statement in a function body
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
if(isImplicitInt(ds.getDeclaration())) {
|
final IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
|
||||||
backup(mark);
|
IASTDeclSpecifier declspec= simpleDecl.getDeclSpecifier();
|
||||||
while (true) {
|
if (declspec instanceof IASTNamedTypeSpecifier) {
|
||||||
if (consume() == lastTokenOfExpression)
|
final IASTDeclarator[] declarators = simpleDecl.getDeclarators();
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return expressionStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
// generalization of the previous check for implicit int
|
|
||||||
if (ds.getDeclaration() instanceof IASTAmbiguousDeclaration ) {
|
|
||||||
IASTAmbiguousDeclaration amb = (IASTAmbiguousDeclaration) ds.getDeclaration();
|
|
||||||
boolean allImplicitInt = true;
|
|
||||||
for(IASTDeclaration ambD : amb.getDeclarations()) {
|
|
||||||
if(!isImplicitInt(ambD)) {
|
|
||||||
allImplicitInt = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(allImplicitInt) {
|
|
||||||
backup(mark);
|
|
||||||
while (true) {
|
|
||||||
if (consume() == lastTokenOfExpression)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return expressionStatement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// x;
|
// x;
|
||||||
// a single identifier can be parsed as a named declaration specifier without a declarator
|
// can be parsed as a named declaration specifier without a declarator
|
||||||
if(ds.getDeclaration() instanceof IASTSimpleDeclaration &&
|
if (declarators.length == 0) {
|
||||||
((IASTSimpleDeclaration) ds.getDeclaration()).getDeclSpecifier() instanceof IASTNamedTypeSpecifier) {
|
backup(lastTokenOfExpression); consume();
|
||||||
final IASTDeclarator[] declarators = ((IASTSimpleDeclaration) ds.getDeclaration()).getDeclarators();
|
return expressionStatement;
|
||||||
if (declarators.length == 0
|
|
||||||
|| (declarators.length == 1 && (declarators[0].getName()
|
|
||||||
.toCharArray().length == 0 && declarators[0]
|
|
||||||
.getNestedDeclarator() == null))) {
|
|
||||||
backup(mark);
|
|
||||||
while (true) {
|
|
||||||
if (consume() == lastTokenOfExpression)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a function call interpreted as declaration: 'func(x);' --> 'func x;'
|
||||||
|
if (declarators.length == 1) {
|
||||||
|
IASTName name= ((IASTNamedTypeSpecifier) declspec).getName();
|
||||||
|
final IASTDeclarator dtor= declarators[0];
|
||||||
|
if (name.contains(declspec)) {
|
||||||
|
if (dtor.getNestedDeclarator() != null) {
|
||||||
|
if (dtor instanceof IASTAmbiguousDeclarator == false
|
||||||
|
&& dtor instanceof IASTArrayDeclarator == false
|
||||||
|
&& dtor instanceof IASTFieldDeclarator == false
|
||||||
|
&& dtor instanceof IASTFunctionDeclarator == false) {
|
||||||
|
backup(lastTokenOfExpression); consume();
|
||||||
return expressionStatement;
|
return expressionStatement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dtor.getName().toCharArray().length == 0 && dtor.getNestedDeclarator() == null) {
|
||||||
|
throw new Error();
|
||||||
|
// backup(lastTokenOfExpression); consume();
|
||||||
|
// return expressionStatement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create and return ambiguity node
|
// create and return ambiguity node
|
||||||
IASTAmbiguousStatement statement = createAmbiguousStatement();
|
IASTAmbiguousStatement statement = createAmbiguousStatement();
|
||||||
statement.addStatement(ds);
|
|
||||||
statement.addStatement(expressionStatement);
|
statement.addStatement(expressionStatement);
|
||||||
|
statement.addStatement(ds);
|
||||||
((ASTNode) statement).setOffsetAndLength((ASTNode) ds);
|
((ASTNode) statement).setOffsetAndLength((ASTNode) ds);
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
@ -1746,7 +1625,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
try {
|
try {
|
||||||
if (typeIdWithParentheses)
|
if (typeIdWithParentheses)
|
||||||
consume(IToken.tLPAREN);
|
consume(IToken.tLPAREN);
|
||||||
typeId = typeId(false);
|
typeId = typeId(DeclarationOptions.TYPEID);
|
||||||
if (typeId != null) {
|
if (typeId != null) {
|
||||||
if (typeIdWithParentheses) {
|
if (typeIdWithParentheses) {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
|
@ -1827,16 +1706,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IASTDeclaration simpleDeclaration() throws BacktrackException,
|
|
||||||
EndOfFileException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTStatement forInitStatement() throws BacktrackException, EndOfFileException {
|
protected IASTStatement forInitStatement(DeclarationOptions option) throws BacktrackException, EndOfFileException {
|
||||||
if( LT(1) == IToken.tSEMI )
|
if( LT(1) == IToken.tSEMI )
|
||||||
return parseNullStatement();
|
return parseNullStatement();
|
||||||
return parseDeclarationOrExpressionStatement();
|
return parseDeclarationOrExpressionStatement(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the parsing of a declaration in various contexts.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class DeclarationOptions {
|
||||||
|
final public static int ALLOW_EMPTY_SPECIFIER= 0x01;
|
||||||
|
final public static int ALLOW_ABSTRACT= 0x02;
|
||||||
|
final public static int REQUIRE_ABSTRACT= 0x04;
|
||||||
|
final public static int ALLOW_BITFIELD= 0x08;
|
||||||
|
final public static int NO_INITIALIZER= 0x10;
|
||||||
|
final public static int ALLOW_CONSTRUCTOR_INITIALIZER= 0x20;
|
||||||
|
final public static int NO_FUNCTIONS= 0x40;
|
||||||
|
final public static int NO_ARRAYS= 0x80;
|
||||||
|
final public static int NO_NESTED= 0x100;
|
||||||
|
|
||||||
|
public static final DeclarationOptions
|
||||||
|
GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_CONSTRUCTOR_INITIALIZER),
|
||||||
|
C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD),
|
||||||
|
CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | ALLOW_CONSTRUCTOR_INITIALIZER),
|
||||||
|
LOCAL= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
|
||||||
|
PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT),
|
||||||
|
TYPEID= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER),
|
||||||
|
TYPEID_NEW= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
|
||||||
|
TYPEID_CONVERSION= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER | NO_FUNCTIONS | NO_NESTED),
|
||||||
|
EXCEPTION= new DeclarationOptions(ALLOW_ABSTRACT | NO_INITIALIZER),
|
||||||
|
CONDITION= new DeclarationOptions(ALLOW_CONSTRUCTOR_INITIALIZER),
|
||||||
|
C_PARAMETER_NON_ABSTRACT= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_EMPTY_SPECIFIER);
|
||||||
|
|
||||||
|
final public boolean fAllowEmptySpecifier;
|
||||||
|
final public boolean fAllowAbstract;
|
||||||
|
final public boolean fRequireAbstract;
|
||||||
|
final public boolean fAllowBitField;
|
||||||
|
final public boolean fAllowInitializer;
|
||||||
|
final public boolean fAllowConstructorInitializer;
|
||||||
|
final public boolean fAllowFunctions;
|
||||||
|
final public boolean fAllowNested;
|
||||||
|
|
||||||
|
public DeclarationOptions(int options) {
|
||||||
|
fAllowEmptySpecifier= (options & ALLOW_EMPTY_SPECIFIER) != 0;
|
||||||
|
fRequireAbstract= (options & REQUIRE_ABSTRACT) != 0;
|
||||||
|
fAllowAbstract= fRequireAbstract || (options & ALLOW_ABSTRACT) != 0;
|
||||||
|
fAllowBitField= (options & ALLOW_BITFIELD) != 0;
|
||||||
|
fAllowInitializer= (options & NO_INITIALIZER) == 0;
|
||||||
|
fAllowConstructorInitializer= fAllowInitializer && (options & ALLOW_CONSTRUCTOR_INITIALIZER) != 0;
|
||||||
|
fAllowFunctions= (options & NO_FUNCTIONS) == 0;
|
||||||
|
fAllowNested= (options & NO_NESTED) == 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Needed to handle the ambiguous declarator.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public interface IASTAmbiguousDeclarator extends IASTDeclarator {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty SUBDECLARATOR = new ASTNodeProperty( "IASTAmbiguousDeclarator.SUBDECLARATOR"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an alternative to this ambiguous declarator.
|
||||||
|
*/
|
||||||
|
public void addDeclarator(IASTDeclarator e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of all alternatives for this ambiguous declarator.
|
||||||
|
*/
|
||||||
|
public IASTDeclarator[] getDeclarators();
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Needed to handle the ambiguity for parameter declarations in plain C
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public interface IASTAmbiguousParameterDeclaration extends IASTParameterDeclaration {
|
||||||
|
|
||||||
|
public static final ASTNodeProperty SUBDECLARATION = new ASTNodeProperty( "IASTAmbiguousParameterDeclaration.SUBDECLARATION"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an alternative to this ambiguous parameter declaration.
|
||||||
|
*/
|
||||||
|
public void addParameterDeclaration(IASTParameterDeclaration e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of all alternatives for this ambiguous parameter declaration.
|
||||||
|
*/
|
||||||
|
public IASTParameterDeclaration[] getParameterDeclarations();
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclarator;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles ambiguities when parsing declarators.
|
||||||
|
* <br>
|
||||||
|
* Example: void f(int (D)); // is D a type?
|
||||||
|
* @since 5.0.1
|
||||||
|
*/
|
||||||
|
public class CASTAmbiguousDeclarator extends CASTAmbiguity implements IASTAmbiguousDeclarator {
|
||||||
|
|
||||||
|
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
||||||
|
private int dtorPos=-1;
|
||||||
|
|
||||||
|
|
||||||
|
public CASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
||||||
|
for(IASTDeclarator d : decls) {
|
||||||
|
if (d != null) {
|
||||||
|
addDeclarator(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeclarator(IASTDeclarator d) {
|
||||||
|
if (d != null) {
|
||||||
|
dtors = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, dtors, ++dtorPos, d);
|
||||||
|
d.setParent(this);
|
||||||
|
d.setPropertyInParent(SUBDECLARATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTDeclarator[] getDeclarators() {
|
||||||
|
dtors = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, dtors, dtorPos );
|
||||||
|
return dtors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IASTNode[] getNodes() {
|
||||||
|
return getDeclarators();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTInitializer getInitializer() {
|
||||||
|
return dtors[0].getInitializer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTName getName() {
|
||||||
|
return dtors[0].getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTDeclarator getNestedDeclarator() {
|
||||||
|
return dtors[0].getNestedDeclarator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTPointerOperator[] getPointerOperators() {
|
||||||
|
return dtors[0].getPointerOperators();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRoleForName(IASTName name) {
|
||||||
|
return dtors[0].getRoleForName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPointerOperator(IASTPointerOperator operator) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitializer(IASTInitializer initializer) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNestedDeclarator(IASTDeclarator nested) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousParameterDeclaration;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles ambiguities for parameter declarations.
|
||||||
|
* <br>
|
||||||
|
* void function(const D*); // is D a type?
|
||||||
|
* @since 5.0.1
|
||||||
|
*/
|
||||||
|
public class CASTAmbiguousParameterDeclaration extends CASTAmbiguity implements IASTAmbiguousParameterDeclaration {
|
||||||
|
|
||||||
|
private IASTParameterDeclaration[] paramDecls = new IASTParameterDeclaration[2];
|
||||||
|
private int declPos=-1;
|
||||||
|
|
||||||
|
|
||||||
|
public CASTAmbiguousParameterDeclaration(IASTParameterDeclaration... decls) {
|
||||||
|
for(IASTParameterDeclaration d : decls)
|
||||||
|
addParameterDeclaration(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addParameterDeclaration(IASTParameterDeclaration d) {
|
||||||
|
if (d != null) {
|
||||||
|
paramDecls = (IASTParameterDeclaration[]) ArrayUtil.append(IASTParameterDeclaration.class, paramDecls, ++declPos, d);
|
||||||
|
d.setParent(this);
|
||||||
|
d.setPropertyInParent(SUBDECLARATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTParameterDeclaration[] getParameterDeclarations() {
|
||||||
|
paramDecls = (IASTParameterDeclaration[]) ArrayUtil.removeNullsAfter(IASTParameterDeclaration.class, paramDecls, declPos );
|
||||||
|
return paramDecls;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IASTNode[] getNodes() {
|
||||||
|
return getParameterDeclarations();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTDeclSpecifier getDeclSpecifier() {
|
||||||
|
return paramDecls[0].getDeclSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTDeclarator getDeclarator() {
|
||||||
|
return paramDecls[0].getDeclarator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeclarator(IASTDeclarator declarator) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,12 @@ 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.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
public class CASTDeclarator extends CASTNode implements IASTDeclarator, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTInitializer initializer;
|
private IASTInitializer initializer;
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
|
@ -207,4 +208,12 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
||||||
}
|
}
|
||||||
return r_unclear;
|
return r_unclear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
|
if (child == nestedDeclarator) {
|
||||||
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
other.setParent(child.getParent());
|
||||||
|
nestedDeclarator= (IASTDeclarator) other;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -16,17 +17,13 @@ import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
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;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTFieldDeclarator extends CASTDeclarator implements
|
public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDeclarator {
|
||||||
IASTFieldDeclarator, IASTAmbiguityParent {
|
|
||||||
|
|
||||||
private IASTExpression bitFieldSize;
|
private IASTExpression bitFieldSize;
|
||||||
|
|
||||||
|
|
||||||
public CASTFieldDeclarator() {
|
public CASTFieldDeclarator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,12 +54,14 @@ public class CASTFieldDeclarator extends CASTDeclarator implements
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == bitFieldSize)
|
if( child == bitFieldSize) {
|
||||||
{
|
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setPropertyInParent( child.getPropertyInParent() );
|
||||||
other.setParent( child.getParent() );
|
other.setParent( child.getParent() );
|
||||||
bitFieldSize = (IASTExpression) other;
|
bitFieldSize = (IASTExpression) other;
|
||||||
|
} else {
|
||||||
|
super.replace(child, other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ 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.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
@ -26,8 +27,6 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
|
||||||
private int parametersPos=-1;
|
private int parametersPos=-1;
|
||||||
private boolean varArgs;
|
private boolean varArgs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CASTFunctionDeclarator() {
|
public CASTFunctionDeclarator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,4 +64,19 @@ public class CASTFunctionDeclarator extends CASTDeclarator implements IASTStanda
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
|
if( parameters != null ) {
|
||||||
|
for (int i = 0; i < parameters.length; ++i) {
|
||||||
|
if (child == parameters[i]) {
|
||||||
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
other.setParent(child.getParent());
|
||||||
|
parameters[i]= (IASTParameterDeclaration) other;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.replace(child, other);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,4 +223,8 @@ public class CASTName extends CASTNode implements IASTName, IASTCompletionContex
|
||||||
}
|
}
|
||||||
return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings);
|
return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTName getLastName() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,21 @@
|
||||||
* 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)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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.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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTParameterDeclaration extends CASTNode implements
|
public class CASTParameterDeclaration extends CASTNode implements IASTParameterDeclaration, IASTAmbiguityParent {
|
||||||
IASTParameterDeclaration {
|
|
||||||
|
|
||||||
private IASTDeclSpecifier declSpec;
|
private IASTDeclSpecifier declSpec;
|
||||||
private IASTDeclarator declarator;
|
private IASTDeclarator declarator;
|
||||||
|
|
||||||
|
@ -79,4 +80,12 @@ public class CASTParameterDeclaration extends CASTNode implements
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
|
if (child == declarator) {
|
||||||
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
other.setParent(child.getParent());
|
||||||
|
declarator= (IASTDeclarator) other;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,11 @@ public class CBasicType implements ICBasicType {
|
||||||
if( type == IBasicType.t_unspecified ){
|
if( type == IBasicType.t_unspecified ){
|
||||||
if( (qualifiers & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
if( (qualifiers & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
||||||
type = IBasicType.t_float;
|
type = IBasicType.t_float;
|
||||||
else if( (qualifiers & ~( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
else {
|
||||||
type = IBasicType.t_int;
|
type = IBasicType.t_int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CBasicType( int type, int qualifiers ){
|
public CBasicType( int type, int qualifiers ){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -65,10 +66,11 @@ public class CBasicType implements ICBasicType {
|
||||||
if( type == IBasicType.t_unspecified ){
|
if( type == IBasicType.t_unspecified ){
|
||||||
if( (qualifiers & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
if( (qualifiers & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
||||||
type = IBasicType.t_float;
|
type = IBasicType.t_float;
|
||||||
else if( (qualifiers & ~( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
else {
|
||||||
type = IBasicType.t_int;
|
type = IBasicType.t_int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CBasicType( int type, int qualifiers, IASTExpression value ){
|
public CBasicType( int type, int qualifiers, IASTExpression value ){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
|
@ -2156,4 +2157,55 @@ public class CVisitor {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the innermost declarator nested within the given <code>declarator</code>, or
|
||||||
|
* <code>declarator</code> itself.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static IASTDeclarator findInnermostDeclarator(IASTDeclarator declarator) {
|
||||||
|
IASTDeclarator innermost= null;
|
||||||
|
while(declarator != null) {
|
||||||
|
innermost= declarator;
|
||||||
|
declarator= declarator.getNestedDeclarator();
|
||||||
|
}
|
||||||
|
return innermost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the outermost declarator the given <code>declarator</code> nests within, or
|
||||||
|
* <code>declarator</code> itself.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static IASTDeclarator findOutermostDeclarator(IASTDeclarator declarator) {
|
||||||
|
while(true) {
|
||||||
|
IASTNode parent= declarator.getParent();
|
||||||
|
if (parent instanceof IASTDeclarator) {
|
||||||
|
declarator= (IASTDeclarator) parent;
|
||||||
|
} else {
|
||||||
|
return declarator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for the innermost declarator that contributes the the type declared.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static IASTDeclarator findTypeRelevantDeclarator(IASTDeclarator declarator) {
|
||||||
|
IASTDeclarator result= findInnermostDeclarator(declarator);
|
||||||
|
while (result.getPointerOperators().length == 0
|
||||||
|
&& result instanceof IASTFieldDeclarator == false
|
||||||
|
&& result instanceof IASTFunctionDeclarator == false
|
||||||
|
&& result instanceof IASTArrayModifier == false) {
|
||||||
|
final IASTNode parent= result.getParent();
|
||||||
|
if (parent instanceof IASTDeclarator) {
|
||||||
|
result= (IASTDeclarator) parent;
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,95 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclarator;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles ambiguities when parsing declarators.
|
||||||
|
* <br>
|
||||||
|
* Example: void f(int (D)); // is D a type?
|
||||||
|
* @since 5.0.1
|
||||||
|
*/
|
||||||
|
public class CPPASTAmbiguousDeclarator extends CPPASTAmbiguity implements IASTAmbiguousDeclarator {
|
||||||
|
|
||||||
|
private IASTDeclarator[] dtors = new IASTDeclarator[2];
|
||||||
|
private int dtorPos=-1;
|
||||||
|
|
||||||
|
|
||||||
|
public CPPASTAmbiguousDeclarator(IASTDeclarator... decls) {
|
||||||
|
for(IASTDeclarator d : decls) {
|
||||||
|
if (d != null) {
|
||||||
|
addDeclarator(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDeclarator(IASTDeclarator d) {
|
||||||
|
if (d != null) {
|
||||||
|
dtors = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, dtors, ++dtorPos, d);
|
||||||
|
d.setParent(this);
|
||||||
|
d.setPropertyInParent(SUBDECLARATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTDeclarator[] getDeclarators() {
|
||||||
|
dtors = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, dtors, dtorPos );
|
||||||
|
return dtors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IASTNode[] getNodes() {
|
||||||
|
return getDeclarators();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTInitializer getInitializer() {
|
||||||
|
return dtors[0].getInitializer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTName getName() {
|
||||||
|
return dtors[0].getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTDeclarator getNestedDeclarator() {
|
||||||
|
return dtors[0].getNestedDeclarator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTPointerOperator[] getPointerOperators() {
|
||||||
|
return dtors[0].getPointerOperators();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRoleForName(IASTName name) {
|
||||||
|
return dtors[0].getRoleForName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPointerOperator(IASTPointerOperator operator) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitializer(IASTInitializer initializer) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(IASTName name) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNestedDeclarator(IASTDeclarator nested) {
|
||||||
|
Assert.isLegal(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ 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.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -115,22 +116,19 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
|
||||||
if( !ptrOps[i].accept( action ) ) return false;
|
if( !ptrOps[i].accept( action ) ) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
|
if (nestedDeclarator == null && name != null) {
|
||||||
nestedDeclarator == null )
|
IASTDeclarator outermost= CPPVisitor.findOutermostDeclarator(this);
|
||||||
{
|
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
||||||
if( getParent() instanceof IASTDeclarator )
|
if (!name.accept(action)) return false;
|
||||||
{
|
|
||||||
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
|
||||||
while( outermostDeclarator.getParent() instanceof IASTDeclarator )
|
|
||||||
outermostDeclarator = (IASTDeclarator) outermostDeclarator.getParent();
|
|
||||||
if( outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR )
|
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nestedDeclarator != null ) if( !nestedDeclarator.accept( action ) ) return false;
|
if (nestedDeclarator != null) {
|
||||||
|
if (!nestedDeclarator.accept(action)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!postAccept(action))
|
||||||
|
return false;
|
||||||
|
|
||||||
if( action.shouldVisitDeclarators ){
|
if( action.shouldVisitDeclarators ){
|
||||||
switch( action.leave( this ) ){
|
switch( action.leave( this ) ){
|
||||||
|
@ -139,8 +137,7 @@ public class CPPASTDeclarator extends CPPASTNode implements IASTDeclarator {
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return postAccept( action );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean postAccept( ASTVisitor action ){
|
protected boolean postAccept( ASTVisitor action ){
|
||||||
|
|
|
@ -274,4 +274,8 @@ public class CPPASTName extends CPPASTNode implements IASTName, IASTCompletionCo
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.CPP_LINKAGE;
|
return Linkage.CPP_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTName getLastName() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,24 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.IASTArrayDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
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.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -32,6 +38,9 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
||||||
private IASTTypeId typeId;
|
private IASTTypeId typeId;
|
||||||
private boolean isNewTypeId;
|
private boolean isNewTypeId;
|
||||||
|
|
||||||
|
private IASTExpression [] arrayExpressions = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CPPASTNewExpression() {
|
public CPPASTNewExpression() {
|
||||||
}
|
}
|
||||||
|
@ -96,19 +105,43 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTExpression [] getNewTypeIdArrayExpressions() {
|
public IASTExpression [] getNewTypeIdArrayExpressions() {
|
||||||
if( arrayExpressions == null ) return IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
if( arrayExpressions == null ) {
|
||||||
return (IASTExpression[]) ArrayUtil.trim( IASTExpression.class, arrayExpressions );
|
if (typeId != null) {
|
||||||
|
IASTDeclarator dtor= CPPVisitor.findInnermostDeclarator(typeId.getAbstractDeclarator());
|
||||||
|
if (dtor instanceof IASTArrayDeclarator) {
|
||||||
|
IASTArrayDeclarator ad= (IASTArrayDeclarator) dtor;
|
||||||
|
IASTArrayModifier[] ams= ad.getArrayModifiers();
|
||||||
|
arrayExpressions= new IASTExpression[ams.length];
|
||||||
|
for (int i = 0; i < ams.length; i++) {
|
||||||
|
IASTArrayModifier am = ams[i];
|
||||||
|
arrayExpressions[i]= am.getConstantExpression();
|
||||||
|
}
|
||||||
|
return arrayExpressions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arrayExpressions= IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
|
}
|
||||||
|
return arrayExpressions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewTypeIdArrayExpression(IASTExpression expression) {
|
public void addNewTypeIdArrayExpression(IASTExpression expression) {
|
||||||
arrayExpressions = (IASTExpression[]) ArrayUtil.append( IASTExpression.class, arrayExpressions, expression );
|
Assert.isNotNull(typeId);
|
||||||
if(expression != null) {
|
IASTDeclarator dtor= CPPVisitor.findInnermostDeclarator(typeId.getAbstractDeclarator());
|
||||||
expression.setParent(this);
|
if (dtor instanceof IASTArrayDeclarator == false) {
|
||||||
expression.setPropertyInParent(NEW_TYPEID_ARRAY_EXPRESSION);
|
Assert.isNotNull(dtor);
|
||||||
|
Assert.isTrue(dtor.getParent() == typeId);
|
||||||
|
IASTArrayDeclarator adtor= new CPPASTArrayDeclarator(dtor.getName());
|
||||||
|
IASTPointerOperator[] ptrOps= dtor.getPointerOperators();
|
||||||
|
for (IASTPointerOperator ptr : ptrOps) {
|
||||||
|
adtor.addPointerOperator(ptr);
|
||||||
}
|
}
|
||||||
|
typeId.setAbstractDeclarator(adtor);
|
||||||
|
dtor= adtor;
|
||||||
|
}
|
||||||
|
IASTArrayModifier mod= new CPPASTArrayModifier(expression);
|
||||||
|
((ASTNode) mod).setOffsetAndLength((ASTNode)expression);
|
||||||
|
((IASTArrayDeclarator) dtor).addArrayModifier(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTExpression [] arrayExpressions = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept( ASTVisitor action ){
|
||||||
|
@ -122,11 +155,6 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
||||||
|
|
||||||
if( placement != null ) if( !placement.accept( action ) ) return false;
|
if( placement != null ) if( !placement.accept( action ) ) return false;
|
||||||
if( typeId != null ) if( !typeId.accept( action ) ) return false;
|
if( typeId != null ) if( !typeId.accept( action ) ) return false;
|
||||||
|
|
||||||
IASTExpression [] exps = getNewTypeIdArrayExpressions();
|
|
||||||
for( int i = 0; i < exps.length; i++ )
|
|
||||||
if( !exps[i].accept( action ) ) return false;
|
|
||||||
|
|
||||||
if( initializer != null ) if( !initializer.accept( action ) ) return false;
|
if( initializer != null ) if( !initializer.accept( action ) ) return false;
|
||||||
|
|
||||||
if( action.shouldVisitExpressions ){
|
if( action.shouldVisitExpressions ){
|
||||||
|
@ -152,14 +180,6 @@ public class CPPASTNewExpression extends CPPASTNode implements
|
||||||
other.setParent( child.getParent() );
|
other.setParent( child.getParent() );
|
||||||
initializer = (IASTExpression) other;
|
initializer = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
if( arrayExpressions == null ) return;
|
|
||||||
for( int i = 0; i < arrayExpressions.length; ++i )
|
|
||||||
if( arrayExpressions[i] == child )
|
|
||||||
{
|
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
|
||||||
other.setParent( child.getParent() );
|
|
||||||
arrayExpressions[i] = (IASTExpression) other;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IType getExpressionType() {
|
public IType getExpressionType() {
|
||||||
|
|
|
@ -7,18 +7,21 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTParameterDeclaration extends CPPASTNode implements ICPPASTParameterDeclaration {
|
public class CPPASTParameterDeclaration extends CPPASTNode implements ICPPASTParameterDeclaration, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTDeclSpecifier declSpec;
|
private IASTDeclSpecifier declSpec;
|
||||||
private IASTDeclarator declarator;
|
private IASTDeclarator declarator;
|
||||||
|
@ -78,4 +81,12 @@ public class CPPASTParameterDeclaration extends CPPASTNode implements ICPPASTPar
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
|
if (child == declarator) {
|
||||||
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
other.setParent(child.getParent());
|
||||||
|
declarator= (IASTDeclarator) other;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,10 +99,10 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTName getLastName() {
|
public IASTName getLastName() {
|
||||||
if (names == null || names.length == 0)
|
if (namesPos < 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return names[names.length - 1];
|
return names[namesPos];
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] toCharArray() {
|
public char[] toCharArray() {
|
||||||
|
|
|
@ -197,10 +197,11 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
|
|
||||||
*/
|
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.CPP_LINKAGE;
|
return Linkage.CPP_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTName getLastName() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
|
@ -2439,4 +2440,54 @@ public class CPPVisitor {
|
||||||
}
|
}
|
||||||
return e1;
|
return e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the outermost declarator the given <code>declarator</code> nests within, or
|
||||||
|
* <code>declarator</code> itself.
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static IASTDeclarator findOutermostDeclarator(IASTDeclarator declarator) {
|
||||||
|
while(true) {
|
||||||
|
IASTNode parent= declarator.getParent();
|
||||||
|
if (parent instanceof IASTDeclarator) {
|
||||||
|
declarator= (IASTDeclarator) parent;
|
||||||
|
} else {
|
||||||
|
return declarator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the innermost declarator nested within the given <code>declarator</code>, or
|
||||||
|
* <code>declarator</code> itself.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public static IASTDeclarator findInnermostDeclarator(IASTDeclarator declarator) {
|
||||||
|
IASTDeclarator innermost= null;
|
||||||
|
while(declarator != null) {
|
||||||
|
innermost= declarator;
|
||||||
|
declarator= declarator.getNestedDeclarator();
|
||||||
|
}
|
||||||
|
return innermost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for the innermost declarator that contributes the the type declared.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public static IASTDeclarator findTypeRelevantDeclarator(IASTDeclarator declarator) {
|
||||||
|
IASTDeclarator result= findInnermostDeclarator(declarator);
|
||||||
|
while (result.getPointerOperators().length == 0
|
||||||
|
&& result instanceof IASTFieldDeclarator == false
|
||||||
|
&& result instanceof IASTFunctionDeclarator == false
|
||||||
|
&& result instanceof IASTArrayModifier == false) {
|
||||||
|
final IASTNode parent= result.getParent();
|
||||||
|
if (parent instanceof IASTDeclarator) {
|
||||||
|
result= (IASTDeclarator) parent;
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGeneratorWriterVisitor;
|
import org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGeneratorWriterVisitor;
|
||||||
|
@ -78,7 +80,16 @@ public class ASTWriter {
|
||||||
*/
|
*/
|
||||||
public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap) throws ProblemRuntimeException {
|
public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap) throws ProblemRuntimeException {
|
||||||
transformationVisitor = new ChangeGeneratorWriterVisitor(modificationStore, givenIndentation, fileScope, commentMap);
|
transformationVisitor = new ChangeGeneratorWriterVisitor(modificationStore, givenIndentation, fileScope, commentMap);
|
||||||
|
|
||||||
|
// mstodo: workaround for
|
||||||
|
if (rootNode instanceof IASTArrayModifier) {
|
||||||
|
int result= transformationVisitor.visit((IASTArrayModifier) rootNode);
|
||||||
|
if (result == ASTVisitor.PROCESS_CONTINUE) {
|
||||||
rootNode.accept(transformationVisitor);
|
rootNode.accept(transformationVisitor);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rootNode.accept(transformationVisitor);
|
||||||
|
}
|
||||||
String str = transformationVisitor.toString();
|
String str = transformationVisitor.toString();
|
||||||
transformationVisitor.cleanCache();
|
transformationVisitor.cleanCache();
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -8,10 +8,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
@ -200,6 +202,12 @@ public class ASTWriterVisitor extends CPPASTVisitor {
|
||||||
return ASTVisitor.PROCESS_SKIP;
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int visit(IASTArrayModifier amod) {
|
||||||
|
if(!macroHandler.checkisMacroExpansionNode(amod)) {
|
||||||
|
declaratorWriter.writeArrayModifier(amod);
|
||||||
|
}
|
||||||
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ 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.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;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
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;
|
||||||
|
@ -254,12 +256,18 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
|
|
||||||
protected void writeArrayModifiers(IASTArrayDeclarator arrDecl, IASTArrayModifier[] arrMods) {
|
protected void writeArrayModifiers(IASTArrayDeclarator arrDecl, IASTArrayModifier[] arrMods) {
|
||||||
for (IASTArrayModifier modifier : arrMods) {
|
for (IASTArrayModifier modifier : arrMods) {
|
||||||
scribe.print('[');
|
writeArrayModifier(modifier);
|
||||||
modifier.accept(visitor);
|
|
||||||
scribe.print(']');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void writeArrayModifier(IASTArrayModifier modifier) {
|
||||||
|
scribe.print('[');
|
||||||
|
IASTExpression ex= modifier.getConstantExpression();
|
||||||
|
if (ex != null) {
|
||||||
|
ex.accept(visitor);
|
||||||
|
}
|
||||||
|
scribe.print(']');
|
||||||
|
}
|
||||||
|
|
||||||
private void writeFieldDeclarator(IASTFieldDeclarator fieldDecl) {
|
private void writeFieldDeclarator(IASTFieldDeclarator fieldDecl) {
|
||||||
IASTPointerOperator[] pointOps = fieldDecl.getPointerOperators();
|
IASTPointerOperator[] pointOps = fieldDecl.getPointerOperators();
|
||||||
|
|
|
@ -353,25 +353,14 @@ public class ExpressionWriter extends NodeWriter{
|
||||||
IASTTypeId typeId = newExp.getTypeId();
|
IASTTypeId typeId = newExp.getTypeId();
|
||||||
visitNodeIfNotNull(typeId);
|
visitNodeIfNotNull(typeId);
|
||||||
|
|
||||||
IASTExpression[] arraySizeExpressions = getNewTypeIdArrayExpressions(newExp, newExp.getNewTypeIdArrayExpressions());
|
IASTExpression initExp= getNewInitializer(newExp);
|
||||||
for (IASTExpression expression : arraySizeExpressions) {
|
if (initExp != null) {
|
||||||
scribe.print('[');
|
|
||||||
expression.accept(visitor);
|
|
||||||
scribe.print(']');
|
|
||||||
}
|
|
||||||
if (arraySizeExpressions.length == 0 ) {
|
|
||||||
scribe.print('(');
|
scribe.print('(');
|
||||||
IASTExpression initExp = getNewInitializer(newExp);
|
initExp.accept(visitor);
|
||||||
visitNodeIfNotNull(initExp);
|
|
||||||
scribe.print(')');
|
scribe.print(')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTExpression[] getNewTypeIdArrayExpressions(
|
|
||||||
ICPPASTNewExpression newExp, IASTExpression[] expressions) {
|
|
||||||
return newExp.getNewTypeIdArrayExpressions();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTExpression getNewInitializer(ICPPASTNewExpression newExp) {
|
protected IASTExpression getNewInitializer(ICPPASTNewExpression newExp) {
|
||||||
return newExp.getNewInitializer();
|
return newExp.getNewInitializer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
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;
|
||||||
|
@ -26,10 +29,13 @@ 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;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
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.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
@ -132,7 +138,7 @@ public class ChangeGenerator extends CPPASTVisitor {
|
||||||
private IASTNode determineParentToBeRewritten(IASTNode modifiedNode, List<ASTModification> modificationsForNode) {
|
private IASTNode determineParentToBeRewritten(IASTNode modifiedNode, List<ASTModification> modificationsForNode) {
|
||||||
IASTNode modifiedNodeParent = modifiedNode;
|
IASTNode modifiedNodeParent = modifiedNode;
|
||||||
for(ASTModification currentModification : modificationsForNode){
|
for(ASTModification currentModification : modificationsForNode){
|
||||||
if(currentModification.getKind() != ASTModification.ModificationKind.APPEND_CHILD){
|
if(currentModification.getKind() == ASTModification.ModificationKind.REPLACE){
|
||||||
modifiedNodeParent = modifiedNode.getParent();
|
modifiedNodeParent = modifiedNode.getParent();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -385,9 +391,51 @@ public class ChangeGenerator extends CPPASTVisitor {
|
||||||
synthTreatment(declarator);
|
synthTreatment(declarator);
|
||||||
return ASTVisitor.PROCESS_SKIP;
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mstodo workaround
|
||||||
|
if (declarator instanceof IASTArrayDeclarator) {
|
||||||
|
IASTPointerOperator [] ptrOps = declarator.getPointerOperators();
|
||||||
|
for ( int i = 0; i < ptrOps.length; i++ ) {
|
||||||
|
if( !ptrOps[i].accept( this ) ) return PROCESS_ABORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTDeclarator nestedDeclarator= declarator.getNestedDeclarator();
|
||||||
|
IASTName name= declarator.getName();
|
||||||
|
if (nestedDeclarator == null && name != null) {
|
||||||
|
IASTDeclarator outermost= CPPVisitor.findOutermostDeclarator(declarator);
|
||||||
|
if (outermost.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR) {
|
||||||
|
if (!name.accept(this)) return PROCESS_ABORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nestedDeclarator != null) {
|
||||||
|
if (!nestedDeclarator.accept(this)) return PROCESS_ABORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTArrayModifier [] mods = ((IASTArrayDeclarator) declarator).getArrayModifiers();
|
||||||
|
for ( int i = 0; i < mods.length; i++ ) {
|
||||||
|
int result= visit(mods[i]);
|
||||||
|
if (result != PROCESS_CONTINUE)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
if( !mods[i].accept( this ) ) return PROCESS_ABORT;
|
||||||
|
}
|
||||||
|
IASTInitializer initializer = declarator.getInitializer();
|
||||||
|
if( initializer != null ) if( !initializer.accept( this ) ) return PROCESS_ABORT;
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
return super.visit(declarator);
|
return super.visit(declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int visit(IASTArrayModifier mod) {
|
||||||
|
if (hasChangedChild(mod)) {
|
||||||
|
synthTreatment(mod);
|
||||||
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
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;
|
||||||
|
@ -270,6 +272,14 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTArrayModifier arrayModifier) {
|
||||||
|
if (doBeforeEveryNode(arrayModifier) == PROCESS_CONTINUE) {
|
||||||
|
return super.visit(arrayModifier);
|
||||||
|
}
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTExpression expression) {
|
public int visit(IASTExpression expression) {
|
||||||
if (doBeforeEveryNode(expression) == PROCESS_CONTINUE) {
|
if (doBeforeEveryNode(expression) == PROCESS_CONTINUE) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
|
||||||
|
|
||||||
|
@ -76,13 +77,4 @@ public class ModifiedASTExpressionWriter extends ExpressionWriter {
|
||||||
}
|
}
|
||||||
return initializer;
|
return initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IASTExpression[] getNewTypeIdArrayExpressions(
|
|
||||||
ICPPASTNewExpression newExp, IASTExpression[] expressions) {
|
|
||||||
IASTExpression[] modifiedExpressions = modificationHelper.createModifiedChildArray(newExp, expressions, IASTExpression.class);
|
|
||||||
return modifiedExpressions;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,9 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
|
||||||
public int getRoleOfName(boolean allowResolution) {
|
public int getRoleOfName(boolean allowResolution) {
|
||||||
return IASTNameOwner.r_unclear;
|
return IASTNameOwner.r_unclear;
|
||||||
}
|
}
|
||||||
|
public IASTName getLastName() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ASTPreprocessorDefinition extends ASTPreprocessorName {
|
class ASTPreprocessorDefinition extends ASTPreprocessorName {
|
||||||
|
|
|
@ -33,8 +33,7 @@ public class BasicTokenDuple implements ITokenDuple {
|
||||||
lastToken = last;
|
lastToken = last;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO - move numSegments to a subclass
|
protected int numSegments = -1;
|
||||||
private int numSegments = -1;
|
|
||||||
|
|
||||||
BasicTokenDuple( ITokenDuple firstDuple, ITokenDuple secondDuple ){
|
BasicTokenDuple( ITokenDuple firstDuple, ITokenDuple secondDuple ){
|
||||||
this( firstDuple.getFirstToken(), secondDuple.getLastToken() );
|
this( firstDuple.getFirstToken(), secondDuple.getLastToken() );
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
public class TemplateTokenDuple extends BasicTokenDuple {
|
public class TemplateTokenDuple extends BasicTokenDuple {
|
||||||
|
|
||||||
protected final List [] argLists;
|
protected final List [] argLists;
|
||||||
private final int numSegments;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param first
|
* @param first
|
||||||
|
|
|
@ -167,6 +167,10 @@ public class PDOMASTAdapter {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return fDelegate.toString();
|
return fDelegate.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IASTName getLastName() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AnonymousEnumeration implements IEnumeration {
|
private static class AnonymousEnumeration implements IEnumeration {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
void anotherMethod();
|
void anotherMethod();
|
||||||
};
|
};
|
||||||
|
|
||||||
class {
|
class xOtherClass {
|
||||||
public:
|
public:
|
||||||
xOtherClass(char*);
|
xOtherClass(char*);
|
||||||
xOtherClass(int);
|
xOtherClass(int);
|
||||||
|
|
|
@ -267,7 +267,7 @@ struct helper {};
|
||||||
|
|
||||||
helper *new_helper()
|
helper *new_helper()
|
||||||
{
|
{
|
||||||
return new helper();
|
return new helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
|
@ -17,15 +17,18 @@ package org.eclipse.cdt.ui.tests.refactoring.rename;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
import junit.framework.*;
|
import junit.framework.AssertionFailedError;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
|
||||||
import org.eclipse.cdt.core.tests.FailingTest;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||||
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
|
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.tests.FailingTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +66,7 @@ public class RenameRegressionTests extends RenameTests {
|
||||||
public void testSimpleRename() throws Exception {
|
public void testSimpleRename() throws Exception {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
writer.write( "int boo; // boo \n" ); //$NON-NLS-1$
|
writer.write( "int boo; // boo \n" ); //$NON-NLS-1$
|
||||||
writer.write( "#ifdef 0 \n" ); //$NON-NLS-1$
|
writer.write( "#if 0 \n" ); //$NON-NLS-1$
|
||||||
writer.write( "boo \n" ); //$NON-NLS-1$
|
writer.write( "boo \n" ); //$NON-NLS-1$
|
||||||
writer.write( "#endif \n" ); //$NON-NLS-1$
|
writer.write( "#endif \n" ); //$NON-NLS-1$
|
||||||
writer.write( "void f() { \n" ); //$NON-NLS-1$
|
writer.write( "void f() { \n" ); //$NON-NLS-1$
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager;
|
import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager;
|
||||||
import org.eclipse.cdt.internal.core.index.provider.ReadOnlyPDOMProviderBridge;
|
import org.eclipse.cdt.internal.core.index.provider.ReadOnlyPDOMProviderBridge;
|
||||||
|
@ -77,7 +78,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
|
|
||||||
String sdkCode=
|
String sdkCode=
|
||||||
"void SDKFunction();\n"+
|
"void SDKFunction();\n"+
|
||||||
"class SDKClass { public: SDKMethod(); };\n\n";
|
"class SDKClass { public: void SDKMethod(); };\n\n";
|
||||||
|
|
||||||
fSdkFile= createExternalSDK(sdkCode);
|
fSdkFile= createExternalSDK(sdkCode);
|
||||||
assertNotNull(fSdkFile);
|
assertNotNull(fSdkFile);
|
||||||
|
@ -148,8 +149,8 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
store.setToDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
|
store.setToDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
|
||||||
|
|
||||||
SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
|
SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
|
||||||
for (int i= 0, n= semanticHighlightings.length; i < n; i++) {
|
for (SemanticHighlighting semanticHighlighting : semanticHighlightings) {
|
||||||
String enabledPreferenceKey= SemanticHighlightings.getEnabledPreferenceKey(semanticHighlightings[i]);
|
String enabledPreferenceKey= SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting);
|
||||||
if (!store.isDefault(enabledPreferenceKey))
|
if (!store.isDefault(enabledPreferenceKey))
|
||||||
store.setToDefault(enabledPreferenceKey);
|
store.setToDefault(enabledPreferenceKey);
|
||||||
}
|
}
|
||||||
|
@ -215,8 +216,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
buf.append("// "+fCurrentHighlighting+'\n');
|
buf.append("// "+fCurrentHighlighting+'\n');
|
||||||
IDocument document= fSourceViewer.getDocument();
|
IDocument document= fSourceViewer.getDocument();
|
||||||
buf.append("Position[] expected= new Position[] {\n");
|
buf.append("Position[] expected= new Position[] {\n");
|
||||||
for (int i= 0, n= positions.length; i < n; i++) {
|
for (Position position : positions) {
|
||||||
Position position= positions[i];
|
|
||||||
int line= document.getLineOfOffset(position.getOffset());
|
int line= document.getLineOfOffset(position.getOffset());
|
||||||
int column= position.getOffset() - document.getLineOffset(line);
|
int column= position.getOffset() - document.getLineOffset(line);
|
||||||
buf.append("\tcreatePosition(" + line + ", " + column + ", " + position.getLength() + "),\n");
|
buf.append("\tcreatePosition(" + line + ", " + column + ", " + position.getLength() + "),\n");
|
||||||
|
@ -253,8 +253,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
|
||||||
store.setValue(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true);
|
store.setValue(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true);
|
||||||
SemanticHighlighting[] semanticHilightings= SemanticHighlightings.getSemanticHighlightings();
|
SemanticHighlighting[] semanticHilightings= SemanticHighlightings.getSemanticHighlightings();
|
||||||
for (int i= 0, n= semanticHilightings.length; i < n; i++) {
|
for (SemanticHighlighting semanticHilighting : semanticHilightings) {
|
||||||
SemanticHighlighting semanticHilighting= semanticHilightings[i];
|
|
||||||
if (store.getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHilighting)))
|
if (store.getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHilighting)))
|
||||||
store.setValue(SemanticHighlightings.getEnabledPreferenceKey(semanticHilighting), false);
|
store.setValue(SemanticHighlightings.getEnabledPreferenceKey(semanticHilighting), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,10 +289,10 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
//main
|
//int main
|
||||||
//(
|
//(
|
||||||
// int argc,
|
// int argc,
|
||||||
// char const * argv[]
|
// char const int* argv[]
|
||||||
//)
|
//)
|
||||||
//try
|
//try
|
||||||
//{
|
//{
|
||||||
|
@ -310,7 +310,7 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// return 2;
|
// return 2;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//main(int argc, char const * argv[])
|
//int main(int argc, char const int* argv[])
|
||||||
//try {
|
//try {
|
||||||
// for (int i = 1; i < argc; ++i) {
|
// for (int i = 1; i < argc; ++i) {
|
||||||
// }
|
// }
|
||||||
|
@ -326,9 +326,9 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
//main(int argc, char const * argv[]) { try { for (int i = 1; i < argc; ++i) { } return 0; } catch (float e) { return 1; } catch (...) { return 2; } }
|
//int main(int argc, char const int * argv[]) { try { for (int i = 1; i < argc; ++i) { } return 0; } catch (float e) { return 1; } catch (...) { return 2; } }
|
||||||
|
|
||||||
//main(int argc, char const * argv[]) {
|
//int main(int argc, char const int * argv[]) {
|
||||||
// try {
|
// try {
|
||||||
// for (int i = 1; i < argc; ++i) {
|
// for (int i = 1; i < argc; ++i) {
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
private final String headerFileName = "CompletionTestStart40.h";
|
private final String headerFileName = "CompletionTestStart40.h";
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {"notAnonymousEnum", "notAnonymousClass"};
|
private final String[] expectedResults = {"notAnonymousEnum", "notAnonymousClass", "xOtherClass"};
|
||||||
|
|
||||||
public CompletionTest_AnonymousTypes(String name) {
|
public CompletionTest_AnonymousTypes(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -39,6 +39,7 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected int getCompletionPosition() {
|
protected int getCompletionPosition() {
|
||||||
return getBuffer().indexOf(" x ");
|
return getBuffer().indexOf(" x ");
|
||||||
}
|
}
|
||||||
|
@ -46,6 +47,7 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String getExpectedPrefix() {
|
protected String getExpectedPrefix() {
|
||||||
return expectedPrefix;
|
return expectedPrefix;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,7 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String[] getExpectedResultsValues() {
|
protected String[] getExpectedResultsValues() {
|
||||||
return expectedResults;
|
return expectedResults;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +63,7 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String getFileName() {
|
protected String getFileName() {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
@ -67,12 +71,14 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String getFileFullPath() {
|
protected String getFileFullPath() {
|
||||||
return fileFullPath;
|
return fileFullPath;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String getHeaderFileFullPath() {
|
protected String getHeaderFileFullPath() {
|
||||||
return headerFileFullPath;
|
return headerFileFullPath;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +86,7 @@ public class CompletionTest_AnonymousTypes extends CompletionProposalsBaseTest{
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected String getHeaderFileName() {
|
protected String getHeaderFileName() {
|
||||||
return headerFileName;
|
return headerFileName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
|
||||||
sourceIndexerID= indexerID;
|
sourceIndexerID= indexerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
closeAllEditors();
|
closeAllEditors();
|
||||||
CProjectHelper.delete(fCProject);
|
CProjectHelper.delete(fCProject);
|
||||||
|
@ -732,7 +734,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
|
||||||
// typedef int TestTypeTwo;
|
// typedef int TestTypeTwo;
|
||||||
|
|
||||||
// #include "testBug78354.h"
|
// #include "testBug78354.h"
|
||||||
// main()
|
// int main()
|
||||||
// {
|
// {
|
||||||
// TestTypeOne myFirstLink = 5;
|
// TestTypeOne myFirstLink = 5;
|
||||||
// TestTypeTwo mySecondLink = 6;
|
// TestTypeTwo mySecondLink = 6;
|
||||||
|
|
|
@ -141,6 +141,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
initProject();
|
initProject();
|
||||||
|
@ -148,6 +149,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
OpenDeclarationsAction.sAllowFallback= false;
|
OpenDeclarationsAction.sAllowFallback= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if( project == null || !project.exists() )
|
if( project == null || !project.exists() )
|
||||||
return;
|
return;
|
||||||
|
@ -155,13 +157,13 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
closeAllEditors();
|
closeAllEditors();
|
||||||
|
|
||||||
IResource [] members = project.members();
|
IResource [] members = project.members();
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for (IResource member : members) {
|
||||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
if( member.getName().equals( ".project" ) || member.getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
continue;
|
continue;
|
||||||
if (members[i].getName().equals(".settings"))
|
if (member.getName().equals(".settings"))
|
||||||
continue;
|
continue;
|
||||||
try{
|
try{
|
||||||
members[i].delete( false, monitor );
|
member.delete( false, monitor );
|
||||||
} catch( Throwable e ){
|
} catch( Throwable e ){
|
||||||
/*boo*/
|
/*boo*/
|
||||||
}
|
}
|
||||||
|
@ -922,7 +924,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$
|
buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$
|
buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$
|
||||||
buffer.append("main()\n"); //$NON-NLS-1$
|
buffer.append("int main()\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$
|
buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$
|
||||||
buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$
|
buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$
|
||||||
|
|
|
@ -115,6 +115,7 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
OpenDeclarationsAction.sIsJUnitTest= true;
|
OpenDeclarationsAction.sIsJUnitTest= true;
|
||||||
|
@ -133,6 +134,7 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if( project == null || !project.exists() )
|
if( project == null || !project.exists() )
|
||||||
return;
|
return;
|
||||||
|
@ -140,13 +142,13 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
closeAllEditors();
|
closeAllEditors();
|
||||||
|
|
||||||
IResource [] members = project.members();
|
IResource [] members = project.members();
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for (IResource member : members) {
|
||||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
if( member.getName().equals( ".project" ) || member.getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
continue;
|
continue;
|
||||||
if (members[i].getName().equals(".settings"))
|
if (member.getName().equals(".settings"))
|
||||||
continue;
|
continue;
|
||||||
try{
|
try{
|
||||||
members[i].delete( true, monitor );
|
member.delete( true, monitor );
|
||||||
} catch( Throwable e ){
|
} catch( Throwable e ){
|
||||||
/*boo*/
|
/*boo*/
|
||||||
}
|
}
|
||||||
|
@ -667,7 +669,7 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$
|
buffer.append("typedef int TestTypeOne;\n"); //$NON-NLS-1$
|
||||||
buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$
|
buffer.append("typedef int TestTypeTwo;\n"); //$NON-NLS-1$
|
||||||
buffer.append("main()\n"); //$NON-NLS-1$
|
buffer.append("int main()\n"); //$NON-NLS-1$
|
||||||
buffer.append("{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$
|
buffer.append("TestTypeOne myFirstLink = 5;\n"); //$NON-NLS-1$
|
||||||
buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$
|
buffer.append("TestTypeTwo mySecondLink = 6;\n"); //$NON-NLS-1$
|
||||||
|
|
|
@ -49,10 +49,6 @@ import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
import org.eclipse.cdt.core.model.ISourceReference;
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
|
import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,46 +161,6 @@ public abstract class CRefactoring extends Refactoring {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AmbiguityFinder extends ASTVisitor{
|
|
||||||
|
|
||||||
private boolean ambiguityFound = false;
|
|
||||||
|
|
||||||
{
|
|
||||||
shouldVisitDeclarations = true;
|
|
||||||
shouldVisitExpressions = true;
|
|
||||||
shouldVisitStatements= true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTDeclaration declaration) {
|
|
||||||
if (declaration instanceof IASTAmbiguousDeclaration) {
|
|
||||||
ambiguityFound = true;
|
|
||||||
}
|
|
||||||
return ASTVisitor.PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTExpression expression) {
|
|
||||||
if (expression instanceof IASTAmbiguousExpression) {
|
|
||||||
ambiguityFound = true;
|
|
||||||
}
|
|
||||||
return ASTVisitor.PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int visit(IASTStatement statement) {
|
|
||||||
if (statement instanceof IASTAmbiguousStatement) {
|
|
||||||
ambiguityFound = true;
|
|
||||||
}
|
|
||||||
return ASTVisitor.PROCESS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean ambiguityFound() {
|
|
||||||
return ambiguityFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
|
public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
|
||||||
throws CoreException, OperationCanceledException {
|
throws CoreException, OperationCanceledException {
|
||||||
|
@ -302,9 +258,8 @@ public abstract class CRefactoring extends Refactoring {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean translationUnitIsAmbiguous() {
|
protected boolean translationUnitIsAmbiguous() {
|
||||||
AmbiguityFinder af = new AmbiguityFinder();
|
// ambiguities are resolved before the tu is passed to the refactoring.
|
||||||
unit.accept(af);
|
return false;
|
||||||
return af.ambiguityFound();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockIndex() throws CoreException, InterruptedException {
|
public void lockIndex() throws CoreException, InterruptedException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue