From 3a6ffef8f855652606f74a14d4b15478c81e5db4 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Wed, 5 May 2004 16:42:41 +0000 Subject: [PATCH] Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=60944 --- .../parser/tests/CompleteParseASTTest.java | 636 +++++++++--------- .../parser/ast/IASTSimpleTypeSpecifier.java | 1 - .../parser/ast/IASTTypedefDeclaration.java | 1 + .../core/parser/ast/complete/ASTTypedef.java | 27 + .../ast/quick/ASTTypedefDeclaration.java | 11 +- 5 files changed, 368 insertions(+), 308 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index 9f86a4a13a2..fc38c2059ff 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -64,67 +64,67 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testEmptyCompilationUnit() throws Exception { - IASTScope compilationUnit = parse( "// no real code "); + IASTScope compilationUnit = parse( "// no real code "); //$NON-NLS-1$ assertNotNull( compilationUnit ); assertFalse( compilationUnit.getDeclarations().hasNext() ); } public void testSimpleNamespace() throws Exception { - Iterator declarations = parse( "namespace A { }").getDeclarations(); + Iterator declarations = parse( "namespace A { }").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next(); - assertEquals( namespaceDefinition.getName(), "A" ); + assertEquals( namespaceDefinition.getName(), "A" ); //$NON-NLS-1$ assertFalse( getDeclarations( namespaceDefinition ).hasNext() ); } public void testMultipleNamespaceDefinitions() throws Exception { - Iterator declarations = parse( "namespace A { } namespace A { }").getDeclarations(); + Iterator declarations = parse( "namespace A { } namespace A { }").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next(); - assertEquals( namespaceDefinition.getName(), "A" ); + assertEquals( namespaceDefinition.getName(), "A" ); //$NON-NLS-1$ namespaceDefinition = (IASTNamespaceDefinition)declarations.next(); - assertEquals( namespaceDefinition.getName(), "A" ); + assertEquals( namespaceDefinition.getName(), "A" ); //$NON-NLS-1$ assertFalse( getDeclarations( namespaceDefinition ).hasNext() ); } public void testNestedNamespaceDefinitions() throws Exception { - Iterator declarations = parse( "namespace A { namespace B { } }").getDeclarations(); + Iterator declarations = parse( "namespace A { namespace B { } }").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next(); - assertEquals( namespaceDefinition.getName(), "A" ); + assertEquals( namespaceDefinition.getName(), "A" ); //$NON-NLS-1$ assertFalse( declarations.hasNext() ); Iterator subDeclarations = getDeclarations( namespaceDefinition ); IASTNamespaceDefinition subDeclaration = (IASTNamespaceDefinition)subDeclarations.next(); - assertEquals( subDeclaration.getName(), "B" ); + assertEquals( subDeclaration.getName(), "B" ); //$NON-NLS-1$ assertFalse( subDeclarations.hasNext() ); } public void testEmptyClassDeclaration() throws Exception { - Iterator declarations = parse( "class A { };").getDeclarations(); + Iterator declarations = parse( "class A { };").getDeclarations(); //$NON-NLS-1$ IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)declarations.next(); IASTClassSpecifier classSpec = (IASTClassSpecifier)abs.getTypeSpecifier(); - assertEquals( classSpec.getName(), "A"); + assertEquals( classSpec.getName(), "A"); //$NON-NLS-1$ assertFalse( getDeclarations( classSpec ).hasNext() ); assertFalse( declarations.hasNext() ); } public void testSimpleSubclass() throws Exception { - Iterator declarations = parse( "class A { }; class B : public A { };").getDeclarations(); + Iterator declarations = parse( "class A { }; class B : public A { };").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); Iterator parentClasses = classB.getBaseClauses(); IASTBaseSpecifier baseClass = (IASTBaseSpecifier)parentClasses.next(); assertEquals( classA, baseClass.getParentClassSpecifier() ); - assertEquals( baseClass.getParentClassName(), "A"); + assertEquals( baseClass.getParentClassName(), "A"); //$NON-NLS-1$ assertEquals( baseClass.getAccess(), ASTAccessVisibility.PUBLIC); assertFalse( baseClass.isVirtual() ); } public void testNestedSubclass() throws Exception { - Iterator declarations = parse( "namespace N { class A { }; } class B : protected virtual N::A { };").getDeclarations(); + Iterator declarations = parse( "namespace N { class A { }; } class B : protected virtual N::A { };").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)getDeclarations( namespaceDefinition).next() ).getTypeSpecifier(); IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); @@ -136,39 +136,39 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleVariable() throws Exception { - Iterator declarations = parse( "int x;").getDeclarations(); + Iterator declarations = parse( "int x;").getDeclarations(); //$NON-NLS-1$ IASTVariable v = (IASTVariable)declarations.next(); - assertEquals( v.getName(), "x"); + assertEquals( v.getName(), "x"); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)v.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.INT ); } public void testSimpleClassReferenceVariable() throws Exception { - Iterator declarations = parse( "class A { }; A x;").getDeclarations(); + Iterator declarations = parse( "class A { }; A x;").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTVariable v = (IASTVariable)declarations.next(); - assertEquals( v.getName(), "x"); + assertEquals( v.getName(), "x"); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)v.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), classA ); } public void testNestedClassReferenceVariable() throws Exception { - Iterator declarations = parse( "namespace N { class A { }; } N::A x;").getDeclarations(); + Iterator declarations = parse( "namespace N { class A { }; } N::A x;").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)declarations.next(); Iterator iter = getDeclarations( namespace ); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)iter.next()).getTypeSpecifier(); IASTVariable v = (IASTVariable)declarations.next(); - assertEquals( v.getName(), "x"); + assertEquals( v.getName(), "x"); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)v.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), classA ); assertEquals( callback.getReferences().size(), 2 ); } public void testMultipleDeclaratorsVariable() throws Exception { - Iterator declarations = parse( "class A { }; A x, y, z;").getDeclarations(); + Iterator declarations = parse( "class A { }; A x, y, z;").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTVariable v = (IASTVariable)declarations.next(); - assertEquals( v.getName(), "x"); + assertEquals( v.getName(), "x"); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)v.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), classA ); assertEquals( callback.getReferences().size(), 3 ); Iterator i = callback.getReferences().iterator(); @@ -178,27 +178,27 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleField() throws Exception { - Iterator declarations = parse( "class A { double x; };").getDeclarations(); + Iterator declarations = parse( "class A { double x; };").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); Iterator fields =getDeclarations(classA); IASTField f = (IASTField)fields.next(); - assertEquals( f.getName(), "x" ); + assertEquals( f.getName(), "x" ); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)f.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.DOUBLE ); } public void testUsingClauses() throws Exception { - Iterator declarations = parse( "namespace A { namespace B { int x; class C { static int y = 5; }; } } \n using namespace A::B;\n using A::B::x;using A::B::C;using A::B::C::y;").getDeclarations(); + Iterator declarations = parse( "namespace A { namespace B { int x; class C { static int y = 5; }; } } \n using namespace A::B;\n using A::B::x;using A::B::C;using A::B::C::y;").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceA = (IASTNamespaceDefinition)declarations.next(); IASTNamespaceDefinition namespaceB = (IASTNamespaceDefinition)getDeclarations( namespaceA ).next(); Iterator i = getDeclarations( namespaceB ); IASTVariable variableX = (IASTVariable)i.next(); IASTClassSpecifier classC = ((IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier()); IASTField fieldY = (IASTField)getDeclarations( classC ).next(); - assertQualifiedName( fieldY.getFullyQualifiedName(), new String [] { "A", "B", "C", "y" } ); + assertQualifiedName( fieldY.getFullyQualifiedName(), new String [] { "A", "B", "C", "y" } ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ IASTUsingDirective directive = (IASTUsingDirective)declarations.next(); assertEquals( directive.getNamespaceDefinition(), namespaceB ); - assertEquals( directive.getNamespaceName(), "A::B" ); + assertEquals( directive.getNamespaceName(), "A::B" ); //$NON-NLS-1$ IASTUsingDeclaration declaration = (IASTUsingDeclaration)declarations.next(); assertEquals( declaration.getUsingTypes().next(), variableX ); declaration = (IASTUsingDeclaration)declarations.next(); @@ -211,35 +211,35 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testEnumerations() throws Exception { - Iterator declarations = parse( "namespace A { enum E { e1, e2, e3 }; E varE;}").getDeclarations(); + Iterator declarations = parse( "namespace A { enum E { e1, e2, e3 }; E varE;}").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceA = (IASTNamespaceDefinition)declarations.next(); Iterator namespaceMembers = getDeclarations( namespaceA ); IASTEnumerationSpecifier enumE = (IASTEnumerationSpecifier)((IASTAbstractTypeSpecifierDeclaration)namespaceMembers.next()).getTypeSpecifier(); - assertEquals( enumE.getName(), "E"); - assertQualifiedName( enumE.getFullyQualifiedName(), new String [] { "A", "E" } ); + assertEquals( enumE.getName(), "E"); //$NON-NLS-1$ + assertQualifiedName( enumE.getFullyQualifiedName(), new String [] { "A", "E" } ); //$NON-NLS-1$ //$NON-NLS-2$ Iterator enumerators = enumE.getEnumerators(); IASTEnumerator enumerator_e1 = (IASTEnumerator)enumerators.next(); IASTEnumerator enumerator_e2 = (IASTEnumerator)enumerators.next(); IASTEnumerator enumerator_e3 = (IASTEnumerator)enumerators.next(); assertFalse( enumerators.hasNext() ); - assertEquals( enumerator_e1.getName(), "e1"); - assertEquals( enumerator_e2.getName(), "e2"); - assertEquals( enumerator_e3.getName(), "e3"); + assertEquals( enumerator_e1.getName(), "e1"); //$NON-NLS-1$ + assertEquals( enumerator_e2.getName(), "e2"); //$NON-NLS-1$ + assertEquals( enumerator_e3.getName(), "e3"); //$NON-NLS-1$ IASTVariable varE = (IASTVariable)namespaceMembers.next(); assertEquals( ((IASTSimpleTypeSpecifier)varE.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), enumE ); } public void testSimpleFunction() throws Exception { - Iterator declarations = parse( "void foo( void );").getDeclarations(); + Iterator declarations = parse( "void foo( void );").getDeclarations(); //$NON-NLS-1$ IASTFunction function = (IASTFunction)declarations.next(); - assertEquals( function.getName(), "foo" ); + assertEquals( function.getName(), "foo" ); //$NON-NLS-1$ assertEquals( callback.getReferences().size(), 0 ); } public void testSimpleFunctionWithTypes() throws Exception { - Iterator declarations = parse( "class A { public: \n class B { }; }; const A::B & foo( A * myParam );").getDeclarations(); + Iterator declarations = parse( "class A { public: \n class B { }; }; const A::B & foo( A * myParam );").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTFunction function = (IASTFunction)declarations.next(); assertEquals( callback.getReferences().size(), 3 ); @@ -247,25 +247,25 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleMethod() throws Exception { - Iterator declarations = parse( "class A { void foo(); };").getDeclarations(); + Iterator declarations = parse( "class A { void foo(); };").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTMethod method = (IASTMethod)getDeclarations( classA ).next(); - assertEquals( method.getName(), "foo" ); + assertEquals( method.getName(), "foo" ); //$NON-NLS-1$ } public void testSimpleMethodWithTypes() throws Exception { - Iterator declarations = parse( "class U { }; class A { U foo( U areDumb ); };").getDeclarations(); + Iterator declarations = parse( "class U { }; class A { U foo( U areDumb ); };").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classU = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTMethod method = (IASTMethod)getDeclarations( classA ).next(); - assertEquals( method.getName(), "foo" ); + assertEquals( method.getName(), "foo" ); //$NON-NLS-1$ assertEquals( callback.getReferences().size(), 2 ); } public void testUsingDeclarationWithFunctionsAndMethods() throws Exception { - Iterator declarations = parse( "namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;" ).getDeclarations(); + Iterator declarations = parse( "namespace N { int foo(void); } class A { static int bar(void); }; using N::foo; using ::A::bar;" ).getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceN = (IASTNamespaceDefinition)declarations.next(); IASTFunction fooFunction = (IASTFunction)(getDeclarations(namespaceN).next()); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); @@ -282,16 +282,16 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testLinkageSpec() throws Exception { - IASTLinkageSpecification linkage = (IASTLinkageSpecification)parse( "extern \"C\" { int foo(); }").getDeclarations().next(); + IASTLinkageSpecification linkage = (IASTLinkageSpecification)parse( "extern \"C\" { int foo(); }").getDeclarations().next(); //$NON-NLS-1$ Iterator i = getDeclarations( linkage ); IASTFunction f = (IASTFunction)i.next(); - assertEquals( f.getName(),"foo"); + assertEquals( f.getName(),"foo"); //$NON-NLS-1$ } public void testBogdansExample() throws Exception { - IASTNamespaceDefinition namespaceA = (IASTNamespaceDefinition)parse( "namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ").getDeclarations().next(); + IASTNamespaceDefinition namespaceA = (IASTNamespaceDefinition)parse( "namespace A { namespace B { enum e1{e_1,e_2}; int x; class C { static int y = 5; }; }} ").getDeclarations().next(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceB = (IASTNamespaceDefinition)(getDeclarations(namespaceA).next()); Iterator subB = getDeclarations( namespaceB ); IASTEnumerationSpecifier enumE1 = (IASTEnumerationSpecifier)((IASTAbstractTypeSpecifierDeclaration)subB.next()).getTypeSpecifier(); @@ -304,7 +304,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testAndrewsExample() throws Exception { - Iterator declarations = parse( "namespace N{ class A {}; } using namespace N; class B: public A{};").getDeclarations(); + Iterator declarations = parse( "namespace N{ class A {}; } using namespace N; class B: public A{};").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceN = (IASTNamespaceDefinition)declarations.next(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)getDeclarations( namespaceN ).next()).getTypeSpecifier(); IASTUsingDirective usingClause = (IASTUsingDirective)declarations.next(); @@ -316,18 +316,18 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleTypedef() throws Exception { - Iterator iter = parse( "typedef int myInt;\n myInt var;").getDeclarations(); + Iterator iter = parse( "typedef int myInt;\n myInt var;").getDeclarations(); //$NON-NLS-1$ IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)iter.next(); - assertEquals( typedef.getName(), "myInt"); + assertEquals( typedef.getName(), "myInt"); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)typedef.getAbstractDeclarator().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.INT ); IASTVariable v = (IASTVariable)iter.next(); - assertEquals( v.getName(), "var"); + assertEquals( v.getName(), "var"); //$NON-NLS-1$ assertEquals( callback.getReferences().size(), 1 ); } public void testComplexTypedef() throws Exception { - Iterator declarations = parse( "class A{ }; typedef A ** A_DOUBLEPTR;").getDeclarations(); + Iterator declarations = parse( "class A{ }; typedef A ** A_DOUBLEPTR;").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)declarations.next(); assertEquals( ((IASTSimpleTypeSpecifier)typedef.getAbstractDeclarator().getTypeSpecifier()).getTypeSpecifier(), classA ); @@ -349,7 +349,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug40842() throws Exception{ Writer code = new StringWriter(); - code.write("class A {} a;\n"); + code.write("class A {} a;\n"); //$NON-NLS-1$ Iterator i = parse(code.toString()).getDeclarations(); IASTVariable instanceA = (IASTVariable)i.next(); assertFalse( i.hasNext() ); @@ -358,7 +358,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testNestedClassname() throws Exception { - Iterator declarations = parse( "namespace A { } \n class A::B { };").getDeclarations(); + Iterator declarations = parse( "namespace A { } \n class A::B { };").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceA = (IASTNamespaceDefinition)declarations.next(); IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier(); assertEquals( classB.getOwnerScope(), namespaceA ); @@ -367,27 +367,27 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testForwardDeclaration() throws Exception { - Iterator i = parse( "class forward;").getDeclarations(); + Iterator i = parse( "class forward;").getDeclarations(); //$NON-NLS-1$ assertTrue( i.hasNext() ); IASTAbstractTypeSpecifierDeclaration d = (IASTAbstractTypeSpecifierDeclaration)i.next(); IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier)d.getTypeSpecifier(); - assertEquals( elab.getName(), "forward"); + assertEquals( elab.getName(), "forward"); //$NON-NLS-1$ assertEquals( elab.getClassKind(), ASTClassKind.CLASS ); } public void testElaboratedType() throws Exception { - Iterator i = parse( "class A; class A * a;").getDeclarations(); + Iterator i = parse( "class A; class A * a;").getDeclarations(); //$NON-NLS-1$ IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); - assertEquals( elab.getName(), "A" ); + assertEquals( elab.getName(), "A" ); //$NON-NLS-1$ IASTVariable variableA = (IASTVariable)i.next(); - assertEquals( variableA.getName(), "a"); + assertEquals( variableA.getName(), "a"); //$NON-NLS-1$ assertEquals( variableA.getAbstractDeclaration().getTypeSpecifier(), elab ); } public void testForewardDeclarationWithUsage() throws Exception { - Iterator declarations = parse( "class A; A * anA;class A { };").getDeclarations(); + Iterator declarations = parse( "class A; A * anA;class A { };").getDeclarations(); //$NON-NLS-1$ IASTAbstractTypeSpecifierDeclaration forewardDecl = (IASTAbstractTypeSpecifierDeclaration)declarations.next(); IASTVariable variable = (IASTVariable)declarations.next(); IASTAbstractTypeSpecifierDeclaration classDecl = (IASTAbstractTypeSpecifierDeclaration)declarations.next(); @@ -409,13 +409,13 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testASM() throws Exception { - IASTASMDefinition asm = (IASTASMDefinition)parse( "asm ( \"blah blah blah\" );" ).getDeclarations().next(); - assertEquals( asm.getBody(), "blah blah blah"); + IASTASMDefinition asm = (IASTASMDefinition)parse( "asm ( \"blah blah blah\" );" ).getDeclarations().next(); //$NON-NLS-1$ + assertEquals( asm.getBody(), "blah blah blah"); //$NON-NLS-1$ } public void testOverride() throws Exception { - Iterator i = parse( "void foo();\n void foo( int );\n").getDeclarations(); + Iterator i = parse( "void foo();\n void foo( int );\n").getDeclarations(); //$NON-NLS-1$ IASTFunction f1 = (IASTFunction)i.next(); IASTFunction f2 = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -423,7 +423,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleExpression() throws Exception { - Iterator i = parse( "int x; int y = x;").getDeclarations(); + Iterator i = parse( "int x; int y = x;").getDeclarations(); //$NON-NLS-1$ IASTVariable varX = (IASTVariable)i.next(); IASTVariable varY = (IASTVariable)i.next(); assertEquals( callback.getReferences().size(), 1 ); @@ -431,7 +431,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testParameterExpressions() throws Exception { - Iterator i = parse( "int x = 5; void foo( int sub = x ) { }").getDeclarations(); + Iterator i = parse( "int x = 5; void foo( int sub = x ) { }").getDeclarations(); //$NON-NLS-1$ IASTVariable varX = (IASTVariable)i.next(); IASTFunction funFoo = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -440,7 +440,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testNestedNamespaceExpression() throws Exception { - Iterator i = parse( "namespace A { int x = 666; } int y = A::x;").getDeclarations(); + Iterator i = parse( "namespace A { int x = 666; } int y = A::x;").getDeclarations(); //$NON-NLS-1$ IASTNamespaceDefinition namespaceA = (IASTNamespaceDefinition)i.next(); IASTVariable variableY = (IASTVariable)i.next(); assertFalse( i.hasNext() ); @@ -449,7 +449,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testConstructorChain() throws Exception { - Iterator i = parse( "int x = 5;\n class A \n{ public : \n int a; \n A() : a( x ) { } };").getDeclarations(); + Iterator i = parse( "int x = 5;\n class A \n{ public : \n int a; \n A() : a( x ) { } };").getDeclarations(); //$NON-NLS-1$ IASTVariable variableX = (IASTVariable)i.next(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); assertFalse( i.hasNext() ); @@ -466,7 +466,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testArrayModExpression() throws Exception { - Iterator i = parse( "const int x = 5; int y [ x ]; ").getDeclarations(); + Iterator i = parse( "const int x = 5; int y [ x ]; ").getDeclarations(); //$NON-NLS-1$ IASTVariable varX = (IASTVariable)i.next(); IASTVariable varY = (IASTVariable)i.next(); assertFalse( i.hasNext() ); @@ -476,7 +476,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testPointerVariable() throws Exception { - Iterator i = parse( "class A { }; A * anA;").getDeclarations(); + Iterator i = parse( "class A { }; A * anA;").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTVariable varAnA = (IASTVariable)i.next(); assertFalse( i.hasNext() ); @@ -487,7 +487,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testExceptionSpecification() throws Exception { - Iterator i = parse( "class A { }; void foo( void ) throw ( A );").getDeclarations(); + Iterator i = parse( "class A { }; void foo( void ) throw ( A );").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTFunction function = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -498,7 +498,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testNewExpressions() throws Exception { - Iterator declarations = parse( "int A; int B; int C; int D; int P; int*p = new (P) (A)[B][C][D];" ).getDeclarations(); + Iterator declarations = parse( "int A; int B; int C; int D; int P; int*p = new (P) (A)[B][C][D];" ).getDeclarations(); //$NON-NLS-1$ IASTVariable variableA = (IASTVariable)declarations.next(); IASTVariable variableB = (IASTVariable)declarations.next(); IASTVariable variableC = (IASTVariable)declarations.next(); @@ -516,7 +516,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug41520() throws Exception { - Iterator i = parse( "const int x = 666; const int y( x );").getDeclarations(); + Iterator i = parse( "const int x = 666; const int y( x );").getDeclarations(); //$NON-NLS-1$ IASTVariable variableX = (IASTVariable)i.next(); IASTVariable variableY = (IASTVariable)i.next(); assertFalse( i.hasNext() ); @@ -524,7 +524,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testNewXReferences() throws Exception { - Iterator declarations = parse( "const int max = 5;\n int * x = new int[max];").getDeclarations(); + Iterator declarations = parse( "const int max = 5;\n int * x = new int[max];").getDeclarations(); //$NON-NLS-1$ IASTVariable max = (IASTVariable) declarations.next(); IASTVariable x = (IASTVariable) declarations.next(); assertFalse( declarations.hasNext() ); @@ -537,7 +537,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest { try { // This is to prove that there are no exceptions // Used to cause AST Semantic exception - Iterator i = parse( "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n" ).getDeclarations(); + Iterator i = parse( "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n" ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(classA); IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)j.next()).getTypeSpecifier(); @@ -559,7 +559,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testIsConstructor() throws Exception { - Iterator i = parse( "class A{ public: A(); }; \n A::A() {}; \n" ).getDeclarations(); + Iterator i = parse( "class A{ public: A(); }; \n A::A() {}; \n" ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTMethod method = (IASTMethod)i.next(); assertTrue (method.isConstructor()); @@ -567,7 +567,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testIsDestructor() throws Exception { - Iterator i = parse( "class A{ public: ~A(); }; \n A::~A() {}; \n" ).getDeclarations(); + Iterator i = parse( "class A{ public: ~A(); }; \n A::~A() {}; \n" ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTMethod method = (IASTMethod)i.next(); assertTrue (method.isDestructor()); @@ -575,7 +575,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug41445() throws Exception { - Iterator i = parse( "class A { }; namespace N { class B : public A { struct A {}; }; }").getDeclarations(); + Iterator i = parse( "class A { }; namespace N { class B : public A { struct A {}; }; }").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTNamespaceDefinition namespaceN = (IASTNamespaceDefinition)i.next(); Iterator sub = getDeclarations( namespaceN ); @@ -585,7 +585,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleFunctionBody() throws Exception { - Iterator i = parse( "class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }").getDeclarations(); + Iterator i = parse( "class A { int f1(); }; const int x = 4; int f() { return x; } int A::f1() { return x; }").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTMethod method_prototype = (IASTMethod)getDeclarations(classA).next(); IASTVariable x = (IASTVariable) i.next(); @@ -605,18 +605,18 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleForLoop() throws Exception { - Iterator i = parse( "const int FIVE = 5; void f() { int x = 0; for( int i = 0; i < FIVE; ++i ) { x += i; } }").getDeclarations(); + Iterator i = parse( "const int FIVE = 5; void f() { int x = 0; for( int i = 0; i < FIVE; ++i ) { x += i; } }").getDeclarations(); //$NON-NLS-1$ IASTVariable five = (IASTVariable) i.next(); IASTFunction f = (IASTFunction) i.next(); assertFalse( i.hasNext() ); assertEquals( callback.getReferences().size(), 5 ); - i = parse( "const int FIVE = 5; void f() { int x = 0; for( int i = 0; i < FIVE; ++i ) x += i; }").getDeclarations(); + i = parse( "const int FIVE = 5; void f() { int x = 0; for( int i = 0; i < FIVE; ++i ) x += i; }").getDeclarations(); //$NON-NLS-1$ five = (IASTVariable) i.next(); f = (IASTFunction) i.next(); assertFalse( i.hasNext() ); assertEquals( callback.getReferences().size(), 5 ); - i = parse( "class A { }; void f() { for( int i = 0; i < (A*)0; ++i ) { A anA; } }").getDeclarations(); + i = parse( "class A { }; void f() { for( int i = 0; i < (A*)0; ++i ) { A anA; } }").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); f = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -625,7 +625,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug42541() throws Exception { - Iterator i = parse( "union{ int v; char a; } id;" ).getDeclarations(); + Iterator i = parse( "union{ int v; char a; } id;" ).getDeclarations(); //$NON-NLS-1$ IASTVariable id = (IASTVariable)i.next(); IASTClassSpecifier union = (IASTClassSpecifier) id.getAbstractDeclaration().getTypeSpecifier(); @@ -638,7 +638,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleIfStatement() throws Exception { - Iterator i = parse( "const bool T = true; int foo() { if( T ) { return 5; } else if( ! T ) return 20; else { return 10; } }").getDeclarations(); + Iterator i = parse( "const bool T = true; int foo() { if( T ) { return 5; } else if( ! T ) return 20; else { return 10; } }").getDeclarations(); //$NON-NLS-1$ IASTVariable t = (IASTVariable)i.next(); IASTFunction foo = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -647,7 +647,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleWhileStatement() throws Exception { - Iterator i = parse( "const bool T = true; void foo() { int x = 0; while( T ) { ++x; if( x == 100 ) break; } }").getDeclarations(); + Iterator i = parse( "const bool T = true; void foo() { int x = 0; while( T ) { ++x; if( x == 100 ) break; } }").getDeclarations(); //$NON-NLS-1$ IASTVariable t = (IASTVariable)i.next(); IASTFunction foo = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -656,7 +656,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleSwitchStatement() throws Exception { - Iterator i = parse( "const int x = 5; const int y = 10; void foo() { switch( x ) { case 1: break; case 2: goto blah; case y: continue; default: break;} }").getDeclarations(); + Iterator i = parse( "const int x = 5; const int y = 10; void foo() { switch( x ) { case 1: break; case 2: goto blah; case y: continue; default: break;} }").getDeclarations(); //$NON-NLS-1$ IASTVariable x = (IASTVariable)i.next(); IASTVariable y = (IASTVariable)i.next(); IASTFunction foo = (IASTFunction)i.next(); @@ -666,7 +666,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testSimpleDoStatement() throws Exception { - Iterator i = parse( "const int x = 3; int counter = 0; void foo() { do { ++counter; } while( counter != x ); } ").getDeclarations(); + Iterator i = parse( "const int x = 3; int counter = 0; void foo() { do { ++counter; } while( counter != x ); } ").getDeclarations(); //$NON-NLS-1$ IASTVariable x = (IASTVariable)i.next(); IASTVariable counter = (IASTVariable)i.next(); IASTFunction foo = (IASTFunction)i.next(); @@ -676,7 +676,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testThrowStatement() throws Exception { - Iterator i = parse( "class A { }; void foo() throw ( A ) { throw A; throw; } ").getDeclarations(); + Iterator i = parse( "class A { }; void foo() throw ( A ) { throw A; throw; } ").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTFunction functionF = (IASTFunction)i.next(); assertFalse( i.hasNext() ); @@ -687,12 +687,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testScoping() throws Exception { - Iterator i = parse( "void foo() { int x = 3; if( x == 1 ) { int x = 4; } else int x = 2; }").getDeclarations(); + Iterator i = parse( "void foo() { int x = 3; if( x == 1 ) { int x = 4; } else int x = 2; }").getDeclarations(); //$NON-NLS-1$ IASTFunction f = (IASTFunction)i.next(); Iterator subDeclarations = getDeclarations(f); IASTVariable topX = (IASTVariable)subDeclarations.next(); - assertEquals( topX.getInitializerClause().getAssigmentExpression().getLiteralString(), "3"); - assertEquals( topX.getName(), "x"); + assertEquals( topX.getInitializerClause().getAssigmentExpression().getLiteralString(), "3"); //$NON-NLS-1$ + assertEquals( topX.getName(), "x"); //$NON-NLS-1$ assertFalse( subDeclarations.hasNext() ); assertFalse( i.hasNext() ); assertEquals( callback.getReferences().size(), 1 ); @@ -702,18 +702,18 @@ public class CompleteParseASTTest extends CompleteParseBaseTest IASTCodeScope codeScope = (IASTCodeScope)level1.next(); Iterator subSubDeclarations = getDeclarations(codeScope); IASTVariable secondX = (IASTVariable)subSubDeclarations.next(); - assertEquals( secondX.getInitializerClause().getAssigmentExpression().getLiteralString(), "4"); + assertEquals( secondX.getInitializerClause().getAssigmentExpression().getLiteralString(), "4"); //$NON-NLS-1$ codeScope = (IASTCodeScope)level1.next(); assertFalse( level1.hasNext() ); subSubDeclarations = getDeclarations(codeScope); IASTVariable thirdX = (IASTVariable)subSubDeclarations.next(); - assertEquals( thirdX.getInitializerClause().getAssigmentExpression().getLiteralString(), "2"); + assertEquals( thirdX.getInitializerClause().getAssigmentExpression().getLiteralString(), "2"); //$NON-NLS-1$ } public void testEnumeratorReferences() throws Exception { - Iterator i = parse( "enum E { e1, e2, e3 }; E anE = e1;").getDeclarations(); + Iterator i = parse( "enum E { e1, e2, e3 }; E anE = e1;").getDeclarations(); //$NON-NLS-1$ IASTEnumerationSpecifier enumE = (IASTEnumerationSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTVariable anE = (IASTVariable)i.next(); IASTEnumerator e1 = (IASTEnumerator)enumE.getEnumerators().next(); @@ -725,14 +725,14 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug42840() throws Exception { - Iterator i = parse( "void foo(); void foo() { } class SearchMe { };").getDeclarations(); + Iterator i = parse( "void foo(); void foo() { } class SearchMe { };").getDeclarations(); //$NON-NLS-1$ IASTFunction fooDeclaration = (IASTFunction)i.next(); IASTFunction fooDefinition = (IASTFunction)i.next(); IASTClassSpecifier classSpec = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); assertFalse( i.hasNext() ); assertTrue( callback.getReferences().isEmpty()); - i = parse( "class A { void f ( A ); }; void A::f( A ){ return; }" ).getDeclarations(); + i = parse( "class A { void f ( A ); }; void A::f( A ){ return; }" ).getDeclarations(); //$NON-NLS-1$ classSpec = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTMethod fooMethodDefinition = (IASTMethod)i.next(); assertFalse( i.hasNext() ); @@ -748,7 +748,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug42872() throws Exception { - Iterator i = parse( "struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast(dp); }" ).getDeclarations(); + Iterator i = parse( "struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast(dp); }" ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier structB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTClassSpecifier structD = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTFunction foo = (IASTFunction)i.next(); @@ -757,7 +757,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest } public void testBug43503A() throws Exception { - Iterator i = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ").getDeclarations(); + Iterator i = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(classA); IASTMethod f = (IASTMethod)j.next(); @@ -772,15 +772,15 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug42979() throws Exception { Writer code = new StringWriter(); - code.write( "class OperatorOverload{\n" ); - code.write( "public:\n" ); - code.write( " bool operator==( const class OperatorOverload& that )\n" ); - code.write( " { return true; }\n" ); - code.write( " bool operator!=( const class OperatorOverload& that );\n" ); - code.write( "}; \n" ); + code.write( "class OperatorOverload{\n" ); //$NON-NLS-1$ + code.write( "public:\n" ); //$NON-NLS-1$ + code.write( " bool operator==( const class OperatorOverload& that )\n" ); //$NON-NLS-1$ + code.write( " { return true; }\n" ); //$NON-NLS-1$ + code.write( " bool operator!=( const class OperatorOverload& that );\n" ); //$NON-NLS-1$ + code.write( "}; \n" ); //$NON-NLS-1$ - code.write( "bool OperatorOverload::operator!=( const class OperatorOverload& that )\n" ); - code.write( "{ return false; }\n" ); + code.write( "bool OperatorOverload::operator!=( const class OperatorOverload& that )\n" ); //$NON-NLS-1$ + code.write( "{ return false; }\n" ); //$NON-NLS-1$ Iterator i = parse( code.toString() ).getDeclarations(); IASTClassSpecifier classOp = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -801,7 +801,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest { try { // This is to prove that there are no exceptions // Used to cause AST Semantic exception - Iterator i = parse( "class A { static int x; }; int A::x = 5;" ).getDeclarations(); + Iterator i = parse( "class A { static int x; }; int A::x = 5;" ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(classA); IASTField field1 = (IASTField) j.next(); @@ -819,7 +819,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug39504() throws Exception { - Iterator i = parse( "const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);" ).getDeclarations(); + Iterator i = parse( "const int w = 2; int x[ 5 ]; int y = sizeof (x[w]);" ).getDeclarations(); //$NON-NLS-1$ IASTVariable varW = (IASTVariable)i.next(); IASTVariable varX = (IASTVariable)i.next(); IASTVariable vary = (IASTVariable)i.next(); @@ -829,7 +829,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug43375() throws Exception { - IASTVariable varX = (IASTVariable)parse( "extern int x;").getDeclarations().next(); + IASTVariable varX = (IASTVariable)parse( "extern int x;").getDeclarations().next(); //$NON-NLS-1$ assertTrue( varX.isExtern() ); } @@ -837,23 +837,23 @@ public class CompleteParseASTTest extends CompleteParseBaseTest { StringBuffer buff = new StringBuffer(); - buff.append( "class SD_02 {"); - buff.append( " public:"); - buff.append( " void f_SD_02();"); - buff.append( " };"); - buff.append( "class SD_01 {\n"); - buff.append( " public:\n"); - buff.append( " SD_02 *next;"); // REFERENCE SD_02 - buff.append( " void f_SD_01();\n"); - buff.append( "};\n"); - buff.append( "int main(){\n"); - buff.append( " SD_01 a = new SD_01();\n"); // REFERENCE SD_01 * 2 - buff.append( " a->f_SD_01();\n"); // REFERENCE a && REFERENCE f_SD_01 - buff.append( "}\n"); - buff.append( "void SD_01::f_SD_01()\n"); // REFERENCE SD_01 - buff.append( "{\n"); - buff.append( " next->f_SD_02();\n"); // REFERENCE next && reference f_SD_02 - buff.append( "}\n"); + buff.append( "class SD_02 {"); //$NON-NLS-1$ + buff.append( " public:"); //$NON-NLS-1$ + buff.append( " void f_SD_02();"); //$NON-NLS-1$ + buff.append( " };"); //$NON-NLS-1$ + buff.append( "class SD_01 {\n"); //$NON-NLS-1$ + buff.append( " public:\n"); //$NON-NLS-1$ + buff.append( " SD_02 *next;"); // REFERENCE SD_02 //$NON-NLS-1$ + buff.append( " void f_SD_01();\n"); //$NON-NLS-1$ + buff.append( "};\n"); //$NON-NLS-1$ + buff.append( "int main(){\n"); //$NON-NLS-1$ + buff.append( " SD_01 a = new SD_01();\n"); // REFERENCE SD_01 * 2 //$NON-NLS-1$ + buff.append( " a->f_SD_01();\n"); // REFERENCE a && REFERENCE f_SD_01 //$NON-NLS-1$ + buff.append( "}\n"); //$NON-NLS-1$ + buff.append( "void SD_01::f_SD_01()\n"); // REFERENCE SD_01 //$NON-NLS-1$ + buff.append( "{\n"); //$NON-NLS-1$ + buff.append( " next->f_SD_02();\n"); // REFERENCE next && reference f_SD_02 //$NON-NLS-1$ + buff.append( "}\n"); //$NON-NLS-1$ Iterator i = parse( buff.toString() ).getDeclarations(); IASTClassSpecifier SD_02 = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTMethod f_SD_02 = (IASTMethod)getDeclarations( SD_02 ).next(); @@ -869,7 +869,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug43679_A () throws Exception { try{ // this used to throw a null pointer exception - Iterator i = parse( "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ", false ).getDeclarations(); + Iterator i = parse( "struct Sample { int size() const; }; extern const Sample * getSample(); int trouble() { return getSample()->size(); } ", false ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(A); IASTMethod s = (IASTMethod) j.next(); @@ -887,7 +887,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug43679_B () throws Exception { try{ // this used to throw a class cast exception - Iterator i = parse( "struct Sample{int size() const; }; struct Sample; ", false ).getDeclarations(); + Iterator i = parse( "struct Sample{int size() const; }; struct Sample; ", false ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(A); IASTMethod s = (IASTMethod) j.next(); @@ -904,18 +904,18 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug43951() throws Exception { - Iterator i = parse( "class B{ B(); ~B(); }; B::B(){} B::~B(){}", false ).getDeclarations(); + Iterator i = parse( "class B{ B(); ~B(); }; B::B(){} B::~B(){}", false ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier b = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); - assertEquals( b.getName(), "B"); + assertEquals( b.getName(), "B"); //$NON-NLS-1$ IASTMethod constructor = (IASTMethod) i.next(); - assertEquals( constructor.getName(), "B" ); + assertEquals( constructor.getName(), "B" ); //$NON-NLS-1$ assertTrue( constructor.previouslyDeclared() ); } public void testBug44342() throws Exception { try{ - IASTScope scope = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} "); + IASTScope scope = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} "); //$NON-NLS-1$ Iterator i = scope.getDeclarations(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(classA); @@ -940,9 +940,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testCDesignatedInitializers() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append( "struct Inner { int a,b,c; };"); - buffer.append( "struct A { int x; int y[]; struct Inner innerArray[]; int z []; };"); - buffer.append( "struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };"); + buffer.append( "struct Inner { int a,b,c; };"); //$NON-NLS-1$ + buffer.append( "struct A { int x; int y[]; struct Inner innerArray[]; int z []; };"); //$NON-NLS-1$ + buffer.append( "struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };"); //$NON-NLS-1$ Iterator i = parse( buffer.toString(), true, ParserLanguage.C ).getDeclarations(); IASTClassSpecifier Inner = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator members = getDeclarations(Inner); @@ -972,33 +972,33 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug39551A() throws Exception { - IASTFunction function = (IASTFunction)parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C).getDeclarations().next(); - assertEquals( function.getName(), "conjf"); + IASTFunction function = (IASTFunction)parse("extern float _Complex conjf (float _Complex);", true, ParserLanguage.C).getDeclarations().next(); //$NON-NLS-1$ + assertEquals( function.getName(), "conjf"); //$NON-NLS-1$ assertTrue( ((IASTSimpleTypeSpecifier)function.getReturnType().getTypeSpecifier()).isComplex() ); } public void testBug39551B() throws Exception { - IASTVariable variable = (IASTVariable)parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C).getDeclarations().next(); - assertEquals( variable.getName(), "id"); + IASTVariable variable = (IASTVariable)parse("_Imaginary double id = 99.99 * __I__;", true, ParserLanguage.C).getDeclarations().next(); //$NON-NLS-1$ + assertEquals( variable.getName(), "id"); //$NON-NLS-1$ assertTrue( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).isImaginary() ); } public void testCBool() throws Exception { - IASTVariable variable = (IASTVariable)parse( "_Bool x;", true, ParserLanguage.C ).getDeclarations().next(); + IASTVariable variable = (IASTVariable)parse( "_Bool x;", true, ParserLanguage.C ).getDeclarations().next(); //$NON-NLS-1$ assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type._BOOL ); } public void testCBoolAsParameter() throws Exception { - Iterator i = parse( "void f( _Bool b ) {} " + - "_Bool g( _Bool b ) {} " + - "void main(){" + - " _Bool b; " + - " f(b);" + - " f( g( (_Bool) 1 ) );" + - "}", + Iterator i = parse( "void f( _Bool b ) {} " + //$NON-NLS-1$ + "_Bool g( _Bool b ) {} " + //$NON-NLS-1$ + "void main(){" + //$NON-NLS-1$ + " _Bool b; " + //$NON-NLS-1$ + " f(b);" + //$NON-NLS-1$ + " f( g( (_Bool) 1 ) );" + //$NON-NLS-1$ + "}", //$NON-NLS-1$ true, ParserLanguage.C ).getDeclarations(); IASTFunction f = (IASTFunction) i.next(); @@ -1011,10 +1011,10 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug44510() throws Exception { - Iterator i = parse( "int initialize(); " + - "int initialize( char ){} " + - "int initialize(){ return 1; } " + - "void main(){ int i = initialize(); }" ).getDeclarations(); + Iterator i = parse( "int initialize(); " + //$NON-NLS-1$ + "int initialize( char ){} " + //$NON-NLS-1$ + "int initialize(){ return 1; } " + //$NON-NLS-1$ + "void main(){ int i = initialize(); }" ).getDeclarations(); //$NON-NLS-1$ IASTFunction function1 = (IASTFunction) i.next(); assertEquals( function1.previouslyDeclared(), false ); @@ -1034,10 +1034,10 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug44925() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append( "class MyClass { };"); - buffer.append( "class MyClass myObj1;"); - buffer.append( "enum MyEnum { Item1 };"); - buffer.append( "enum MyEnum myObj2;"); + buffer.append( "class MyClass { };"); //$NON-NLS-1$ + buffer.append( "class MyClass myObj1;"); //$NON-NLS-1$ + buffer.append( "enum MyEnum { Item1 };"); //$NON-NLS-1$ + buffer.append( "enum MyEnum myObj2;"); //$NON-NLS-1$ Iterator i = parse( buffer.toString() ).getDeclarations(); IASTClassSpecifier MyClass = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1053,8 +1053,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug44838() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append( "class A { int myX; A( int x ); };\n"); - buffer.append( "A::A( int x ) : myX( x ) { if( x == 5 ) myX++; }\n"); + buffer.append( "class A { int myX; A( int x ); };\n"); //$NON-NLS-1$ + buffer.append( "A::A( int x ) : myX( x ) { if( x == 5 ) myX++; }\n"); //$NON-NLS-1$ Iterator i = parse( buffer.toString() ).getDeclarations(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTField myX = (IASTField)getDeclarations( classA ).next(); @@ -1067,8 +1067,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug46165() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append( "class A { int myX; A( int x ); };\n"); - buffer.append( "A::A( int x ) : myX( x ) { if( x == 5 ) myX++; }\n"); + buffer.append( "class A { int myX; A( int x ); };\n"); //$NON-NLS-1$ + buffer.append( "A::A( int x ) : myX( x ) { if( x == 5 ) myX++; }\n"); //$NON-NLS-1$ Iterator i = parse( buffer.toString() ).getDeclarations(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTField myX = (IASTField)getDeclarations( classA ).next(); @@ -1082,10 +1082,10 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug47624() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append( "struct s { }; \n" ); - buffer.append( "void f ( int s ) { \n" ); - buffer.append( " struct s sInstance; \n" ); - buffer.append( "}\n"); + buffer.append( "struct s { }; \n" ); //$NON-NLS-1$ + buffer.append( "void f ( int s ) { \n" ); //$NON-NLS-1$ + buffer.append( " struct s sInstance; \n" ); //$NON-NLS-1$ + buffer.append( "}\n"); //$NON-NLS-1$ Iterator i = parse( buffer.toString() ).getDeclarations(); IASTClassSpecifier structS = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1103,11 +1103,11 @@ public class CompleteParseASTTest extends CompleteParseBaseTest //this is meant to test that on a->f, the lookup for f is qualified //the namespace is necessary because of bug 47926 StringBuffer buffer = new StringBuffer(); - buffer.append( "namespace N {" ); - buffer.append( " void f () {} \n" ); - buffer.append( " class A { }; \n" ); - buffer.append( "}" ); - buffer.append( "void main() { N::A * a = new N::A(); a->f(); } "); + buffer.append( "namespace N {" ); //$NON-NLS-1$ + buffer.append( " void f () {} \n" ); //$NON-NLS-1$ + buffer.append( " class A { }; \n" ); //$NON-NLS-1$ + buffer.append( "}" ); //$NON-NLS-1$ + buffer.append( "void main() { N::A * a = new N::A(); a->f(); } "); //$NON-NLS-1$ Iterator i = parse( buffer.toString() ).getDeclarations(); @@ -1130,9 +1130,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug43110() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append("void x( int y, ... );\n"); - buffer.append("void y( int x... );\n"); - buffer.append("void z(...);"); + buffer.append("void x( int y, ... );\n"); //$NON-NLS-1$ + buffer.append("void y( int x... );\n"); //$NON-NLS-1$ + buffer.append("void z(...);"); //$NON-NLS-1$ Iterator i = parse(buffer.toString() ).getDeclarations(); while( i.hasNext() ) assertTrue( ((IASTFunction)i.next()).takesVarArgs() ); @@ -1141,8 +1141,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug43110_XRef() throws Exception { StringBuffer buffer = new StringBuffer(); - buffer.append( "void foo( ... ) {}\n" ); - buffer.append( "void main( ){ foo( 1 ); }\n" ); + buffer.append( "void foo( ... ) {}\n" ); //$NON-NLS-1$ + buffer.append( "void main( ){ foo( 1 ); }\n" ); //$NON-NLS-1$ Iterator i = parse( buffer.toString() ).getDeclarations(); IASTFunction foo = (IASTFunction)i.next(); @@ -1150,9 +1150,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest assertAllReferences( 1, createTaskList( new Task( foo ) ) ); buffer = new StringBuffer(); - buffer.append( "void foo( ... ) {}\n" ); - buffer.append( "void foo( int x ) {}\n" ); - buffer.append( "void main( ){ foo( 1 ); }\n" ); + buffer.append( "void foo( ... ) {}\n" ); //$NON-NLS-1$ + buffer.append( "void foo( int x ) {}\n" ); //$NON-NLS-1$ + buffer.append( "void main( ){ foo( 1 ); }\n" ); //$NON-NLS-1$ i = parse( buffer.toString() ).getDeclarations(); IASTFunction foo1 = (IASTFunction)i.next(); @@ -1162,9 +1162,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest assertAllReferences( 1, createTaskList( new Task( foo2 ) ) ); buffer = new StringBuffer(); - buffer.append( "void foo( ... ) {}\n" ); - buffer.append( "void foo( int x = 1) {}\n" ); - buffer.append( "void main( ){ foo(); }\n" ); + buffer.append( "void foo( ... ) {}\n" ); //$NON-NLS-1$ + buffer.append( "void foo( int x = 1) {}\n" ); //$NON-NLS-1$ + buffer.append( "void main( ){ foo(); }\n" ); //$NON-NLS-1$ i = parse( buffer.toString() ).getDeclarations(); foo1 = (IASTFunction)i.next(); @@ -1174,8 +1174,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest assertAllReferences( 1, createTaskList( new Task( foo2 ) ) ); buffer = new StringBuffer(); - buffer.append( "void foo( int x ... ) {}\n" ); - buffer.append( "void main( ){ foo( 1, 2, 'a' ); }\n" ); + buffer.append( "void foo( int x ... ) {}\n" ); //$NON-NLS-1$ + buffer.append( "void main( ){ foo( 1, 2, 'a' ); }\n" ); //$NON-NLS-1$ i = parse( buffer.toString() ).getDeclarations(); foo = (IASTFunction)i.next(); @@ -1185,19 +1185,19 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testErrorHandling_1() throws Exception { - Iterator i = parse( "A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false ).getDeclarations(); + Iterator i = parse( "A anA; int x = c; class A {}; A * anotherA = &anA; int b;", false ).getDeclarations(); //$NON-NLS-1$ IASTVariable x = (IASTVariable)i.next(); - assertEquals( x.getName(), "x"); + assertEquals( x.getName(), "x"); //$NON-NLS-1$ IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); - assertEquals( A.getName(), "A"); + assertEquals( A.getName(), "A"); //$NON-NLS-1$ IASTVariable anotherA = (IASTVariable)i.next(); - assertEquals( anotherA.getName(), "b"); + assertEquals( anotherA.getName(), "b"); //$NON-NLS-1$ assertFalse(i.hasNext()); // should be true } public void testBug44340() throws Exception { // inline function with reference to variables declared after them - IASTScope scope = parse ("class A{ int getX() {return x[1];} int x[10];};", false ); + IASTScope scope = parse ("class A{ int getX() {return x[1];} int x[10];};", false ); //$NON-NLS-1$ Iterator i = scope.getDeclarations(); IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); Iterator j = getDeclarations(classA); @@ -1210,32 +1210,32 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug47628() throws Exception { Writer writer = new StringWriter(); - writer.write( "void h(char) { }\n"); - writer.write( "void h(unsigned char) { }\n"); - writer.write( "void h(signed char) { } // not shown in outline, parsed as char\n"); + writer.write( "void h(char) { }\n"); //$NON-NLS-1$ + writer.write( "void h(unsigned char) { }\n"); //$NON-NLS-1$ + writer.write( "void h(signed char) { } // not shown in outline, parsed as char\n"); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTFunction h1 = (IASTFunction) i.next(); - assertEquals( h1.getName(), "h"); + assertEquals( h1.getName(), "h"); //$NON-NLS-1$ Iterator parms = h1.getParameters(); IASTParameterDeclaration parm = (IASTParameterDeclaration) parms.next(); assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); - assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "char" ); + assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "char" ); //$NON-NLS-1$ IASTFunction h2 = (IASTFunction) i.next(); - assertEquals( h2.getName(), "h"); + assertEquals( h2.getName(), "h"); //$NON-NLS-1$ parms = h2.getParameters(); parm = (IASTParameterDeclaration) parms.next(); assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); - assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "unsigned char" ); + assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "unsigned char" ); //$NON-NLS-1$ IASTFunction h3 = (IASTFunction) i.next(); - assertEquals( h3.getName(), "h"); + assertEquals( h3.getName(), "h"); //$NON-NLS-1$ parms = h3.getParameters(); parm = (IASTParameterDeclaration) parms.next(); assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); - assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "signed char" ); + assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "signed char" ); //$NON-NLS-1$ assertFalse( i.hasNext() ); } @@ -1243,17 +1243,17 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug47636() throws Exception { Writer writer = new StringWriter(); - writer.write( "void f( char [] ); \n" ); - writer.write( "void f( char * ){} \n" ); + writer.write( "void f( char [] ); \n" ); //$NON-NLS-1$ + writer.write( "void f( char * ){} \n" ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTFunction fDec = (IASTFunction) i.next(); - assertEquals( fDec.getName(), "f"); + assertEquals( fDec.getName(), "f"); //$NON-NLS-1$ IASTFunction fDef = (IASTFunction) i.next(); - assertEquals( fDef.getName(), "f"); + assertEquals( fDef.getName(), "f"); //$NON-NLS-1$ assertTrue( fDef.previouslyDeclared() ); @@ -1263,24 +1263,24 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug45697() throws Exception { Writer writer = new StringWriter(); - writer.write( " int f( bool ); \n"); - writer.write( " int f( char ){ } "); + writer.write( " int f( bool ); \n"); //$NON-NLS-1$ + writer.write( " int f( char ){ } "); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTFunction f1 = (IASTFunction) i.next(); - assertEquals( f1.getName(), "f"); + assertEquals( f1.getName(), "f"); //$NON-NLS-1$ Iterator parms = f1.getParameters(); IASTParameterDeclaration parm = (IASTParameterDeclaration) parms.next(); assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); - assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "bool" ); + assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "bool" ); //$NON-NLS-1$ IASTFunction f2 = (IASTFunction) i.next(); - assertEquals( f2.getName(), "f"); + assertEquals( f2.getName(), "f"); //$NON-NLS-1$ parms = f2.getParameters(); parm = (IASTParameterDeclaration) parms.next(); assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); - assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "char" ); + assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "char" ); //$NON-NLS-1$ assertFalse( f2.previouslyDeclared() ); assertFalse( i.hasNext() ); } @@ -1288,20 +1288,20 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug54639() throws Exception { Writer writer = new StringWriter(); - writer.write( "typedef enum _A { } A, *pA; " ); + writer.write( "typedef enum _A { } A, *pA; " ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)i.next(); - assertEquals( typedef.getName(), "A" ); + assertEquals( typedef.getName(), "A" ); //$NON-NLS-1$ IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier) typedef.getAbstractDeclarator().getTypeSpecifier(); - assertEquals( enumSpec.getName(), "_A" ); + assertEquals( enumSpec.getName(), "_A" ); //$NON-NLS-1$ IASTTypedefDeclaration typedef2 = (IASTTypedefDeclaration)i.next(); - assertEquals( typedef2.getName(), "pA" ); + assertEquals( typedef2.getName(), "pA" ); //$NON-NLS-1$ assertEquals( typedef2.getAbstractDeclarator().getPointerOperators().next(), ASTPointerOperator.POINTER ); enumSpec = (IASTEnumerationSpecifier) typedef2.getAbstractDeclarator().getTypeSpecifier(); - assertEquals( enumSpec.getName(), "_A" ); + assertEquals( enumSpec.getName(), "_A" ); //$NON-NLS-1$ assertFalse( i.hasNext() ); } @@ -1309,11 +1309,11 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug55163() throws Exception { Writer writer = new StringWriter(); - writer.write( "void foo() { \n"); - writer.write( " int i, n; \n"); - writer.write( " double di; \n"); - writer.write( " for( i = n - 1, di = (double)( i + i ); i > 0; i-- ){ } \n"); - writer.write( "}\n"); + writer.write( "void foo() { \n"); //$NON-NLS-1$ + writer.write( " int i, n; \n"); //$NON-NLS-1$ + writer.write( " double di; \n"); //$NON-NLS-1$ + writer.write( " for( i = n - 1, di = (double)( i + i ); i > 0; i-- ){ } \n"); //$NON-NLS-1$ + writer.write( "}\n"); //$NON-NLS-1$ Iterator iter = parse( writer.toString() ).getDeclarations(); @@ -1329,7 +1329,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest } public void testBug55673() throws Exception{ Writer writer = new StringWriter(); - writer.write( "struct Example { int i; int ( * pfi ) ( int ); }; "); + writer.write( "struct Example { int i; int ( * pfi ) ( int ); }; "); //$NON-NLS-1$ Iterator iter = parse( writer.toString() ).getDeclarations(); @@ -1346,49 +1346,49 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug54531() throws Exception { - Iterator i = parse( "typedef enum _A {} A, *pA;" ).getDeclarations(); + Iterator i = parse( "typedef enum _A {} A, *pA;" ).getDeclarations(); //$NON-NLS-1$ IASTTypedefDeclaration theEnum = (IASTTypedefDeclaration) i.next(); - assertEquals( theEnum.getName(), "A"); + assertEquals( theEnum.getName(), "A"); //$NON-NLS-1$ IASTTypedefDeclaration thePointer = (IASTTypedefDeclaration) i.next(); - assertEquals( thePointer.getName(), "pA" ); + assertEquals( thePointer.getName(), "pA" ); //$NON-NLS-1$ assertFalse( i.hasNext() ); } public void testBug56516() throws Exception { - Iterator i = parse( "typedef struct blah sb;").getDeclarations(); + Iterator i = parse( "typedef struct blah sb;").getDeclarations(); //$NON-NLS-1$ IASTTypedefDeclaration sb = (IASTTypedefDeclaration) i.next(); - assertEquals( sb.getName(), "sb"); + assertEquals( sb.getName(), "sb"); //$NON-NLS-1$ assertFalse( i.hasNext() ); IASTElaboratedTypeSpecifier elab = ((IASTElaboratedTypeSpecifier)sb.getAbstractDeclarator().getTypeSpecifier()); - assertEquals( elab.getName(), "blah"); + assertEquals( elab.getName(), "blah"); //$NON-NLS-1$ assertEquals( elab.getClassKind(), ASTClassKind.STRUCT ); } public void testBug53786() throws Exception { - Iterator i = parse( "struct Example { struct Data * data; };").getDeclarations(); + Iterator i = parse( "struct Example { struct Data * data; };").getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier Example = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); assertFalse( i.hasNext() ); - assertEquals( Example.getName(), "Example"); + assertEquals( Example.getName(), "Example"); //$NON-NLS-1$ assertEquals( Example.getClassKind(), ASTClassKind.STRUCT ); Iterator j = getDeclarations( Example ); IASTField data = (IASTField) j.next(); assertFalse( j.hasNext() ); - assertEquals( data.getName(), "data" ); + assertEquals( data.getName(), "data" ); //$NON-NLS-1$ } public void testBug54029() throws Exception { - Iterator i = parse( "typedef int T; T i;" ).getDeclarations(); + Iterator i = parse( "typedef int T; T i;" ).getDeclarations(); //$NON-NLS-1$ IASTTypedefDeclaration typedef = (IASTTypedefDeclaration) i.next(); - assertEquals( typedef.getName(), "T"); + assertEquals( typedef.getName(), "T"); //$NON-NLS-1$ assertTrue( typedef.getAbstractDeclarator().getTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); assertEquals( ((IASTSimpleTypeSpecifier)typedef.getAbstractDeclarator().getTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.INT ); IASTVariable variable = (IASTVariable) i.next(); assertFalse( i.hasNext() ); - assertEquals( variable.getName(), "i"); - assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getTypename(), "T" ); + assertEquals( variable.getName(), "i"); //$NON-NLS-1$ + assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getTypename(), "T" ); //$NON-NLS-1$ assertNotNull( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier() ); assertEquals( ((IASTSimpleTypeSpecifier)variable.getAbstractDeclaration().getTypeSpecifier()).getTypeSpecifier(), typedef ); } @@ -1396,12 +1396,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug47625() throws Exception { Writer writer = new StringWriter(); - writer.write("struct s { int num; }; "); - writer.write("namespace ns{ "); - writer.write(" struct s { double num; };"); - writer.write(" s inner = { 3.14 };"); - writer.write(" ::s outer = { 42 };"); - writer.write("}"); + writer.write("struct s { int num; }; "); //$NON-NLS-1$ + writer.write("namespace ns{ "); //$NON-NLS-1$ + writer.write(" struct s { double num; };"); //$NON-NLS-1$ + writer.write(" s inner = { 3.14 };"); //$NON-NLS-1$ + writer.write(" ::s outer = { 42 };"); //$NON-NLS-1$ + writer.write("}"); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTClassSpecifier outerS = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1418,11 +1418,11 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug57754() throws Exception { Writer writer = new StringWriter(); - writer.write( "struct X { " ); - writer.write( " typedef int T; " ); - writer.write( " void f( T ); " ); - writer.write( "}; " ); - writer.write( "void X::f( T ) { } " ); + writer.write( "struct X { " ); //$NON-NLS-1$ + writer.write( " typedef int T; " ); //$NON-NLS-1$ + writer.write( " void f( T ); " ); //$NON-NLS-1$ + writer.write( "}; " ); //$NON-NLS-1$ + writer.write( "void X::f( T ) { } " ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); @@ -1440,9 +1440,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug57800() throws Exception { Writer writer= new StringWriter(); - writer.write( "class G2 { int j; };"); - writer.write( "typedef G2 AltG2;"); - writer.write( "class AltG3 : AltG2 { int x;};"); + writer.write( "class G2 { int j; };"); //$NON-NLS-1$ + writer.write( "typedef G2 AltG2;"); //$NON-NLS-1$ + writer.write( "class AltG3 : AltG2 { int x;};"); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTClassSpecifier G2 = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); IASTTypedefDeclaration AltG2 = (IASTTypedefDeclaration) i.next(); @@ -1457,12 +1457,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug46246() throws Exception { Writer writer = new StringWriter(); - writer.write( "struct A { "); - writer.write( " struct B { int ab; } b; "); - writer.write( " int a; "); - writer.write( "}; "); - writer.write( "struct A a1; "); - writer.write( "struct B b1; "); + writer.write( "struct A { "); //$NON-NLS-1$ + writer.write( " struct B { int ab; } b; "); //$NON-NLS-1$ + writer.write( " int a; "); //$NON-NLS-1$ + writer.write( "}; "); //$NON-NLS-1$ + writer.write( "struct A a1; "); //$NON-NLS-1$ + writer.write( "struct B b1; "); //$NON-NLS-1$ Iterator i = parse( writer.toString(), true, ParserLanguage.C ).getDeclarations(); IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1478,7 +1478,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug45235() throws Exception { - Iterator i = parse( "class A { friend class B; friend void f(); }; " ).getDeclarations(); + Iterator i = parse( "class A { friend class B; friend void f(); }; " ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1494,10 +1494,10 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug57791() throws Exception { Writer writer = new StringWriter(); - writer.write(" void f() { "); - writer.write(" struct astruct astruct; "); - writer.write(" astruct.foo++; "); - writer.write(" }"); + writer.write(" void f() { "); //$NON-NLS-1$ + writer.write(" struct astruct astruct; "); //$NON-NLS-1$ + writer.write(" astruct.foo++; "); //$NON-NLS-1$ + writer.write(" }"); //$NON-NLS-1$ parse( writer.toString(), true, ParserLanguage.C ); } @@ -1505,27 +1505,27 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug44249() throws Exception { - Iterator i = parse( "class SD_01 { public:\n void SD_01::f_SD_01();};" ).getDeclarations(); + Iterator i = parse( "class SD_01 { public:\n void SD_01::f_SD_01();};" ).getDeclarations(); //$NON-NLS-1$ IASTClassSpecifier SD_01 = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); assertFalse( i.hasNext() ); i = getDeclarations( SD_01 ); IASTMethod f_SD_01 = (IASTMethod) i.next(); assertFalse( i.hasNext() ); - assertEquals( f_SD_01.getName(), "f_SD_01"); + assertEquals( f_SD_01.getName(), "f_SD_01"); //$NON-NLS-1$ assertAllReferences( 1, createTaskList( new Task( SD_01 ))); } public void testBug39697() throws Exception { Writer writer = new StringWriter(); - writer.write( "__asm__( \"CODE\" );\n" ); - writer.write( "__inline__ int foo() { return 4; }\n"); - writer.write( "__const__ int constInt;\n"); - writer.write( "__volatile__ int volInt;\n"); - writer.write( "__signed__ int signedInt;\n"); + writer.write( "__asm__( \"CODE\" );\n" ); //$NON-NLS-1$ + writer.write( "__inline__ int foo() { return 4; }\n"); //$NON-NLS-1$ + writer.write( "__const__ int constInt;\n"); //$NON-NLS-1$ + writer.write( "__volatile__ int volInt;\n"); //$NON-NLS-1$ + writer.write( "__signed__ int signedInt;\n"); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTASMDefinition asmDefinition = (IASTASMDefinition) i.next(); - assertEquals( asmDefinition.getBody(), "CODE"); + assertEquals( asmDefinition.getBody(), "CODE"); //$NON-NLS-1$ IASTFunction foo = (IASTFunction) i.next(); assertTrue( foo.isInline() ); IASTVariable constInt = (IASTVariable) i.next(); @@ -1538,8 +1538,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest for( int j = 0; j < 2; ++j ) { writer = new StringWriter(); - writer.write( "int * __restrict__ resPointer1;\n"); - writer.write( "int * __restrict resPointer2;\n"); + writer.write( "int * __restrict__ resPointer1;\n"); //$NON-NLS-1$ + writer.write( "int * __restrict resPointer2;\n"); //$NON-NLS-1$ i = parse( writer.toString(), true, ((j == 0 )? ParserLanguage.C : ParserLanguage.CPP) ).getDeclarations(); int count = 0; while( i.hasNext() ) @@ -1559,8 +1559,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug59149() throws Exception { Writer writer = new StringWriter(); - writer.write( "class A{ friend class B; friend class B; };" ); - writer.write( "class B{ };" ); + writer.write( "class A{ friend class B; friend class B; };" ); //$NON-NLS-1$ + writer.write( "class B{ };" ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1568,7 +1568,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest } public void testBug39695() throws Exception { - Iterator i = parse("int a = __alignof__ (int);").getDeclarations(); + Iterator i = parse("int a = __alignof__ (int);").getDeclarations(); //$NON-NLS-1$ IASTVariable a = (IASTVariable) i.next(); assertFalse( i.hasNext() ); assertEquals( a.getInitializerClause().getAssigmentExpression().getExpressionKind(), IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID ); @@ -1576,7 +1576,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug39684() throws Exception { - IASTFunction bar = (IASTFunction) parse("typeof(foo(1)) bar () { return foo(1); }").getDeclarations().next(); + IASTFunction bar = (IASTFunction) parse("typeof(foo(1)) bar () { return foo(1); }").getDeclarations().next(); //$NON-NLS-1$ IASTSimpleTypeSpecifier simpleTypeSpec = ((IASTSimpleTypeSpecifier)bar.getReturnType().getTypeSpecifier()); assertEquals( simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF ); @@ -1585,8 +1585,8 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug59302() throws Exception { Writer writer = new StringWriter(); - writer.write("class A { class N{}; }; "); - writer.write("class B { friend class A::N; }; "); + writer.write("class A { class N{}; }; "); //$NON-NLS-1$ + writer.write("class B { friend class A::N; }; "); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); @@ -1602,30 +1602,30 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug39698A() throws Exception { - parse("int c = a ? b;"); + parse("int c = a >? b;"); //$NON-NLS-1$ } public void testULong() throws Exception { Writer writer = new StringWriter(); - writer.write( "#ifndef ASMINCLUDE\n"); - writer.write( "typedef unsigned short ushort;\n"); - writer.write( "typedef volatile unsigned long semaphore;\n"); - writer.write( "typedef unsigned long ulong;\n"); - writer.write( "#ifndef _NO_LONGLONG\n"); - writer.write( "typedef long long longlong;\n"); - writer.write( "typedef unsigned long long ulonglong;\n"); - writer.write( "#endif /* _NO_LONGLONG */\n"); - writer.write( "#endif /* ASMINCLUDE */\n"); - writer.write( "typedef struct section_type_ {\n"); - writer.write( "ulong source;\n"); - writer.write( "ulong dest;\n"); - writer.write( "ulong bytes;\n"); - writer.write( "} section_type;\n"); + writer.write( "#ifndef ASMINCLUDE\n"); //$NON-NLS-1$ + writer.write( "typedef unsigned short ushort;\n"); //$NON-NLS-1$ + writer.write( "typedef volatile unsigned long semaphore;\n"); //$NON-NLS-1$ + writer.write( "typedef unsigned long ulong;\n"); //$NON-NLS-1$ + writer.write( "#ifndef _NO_LONGLONG\n"); //$NON-NLS-1$ + writer.write( "typedef long long longlong;\n"); //$NON-NLS-1$ + writer.write( "typedef unsigned long long ulonglong;\n"); //$NON-NLS-1$ + writer.write( "#endif /* _NO_LONGLONG */\n"); //$NON-NLS-1$ + writer.write( "#endif /* ASMINCLUDE */\n"); //$NON-NLS-1$ + writer.write( "typedef struct section_type_ {\n"); //$NON-NLS-1$ + writer.write( "ulong source;\n"); //$NON-NLS-1$ + writer.write( "ulong dest;\n"); //$NON-NLS-1$ + writer.write( "ulong bytes;\n"); //$NON-NLS-1$ + writer.write( "} section_type;\n"); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); IASTTypedefDeclaration ushort = (IASTTypedefDeclaration) i.next(); IASTTypedefDeclaration semaphore = (IASTTypedefDeclaration) i.next(); @@ -1648,7 +1648,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug47926() throws Exception { - Iterator i = parse( "void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false ).getDeclarations(); + Iterator i = parse( "void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false ).getDeclarations(); //$NON-NLS-1$ IASTFunction f = (IASTFunction) i.next(); IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next() ).getTypeSpecifier(); IASTFunction main = (IASTFunction) i.next(); @@ -1661,15 +1661,15 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testBug50984_ASTMethod_getOwnerClassSpecifier_ClassCastException() throws Exception { Writer writer = new StringWriter(); - writer.write( "template < typename _OutIter > " ); - writer.write( "class num_put { " ); - writer.write( " typedef _OutIter iter_type; " ); - writer.write( " template< typename _ValueT > " ); - writer.write( " iter_type _M_convert_float( iter_type ); " ); - writer.write( "}; " ); - writer.write( "template < typename _OutIter > " ); - writer.write( "template < typename _ValueT > " ); - writer.write( "_OutIter num_put<_OutIter>::_M_convert_float( _OutIter ) { } " ); + writer.write( "template < typename _OutIter > " ); //$NON-NLS-1$ + writer.write( "class num_put { " ); //$NON-NLS-1$ + writer.write( " typedef _OutIter iter_type; " ); //$NON-NLS-1$ + writer.write( " template< typename _ValueT > " ); //$NON-NLS-1$ + writer.write( " iter_type _M_convert_float( iter_type ); " ); //$NON-NLS-1$ + writer.write( "}; " ); //$NON-NLS-1$ + writer.write( "template < typename _OutIter > " ); //$NON-NLS-1$ + writer.write( "template < typename _ValueT > " ); //$NON-NLS-1$ + writer.write( "_OutIter num_put<_OutIter>::_M_convert_float( _OutIter ) { } " ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); @@ -1683,7 +1683,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void testGloballyQualifiedUsingDeclaration() throws Exception { - Iterator declarations = parse( "int iii; namespace N { using ::iii; }" ).getDeclarations(); + Iterator declarations = parse( "int iii; namespace N { using ::iii; }" ).getDeclarations(); //$NON-NLS-1$ IASTVariable iii = (IASTVariable) declarations.next(); IASTNamespaceDefinition namespaceN = (IASTNamespaceDefinition)declarations.next(); @@ -1699,12 +1699,12 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void test57513_new() throws Exception { Writer writer = new StringWriter(); - writer.write( "class A{ A(); A( int ); }; \n" ); - writer.write( " void f() { \n" ); - writer.write( " A * a1 = new A; \n" ); - writer.write( " A * a2 = new(1)A(); \n" ); - writer.write( " A * a3 = new A( 1 ); \n" ); - writer.write( "} \n" ); + writer.write( "class A{ A(); A( int ); }; \n" ); //$NON-NLS-1$ + writer.write( " void f() { \n" ); //$NON-NLS-1$ + writer.write( " A * a1 = new A; \n" ); //$NON-NLS-1$ + writer.write( " A * a2 = new(1)A(); \n" ); //$NON-NLS-1$ + writer.write( " A * a3 = new A( 1 ); \n" ); //$NON-NLS-1$ + writer.write( "} \n" ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); @@ -1725,10 +1725,10 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void test57513_NoConstructor() throws Exception { Writer writer = new StringWriter(); - writer.write( "class A{ }; \n" ); - writer.write( " void f() { \n" ); - writer.write( " A * a1 = new A; \n" ); - writer.write( "} \n" ); + writer.write( "class A{ }; \n" ); //$NON-NLS-1$ + writer.write( " void f() { \n" ); //$NON-NLS-1$ + writer.write( " A * a1 = new A; \n" ); //$NON-NLS-1$ + writer.write( "} \n" ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); @@ -1742,9 +1742,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest public void test57513_ctorinit() throws Exception { Writer writer = new StringWriter(); - writer.write( "class A{ A(); A( A * ); }; \n" ); - writer.write( "class B : public A { B(); }; \n" ); - writer.write( "B::B():A( new A ){} \n" ); + writer.write( "class A{ A(); A( A * ); }; \n" ); //$NON-NLS-1$ + writer.write( "class B : public A { B(); }; \n" ); //$NON-NLS-1$ + writer.write( "B::B():A( new A ){} \n" ); //$NON-NLS-1$ Iterator i = parse( writer.toString() ).getDeclarations(); @@ -1762,4 +1762,28 @@ public class CompleteParseASTTest extends CompleteParseBaseTest assertReferenceTask( new Task( constructor2, 1, false, false ) ); assertReferenceTask( new Task( A, 2, false, false ) ); } + + public void testBug60944() throws Exception + { + Writer writer = new StringWriter(); + writer.write( "typedef int OurInt;\n"); //$NON-NLS-1$ + writer.write( "class A { int x; };\n"); //$NON-NLS-1$ + writer.write( "typedef A AnotherA;\n"); //$NON-NLS-1$ + writer.write( "typedef AnotherA SecondA;\n"); //$NON-NLS-1$ + writer.write( "typedef OurInt AnotherInt;\n" ); //$NON-NLS-1$ + Iterator i = parse( writer.toString() ).getDeclarations(); + IASTTypedefDeclaration OurInt = (IASTTypedefDeclaration) i.next(); + assertTrue( OurInt.getFinalTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); + assertEquals( ((IASTSimpleTypeSpecifier)OurInt.getFinalTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.INT ); + IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier(); + IASTTypedefDeclaration AnotherA = (IASTTypedefDeclaration) i.next(); + assertEquals( AnotherA.getFinalTypeSpecifier(), A ); + IASTTypedefDeclaration SecondA = (IASTTypedefDeclaration) i.next(); + assertEquals( SecondA.getFinalTypeSpecifier(), A ); + IASTTypedefDeclaration AnotherInt = (IASTTypedefDeclaration) i.next(); + assertTrue( AnotherInt.getFinalTypeSpecifier() instanceof IASTSimpleTypeSpecifier ); + assertEquals( ((IASTSimpleTypeSpecifier)AnotherInt.getFinalTypeSpecifier()).getType(), IASTSimpleTypeSpecifier.Type.INT ); + + assertFalse( i.hasNext() ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTSimpleTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTSimpleTypeSpecifier.java index 444ca987e63..ac942be2cb7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTSimpleTypeSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTSimpleTypeSpecifier.java @@ -29,7 +29,6 @@ public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier public static final Type DOUBLE = new Type( 6 ); public static final Type VOID = new Type( 7 ); public static final Type CLASS_OR_TYPENAME = new Type( 8 ); - public static final Type TEMPLATE = new Type( 9 ); public static final Type _BOOL = new Type( 10 ); protected static final int LAST_TYPE = 10; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java index bc56869eb1c..c9469b60cb0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java @@ -20,4 +20,5 @@ public interface IASTTypedefDeclaration extends IASTDeclaration, IASTOffsetableN public String getName(); public IASTAbstractDeclaration getAbstractDeclarator(); + public IASTTypeSpecifier getFinalTypeSpecifier() throws ASTNotImplementedException; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypedef.java index b6d415d7fc3..d20c7ddbe81 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTTypedef.java @@ -13,7 +13,10 @@ package org.eclipse.cdt.internal.core.parser.ast.complete; import java.util.List; import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration; import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement; import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; @@ -185,4 +188,28 @@ public class ASTTypedef extends ASTSymbol implements IASTTypedefDeclaration public int getNameLineNumber() { return offsets.getNameLineNumber(); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration#getFinalTypeSpecifier() + */ + public IASTTypeSpecifier getFinalTypeSpecifier() throws ASTNotImplementedException { + IASTTypeSpecifier currentTypeSpec = mapping.getTypeSpecifier(); + while( currentTypeSpec instanceof IASTSimpleTypeSpecifier || + currentTypeSpec instanceof IASTTypedefDeclaration ) + { + if( currentTypeSpec instanceof IASTSimpleTypeSpecifier ) + { + IASTSimpleTypeSpecifier simpleTypeSpec = (IASTSimpleTypeSpecifier) currentTypeSpec; + if( simpleTypeSpec.getType() == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME ) + currentTypeSpec = simpleTypeSpec.getTypeSpecifier(); + else + break; + } + else if( currentTypeSpec instanceof IASTTypedefDeclaration ) + { + currentTypeSpec = ((IASTTypedefDeclaration)currentTypeSpec).getAbstractDeclarator().getTypeSpecifier(); + } + } + return currentTypeSpec; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedefDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedefDeclaration.java index c77ee2e596c..87b7dd3403b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedefDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedefDeclaration.java @@ -11,8 +11,10 @@ package org.eclipse.cdt.internal.core.parser.ast.quick; import org.eclipse.cdt.core.parser.ISourceElementRequestor; +import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration; import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement; import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; @@ -23,7 +25,8 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; */ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedefDeclaration { - private final String name; + protected static final ASTNotImplementedException NOT_IMPLEMENTED = new ASTNotImplementedException(); + private final String name; private final IASTAbstractDeclaration mapping; private NamedOffsets offsets = new NamedOffsets(); private final ASTQualifiedNamedElement qualifiedName; @@ -167,4 +170,10 @@ public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedef public int getNameLineNumber() { return offsets.getNameLineNumber(); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration#getFinalTypeSpecifier() + */ + public IASTTypeSpecifier getFinalTypeSpecifier() throws ASTNotImplementedException { + throw NOT_IMPLEMENTED; + } }