1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

fix bug 66744

This commit is contained in:
Andrew Niefer 2004-06-11 19:47:57 +00:00
parent 5c9fe1859c
commit 7bc8d33c1a
3 changed files with 31 additions and 1 deletions

View file

@ -282,4 +282,15 @@ public class SelectionParseTest extends SelectionParseBaseTest {
int startIndex = code.indexOf( "foo(1)"); //$NON-NLS-1$
parse( code, startIndex, startIndex + 3 );
}
public void testBug66744() throws Exception
{
Writer writer = new StringWriter();
writer.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
writer.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$
String code = writer.toString();
int startIndex = code.indexOf( "EColours color"); //$NON-NLS-1$
parse( code, startIndex, startIndex + 8 );
}
}

View file

@ -2651,6 +2651,7 @@ public abstract class Parser extends ExpressionParser implements IParser
IToken t = consume(IToken.tRBRACE);
enumeration.setEndingOffsetAndLineNumber(t.getEndOffset(), t.getLineNumber());
enumeration.acceptElement( requestor, astFactory.getReferenceManager() );
handleEnumeration( enumeration );
sdw.setTypeSpecifier(enumeration);
}
else
@ -2660,6 +2661,7 @@ public abstract class Parser extends ExpressionParser implements IParser
throw backtrack;
}
}
/**
* Parse a class/struct/union definition.
*
@ -3339,6 +3341,11 @@ public abstract class Parser extends ExpressionParser implements IParser
}
protected void handleEnumeration(IASTEnumerationSpecifier enumeration) throws EndOfFileException {
cleanupLastToken();
handleOffsetableNamedElement( enumeration );
}
/**
* @param expression
*/

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
import org.eclipse.cdt.core.parser.ast.IASTFunction;
@ -376,4 +377,15 @@ public class SelectionParser extends ContextualParser {
throw new EndOfFileException();
}
}
protected void handleEnumeration(IASTEnumerationSpecifier enumeration) throws EndOfFileException {
if( ! tokenDupleCompleted() )
super.handleEnumeration(enumeration);
else
{
contextNode = enumeration;
handleOffsetableNamedElement( enumeration );
throw new EndOfFileException();
}
}
}