1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Fixed Bug 84366 - [Offsets] no offset/length information for IASTEnumerationSpecifier in C++

This commit is contained in:
John Camelon 2005-02-07 17:42:27 +00:00
parent f1819be172
commit c3aceabecc
2 changed files with 13 additions and 1 deletions

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@ -185,6 +186,15 @@ public class DOMLocationTests extends AST2BaseTest {
ICPPASTNamedTypeSpecifier namedTypeSpec = (ICPPASTNamedTypeSpecifier) b.getDeclSpecifier();
assertSoleLocation( namedTypeSpec, code.indexOf( "\nA") + 1, 1 ); //$NON-NLS-1$
}
public void testBug84366() throws Exception {
String code = "enum hue { red, blue, green };"; //$NON-NLS-1$
IASTTranslationUnit tu = parse( code, ParserLanguage.CPP );
IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTEnumerationSpecifier enum = (IASTEnumerationSpecifier) d.getDeclSpecifier();
IASTEnumerationSpecifier.IASTEnumerator enumerator = enum.getEnumerators()[0];
assertSoleLocation( enumerator, code.indexOf( "red"), "red".length() ); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testBug84375() throws Exception {
String code = "class D { public: int x; };\nclass C : public virtual D {};"; //$NON-NLS-1$

View file

@ -4428,7 +4428,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createName(org.eclipse.cdt.core.parser.IToken)
*/
protected IASTName createName(IToken token) {
return new CPPASTName(token.getCharImage());
CPPASTName n = new CPPASTName(token.getCharImage());
n.setOffsetAndLength( token.getOffset(), token.getLength() );
return n;
}
/*