mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
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.
This commit is contained in:
parent
2566b4d3d9
commit
e042f101ba
24 changed files with 263 additions and 78 deletions
|
@ -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.
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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" } );
|
||||
}
|
||||
|
||||
}
|
|
@ -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).
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
@ -142,6 +145,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()
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue