mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
224b4ef3a3
commit
3604f812ce
18 changed files with 2296 additions and 2371 deletions
|
@ -366,19 +366,20 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public int size() { return nameList.size(); }
|
public int size() { return nameList.size(); }
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
for (int i=0; i<size(); i++) {
|
for (int i= 0; i < size(); i++) {
|
||||||
IASTName name= getName(i);
|
IASTName name= getName(i);
|
||||||
String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
|
String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
|
||||||
System.out.println(i+": #"+name.getRawSignature()+"# "+parent);
|
System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertInstances(CPPNameCollector collector, IBinding binding, int num) throws Exception {
|
protected void assertInstances(CPPNameCollector collector, IBinding binding, int num) throws Exception {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < collector.size(); i++)
|
for (int i = 0; i < collector.size(); i++) {
|
||||||
if (collector.getName(i).resolveBinding() == binding)
|
if (collector.getName(i).resolveBinding() == binding)
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(num, count);
|
assertEquals(num, count);
|
||||||
}
|
}
|
||||||
|
@ -490,11 +491,11 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
||||||
assertNotNull("Expected object of "+clazz.getName()+" but got a null value", o);
|
assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
|
||||||
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
||||||
for (Class c : cs) {
|
for (Class c : cs) {
|
||||||
assertNotNull("Expected object of "+c.getName()+" but got a null value", o);
|
assertNotNull("Expected object of " + c.getName() + " but got a null value", o);
|
||||||
assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
|
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
|
||||||
}
|
}
|
||||||
return clazz.cast(o);
|
return clazz.cast(o);
|
||||||
}
|
}
|
||||||
|
@ -523,7 +524,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public IProblemBinding assertProblem(String section, int len) {
|
public IProblemBinding assertProblem(String section, int len) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len= section.length()+len;
|
len= section.length() + len;
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
||||||
binding instanceof IProblemBinding);
|
binding instanceof IProblemBinding);
|
||||||
|
@ -532,11 +533,11 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len= section.length()+len;
|
len= section.length() + len;
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
|
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
||||||
}
|
}
|
||||||
if (binding == null) {
|
if (binding == null) {
|
||||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||||
|
@ -548,7 +549,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
IASTName name= findName(section, len);
|
IASTName name= findName(section, len);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
String selection = section.substring(0, len);
|
String selection = section.substring(0, len);
|
||||||
fail("Found unexpected \""+selection+"\": " + name.resolveBinding());
|
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +560,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \""+selection+"\"", name);
|
assertNotNull("did not find \"" + selection + "\"", name);
|
||||||
|
|
||||||
assertInstance(name, IASTImplicitName.class);
|
assertInstance(name, IASTImplicitName.class);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
|
@ -587,7 +588,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public void assertNoImplicitName(String section, int len) {
|
public void assertNoImplicitName(String section, int len) {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNull("found name \""+selection+"\"", name);
|
assertNull("found name \"" + selection + "\"", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||||
|
@ -647,7 +648,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len+= section.length();
|
len += section.length();
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||||
!(binding instanceof IProblemBinding));
|
!(binding instanceof IProblemBinding));
|
||||||
|
@ -661,11 +662,11 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
private IBinding binding(String section, int len) {
|
private IBinding binding(String section, int len) {
|
||||||
IASTName name = findName(section, len);
|
IASTName name = findName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \""+selection+"\"", name);
|
assertNotNull("did not find \"" + selection + "\"", name);
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull("No binding for "+name.getRawSignature(), binding);
|
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||||
|
|
||||||
return name.resolveBinding();
|
return name.resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
* Testcases on the AST.
|
* Testcases on the AST.
|
||||||
*/
|
*/
|
||||||
public class AST2Tests extends AST2BaseTest {
|
public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
private static final int NUM_TESTS = 3;
|
private static final int NUM_TESTS = 3;
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
|
@ -1625,10 +1624,10 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
|
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
|
||||||
IASTDeclaration[] declarations = tu.getDeclarations();
|
IASTDeclaration[] declarations = tu.getDeclarations();
|
||||||
IType plainInt = ((IVariable)((IASTSimpleDeclaration)declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType plainInt = ((IVariable)((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
IType signedInt = ((IVariable)((IASTSimpleDeclaration)declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType signedInt = ((IVariable)((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
IType unsignedInt = ((IVariable)((IASTSimpleDeclaration)declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType unsignedInt = ((IVariable)((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
IType noSpec = ((IVariable)((IASTSimpleDeclaration)declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType noSpec = ((IVariable)((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
assertTrue(plainInt.isSameType(signedInt));
|
assertTrue(plainInt.isSameType(signedInt));
|
||||||
assertFalse(plainInt.isSameType(unsignedInt));
|
assertFalse(plainInt.isSameType(unsignedInt));
|
||||||
assertFalse(signedInt.isSameType(unsignedInt));
|
assertFalse(signedInt.isSameType(unsignedInt));
|
||||||
|
@ -2055,7 +2054,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getName();
|
.getName();
|
||||||
final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
|
final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
|
||||||
.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
|
.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
|
||||||
final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer)dtor.getInitializer()).getInitializerClause();
|
final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor.getInitializer()).getInitializerClause();
|
||||||
IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
|
IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
|
||||||
.getDesignators()[0]).getName();
|
.getDesignators()[0]).getName();
|
||||||
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
|
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
|
||||||
|
@ -2229,18 +2228,12 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
for (int i = 0; i < NUM_TESTS; i++) {
|
for (int i = 0; i < NUM_TESTS; i++) {
|
||||||
IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
.getDeclarations()[0];
|
IFunction f = (IFunction) def1.getDeclarator().getName().resolveBinding();
|
||||||
IFunction f = (IFunction) def1.getDeclarator().getName()
|
IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
.resolveBinding();
|
IFunction f2 = (IFunction) def2.getDeclarator().getName().resolveBinding();
|
||||||
IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu.getDeclarations()[2];
|
||||||
.getDeclarations()[1];
|
IFunction f3 = (IFunction) def3.getDeclarator().getName().resolveBinding();
|
||||||
IFunction f2 = (IFunction) def2.getDeclarator().getName()
|
|
||||||
.resolveBinding();
|
|
||||||
IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu
|
|
||||||
.getDeclarations()[2];
|
|
||||||
IFunction f3 = (IFunction) def3.getDeclarator().getName()
|
|
||||||
.resolveBinding();
|
|
||||||
|
|
||||||
IFunctionType ft = f.getType();
|
IFunctionType ft = f.getType();
|
||||||
IFunctionType ft2 = f2.getType();
|
IFunctionType ft2 = f2.getType();
|
||||||
|
@ -2251,17 +2244,15 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
|
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
|
||||||
assertTrue(ft3.getReturnType() instanceof IPointerType);
|
assertTrue(ft3.getReturnType() instanceof IPointerType);
|
||||||
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
|
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
|
||||||
assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType())
|
assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType()).getReturnType()
|
||||||
.getType()).getReturnType() instanceof IBasicType);
|
instanceof IBasicType);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName()
|
IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName().resolveBinding());
|
||||||
.resolveBinding());
|
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], def1.getDeclarator().getName());
|
assertEquals(decls[0], def1.getDeclarator().getName());
|
||||||
|
|
||||||
decls = tu.getDeclarationsInAST(def2.getDeclarator().getName()
|
decls = tu.getDeclarationsInAST(def2.getDeclarator().getName().resolveBinding());
|
||||||
.resolveBinding());
|
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], def2.getDeclarator().getName());
|
assertEquals(decls[0], def2.getDeclarator().getName());
|
||||||
|
|
||||||
|
@ -2276,8 +2267,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// any parameter to type function returning T is adjusted to be pointer to
|
// any parameter to type function returning T is adjusted to be pointer to
|
||||||
// function returning T
|
// function returning T
|
||||||
public void testParmToFunction() throws Exception {
|
public void testParmToFunction() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(
|
IASTTranslationUnit tu = parse("int f(int g(void)) { return g();}", ParserLanguage.C);
|
||||||
"int f(int g(void)) { return g();}", ParserLanguage.C); //$NON-NLS-1$
|
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
for (int i = 0; i < NUM_TESTS; i++) {
|
for (int i = 0; i < NUM_TESTS; i++) {
|
||||||
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
|
@ -2300,7 +2290,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
||||||
IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator())
|
IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator())
|
||||||
.getParameters()[0].getDeclarator().getName();
|
.getParameters()[0].getDeclarator().getName();
|
||||||
IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
|
IASTName name_g_call =
|
||||||
|
((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
|
||||||
.getBody()).getStatements()[0]).getReturnValue())
|
.getBody()).getStatements()[0]).getReturnValue())
|
||||||
.getFunctionNameExpression()).getName();
|
.getFunctionNameExpression()).getName();
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
|
||||||
|
@ -2312,15 +2303,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testArrayPointerFunction() throws Exception {
|
public void testArrayPointerFunction() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(
|
IASTTranslationUnit tu = parse("int (*v[])(int *x, int *y);", ParserLanguage.C);
|
||||||
"int (*v[])(int *x, int *y);", ParserLanguage.C); //$NON-NLS-1$
|
|
||||||
|
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
for (int i = 0; i < NUM_TESTS; i++) {
|
for (int i = 0; i < NUM_TESTS; i++) {
|
||||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl
|
IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
|
||||||
.getDeclarators()[0]).getNestedDeclarator().getName()
|
.getNestedDeclarator().getName().resolveBinding();
|
||||||
.resolveBinding();
|
|
||||||
|
|
||||||
IType vt_1 = v.getType();
|
IType vt_1 = v.getType();
|
||||||
assertTrue(vt_1 instanceof IArrayType);
|
assertTrue(vt_1 instanceof IArrayType);
|
||||||
|
@ -2348,8 +2337,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getDeclarators()[0]).getNestedDeclarator().getName()
|
.getDeclarators()[0]).getNestedDeclarator().getName()
|
||||||
.resolveBinding());
|
.resolveBinding());
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl
|
assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
|
||||||
.getDeclarators()[0]).getNestedDeclarator().getName());
|
.getNestedDeclarator().getName());
|
||||||
|
|
||||||
tu = validateCopy(tu);
|
tu = validateCopy(tu);
|
||||||
}
|
}
|
||||||
|
@ -2396,8 +2385,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], name_DWORD);
|
assertEquals(decls[0], name_DWORD);
|
||||||
|
|
||||||
decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2
|
decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2.getDeclSpecifier())
|
||||||
.getDeclSpecifier()).getName().resolveBinding());
|
.getName().resolveBinding());
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], name_DWORD);
|
assertEquals(decls[0], name_DWORD);
|
||||||
|
|
||||||
|
@ -3226,10 +3215,10 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
|
||||||
IASTDeclaration[] decls = tu.getDeclarations();
|
IASTDeclaration[] decls = tu.getDeclarations();
|
||||||
|
|
||||||
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
|
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
|
||||||
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
|
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
|
||||||
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
|
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
|
||||||
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
|
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int foo();
|
// int foo();
|
||||||
|
@ -3246,7 +3235,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IVariable zoot = (IVariable) col.getName(4).resolveBinding();
|
IVariable zoot = (IVariable) col.getName(4).resolveBinding();
|
||||||
IType t = zoot.getType();
|
IType t = zoot.getType();
|
||||||
assertTrue(t instanceof IBasicType);
|
assertTrue(t instanceof IBasicType);
|
||||||
assertEquals(((IBasicType)t).getType(), IBasicType.t_int);
|
assertEquals(((IBasicType) t).getType(), IBasicType.t_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug95866() throws Exception {
|
public void testBug95866() throws Exception {
|
||||||
|
@ -3392,7 +3381,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void test1043290() throws Exception {
|
public void test1043290() throws Exception {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
|
||||||
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
IASTStatement [] statements = ((IASTCompoundStatement)fd.getBody()).getStatements();
|
IASTStatement [] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
|
||||||
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
|
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
|
||||||
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
|
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
|
||||||
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
|
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
|
||||||
|
@ -3765,8 +3754,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals("method", methodc.getName());
|
assertEquals("method", methodc.getName());
|
||||||
assertInstance(methodb, ICPPMethod.class);
|
assertInstance(methodb, ICPPMethod.class);
|
||||||
assertInstance(methodc, ICPPMethod.class);
|
assertInstance(methodc, ICPPMethod.class);
|
||||||
assertEquals("A", ((ICPPMethod)methodb).getClassOwner().getName());
|
assertEquals("A", ((ICPPMethod) methodb).getClassOwner().getName());
|
||||||
assertEquals("A", ((ICPPMethod)methodc).getClassOwner().getName());
|
assertEquals("A", ((ICPPMethod) methodc).getClassOwner().getName());
|
||||||
|
|
||||||
tu = validateCopy(tu);
|
tu = validateCopy(tu);
|
||||||
}
|
}
|
||||||
|
@ -3817,8 +3806,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals("method", methodAA.getName());
|
assertEquals("method", methodAA.getName());
|
||||||
assertInstance(methodA, ICPPMethod.class);
|
assertInstance(methodA, ICPPMethod.class);
|
||||||
assertInstance(methodAA, ICPPMethod.class);
|
assertInstance(methodAA, ICPPMethod.class);
|
||||||
assertEquals("A", ((ICPPMethod)methodA).getClassOwner().getName());
|
assertEquals("A", ((ICPPMethod) methodA).getClassOwner().getName());
|
||||||
assertEquals("AA", ((ICPPMethod)methodAA).getClassOwner().getName());
|
assertEquals("AA", ((ICPPMethod) methodAA).getClassOwner().getName());
|
||||||
|
|
||||||
tu = validateCopy(tu);
|
tu = validateCopy(tu);
|
||||||
}
|
}
|
||||||
|
@ -4217,7 +4206,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
for (Object o : col.nameList) {
|
for (Object o : col.nameList) {
|
||||||
IASTName n = (IASTName)o;
|
IASTName n = (IASTName) o;
|
||||||
if (n.isReference() && "f1".equals(n.toString()))
|
if (n.isReference() && "f1".equals(n.toString()))
|
||||||
assertTrue(n.resolveBinding() instanceof IProblemBinding);
|
assertTrue(n.resolveBinding() instanceof IProblemBinding);
|
||||||
else
|
else
|
||||||
|
@ -4773,20 +4762,20 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
{
|
{
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.C, true);
|
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.C, true);
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
|
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
|
||||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement)body.getStatements()[0];
|
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
|
||||||
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement)switchStmt.getBody()).getStatements()[0];
|
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
|
||||||
IASTBinaryExpression binExpr = (IASTBinaryExpression)caseStmt.getExpression();
|
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
|
||||||
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
||||||
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
||||||
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
|
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
|
||||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement)body.getStatements()[0];
|
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
|
||||||
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement)switchStmt.getBody()).getStatements()[0];
|
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
|
||||||
IASTBinaryExpression binExpr = (IASTBinaryExpression)caseStmt.getExpression();
|
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
|
||||||
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
||||||
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
||||||
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
||||||
|
@ -4982,7 +4971,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// VOID func(VOID) {
|
// VOID func(VOID) {
|
||||||
// }
|
// }
|
||||||
public void testTypedefVoid_Bug221567() throws Exception {
|
public void testTypedefVoid_Bug221567() throws Exception {
|
||||||
final boolean[] isCpps= {false, true};
|
final boolean[] isCpps= { false, true };
|
||||||
String code= getAboveComment();
|
String code= getAboveComment();
|
||||||
for (boolean isCpp : isCpps) {
|
for (boolean isCpp : isCpps) {
|
||||||
BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
|
BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
|
||||||
|
@ -4998,13 +4987,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IType pt = pts[0];
|
IType pt = pts[0];
|
||||||
assertInstance(rt, ITypedef.class);
|
assertInstance(rt, ITypedef.class);
|
||||||
assertInstance(pt, ITypedef.class);
|
assertInstance(pt, ITypedef.class);
|
||||||
rt= ((ITypedef)rt).getType();
|
rt= ((ITypedef) rt).getType();
|
||||||
pt= ((ITypedef)pt).getType();
|
pt= ((ITypedef) pt).getType();
|
||||||
|
|
||||||
assertTrue(rt instanceof IBasicType);
|
assertTrue(rt instanceof IBasicType);
|
||||||
assertEquals(IBasicType.t_void, ((IBasicType)rt).getType());
|
assertEquals(IBasicType.t_void, ((IBasicType) rt).getType());
|
||||||
assertTrue(pt instanceof IBasicType);
|
assertTrue(pt instanceof IBasicType);
|
||||||
assertEquals(IBasicType.t_void, ((IBasicType)pt).getType());
|
assertEquals(IBasicType.t_void, ((IBasicType) pt).getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6317,8 +6306,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
|
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
|
||||||
IASTInitializer init = ((IASTSimpleDeclaration)declarations[index]).getDeclarators()[0].getInitializer();
|
IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
|
||||||
return (IBasicType)((IASTExpression)((IASTEqualsInitializer)init).getInitializerClause()).getExpressionType();
|
return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void test() {
|
// void test() {
|
||||||
|
@ -6862,10 +6851,10 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
//
|
//
|
||||||
public void testBug273797() throws Exception {
|
public void testBug273797() throws Exception {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
||||||
IASTName n = ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0].getName();
|
IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0].getName();
|
||||||
IVariable v = (IVariable) n.resolveBinding();
|
IVariable v = (IVariable) n.resolveBinding();
|
||||||
|
|
||||||
ICArrayType t = (ICArrayType)v.getType();
|
ICArrayType t = (ICArrayType) v.getType();
|
||||||
assertFalse(t.isConst());
|
assertFalse(t.isConst());
|
||||||
assertFalse(t.isRestrict());
|
assertFalse(t.isRestrict());
|
||||||
assertFalse(t.isVolatile());
|
assertFalse(t.isVolatile());
|
||||||
|
@ -6884,9 +6873,9 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testBug278797() throws Exception {
|
public void testBug278797() throws Exception {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
||||||
IASTFunctionDefinition func = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement)func.getBody()).getStatements()[0]);
|
IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]);
|
||||||
IType t = ((IASTCastExpression)stmt.getExpression()).getOperand().getExpressionType();
|
IType t = ((IASTCastExpression) stmt.getExpression()).getOperand().getExpressionType();
|
||||||
assertNotNull(t);
|
assertNotNull(t);
|
||||||
assertTrue(t instanceof IEnumeration);
|
assertTrue(t instanceof IEnumeration);
|
||||||
}
|
}
|
||||||
|
@ -6902,34 +6891,34 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
//int a[2][3] = {{1,2,3},{4,5,6}};
|
//int a[2][3] = {{1,2,3},{4,5,6}};
|
||||||
{
|
{
|
||||||
IASTDeclaration d = tu.getDeclarations()[0];
|
IASTDeclaration d = tu.getDeclarations()[0];
|
||||||
IBinding b = ((IASTSimpleDeclaration)d).getDeclarators()[0].getName().resolveBinding();
|
IBinding b = ((IASTSimpleDeclaration) d).getDeclarators()[0].getName().resolveBinding();
|
||||||
IType t = ((IVariable)b).getType();
|
IType t = ((IVariable) b).getType();
|
||||||
assertTrue(t instanceof IArrayType);
|
assertTrue(t instanceof IArrayType);
|
||||||
IArrayType at1 = (IArrayType)t;
|
IArrayType at1 = (IArrayType) t;
|
||||||
IASTExpression size1 = at1.getArraySizeExpression();
|
IASTExpression size1 = at1.getArraySizeExpression();
|
||||||
assertTrue(at1.getType() instanceof IArrayType);
|
assertTrue(at1.getType() instanceof IArrayType);
|
||||||
IArrayType at2 = (IArrayType) at1.getType();
|
IArrayType at2 = (IArrayType) at1.getType();
|
||||||
IASTExpression size2 = at2.getArraySizeExpression();
|
IASTExpression size2 = at2.getArraySizeExpression();
|
||||||
assertTrue(size1 instanceof IASTLiteralExpression);
|
assertTrue(size1 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size1).getValue()[0], '2');
|
assertEquals(((IASTLiteralExpression) size1).getValue()[0], '2');
|
||||||
assertTrue(size2 instanceof IASTLiteralExpression);
|
assertTrue(size2 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size2).getValue()[0], '3');
|
assertEquals(((IASTLiteralExpression) size2).getValue()[0], '3');
|
||||||
}
|
}
|
||||||
//int b[3][2] = {{1,2},{3,4},{5,6}};
|
//int b[3][2] = {{1,2},{3,4},{5,6}};
|
||||||
{
|
{
|
||||||
IASTDeclaration d = tu.getDeclarations()[1];
|
IASTDeclaration d = tu.getDeclarations()[1];
|
||||||
IBinding b = ((IASTSimpleDeclaration)d).getDeclarators()[0].getName().resolveBinding();
|
IBinding b = ((IASTSimpleDeclaration) d).getDeclarators()[0].getName().resolveBinding();
|
||||||
IType t = ((IVariable)b).getType();
|
IType t = ((IVariable) b).getType();
|
||||||
assertTrue(t instanceof IArrayType);
|
assertTrue(t instanceof IArrayType);
|
||||||
IArrayType at1 = (IArrayType)t;
|
IArrayType at1 = (IArrayType) t;
|
||||||
IASTExpression size1 = at1.getArraySizeExpression();
|
IASTExpression size1 = at1.getArraySizeExpression();
|
||||||
assertTrue(at1.getType() instanceof IArrayType);
|
assertTrue(at1.getType() instanceof IArrayType);
|
||||||
IArrayType at2 = (IArrayType) at1.getType();
|
IArrayType at2 = (IArrayType) at1.getType();
|
||||||
IASTExpression size2 = at2.getArraySizeExpression();
|
IASTExpression size2 = at2.getArraySizeExpression();
|
||||||
assertTrue(size1 instanceof IASTLiteralExpression);
|
assertTrue(size1 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size1).getValue()[0], '3');
|
assertEquals(((IASTLiteralExpression) size1).getValue()[0], '3');
|
||||||
assertTrue(size2 instanceof IASTLiteralExpression);
|
assertTrue(size2 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size2).getValue()[0], '2');
|
assertEquals(((IASTLiteralExpression) size2).getValue()[0], '2');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6962,7 +6951,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void testBug295851() throws Exception {
|
public void testBug295851() throws Exception {
|
||||||
for (ParserLanguage lang : ParserLanguage.values()) {
|
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
|
||||||
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclSpecifier();
|
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclSpecifier();
|
||||||
IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
|
IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
|
||||||
IValue value = enumeratorBinding.getValue();
|
IValue value = enumeratorBinding.getValue();
|
||||||
assertEquals(2, value.numericalValue().longValue());
|
assertEquals(2, value.numericalValue().longValue());
|
||||||
|
@ -6984,20 +6973,20 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testBindingsOnFields() throws Exception {
|
public void testBindingsOnFields() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false);
|
||||||
IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[2]).getBody();
|
IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[2]).getBody();
|
||||||
|
|
||||||
// Get the IFields bindings from the type used in the declaration of structure
|
// Get the IFields bindings from the type used in the declaration of structure
|
||||||
IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement)bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
|
IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
|
||||||
ICompositeType t = (ICompositeType)((IVariable)n.resolveBinding()).getType();
|
ICompositeType t = (ICompositeType)((IVariable) n.resolveBinding()).getType();
|
||||||
IField[] fields = t.getFields();
|
IField[] fields = t.getFields();
|
||||||
assertTrue(fields.length == 2);
|
assertTrue(fields.length == 2);
|
||||||
|
|
||||||
// Get the IField for the first assignment
|
// Get the IField for the first assignment
|
||||||
IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)bodyStmt.getStatements()[1]).getExpression()).getOperand1();
|
IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[1]).getExpression()).getOperand1();
|
||||||
IBinding field1 = ref1.getFieldName().resolveBinding();
|
IBinding field1 = ref1.getFieldName().resolveBinding();
|
||||||
|
|
||||||
// Get the IField for the second assignment
|
// Get the IField for the second assignment
|
||||||
IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)bodyStmt.getStatements()[2]).getExpression()).getOperand1();
|
IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[2]).getExpression()).getOperand1();
|
||||||
IBinding field2 = ref2.getFieldName().resolveBinding();
|
IBinding field2 = ref2.getFieldName().resolveBinding();
|
||||||
|
|
||||||
// Compare the IField from the type and the assignments
|
// Compare the IField from the type and the assignments
|
||||||
|
@ -7045,7 +7034,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
|
IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
|
||||||
IType t = owner.getExpressionType();
|
IType t = owner.getExpressionType();
|
||||||
assertTrue(t instanceof ICompositeType);
|
assertTrue(t instanceof ICompositeType);
|
||||||
assertEquals("s",((ICompositeType)t).getName());
|
assertEquals("s", ((ICompositeType) t).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7347,7 +7336,6 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
|
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void a() {
|
// void a() {
|
||||||
// typedef float size_t;
|
// typedef float size_t;
|
||||||
// sizeof(10); // wrong - getExpressionType returns float
|
// sizeof(10); // wrong - getExpressionType returns float
|
||||||
|
|
|
@ -13,8 +13,8 @@ package org.eclipse.cdt.core.settings.model.extension;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
|
||||||
public abstract class CLanguageData extends CDataObject {
|
public abstract class CLanguageData extends CDataObject {
|
||||||
protected CLanguageData() {
|
|
||||||
|
|
||||||
|
protected CLanguageData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// public abstract CDataObject[] getChildrenOfKind(int kind);
|
// public abstract CDataObject[] getChildrenOfKind(int kind);
|
||||||
|
@ -52,7 +52,7 @@ public abstract class CLanguageData extends CDataObject {
|
||||||
|
|
||||||
public abstract void setSourceExtensions(String exts[]);
|
public abstract void setSourceExtensions(String exts[]);
|
||||||
|
|
||||||
public boolean containsDiscoveredScannerInfo(){
|
public boolean containsDiscoveredScannerInfo() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,21 +62,21 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
private boolean fNeedsPersistance;
|
private boolean fNeedsPersistance;
|
||||||
private boolean fIsCfgModified;
|
private boolean fIsCfgModified;
|
||||||
|
|
||||||
CfgIdPair(CfgIdPair base){
|
CfgIdPair(CfgIdPair base) {
|
||||||
fId = base.fId;
|
fId = base.fId;
|
||||||
fPersistanceName = base.fPersistanceName;
|
fPersistanceName = base.fPersistanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
CfgIdPair(QualifiedName persistanceName){
|
CfgIdPair(QualifiedName persistanceName) {
|
||||||
fPersistanceName = persistanceName;
|
fPersistanceName = persistanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId(){
|
public String getId() {
|
||||||
if(fId == null){
|
if (fId == null) {
|
||||||
fId = load();
|
fId = load();
|
||||||
if(fId == null){
|
if (fId == null) {
|
||||||
fId = getFirstCfgId();
|
fId = getFirstCfgId();
|
||||||
if(fId != null){
|
if (fId != null) {
|
||||||
fNeedsPersistance = true;
|
fNeedsPersistance = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICConfigurationDescription getConfiguration() {
|
public ICConfigurationDescription getConfiguration() {
|
||||||
if(fCfg == null){
|
if (fCfg == null) {
|
||||||
String id = getId();
|
String id = getId();
|
||||||
if(id != null){
|
if (id != null) {
|
||||||
fCfg = getConfigurationById(id);
|
fCfg = getConfigurationById(id);
|
||||||
if(fCfg == null){
|
if (fCfg == null) {
|
||||||
fId = getFirstCfgId();
|
fId = getFirstCfgId();
|
||||||
if(fId != null){
|
if (fId != null) {
|
||||||
fCfg = getConfigurationById(fId);
|
fCfg = getConfigurationById(fId);
|
||||||
fNeedsPersistance = true;
|
fNeedsPersistance = true;
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return fCfg;
|
return fCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfiguration(ICConfigurationDescription cfg){
|
public void setConfiguration(ICConfigurationDescription cfg) {
|
||||||
if(cfg.getProjectDescription() != CProjectDescription.this)
|
if (cfg.getProjectDescription() != CProjectDescription.this)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
if(cfg.getId().equals(getId()))
|
if (cfg.getId().equals(getId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fCfg = cfg;
|
fCfg = cfg;
|
||||||
|
@ -114,11 +114,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
fNeedsPersistance = true;
|
fNeedsPersistance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configurationRemoved(ICConfigurationDescription cfg){
|
public void configurationRemoved(ICConfigurationDescription cfg) {
|
||||||
if(cfg.getProjectDescription() != CProjectDescription.this)
|
if (cfg.getProjectDescription() != CProjectDescription.this)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
if(!cfg.getId().equals(getId()))
|
if (!cfg.getId().equals(getId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fIsCfgModified = true;
|
fIsCfgModified = true;
|
||||||
|
@ -126,7 +126,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
getConfiguration();
|
getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String load(){
|
private String load() {
|
||||||
try {
|
try {
|
||||||
return getProject().getPersistentProperty(fPersistanceName);
|
return getProject().getPersistentProperty(fPersistanceName);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -135,8 +135,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean store(String oldId, boolean force){
|
private boolean store(String oldId, boolean force) {
|
||||||
if(force || fIsCfgModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)){
|
if (force || fIsCfgModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)) {
|
||||||
try {
|
try {
|
||||||
getProject().setPersistentProperty(fPersistanceName, fId);
|
getProject().setPersistentProperty(fPersistanceName, fId);
|
||||||
fIsCfgModified = false;
|
fIsCfgModified = false;
|
||||||
|
@ -162,7 +162,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
fIsCreating = isCreating;
|
fIsCreating = isCreating;
|
||||||
ICStorageElement el = null;
|
ICStorageElement el = null;
|
||||||
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||||
if(loading){
|
if (loading) {
|
||||||
Map<String, ICStorageElement> cfgStorMap = mngr.createCfgStorages(this);
|
Map<String, ICStorageElement> cfgStorMap = mngr.createCfgStorages(this);
|
||||||
|
|
||||||
for (ICStorageElement sel : cfgStorMap.values()) {
|
for (ICStorageElement sel : cfgStorMap.values()) {
|
||||||
|
@ -174,22 +174,22 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrefs = new CProjectDescriptionPreferences(el,
|
fPrefs = new CProjectDescriptionPreferences(el,
|
||||||
(CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false),
|
(CProjectDescriptionPreferences) mngr.getProjectDescriptionWorkspacePreferences(false),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
fPropertiesMap = new HashMap<QualifiedName, Object>();
|
fPropertiesMap = new HashMap<QualifiedName, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateProject(IProject project){
|
public void updateProject(IProject project) {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadDatas(){
|
public void loadDatas() {
|
||||||
if(!fIsReadOnly || !fIsLoading)
|
if (!fIsReadOnly || !fIsLoading)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) iter.next();
|
||||||
try {
|
try {
|
||||||
cache.loadData();
|
cache.loadData();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -203,15 +203,15 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
// fIsLoading = false;
|
// fIsLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applyDatas(SettingsContext context){
|
public boolean applyDatas(SettingsContext context) {
|
||||||
if(!fIsReadOnly || !fIsApplying)
|
if (!fIsReadOnly || !fIsApplying)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) iter.next();
|
||||||
try {
|
try {
|
||||||
if(cache.applyData(context))
|
if (cache.applyData(context))
|
||||||
modified = true;
|
modified = true;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -233,7 +233,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
* setModified (false)
|
* setModified (false)
|
||||||
* set the ICSettingsStorage to readonly
|
* set the ICSettingsStorage to readonly
|
||||||
*/
|
*/
|
||||||
public void doneApplying(){
|
public void doneApplying() {
|
||||||
doneInitializing();
|
doneInitializing();
|
||||||
fIsApplying = false;
|
fIsApplying = false;
|
||||||
|
|
||||||
|
@ -246,31 +246,31 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
setModified(false);
|
setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doneLoading(){
|
public void doneLoading() {
|
||||||
doneInitializing();
|
doneInitializing();
|
||||||
fIsLoading = false;
|
fIsLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoading(boolean loading){
|
public void setLoading(boolean loading) {
|
||||||
fIsLoading = loading;
|
fIsLoading = loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doneInitializing(){
|
private void doneInitializing() {
|
||||||
for (ICConfigurationDescription cfg : fCfgMap.values()) {
|
for (ICConfigurationDescription cfg : fCfgMap.values()) {
|
||||||
// FIXME How and why are we down casting to a CConfigurationDescriptionCache. Comments, please!
|
// FIXME How and why are we down casting to a CConfigurationDescriptionCache. Comments, please!
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)cfg;
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) cfg;
|
||||||
cache.doneInitialization();
|
cache.doneInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
fPrefs.setReadOnly(true);
|
fPrefs.setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoading(){
|
public boolean isLoading() {
|
||||||
return fIsLoading;
|
return fIsLoading;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplying(){
|
public boolean isApplying() {
|
||||||
return fIsApplying;
|
return fIsApplying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,30 +296,30 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false);
|
fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false);
|
||||||
|
|
||||||
for(Iterator<ICConfigurationDescription> iter = base.fCfgMap.values().iterator(); iter.hasNext();){
|
for (Iterator<ICConfigurationDescription> iter = base.fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
try {
|
try {
|
||||||
IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next();
|
IInternalCCfgInfo cfgDes = (IInternalCCfgInfo) iter.next();
|
||||||
if(fIsReadOnly){
|
if (fIsReadOnly) {
|
||||||
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
||||||
CConfigurationDescriptionCache baseCache = null;
|
CConfigurationDescriptionCache baseCache = null;
|
||||||
if(baseData instanceof CConfigurationDescriptionCache){
|
if (baseData instanceof CConfigurationDescriptionCache) {
|
||||||
baseCache = (CConfigurationDescriptionCache)baseData;
|
baseCache = (CConfigurationDescriptionCache) baseData;
|
||||||
baseData = baseCache.getConfigurationData();
|
baseData = baseCache.getConfigurationData();
|
||||||
}
|
}
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription)cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null);
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription) cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null);
|
||||||
configurationCreated(cache);
|
configurationCreated(cache);
|
||||||
} else {
|
} else {
|
||||||
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(baseData, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(baseData, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
}
|
}
|
||||||
} catch (CoreException e){
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashMap<QualifiedName, Object> cloneMap = (HashMap<QualifiedName, Object>)base.fPropertiesMap.clone();
|
HashMap<QualifiedName, Object> cloneMap = (HashMap<QualifiedName, Object>) base.fPropertiesMap.clone();
|
||||||
fPropertiesMap = cloneMap;
|
fPropertiesMap = cloneMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,14 +328,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
* This occurs during the SetCProjectDescription Operation
|
* This occurs during the SetCProjectDescription Operation
|
||||||
*/
|
*/
|
||||||
void switchToCachedConfigurationDescriptions() throws CoreException {
|
void switchToCachedConfigurationDescriptions() throws CoreException {
|
||||||
|
|
||||||
for (Map.Entry<String, ICConfigurationDescription> e : fCfgMap.entrySet()) {
|
for (Map.Entry<String, ICConfigurationDescription> e : fCfgMap.entrySet()) {
|
||||||
if (e.getValue() instanceof CConfigurationDescription) {
|
if (e.getValue() instanceof CConfigurationDescription) {
|
||||||
CConfigurationDescription cfgDes = (CConfigurationDescription)e.getValue();
|
CConfigurationDescription cfgDes = (CConfigurationDescription) e.getValue();
|
||||||
CConfigurationData baseData = ((IInternalCCfgInfo)cfgDes).getConfigurationData(false);
|
CConfigurationData baseData = ((IInternalCCfgInfo) cfgDes).getConfigurationData(false);
|
||||||
CConfigurationDescriptionCache baseCache = null;
|
CConfigurationDescriptionCache baseCache = null;
|
||||||
if(baseData instanceof CConfigurationDescriptionCache){
|
if (baseData instanceof CConfigurationDescriptionCache) {
|
||||||
baseCache = (CConfigurationDescriptionCache)baseData;
|
baseCache = (CConfigurationDescriptionCache) baseData;
|
||||||
baseData = baseCache.getConfigurationData();
|
baseData = baseCache.getConfigurationData();
|
||||||
}
|
}
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache,
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache,
|
||||||
|
@ -345,14 +344,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void configurationCreated(ICConfigurationDescription des){
|
void configurationCreated(ICConfigurationDescription des) {
|
||||||
fCfgMap.put(des.getId(), des);
|
fCfgMap.put(des.getId(), des);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription createConfiguration(String id, String name,
|
public ICConfigurationDescription createConfiguration(String id, String name,
|
||||||
ICConfigurationDescription base) throws CoreException{
|
ICConfigurationDescription base) throws CoreException{
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
|
@ -364,8 +363,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return fActiveCfgInfo.getConfiguration();
|
return fActiveCfgInfo.getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFirstCfgId(){
|
private String getFirstCfgId() {
|
||||||
if(!fCfgMap.isEmpty()){
|
if (!fCfgMap.isEmpty()) {
|
||||||
return fCfgMap.keySet().iterator().next();
|
return fCfgMap.keySet().iterator().next();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -378,9 +377,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription getConfigurationByName(String name) {
|
public ICConfigurationDescription getConfigurationByName(String name) {
|
||||||
for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
ICConfigurationDescription cfg = iter.next();
|
ICConfigurationDescription cfg = iter.next();
|
||||||
if(name.equals(cfg.getName()))
|
if (name.equals(cfg.getName()))
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -393,18 +392,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeConfiguration(String name) throws WriteAccessException {
|
public void removeConfiguration(String name) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
|
|
||||||
CConfigurationDescription cfgDes = (CConfigurationDescription)getConfigurationByName(name);
|
CConfigurationDescription cfgDes = (CConfigurationDescription) getConfigurationByName(name);
|
||||||
if(cfgDes != null){
|
if (cfgDes != null) {
|
||||||
cfgDes.removeConfiguration();
|
cfgDes.removeConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void configurationRemoved(CConfigurationDescription des){
|
void configurationRemoved(CConfigurationDescription des) {
|
||||||
fCfgMap.remove(des.getId());
|
fCfgMap.remove(des.getId());
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
|
|
||||||
|
@ -414,25 +412,24 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
((CConfigurationDescription)cfg).removeConfiguration();
|
((CConfigurationDescription) cfg).removeConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setActiveConfiguration(
|
public void setActiveConfiguration(
|
||||||
ICConfigurationDescription cfg) throws WriteAccessException {
|
ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
if(cfg == null)
|
if (cfg == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
|
||||||
fActiveCfgInfo.setConfiguration(cfg);
|
fActiveCfgInfo.setConfiguration(cfg);
|
||||||
|
|
||||||
if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
fSettingCfgInfo.setConfiguration(cfg);
|
fSettingCfgInfo.setConfiguration(cfg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -492,10 +489,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateChild(CDataProxy child, boolean write) {
|
public void updateChild(CDataProxy child, boolean write) {
|
||||||
if(write){
|
if (write) {
|
||||||
try {
|
try {
|
||||||
String oldId = child.getId();
|
String oldId = child.getId();
|
||||||
CConfigurationDescription cfgDes = ((CConfigurationDescription)child);
|
CConfigurationDescription cfgDes = ((CConfigurationDescription) child);
|
||||||
cfgDes.doWritable();
|
cfgDes.doWritable();
|
||||||
updateMap(cfgDes, oldId);
|
updateMap(cfgDes, oldId);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -504,8 +501,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMap(CConfigurationDescription des, String oldId){
|
void updateMap(CConfigurationDescription des, String oldId) {
|
||||||
if(!oldId.equals(des.getId())){
|
if (!oldId.equals(des.getId())) {
|
||||||
fCfgMap.remove(oldId);
|
fCfgMap.remove(oldId);
|
||||||
fCfgMap.put(des.getId(), des);
|
fCfgMap.put(des.getId(), des);
|
||||||
}
|
}
|
||||||
|
@ -515,26 +512,26 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
if (fRootStorageElement == null)
|
if (fRootStorageElement == null)
|
||||||
throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$
|
throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$
|
||||||
|
|
||||||
// if(fRootStorageElement == null){
|
// if (fRootStorageElement == null) {
|
||||||
// fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
|
// fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
|
||||||
// }
|
// }
|
||||||
return fRootStorageElement;
|
return fRootStorageElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICStorageElement doGetCachedRootStorageElement(){
|
// ICStorageElement doGetCachedRootStorageElement() {
|
||||||
// return fRootStorageElement;
|
// return fRootStorageElement;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ICSettingsStorage getStorageBase() throws CoreException{
|
ICSettingsStorage getStorageBase() throws CoreException{
|
||||||
if(fStorage == null)
|
if (fStorage == null)
|
||||||
// fStorage = new CStorage((InternalXmlStorageElement)getRootStorageElement());
|
// fStorage = new CStorage((InternalXmlStorageElement) getRootStorageElement());
|
||||||
throw ExceptionFactory.createCoreException("CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$
|
throw ExceptionFactory.createCoreException("CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$
|
||||||
return fStorage;
|
return fStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException {
|
public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
|
@ -542,7 +539,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{
|
public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
|
@ -550,47 +547,48 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsDescriptionPersistence() {
|
boolean needsDescriptionPersistence() {
|
||||||
if(fIsModified)
|
if (fIsModified)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(fPrefs.isModified())
|
if (fPrefs.isModified())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(fStorage.isModified())
|
if (fStorage.isModified())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for(ICConfigurationDescription cfgDes : fCfgMap.values())
|
for (ICConfigurationDescription cfgDes : fCfgMap.values()) {
|
||||||
if(cfgDes.isModified())
|
if (cfgDes.isModified())
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
if(needsDescriptionPersistence())
|
if (needsDescriptionPersistence())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(needsActiveCfgPersistence())
|
if (needsActiveCfgPersistence())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(needsSettingCfgPersistence())
|
if (needsSettingCfgPersistence())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setModified(boolean modified){
|
private void setModified(boolean modified) {
|
||||||
fIsModified = modified;
|
fIsModified = modified;
|
||||||
|
|
||||||
if(!modified){
|
if (!modified) {
|
||||||
fActiveCfgInfo.fIsCfgModified = false;
|
fActiveCfgInfo.fIsCfgModified = false;
|
||||||
|
|
||||||
fSettingCfgInfo.fIsCfgModified = false;
|
fSettingCfgInfo.fIsCfgModified = false;
|
||||||
|
|
||||||
fPrefs.setModified(false);
|
fPrefs.setModified(false);
|
||||||
|
|
||||||
//no need to do that for config cache since they always maintain the "isModified == false"
|
// no need to do that for config cache since they always maintain the "isModified == false"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,8 +612,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription getDefaultSettingConfiguration(){
|
public ICConfigurationDescription getDefaultSettingConfiguration() {
|
||||||
if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
return getActiveConfiguration();
|
return getActiveConfiguration();
|
||||||
|
|
||||||
return fSettingCfgInfo.getConfiguration();
|
return fSettingCfgInfo.getConfiguration();
|
||||||
|
@ -623,14 +621,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
if(cfg == null)
|
if (cfg == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
|
||||||
fSettingCfgInfo.setConfiguration(cfg);
|
fSettingCfgInfo.setConfiguration(cfg);
|
||||||
|
|
||||||
if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
fActiveCfgInfo.setConfiguration(cfg);
|
fActiveCfgInfo.setConfiguration(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,10 +639,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSessionProperty(QualifiedName name, Object value) {
|
public void setSessionProperty(QualifiedName name, Object value) {
|
||||||
if(value != null)
|
if (value != null) {
|
||||||
fPropertiesMap.put(name, value);
|
fPropertiesMap.put(name, value);
|
||||||
else
|
} else {
|
||||||
fPropertiesMap.remove(name);
|
fPropertiesMap.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
}
|
}
|
||||||
|
@ -654,41 +653,41 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
getStorageBase().removeStorage(id);
|
getStorageBase().removeStorage(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchToCachedAppliedData(CProjectDescription appliedCache){
|
void switchToCachedAppliedData(CProjectDescription appliedCache) {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ICConfigurationDescription[] cfgs = appliedCache.getConfigurations();
|
ICConfigurationDescription[] cfgs = appliedCache.getConfigurations();
|
||||||
for(int i = 0; i < cfgs.length; i++){
|
for (int i = 0; i < cfgs.length; i++) {
|
||||||
CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache)cfgs[i];
|
CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache) cfgs[i];
|
||||||
CConfigurationDescription des = (CConfigurationDescription)getChildSettingById(cfgCache.getId());
|
CConfigurationDescription des = (CConfigurationDescription) getChildSettingById(cfgCache.getId());
|
||||||
if(des != null){
|
if (des != null) {
|
||||||
des.setData(cfgCache);
|
des.setData(cfgCache);
|
||||||
// ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false);
|
// ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false);
|
||||||
// rcDes = des.getResourceDescription(new Path("dd"), false);
|
// rcDes = des.getResourceDescription(new Path("dd"), false);
|
||||||
// ICBuildSetting bs = des.getBuildSetting();
|
// ICBuildSetting bs = des.getBuildSetting();
|
||||||
// ICLanguageSetting lss[] = ((ICFolderDescription)rcDes).getLanguageSettings();
|
// ICLanguageSetting lss[] = ((ICFolderDescription) rcDes).getLanguageSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkPersistActiveCfg(String oldId, boolean force){
|
boolean checkPersistActiveCfg(String oldId, boolean force) {
|
||||||
return fActiveCfgInfo.store(oldId, force);
|
return fActiveCfgInfo.store(oldId, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkPersistSettingCfg(String oldId, boolean force){
|
boolean checkPersistSettingCfg(String oldId, boolean force) {
|
||||||
return fSettingCfgInfo.store(oldId, force);
|
return fSettingCfgInfo.store(oldId, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsActiveCfgPersistence(){
|
boolean needsActiveCfgPersistence() {
|
||||||
return fActiveCfgInfo.fIsCfgModified;
|
return fActiveCfgInfo.fIsCfgModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsSettingCfgPersistence(){
|
boolean needsSettingCfgPersistence() {
|
||||||
return fSettingCfgInfo.fIsCfgModified;
|
return fSettingCfgInfo.fIsCfgModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
CProjectDescriptionPreferences getPreferences(){
|
CProjectDescriptionPreferences getPreferences() {
|
||||||
return fPrefs;
|
return fPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,10 +718,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCdtProjectCreated() {
|
public void setCdtProjectCreated() {
|
||||||
if(!fIsCreating)
|
if (!fIsCreating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
fIsCreating = false;
|
fIsCreating = false;
|
||||||
|
@ -730,11 +729,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public void touch() throws WriteAccessException {
|
public void touch() throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public interface IASTNodeSelector {
|
public interface IASTNodeSelector {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name for the exact given range, or <code>null</code> if there is no such node.
|
* Returns the name for the exact given range, or <code>null</code> if there is no such node.
|
||||||
* Will not return an implicit name.
|
* Will not return an implicit name.
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IType extends Cloneable {
|
public interface IType extends Cloneable {
|
||||||
public static final IType[] EMPTY_TYPE_ARRAY = new IType[0];
|
public static final IType[] EMPTY_TYPE_ARRAY = {};
|
||||||
public static final ASTTypeMatcher TYPE_MATCHER = new ASTTypeMatcher();
|
public static final ASTTypeMatcher TYPE_MATCHER = new ASTTypeMatcher();
|
||||||
|
|
||||||
public Object clone();
|
public Object clone();
|
||||||
|
|
|
@ -15,7 +15,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ITypedef extends IBinding, IType {
|
public interface ITypedef extends IBinding, IType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type that this thing is a typedef of
|
* Returns the type that this thing is a typedef of
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,9 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPPointerToMemberType extends IPointerType {
|
public interface ICPPPointerToMemberType extends IPointerType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class to whose members this points to.
|
* Returns the class to whose members this points to.
|
||||||
* @return Either ICPPClassType or ICPPTeplateTypeParameter.
|
* @return Either ICPPClassType or ICPPTeplateTypeParameter.
|
||||||
*/
|
*/
|
||||||
public IType getMemberOfClass();
|
public IType getMemberOfClass();
|
||||||
|
|
|
@ -85,7 +85,7 @@ public abstract class ArithmeticConversion {
|
||||||
|
|
||||||
private boolean isArithmeticOrUnscopedEnum(IType op1) {
|
private boolean isArithmeticOrUnscopedEnum(IType op1) {
|
||||||
if (op1 instanceof IBasicType) {
|
if (op1 instanceof IBasicType) {
|
||||||
final Kind kind = ((IBasicType)op1).getKind();
|
final Kind kind = ((IBasicType) op1).getKind();
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case eUnspecified:
|
case eUnspecified:
|
||||||
case eVoid:
|
case eVoid:
|
||||||
|
@ -190,7 +190,8 @@ public abstract class ArithmeticConversion {
|
||||||
return signedType;
|
return signedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
return createBasicType(signedType.getKind(), changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
|
return createBasicType(signedType.getKind(),
|
||||||
|
changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBasicType promote(IType type, Domain domain) {
|
private IBasicType promote(IType type, Domain domain) {
|
||||||
|
@ -331,21 +332,21 @@ public abstract class ArithmeticConversion {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (basicTarget.isShort()) {
|
if (basicTarget.isShort()) {
|
||||||
return n < (Short.MAX_VALUE + 1L)*2;
|
return n < (Short.MAX_VALUE + 1L) * 2;
|
||||||
}
|
}
|
||||||
// Can't represent long longs with java longs.
|
// Can't represent long longs with java longs.
|
||||||
if (basicTarget.isLong() || basicTarget.isLongLong()) {
|
if (basicTarget.isLong() || basicTarget.isLongLong()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return n < (Integer.MAX_VALUE + 1L)*2;
|
return n < (Integer.MAX_VALUE + 1L) * 2;
|
||||||
|
|
||||||
case eFloat:
|
case eFloat:
|
||||||
float f= n;
|
float f= n;
|
||||||
return (long)f == n;
|
return (long) f == n;
|
||||||
|
|
||||||
case eDouble:
|
case eDouble:
|
||||||
double d= n;
|
double d= n;
|
||||||
return (long)d == n;
|
return (long) d == n;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -54,11 +54,7 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
copy.op = op;
|
copy.op = op;
|
||||||
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
|
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
|
||||||
copy.setOperand2(operand2 == null ? null : operand2.copy(style));
|
copy.setOperand2(operand2 == null ? null : operand2.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,9 +114,9 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
|
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
switch (action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +143,7 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
|
|
||||||
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
|
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
|
||||||
N stack= new N(bexpr);
|
N stack= new N(bexpr);
|
||||||
while(stack != null) {
|
while (stack != null) {
|
||||||
IASTBinaryExpression expr= stack.fExpression;
|
IASTBinaryExpression expr= stack.fExpression;
|
||||||
if (stack.fState == 0) {
|
if (stack.fState == 0) {
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
|
|
|
@ -30,7 +30,6 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
private int operator;
|
private int operator;
|
||||||
private IASTExpression operand;
|
private IASTExpression operand;
|
||||||
|
|
||||||
|
|
||||||
public CASTUnaryExpression() {
|
public CASTUnaryExpression() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +45,9 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CASTUnaryExpression copy(CopyStyle style) {
|
public CASTUnaryExpression copy(CopyStyle style) {
|
||||||
CASTUnaryExpression copy = new CASTUnaryExpression(operator, operand == null ? null
|
CASTUnaryExpression copy =
|
||||||
: operand.copy(style));
|
new CASTUnaryExpression(operator, operand == null ? null : operand.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,22 +77,22 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( operand != null ) if( !operand.accept( action ) ) return false;
|
if (operand != null && !operand.accept(action)) return false;
|
||||||
|
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -105,10 +100,9 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == operand )
|
if (child == operand) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
operand = (IASTExpression) other;
|
operand = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +115,7 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
}
|
}
|
||||||
final IType exprType = getOperand().getExpressionType();
|
final IType exprType = getOperand().getExpressionType();
|
||||||
IType type = CVisitor.unwrapTypedefs(exprType);
|
IType type = CVisitor.unwrapTypedefs(exprType);
|
||||||
switch(op) {
|
switch (op) {
|
||||||
case op_star:
|
case op_star:
|
||||||
if (type instanceof IPointerType || type instanceof IArrayType) {
|
if (type instanceof IPointerType || type instanceof IArrayType) {
|
||||||
return ((ITypeContainer) type).getType();
|
return ((ITypeContainer) type).getType();
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
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.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion;
|
import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion;
|
||||||
|
|
||||||
public class CPPArithmeticConversion extends ArithmeticConversion {
|
public class CPPArithmeticConversion extends ArithmeticConversion {
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
* An example is the GCC built-in typedef: typedef char * __builtin_va_list;
|
* An example is the GCC built-in typedef: typedef char * __builtin_va_list;
|
||||||
*/
|
*/
|
||||||
public class CPPImplicitTypedef extends CPPTypedef {
|
public class CPPImplicitTypedef extends CPPTypedef {
|
||||||
private IType type=null;
|
private IType type;
|
||||||
private char[] name=null;
|
private char[] name;
|
||||||
private IScope scope=null;
|
private IScope scope;
|
||||||
|
|
||||||
public CPPImplicitTypedef(IType type, char[] name, IScope scope) {
|
public CPPImplicitTypedef(IType type, char[] name, IScope scope) {
|
||||||
super(null);
|
super(null);
|
||||||
|
@ -135,5 +135,4 @@ public class CPPImplicitTypedef extends CPPTypedef {
|
||||||
public boolean isGloballyQualified() {
|
public boolean isGloballyQualified() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,20 +38,20 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binding for a c++ function parameter
|
* Binding for a c++ function parameter.
|
||||||
*/
|
*/
|
||||||
public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding, ICPPTwoPhaseBinding {
|
public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding, ICPPTwoPhaseBinding {
|
||||||
|
|
||||||
public static class CPPParameterProblem extends ProblemBinding implements ICPPParameter {
|
public static class CPPParameterProblem extends ProblemBinding implements ICPPParameter {
|
||||||
public CPPParameterProblem(IASTNode node, int id, char[] arg) {
|
public CPPParameterProblem(IASTNode node, int id, char[] arg) {
|
||||||
super(node, id, arg);
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IType fType = null;
|
private IType fType;
|
||||||
private IASTName[] fDeclarations = null;
|
private IASTName[] fDeclarations;
|
||||||
private int fPosition;
|
private int fPosition;
|
||||||
|
|
||||||
|
|
||||||
public CPPParameter(IASTName name, int pos) {
|
public CPPParameter(IASTName name, int pos) {
|
||||||
this.fDeclarations = new IASTName[] { name };
|
this.fDeclarations = new IASTName[] { name };
|
||||||
fPosition= pos;
|
fPosition= pos;
|
||||||
|
@ -67,17 +67,11 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
return getType() instanceof ICPPParameterPackType;
|
return getType() instanceof ICPPParameterPackType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return fDeclarations;
|
return fDeclarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -121,17 +115,12 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return new String(getNameCharArray());
|
return new String(getNameCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
IASTName name = getPrimaryDeclaration();
|
IASTName name = getPrimaryDeclaration();
|
||||||
|
@ -140,26 +129,17 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
return CharArrayUtils.EMPTY;
|
return CharArrayUtils.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
|
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
|
||||||
*/
|
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
if (fDeclarations != null)
|
if (fDeclarations != null)
|
||||||
return fDeclarations[0];
|
return fDeclarations[0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (fType == null && fDeclarations != null) {
|
if (fType == null && fDeclarations != null) {
|
||||||
|
@ -175,75 +155,48 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
return fType;
|
return fType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getQualifiedName() {
|
public String[] getQualifiedName() {
|
||||||
return new String[] { getName() };
|
return new String[] { getName() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public char[][] getQualifiedNameCharArray() {
|
public char[][] getQualifiedNameCharArray() {
|
||||||
return new char[][] { getNameCharArray() };
|
return new char[][] { getNameCharArray() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGloballyQualified() {
|
public boolean isGloballyQualified() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addDefinition(IASTNode node) {
|
public void addDefinition(IASTNode node) {
|
||||||
addDeclaration(node);
|
addDeclaration(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
//7.1.1-5 extern can not be used in the declaration of a parameter
|
// 7.1.1-5 extern can not be used in the declaration of a parameter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable#isMutable()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
//7.1.1-8 mutable can only apply to class members
|
// 7.1.1-8 mutable can only apply to class members
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
private IType type;
|
private IType type;
|
||||||
|
|
||||||
public CPPTypedef(IASTName name) {
|
public CPPTypedef(IASTName name) {
|
||||||
// bug 223020 even though qualified names are not legal, we need to deal with them.
|
// Bug 223020 even though qualified names are not legal, we need to deal with them.
|
||||||
if (name != null && name.getParent() instanceof ICPPASTQualifiedName) {
|
if (name != null && name.getParent() instanceof ICPPASTQualifiedName) {
|
||||||
name= (IASTName) name.getParent();
|
name= (IASTName) name.getParent();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
if (o instanceof ITypedef) {
|
if (o instanceof ITypedef) {
|
||||||
IType t = getType();
|
IType t = getType();
|
||||||
if (t != null)
|
if (t != null)
|
||||||
return t.isSameType(((ITypedef)o).getType());
|
return t.isSameType(((ITypedef) o).getType());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
try {
|
try {
|
||||||
t = (IType) super.clone();
|
t = (IType) super.clone();
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//not going to happen
|
// Not going to happen
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
@Override
|
@Override
|
||||||
public boolean isGloballyQualified() throws DOMException {
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
IScope scope = getScope();
|
IScope scope = getScope();
|
||||||
while(scope != null) {
|
while (scope != null) {
|
||||||
if (scope instanceof ICPPBlockScope)
|
if (scope instanceof ICPPBlockScope)
|
||||||
return false;
|
return false;
|
||||||
scope = scope.getParent();
|
scope = scope.getParent();
|
||||||
|
|
|
@ -2017,7 +2017,8 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return createAutoType(autoInitClause, declSpec, declarator);
|
return createAutoType(autoInitClause, declSpec, declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec,
|
||||||
|
IASTDeclarator declarator) {
|
||||||
// C++0x: 7.1.6.4
|
// C++0x: 7.1.6.4
|
||||||
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
||||||
// Detected a self referring auto type, e.g.: auto x = x;
|
// Detected a self referring auto type, e.g.: auto x = x;
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods for computing the type of an expression
|
* Methods for computing the type of an expression
|
||||||
*/
|
*/
|
||||||
|
@ -41,7 +40,6 @@ public class ExpressionTypes {
|
||||||
return Conversions.lvalue_to_rvalue(type);
|
return Conversions.lvalue_to_rvalue(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) {
|
public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) {
|
||||||
final ICPPFunctionType ft = function.getType();
|
final ICPPFunctionType ft = function.getType();
|
||||||
return valueCategoryFromReturnType(ft.getReturnType());
|
return valueCategoryFromReturnType(ft.getReturnType());
|
||||||
|
|
Loading…
Add table
Reference in a new issue