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:
parent
62a75efc6b
commit
196aedf345
3 changed files with 28 additions and 4 deletions
|
@ -765,6 +765,28 @@ public class CompleteParseASTTest extends TestCase
|
||||||
assertEquals( f.getName(),"foo");
|
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)
|
protected void assertQualifiedName(String [] fromAST, String [] theTruth)
|
||||||
{
|
{
|
||||||
assertNotNull( fromAST );
|
assertNotNull( fromAST );
|
||||||
|
|
|
@ -25,25 +25,27 @@ public class ASTEnumerator extends ASTSymbol implements IASTEnumerator
|
||||||
{
|
{
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
private final IASTExpression initialValue;
|
private final IASTExpression initialValue;
|
||||||
|
private final IASTEnumerationSpecifier owner;
|
||||||
/**
|
/**
|
||||||
* @param enumeratorSymbol
|
* @param enumeratorSymbol
|
||||||
* @param startingOffset
|
* @param startingOffset
|
||||||
* @param endingOffset
|
* @param endingOffset
|
||||||
* @param initialValue
|
* @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 );
|
super( enumeratorSymbol );
|
||||||
setStartingOffset(startingOffset);
|
setStartingOffset(startingOffset);
|
||||||
setEndingOffset( endingOffset );
|
setEndingOffset( endingOffset );
|
||||||
this.initialValue = initialValue;
|
this.initialValue = initialValue;
|
||||||
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getOwnerEnumerationSpecifier()
|
* @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getOwnerEnumerationSpecifier()
|
||||||
*/
|
*/
|
||||||
public IASTEnumerationSpecifier getOwnerEnumerationSpecifier()
|
public IASTEnumerationSpecifier getOwnerEnumerationSpecifier()
|
||||||
{
|
{
|
||||||
return (IASTEnumerationSpecifier)getSymbol().getContainingSymbol().getASTExtension();
|
return owner;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getInitialValue()
|
* @see org.eclipse.cdt.core.parser.ast.IASTEnumerator#getInitialValue()
|
||||||
|
|
|
@ -529,7 +529,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
{
|
{
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, startingOffset, endingOffset, initialValue );
|
ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, enumeration, startingOffset, endingOffset, initialValue );
|
||||||
((ASTEnumerationSpecifier)enumeration).addEnumerator( enumerator );
|
((ASTEnumerationSpecifier)enumeration).addEnumerator( enumerator );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue