1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed ASTEnumerator::getOwnerEnumerationSpecifier() in COMPLETE_PARSE mode for Bogdan.

This commit is contained in:
John Camelon 2003-07-25 14:30:11 +00:00
parent 62a75efc6b
commit 196aedf345
3 changed files with 28 additions and 4 deletions

View file

@ -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 );

View file

@ -25,25 +25,27 @@ public class ASTEnumerator extends ASTSymbol implements IASTEnumerator
{
private Offsets offsets = new Offsets();
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()

View file

@ -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
{