diff options
author | John Camelon | 2003-07-18 12:40:48 +0000 |
---|---|---|
committer | John Camelon | 2003-07-18 12:40:48 +0000 |
commit | e042f101ba81d46e0f4adf903e8821b3b20ec606 (patch) | |
tree | 2fe0bdee999c259722cb59ea0ff96988d20f7497 | |
parent | 2566b4d3d958419e14790f9007d967d70c1a5a75 (diff) | |
download | org.eclipse.cdt-e042f101ba81d46e0f4adf903e8821b3b20ec606.tar.gz org.eclipse.cdt-e042f101ba81d46e0f4adf903e8821b3b20ec606.tar.xz org.eclipse.cdt-e042f101ba81d46e0f4adf903e8821b3b20ec606.zip |
CORE
Removed DeclaratorDuple as it was obsolete.
Fixed offsets in quickParse's IASTTypedefDeclaration implementation.
Fixed Bug 40436 - Fully Qualified Names Needed (for Indexer/Search features)
TESTS
Wrote new tests in QuickParseASTQualifiedNameTest.java and added it to ParserTestSuite's suite.
24 files changed, 263 insertions, 78 deletions
diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index 024f5d2fad6..fb162e0ad28 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,7 +1,10 @@ +2003-07-18 John Camelon
+ Wrote new tests in QuickParseASTQualifiedNameTest.java and added it to ParserTestSuite's suite.
+
2003-07-18 Peter Graves
Removed un-needed file that was using a Java 1.4 reserved keyword (assert)
-
-2003-07-17
+
+2003-07-17 John Camelon
Rewrote the entire DOMTests suite to now be AST tests.
Removed DOMTests, BaseDOMTest, DOMFailedTests after methods were migrated to QuickParseASTTests & ASTFailedTests.
Made sure every parser failed test had a defect number associated with it.
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseASTTest.java index 4722f2edb7f..c998607f20d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseASTTest.java @@ -104,4 +104,15 @@ public class BaseASTTest extends TestCase fail( "We should not reach this point"); } + protected void assertQualifiedName(String [] fromAST, String [] theTruth) + { + assertNotNull( fromAST ); + assertNotNull( theTruth ); + assertEquals( fromAST.length, theTruth.length ); + for( int i = 0; i < fromAST.length; ++i ) + { + assertEquals( fromAST[i], theTruth[i]); + } + } + } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java index c1e120ecdd5..f7d9ea22ed6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java @@ -35,6 +35,7 @@ public class ParserTestSuite extends TestCase { suite.addTestSuite(MacroTests.class); suite.addTestSuite( PreprocessorTest.class ); suite.addTestSuite( PreprocessorConditionalTest.class ); + suite.addTestSuite( QuickParseASTQualifiedNameTest.class); return suite; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTQualifiedNameTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTQualifiedNameTest.java new file mode 100644 index 00000000000..3263c72e394 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/QuickParseASTQualifiedNameTest.java @@ -0,0 +1,114 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.core.parser.tests; + +import java.util.Iterator; + +import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTField; +import org.eclipse.cdt.core.parser.ast.IASTFunction; +import org.eclipse.cdt.core.parser.ast.IASTMethod; +import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; +import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration; +import org.eclipse.cdt.core.parser.ast.IASTVariable; + +/** + * @author jcamelon + * + */ +public class QuickParseASTQualifiedNameTest extends BaseASTTest +{ + /** + * @param a + */ + public QuickParseASTQualifiedNameTest(String a) + { + super(a); + } + + public void testNamespace() throws Exception + { + IASTNamespaceDefinition namespace = (IASTNamespaceDefinition)assertSoleDeclaration("namespace A { namespace B { int x; } }"); + assertQualifiedName( namespace.getFullyQualifiedName(), new String [] {"A" } ); + IASTNamespaceDefinition namespace2 = (IASTNamespaceDefinition)namespace.getDeclarations().next(); + assertQualifiedName( namespace2.getFullyQualifiedName(), new String [] { "A", "B" } ); + + } + + public void testClass() throws Exception + { + IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)assertSoleDeclaration( "class A { class B { int a; }; };"); + IASTClassSpecifier classSpec = (IASTClassSpecifier)abs.getTypeSpecifier(); + assertQualifiedName( classSpec.getFullyQualifiedName(), new String [] { "A" } ); + Iterator subDecls = classSpec.getDeclarations(); + abs = (IASTAbstractTypeSpecifierDeclaration)subDecls.next(); + assertFalse( subDecls.hasNext() ); + classSpec = (IASTClassSpecifier)abs.getTypeSpecifier(); + assertQualifiedName( classSpec.getFullyQualifiedName(), new String [] { "A", "B" } ); + } + + public void testEnum() throws Exception + { + Iterator declarations = parse( "class A { enum E1 { enumerator = 1 }; };\n namespace N { enum E2 { enumerator = 4 }; }\n" ).getDeclarations(); + IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)declarations.next(); + IASTClassSpecifier classSpec = (IASTClassSpecifier)abs.getTypeSpecifier(); + IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)(((IASTAbstractTypeSpecifierDeclaration)classSpec.getDeclarations().next()).getTypeSpecifier()); + assertQualifiedName( enumSpec.getFullyQualifiedName(), new String[] { "A", "E1" } ); + IASTNamespaceDefinition nms = (IASTNamespaceDefinition)declarations.next(); + enumSpec = (IASTEnumerationSpecifier)(((IASTAbstractTypeSpecifierDeclaration)nms.getDeclarations().next()).getTypeSpecifier()); + assertQualifiedName( enumSpec.getFullyQualifiedName(), new String[] { "N", "E2" } ); + assertFalse( declarations.hasNext() ); + } + + public void testVariable() throws Exception + { + IASTNamespaceDefinition topNMS = (IASTNamespaceDefinition)assertSoleDeclaration("namespace A { int x; namespace B { int y; } }"); + Iterator level1 = topNMS.getDeclarations(); + IASTVariable var = (IASTVariable)level1.next(); + assertQualifiedName( var.getFullyQualifiedName(), new String[] {"A","x"}); + Iterator level2 = ((IASTNamespaceDefinition)level1.next()).getDeclarations(); + assertFalse( level1.hasNext()); + var = (IASTVariable)level2.next(); + assertQualifiedName( var.getFullyQualifiedName(), new String[] {"A","B","y"}); + } + + public void testTypedef() throws Exception + { + IASTNamespaceDefinition topNMS = (IASTNamespaceDefinition) + assertSoleDeclaration("namespace FLEA { typedef int GODS_INT; class ANTHONY { typedef ANTHONY * tonyPointer; }; }"); + Iterator level1 = topNMS.getDeclarations(); + assertQualifiedName( ((IASTTypedefDeclaration)level1.next()).getFullyQualifiedName(), new String [] { "FLEA", "GODS_INT" } ); + assertQualifiedName( ((IASTTypedefDeclaration)((IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)level1.next()).getTypeSpecifier()).getDeclarations().next()).getFullyQualifiedName(), new String [] { "FLEA", "ANTHONY", "tonyPointer" } ); + } + + + public void testMembers() throws Exception + { + IASTNamespaceDefinition topNMS = + (IASTNamespaceDefinition)assertSoleDeclaration( "namespace John { class David { int Shannon; void Camelon(); }; } "); + Iterator members = + ((IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)topNMS.getDeclarations().next()).getTypeSpecifier()).getDeclarations(); + assertQualifiedName( ((IASTField)members.next()).getFullyQualifiedName(), new String[] { "John", "David", "Shannon" } ); + assertQualifiedName( ((IASTMethod)members.next()).getFullyQualifiedName(), new String[] { "John", "David", "Camelon" } ); + } + + public void testFunction() throws Exception + { + IASTNamespaceDefinition topNMS = + (IASTNamespaceDefinition)assertSoleDeclaration( "namespace Bogdan { void Wears(); namespace Fancy { int Pants(); } }" ); + Iterator members = topNMS.getDeclarations(); + assertQualifiedName( ((IASTFunction)members.next()).getFullyQualifiedName(), new String[] { "Bogdan", "Wears" } ); + assertQualifiedName( ((IASTFunction)((IASTNamespaceDefinition)members.next()).getDeclarations().next()).getFullyQualifiedName(), new String[] { "Bogdan", "Fancy", "Pants" } ); + } + +} diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index cf79b68472f..4028b3f3895 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,8 @@ +2003-07-18 John Camelon + Removed DeclaratorDuple as it was obsolete. + Fixed offsets in quickParse's IASTTypedefDeclaration implementation. + Fixed Bug 40436 - Fully Qualified Names Needed (for Indexer/Search features) + 2003-07-17 John Camelon Removed IParserCallback. Partially converted DOM to ISourceElementRequestor (requires refactoring of CModelBuilder & StuctureComparator modules in near future). diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java index 98443eba84e..03f124d1d5a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.Enum; * @author jcamelon * */ -public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTScopedElement, IASTOffsetableNamedElement, IASTQualifiedNameElement { +public interface IASTClassSpecifier extends IASTTypeSpecifier, IASTScope, IASTOffsetableNamedElement, IASTScopedTypeSpecifier { public class ClassNameType extends Enum { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java index df989480c29..b3bcc2f944c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTEnumerationSpecifier.java @@ -16,7 +16,7 @@ import java.util.Iterator; * @author jcamelon * */ -public interface IASTEnumerationSpecifier extends IASTTypeSpecifier, IASTOffsetableNamedElement { +public interface IASTEnumerationSpecifier extends IASTScopedTypeSpecifier, IASTOffsetableNamedElement { public void addEnumerator( IASTEnumerator enumerator ); public Iterator getEnumerators(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java index 1c1f36f06a8..6e2ba6e0883 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java @@ -82,9 +82,9 @@ public interface IASTFactory int startingOffset, int endOffset); public IASTEnumerationSpecifier createEnumerationSpecifier( + IASTScope scope, String name, - int startingOffset, - int nameOffset); + int startingOffset, int nameOffset); public void addEnumerator( IASTEnumerationSpecifier enumeration, String string, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java index 9f25dc7eec1..9576fb79b35 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java @@ -16,7 +16,7 @@ import java.util.Iterator; * @author jcamelon * */ -public interface IASTFunction extends IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration, IASTDeclaration { +public interface IASTFunction extends IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration, IASTDeclaration, IASTQualifiedNameElement { public boolean isInline(); public boolean isFriend(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java index a2cec3c734f..c4599e73320 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTMember.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTMember extends IASTDeclaration +public interface IASTMember extends IASTDeclaration, IASTQualifiedNameElement { public ASTAccessVisibility getVisiblity(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclaratorDuple.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTScopedTypeSpecifier.java index b4467fea017..2245f3c48fb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclaratorDuple.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTScopedTypeSpecifier.java @@ -8,23 +8,12 @@ * Contributors: * IBM Rational Software - Initial API and implementation ***********************************************************************/ -package org.eclipse.cdt.internal.core.parser; +package org.eclipse.cdt.core.parser.ast; /** * @author jcamelon + * */ -public class DeclaratorDuple { - - public DeclaratorDuple( Declarator d ) - { - declarator = d; - } - - private final Declarator declarator; - /** - * @return - */ - public Declarator getDeclarator() { - return declarator; - } +public interface IASTScopedTypeSpecifier extends IASTTypeSpecifier, IASTScopedElement, IASTQualifiedNameElement +{ } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java index 63d03ce4f5c..9023f87e21f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTTypedefDeclaration.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTTypedefDeclaration extends IASTDeclaration, IASTOffsetableNamedElement { +public interface IASTTypedefDeclaration extends IASTDeclaration, IASTOffsetableNamedElement, IASTQualifiedNameElement { public String getName(); public IASTAbstractDeclaration getAbstractDeclarator(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java index 57c81c6fee6..be4e1235991 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast; * @author jcamelon * */ -public interface IASTVariable extends IASTDeclaration, IASTOffsetableNamedElement { +public interface IASTVariable extends IASTDeclaration, IASTOffsetableNamedElement, IASTQualifiedNameElement { public boolean isAuto(); public boolean isRegister(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 10ecd8c594e..b978513dce0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -766,18 +766,18 @@ public class Parser implements IParser sdw.isUnsigned(), sdw.isTypeNamed())); - DeclaratorDuple d = null; + Declarator declarator = null; if (LT(1) != IToken.tSEMI) try { - d = initDeclarator(sdw); + declarator = initDeclarator(sdw); while (LT(1) == IToken.tCOMMA) { consume(); try { - d = initDeclarator(sdw); + initDeclarator(sdw); } catch (Backtrack b) { @@ -800,12 +800,12 @@ public class Parser implements IParser case IToken.tCOLON : if (forKR) throw backtrack; - ctorInitializer(d.getDeclarator()); + ctorInitializer(declarator); // Falling through on purpose case IToken.tLBRACE : if (forKR) throw backtrack; - d.getDeclarator().hasFunctionBody(true); + declarator.hasFunctionBody(true); hasFunctionBody = true; break; default : @@ -869,7 +869,7 @@ public class Parser implements IParser } } - handleFunctionBody(d.getDeclarator()); + handleFunctionBody(declarator); if (declaration instanceof IASTMethod) requestor.exitMethodBody((IASTMethod)declaration); @@ -987,7 +987,7 @@ public class Parser implements IParser if (LT(1) != IToken.tSEMI) try { - DeclaratorDuple d = initDeclarator(sdw); + initDeclarator(sdw); } catch (Backtrack b) { @@ -1633,12 +1633,11 @@ public class Parser implements IParser * @return declarator that this parsing produced. * @throws Backtrack request a backtrack */ - protected DeclaratorDuple initDeclarator( + protected Declarator initDeclarator( DeclarationWrapper sdw) throws Backtrack { - DeclaratorDuple duple = declarator(sdw); - Declarator d = duple.getDeclarator(); + Declarator d = declarator(sdw); // handle = initializerClause if (LT(1) == IToken.tASSIGN) { @@ -1655,7 +1654,7 @@ public class Parser implements IParser d.setConstructorExpression(astExpression); } sdw.addDeclarator(d); - return duple; + return d; } /** * @@ -1732,7 +1731,7 @@ public class Parser implements IParser * @return declarator that this parsing produced. * @throws Backtrack request a backtrack */ - protected DeclaratorDuple declarator( + protected Declarator declarator( IDeclaratorOwner owner) throws Backtrack { @@ -1756,7 +1755,7 @@ public class Parser implements IParser if (LT(1) == IToken.tLPAREN) { consume(); - DeclaratorDuple subDeclarator = declarator(d); + declarator(d); consume(IToken.tRPAREN); } else if (LT(1) == IToken.t_operator) @@ -1988,7 +1987,7 @@ public class Parser implements IParser while (true); if (d.getOwner() instanceof Declarator) ((Declarator)d.getOwner()).setOwnedDeclarator(d); - return new DeclaratorDuple(d); + return d; } protected void operatorId( Declarator d, @@ -2138,9 +2137,9 @@ public class Parser implements IParser { IASTEnumerationSpecifier enumeration = astFactory.createEnumerationSpecifier( + sdw.getScope(), ((identifier == null) ? "" : identifier.getImage()), - mark.getOffset(), - ((identifier == null) + mark.getOffset(), ((identifier == null) ? mark.getOffset() : identifier.getOffset())); consume(IToken.tLBRACE); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java index 54956fa3c2d..ef965d405d6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java @@ -206,7 +206,7 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory { /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createEnumerationSpecifier(java.lang.String, int) */ - public IASTEnumerationSpecifier createEnumerationSpecifier(String name, int startingOffset, int nameOffset) + public IASTEnumerationSpecifier createEnumerationSpecifier(IASTScope scope, String name, int startingOffset, int nameOffset) { // TODO Auto-generated method stub return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java index 56b593358e8..2174d7c4e9d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTClassSpecifier.java @@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; * @author jcamelon * */ -public class ASTClassSpecifier implements IASTQClassSpecifier, IASTQScope +public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQClassSpecifier, IASTQScope { private final IASTScope scope; @@ -36,6 +36,7 @@ public class ASTClassSpecifier implements IASTQClassSpecifier, IASTQScope ASTAccessVisibility access, IASTTemplate ownerTemplate) { + super( scope, name ); this.scope = scope; qualifiedNameElement = new ASTQualifiedNamedElement( scope, name ); classNameType = type; @@ -151,20 +152,7 @@ public class ASTClassSpecifier implements IASTQClassSpecifier, IASTQScope { baseClauses.add(baseSpecifier); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName() - */ - public String[] getFullyQualifiedName() - { - return qualifiedNameElement.getFullyQualifiedName(); - } - /** - * @return - */ - public IASTScope getOwnerScope() - { - return scope; - } + /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#setCurrentVisibility(org.eclipse.cdt.core.parser.ast.ASTAccessVisibility) */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerationSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerationSpecifier.java index 5d4bccbc656..e1ca3ff5acf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerationSpecifier.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTEnumerationSpecifier.java @@ -18,13 +18,14 @@ import java.util.List; import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.parser.ast.IASTEnumerator; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; +import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; /** * @author jcamelon * */ -public class ASTEnumerationSpecifier +public class ASTEnumerationSpecifier extends ASTScopedTypeSpecifier implements IASTEnumerationSpecifier, IASTOffsetableNamedElement { private final String name; @@ -34,8 +35,9 @@ public class ASTEnumerationSpecifier * @param name * @param startingOffset */ - public ASTEnumerationSpecifier(String name, int startingOffset, int nameOffset) + public ASTEnumerationSpecifier(IASTScope scope, String name, int startingOffset, int nameOffset) { + super( scope, name ); this.name = name; offsets.setNameOffset( nameOffset ); offsets.setStartingOffset( startingOffset); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java index fbd0214fb03..095f0b5b3cf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTFunction.java @@ -17,6 +17,7 @@ import java.util.List; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTFunction; +import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTTemplate; import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; @@ -46,8 +47,10 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction ownerTemplate.setOwnedDeclaration( this ); offsets.setStartingOffset( startOffset ); offsets.setNameOffset( nameOffset ); + qualifiedName = new ASTQualifiedNamedElement( scope, name ); } + private final IASTQualifiedNameElement qualifiedName; private final IASTTemplate ownerTemplateDeclaration; private NamedOffsets offsets = new NamedOffsets(); private List declarations = new ArrayList(); @@ -163,4 +166,11 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction { return declarations.iterator(); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName() + */ + public String[] getFullyQualifiedName() + { + return qualifiedName.getFullyQualifiedName(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java index b29eb20772a..462a076f733 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTMethod.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; import org.eclipse.cdt.core.parser.ast.IASTExceptionSpecification; import org.eclipse.cdt.core.parser.ast.IASTMethod; +import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTTemplate; /** @@ -31,6 +32,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod private final boolean isVirtual; private final boolean isVolatile; private final ASTAccessVisibility visibility; + private final IASTQualifiedNameElement qualifiedName; /** * @param scope * @param name @@ -84,6 +86,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod this.isConst = isConst; this.isVolatile = isVolatile; this.visibility = visibility; + qualifiedName = new ASTQualifiedNamedElement( scope, name ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTMethod#isVirtual() @@ -143,6 +146,13 @@ public class ASTMethod extends ASTFunction implements IASTMethod return visibility; } /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName() + */ + public String[] getFullyQualifiedName() + { + return qualifiedName.getFullyQualifiedName(); + } + /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTMember#getOwnerClassSpecifier() */ } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTQualifiedNamedElement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTQualifiedNamedElement.java index 5c2b272cbee..a33d99dfeb3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTQualifiedNamedElement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTQualifiedNamedElement.java @@ -15,6 +15,7 @@ import java.util.Stack; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; +import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScopedElement; @@ -22,7 +23,7 @@ import org.eclipse.cdt.core.parser.ast.IASTScopedElement; * @author jcamelon * */ -public class ASTQualifiedNamedElement +public class ASTQualifiedNamedElement implements IASTQualifiedNameElement { /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTScopedTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTScopedTypeSpecifier.java new file mode 100644 index 00000000000..21b2585c957 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTScopedTypeSpecifier.java @@ -0,0 +1,37 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.quick; + +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTScopedTypeSpecifier; + +/** + * @author jcamelon + * + */ +public class ASTScopedTypeSpecifier extends ASTQualifiedNamedElement implements IASTScopedTypeSpecifier +{ + private final IASTScope scope; + + public ASTScopedTypeSpecifier( IASTScope scope, String name ) + { + super( scope, name ); + this.scope = scope; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTScopedElement#getOwnerScope() + */ + public IASTScope getOwnerScope() + { + return scope; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedefDeclaration.java index f843e16d002..ef0be3e7081 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTTypedefDeclaration.java @@ -19,21 +19,25 @@ import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets; * @author jcamelon * */ -public class ASTTypedef extends ASTDeclaration implements IASTTypedefDeclaration +public class ASTTypedefDeclaration extends ASTDeclaration implements IASTTypedefDeclaration { private final String name; private final IASTAbstractDeclaration mapping; - private NamedOffsets offsets = new NamedOffsets(); + private NamedOffsets offsets = new NamedOffsets(); + private final ASTQualifiedNamedElement qualifiedName; /** * @param scope * @param name * @param mapping */ - public ASTTypedef(IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset) + public ASTTypedefDeclaration(IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset) { super( scope ); this.name = name; this.mapping = mapping; + setStartingOffset(startingOffset); + setElementNameOffset(nameOffset); + qualifiedName = new ASTQualifiedNamedElement( scope, name ); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTTypedef#getName() @@ -54,23 +58,21 @@ public class ASTTypedef extends ASTDeclaration implements IASTTypedefDeclaration */ public int getElementNameOffset() { - // TODO Auto-generated method stub - return 0; + return offsets.getElementNameOffset(); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int) */ public void setElementNameOffset(int o) { - // TODO Auto-generated method stub - + offsets.setNameOffset(o); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int) */ public void setStartingOffset(int o) { - // TODO Auto-generated method stub + offsets.setStartingOffset(o); } /* (non-Javadoc) @@ -78,24 +80,28 @@ public class ASTTypedef extends ASTDeclaration implements IASTTypedefDeclaration */ public void setEndingOffset(int o) { - // TODO Auto-generated method stub - + offsets.setEndingOffset(o); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset() */ public int getElementStartingOffset() { - // TODO Auto-generated method stub - return 0; + return offsets.getElementStartingOffset(); } /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset() */ public int getElementEndingOffset() { - // TODO Auto-generated method stub - return 0; + return offsets.getElementEndingOffset(); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName() + */ + public String[] getFullyQualifiedName() + { + return qualifiedName.getFullyQualifiedName(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java index 30fbda0e194..9331201700f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTVariable.java @@ -32,7 +32,8 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable private final boolean isRegister; private final boolean isStatic; private final String name; - private NamedOffsets offsets = new NamedOffsets(); + private NamedOffsets offsets = new NamedOffsets(); + private final ASTQualifiedNamedElement qualifiedName; /** * @param scope */ @@ -49,6 +50,7 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable this.isRegister = isRegister; this.isStatic = isStatic; this.name = name; + qualifiedName = new ASTQualifiedNamedElement( scope, name ); } /* (non-Javadoc) @@ -163,6 +165,13 @@ public class ASTVariable extends ASTDeclaration implements IASTVariable { offsets.setNameOffset(o); } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement#getFullyQualifiedName() + */ + public String[] getFullyQualifiedName() + { + return qualifiedName.getFullyQualifiedName(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java index 8c543255d20..291bad5e91d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java @@ -141,9 +141,9 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createEnumerationSpecifier(java.lang.String, int) */ - public IASTEnumerationSpecifier createEnumerationSpecifier(String name, int startingOffset, int nameOffset) + public IASTEnumerationSpecifier createEnumerationSpecifier(IASTScope scope, String name, int startingOffset, int nameOffset) { - return new ASTEnumerationSpecifier( name, startingOffset, nameOffset ); + return new ASTEnumerationSpecifier( scope, name, startingOffset, nameOffset ); } /* (non-Javadoc) @@ -292,7 +292,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory */ public IASTTypedefDeclaration createTypedef(IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int nameOffset) { - return new ASTTypedef( scope, name, mapping, startingOffset, nameOffset ); + return new ASTTypedefDeclaration( scope, name, mapping, startingOffset, nameOffset ); } /* (non-Javadoc) |