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 228beba0c51..975592267dd 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 @@ -765,6 +765,28 @@ public class CompleteParseASTTest extends TestCase assertEquals( f.getName(),"foo"); } + + 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 namespaceB = (IASTNamespaceDefinition)(getDeclarations(namespaceA).next()); + Iterator subB = getDeclarations( namespaceB ); + IASTEnumerationSpecifier enumE1 = (IASTEnumerationSpecifier)((IASTAbstractTypeSpecifierDeclaration)subB.next()).getTypeSpecifier(); + Iterator enumerators = enumE1.getEnumerators(); + IASTEnumerator enumeratorE_1 = (IASTEnumerator)enumerators.next(); + assertEquals( enumeratorE_1.getOwnerEnumerationSpecifier(), enumE1 ); + IASTVariable variableX = (IASTVariable)subB.next(); + IASTClassSpecifier classC = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)subB.next()).getTypeSpecifier(); + + + } + +// public void testSimpleTypedef() throws Exception +// { +// IASTTypedefDeclaration typedef = (IASTTypedefDeclaration)parse( "typedef int myInt;").getDeclarations().next(); +// assertEquals( typedef.getName(), "myInt"); +// } + protected void assertQualifiedName(String [] fromAST, String [] theTruth) { assertNotNull( fromAST ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTEnumerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTEnumerator.java index 829f9469e4a..660e02a3eda 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTEnumerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTEnumerator.java @@ -24,26 +24,28 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol; public class ASTEnumerator extends ASTSymbol implements IASTEnumerator { private Offsets offsets = new Offsets(); - private final IASTExpression initialValue; + private final IASTExpression initialValue; + private final IASTEnumerationSpecifier owner; /** * @param enumeratorSymbol * @param startingOffset * @param endingOffset * @param initialValue */ - public ASTEnumerator(ISymbol enumeratorSymbol, int startingOffset, int endingOffset, IASTExpression initialValue) + public ASTEnumerator(ISymbol enumeratorSymbol, IASTEnumerationSpecifier owner, int startingOffset, int endingOffset, IASTExpression initialValue) { super( enumeratorSymbol ); setStartingOffset(startingOffset); setEndingOffset( endingOffset ); this.initialValue = initialValue; + this.owner = owner; } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getOwnerEnumerationSpecifier() */ public IASTEnumerationSpecifier getOwnerEnumerationSpecifier() { - return (IASTEnumerationSpecifier)getSymbol().getContainingSymbol().getASTExtension(); + return owner; } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getInitialValue() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java index d5c0c5ce4f4..eb31af143a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java @@ -529,7 +529,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto { throw new ASTSemanticException(); } - ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, startingOffset, endingOffset, initialValue ); + ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, enumeration, startingOffset, endingOffset, initialValue ); ((ASTEnumerationSpecifier)enumeration).addEnumerator( enumerator ); try {