mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Addded in support for BaseSpecifier & class/namespace reference callbacks upon those. TESTS Updated CompleteParseASTTests.
This commit is contained in:
parent
d8ee61be38
commit
c39bb334d0
22 changed files with 749 additions and 129 deletions
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
@ -19,21 +20,31 @@ import java.util.Stack;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
@ -41,10 +52,11 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
import org.eclipse.cdt.internal.core.parser.ScannerInfo;
|
||||||
|
|
||||||
|
@ -73,11 +85,20 @@ public class CompleteParseASTTest extends TestCase
|
||||||
{
|
{
|
||||||
return decls.iterator();
|
return decls.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IASTScope getScope()
|
||||||
|
{
|
||||||
|
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FullParseCallback extends NullSourceElementRequestor implements ISourceElementRequestor
|
public class FullParseCallback implements ISourceElementRequestor
|
||||||
{
|
{
|
||||||
|
private List references = new ArrayList();
|
||||||
private Stack inclusions = new Stack();
|
private Stack inclusions = new Stack();
|
||||||
private Scope compilationUnit;
|
private Scope compilationUnit;
|
||||||
|
|
||||||
|
@ -378,7 +399,9 @@ public class CompleteParseASTTest extends TestCase
|
||||||
|
|
||||||
protected Scope popScope()
|
protected Scope popScope()
|
||||||
{
|
{
|
||||||
return (Scope)scopes.pop();
|
Scope s = (Scope)scopes.pop();
|
||||||
|
h.put( s.getScope(), s );
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void pushScope( IASTScope scope )
|
protected void pushScope( IASTScope scope )
|
||||||
|
@ -386,6 +409,113 @@ public class CompleteParseASTTest extends TestCase
|
||||||
scopes.push( new Scope( scope ));
|
scopes.push( new Scope( scope ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Hashtable h = new Hashtable();
|
||||||
|
|
||||||
|
public Scope lookup( IASTScope s)
|
||||||
|
{
|
||||||
|
return (Scope)h.get(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
||||||
|
*/
|
||||||
|
public void acceptProblem(IProblem problem)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
|
||||||
|
*/
|
||||||
|
public void acceptMacro(IASTMacro macro)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassReference)
|
||||||
|
*/
|
||||||
|
public void acceptClassReference(IASTClassReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedefReference(org.eclipse.cdt.core.parser.ast.IASTTypedefReference)
|
||||||
|
*/
|
||||||
|
public void acceptTypedefReference(IASTTypedefReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptNamespaceReference(org.eclipse.cdt.core.parser.ast.IASTNamespaceReference)
|
||||||
|
*/
|
||||||
|
public void acceptNamespaceReference(IASTNamespaceReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
|
||||||
|
*/
|
||||||
|
public void acceptEnumerationReference(IASTEnumerationReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariableReference(org.eclipse.cdt.core.parser.ast.IASTVariableReference)
|
||||||
|
*/
|
||||||
|
public void acceptVariableReference(IASTVariableReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionReference(org.eclipse.cdt.core.parser.ast.IASTFunctionReference)
|
||||||
|
*/
|
||||||
|
public void acceptFunctionReference(IASTFunctionReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFieldReference(org.eclipse.cdt.core.parser.ast.IASTFieldReference)
|
||||||
|
*/
|
||||||
|
public void acceptFieldReference(IASTFieldReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodReference(org.eclipse.cdt.core.parser.ast.IASTMethodReference)
|
||||||
|
*/
|
||||||
|
public void acceptMethodReference(IASTMethodReference reference)
|
||||||
|
{
|
||||||
|
references.add( reference );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getReferences()
|
||||||
|
{
|
||||||
|
return references;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Iterator getDeclarations( IASTScope scope )
|
||||||
|
{
|
||||||
|
Scope s = callback.lookup( scope );
|
||||||
|
if( s != null )
|
||||||
|
return s.getDeclarations();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,7 +552,7 @@ public class CompleteParseASTTest extends TestCase
|
||||||
Iterator declarations = parse( "namespace A { }").getDeclarations();
|
Iterator declarations = parse( "namespace A { }").getDeclarations();
|
||||||
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
assertEquals( namespaceDefinition.getName(), "A" );
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
assertFalse( namespaceDefinition.getDeclarations().hasNext() );
|
assertFalse( getDeclarations( namespaceDefinition ).hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultipleNamespaceDefinitions() throws Exception
|
public void testMultipleNamespaceDefinitions() throws Exception
|
||||||
|
@ -432,7 +562,7 @@ public class CompleteParseASTTest extends TestCase
|
||||||
assertEquals( namespaceDefinition.getName(), "A" );
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
assertEquals( namespaceDefinition.getName(), "A" );
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
assertFalse( namespaceDefinition.getDeclarations().hasNext() );
|
assertFalse( getDeclarations( namespaceDefinition ).hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNestedNamespaceDefinitions() throws Exception
|
public void testNestedNamespaceDefinitions() throws Exception
|
||||||
|
@ -441,18 +571,46 @@ public class CompleteParseASTTest extends TestCase
|
||||||
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
assertEquals( namespaceDefinition.getName(), "A" );
|
assertEquals( namespaceDefinition.getName(), "A" );
|
||||||
assertFalse( declarations.hasNext() );
|
assertFalse( declarations.hasNext() );
|
||||||
Iterator subDeclarations = namespaceDefinition.getDeclarations();
|
Iterator subDeclarations = getDeclarations( namespaceDefinition );
|
||||||
IASTNamespaceDefinition subDeclaration = (IASTNamespaceDefinition)subDeclarations.next();
|
IASTNamespaceDefinition subDeclaration = (IASTNamespaceDefinition)subDeclarations.next();
|
||||||
assertEquals( subDeclaration.getName(), "B" );
|
assertEquals( subDeclaration.getName(), "B" );
|
||||||
assertFalse( subDeclarations.hasNext() );
|
assertFalse( subDeclarations.hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testEmptyClassDeclaration() throws Exception
|
public void testEmptyClassDeclaration() throws Exception
|
||||||
// {
|
{
|
||||||
// Iterator declarations = parse( "class A { };").getDeclarations();
|
Iterator declarations = parse( "class A { };").getDeclarations();
|
||||||
// IASTClassSpecifier classSpec = (IASTClassSpecifier)declarations.next();
|
IASTAbstractTypeSpecifierDeclaration abs = (IASTAbstractTypeSpecifierDeclaration)declarations.next();
|
||||||
// assertEquals( classSpec.getName(), "A");
|
IASTClassSpecifier classSpec = (IASTClassSpecifier)abs.getTypeSpecifier();
|
||||||
// assertFalse( classSpec.getDeclarations().hasNext() );
|
assertEquals( classSpec.getName(), "A");
|
||||||
// assertFalse( declarations.hasNext() );
|
assertFalse( getDeclarations( classSpec ).hasNext() );
|
||||||
// }
|
assertFalse( declarations.hasNext() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSimpleSubclass() throws Exception
|
||||||
|
{
|
||||||
|
Iterator declarations = parse( "class A { }; class B : public A { };").getDeclarations();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
|
||||||
|
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
|
||||||
|
Iterator parentClasses = classB.getBaseClauses();
|
||||||
|
IASTBaseSpecifier baseClass = (IASTBaseSpecifier)parentClasses.next();
|
||||||
|
assertEquals( classA, baseClass.getParentClassSpecifier() );
|
||||||
|
assertEquals( baseClass.getParentClassName(), "A");
|
||||||
|
assertEquals( baseClass.getAccess(), ASTAccessVisibility.PUBLIC);
|
||||||
|
assertFalse( baseClass.isVirtual() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNestedSubclass() throws Exception
|
||||||
|
{
|
||||||
|
Iterator declarations = parse( "namespace N { class A { }; } class B : protected virtual N::A { };").getDeclarations();
|
||||||
|
IASTNamespaceDefinition namespaceDefinition = (IASTNamespaceDefinition)declarations.next();
|
||||||
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)getDeclarations( namespaceDefinition).next() ).getTypeSpecifier();
|
||||||
|
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)declarations.next()).getTypeSpecifier();
|
||||||
|
Iterator baseClauses = classB.getBaseClauses();
|
||||||
|
IASTBaseSpecifier baseClass = (IASTBaseSpecifier)baseClauses.next();
|
||||||
|
assertEquals( classA, baseClass.getParentClassSpecifier() );
|
||||||
|
assertEquals( callback.getReferences().size(), 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,10 +307,10 @@ public class ParserSymbolTableTest extends TestCase {
|
||||||
IDerivableContainerSymbol c = table.newDerivableContainerSymbol("C");
|
IDerivableContainerSymbol c = table.newDerivableContainerSymbol("C");
|
||||||
|
|
||||||
IDerivableContainerSymbol a = table.newDerivableContainerSymbol("A");
|
IDerivableContainerSymbol a = table.newDerivableContainerSymbol("A");
|
||||||
a.addParent( c, true, ASTAccessVisibility.PUBLIC );
|
a.addParent( c, true, ASTAccessVisibility.PUBLIC, 3, null );
|
||||||
|
|
||||||
IDerivableContainerSymbol b = table.newDerivableContainerSymbol("B");
|
IDerivableContainerSymbol b = table.newDerivableContainerSymbol("B");
|
||||||
b.addParent( c, true, ASTAccessVisibility.PUBLIC );
|
b.addParent( c, true, ASTAccessVisibility.PUBLIC, 6, null );
|
||||||
|
|
||||||
decl.addParent( a );
|
decl.addParent( a );
|
||||||
decl.addParent( b );
|
decl.addParent( b );
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2003-07-21 John Camelon
|
||||||
|
Addded in support for BaseSpecifier & class/namespace reference callbacks upon those.
|
||||||
|
|
||||||
2003-07-21 John Camelon
|
2003-07-21 John Camelon
|
||||||
Fleshed out basic declarations for FullParse AST.
|
Fleshed out basic declarations for FullParse AST.
|
||||||
Fixed Bug 40554 - Fields coming back as Vars
|
Fixed Bug 40554 - Fields coming back as Vars
|
||||||
|
|
|
@ -10,16 +10,19 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IASTBaseSpecifier {
|
public interface IASTBaseSpecifier extends ISourceElementCallbackDelegate {
|
||||||
|
|
||||||
public ASTAccessVisibility getAccess();
|
public ASTAccessVisibility getAccess();
|
||||||
public boolean isVirtual();
|
public boolean isVirtual();
|
||||||
public String getParentClassName();
|
public String getParentClassName();
|
||||||
public IASTClassSpecifier getParentClassSpecifier() throws ASTNotImplementedException;
|
public IASTClassSpecifier getParentClassSpecifier() throws ASTNotImplementedException;
|
||||||
|
public int getNameOffset();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public interface IASTFactory
|
||||||
IASTClassSpecifier astClassSpec,
|
IASTClassSpecifier astClassSpec,
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
ASTAccessVisibility visibility,
|
ASTAccessVisibility visibility,
|
||||||
String string);
|
ITokenDuple parentClassName) throws ASTSemanticException;
|
||||||
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(
|
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(
|
||||||
ASTClassKind elaboratedClassKind,
|
ASTClassKind elaboratedClassKind,
|
||||||
String typeName,
|
String typeName,
|
||||||
|
|
|
@ -2343,11 +2343,18 @@ public class Parser implements IParser
|
||||||
nameDuple = name();
|
nameDuple = name();
|
||||||
break;
|
break;
|
||||||
case IToken.tCOMMA :
|
case IToken.tCOMMA :
|
||||||
astFactory.addBaseSpecifier(
|
try
|
||||||
astClassSpec,
|
{
|
||||||
isVirtual,
|
astFactory.addBaseSpecifier(
|
||||||
visibility,
|
astClassSpec,
|
||||||
nameDuple.toString());
|
isVirtual,
|
||||||
|
visibility,
|
||||||
|
nameDuple );
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
}
|
||||||
isVirtual = false;
|
isVirtual = false;
|
||||||
visibility = ASTAccessVisibility.PUBLIC;
|
visibility = ASTAccessVisibility.PUBLIC;
|
||||||
nameDuple = null;
|
nameDuple = null;
|
||||||
|
@ -2358,11 +2365,18 @@ public class Parser implements IParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
astFactory.addBaseSpecifier(
|
try
|
||||||
astClassSpec,
|
{
|
||||||
isVirtual,
|
astFactory.addBaseSpecifier(
|
||||||
visibility,
|
astClassSpec,
|
||||||
nameDuple.toString());
|
isVirtual,
|
||||||
|
visibility,
|
||||||
|
nameDuple );
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Parses a function body.
|
* Parses a function body.
|
||||||
|
|
|
@ -313,7 +313,7 @@ public class Scanner implements IScanner {
|
||||||
{
|
{
|
||||||
String currentFilename = contextStack.getCurrentContext().getFilename();
|
String currentFilename = contextStack.getCurrentContext().getFilename();
|
||||||
File currentIncludeFile = new File( currentFilename );
|
File currentIncludeFile = new File( currentFilename );
|
||||||
String parentDirectory = currentIncludeFile.getParent();
|
String parentDirectory = currentIncludeFile.getParentFile().getAbsolutePath();
|
||||||
currentIncludeFile = null;
|
currentIncludeFile = null;
|
||||||
newPath = parentDirectory + File.separatorChar + fileName;
|
newPath = parentDirectory + File.separatorChar + fileName;
|
||||||
File includeFile = new File( newPath );
|
File includeFile = new File( newPath );
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class TokenDuple implements ITokenDuple {
|
||||||
* @see java.util.Iterator#hasNext()
|
* @see java.util.Iterator#hasNext()
|
||||||
*/
|
*/
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return ( iter != TokenDuple.this.lastToken);
|
return ( iter != null );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -65,7 +65,10 @@ public class TokenDuple implements ITokenDuple {
|
||||||
if( ! hasNext() )
|
if( ! hasNext() )
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
IToken temp = iter;
|
IToken temp = iter;
|
||||||
iter = iter.getNext();
|
if( iter == lastToken )
|
||||||
|
iter = null;
|
||||||
|
else
|
||||||
|
iter = iter.getNext();
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.complete;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTBaseSpecifier implements IASTBaseSpecifier
|
||||||
|
{
|
||||||
|
private ASTReferenceStore referenceDelegate;
|
||||||
|
private final boolean isVirtual;
|
||||||
|
private final ISymbol symbol;
|
||||||
|
private final ASTAccessVisibility visibility;
|
||||||
|
private final int offset;
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
* @param b
|
||||||
|
* @param visibility
|
||||||
|
*/
|
||||||
|
public ASTBaseSpecifier(ISymbol symbol, boolean b, ASTAccessVisibility visibility, int nameOffset, List references)
|
||||||
|
{
|
||||||
|
isVirtual = b;
|
||||||
|
this.visibility = visibility;
|
||||||
|
this.symbol = symbol;
|
||||||
|
this.offset = nameOffset;
|
||||||
|
referenceDelegate = new ASTReferenceStore( references );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getAccess()
|
||||||
|
*/
|
||||||
|
public ASTAccessVisibility getAccess()
|
||||||
|
{
|
||||||
|
return visibility;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#isVirtual()
|
||||||
|
*/
|
||||||
|
public boolean isVirtual()
|
||||||
|
{
|
||||||
|
return isVirtual;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParentClassName()
|
||||||
|
*/
|
||||||
|
public String getParentClassName()
|
||||||
|
{
|
||||||
|
return symbol.getName();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParentClassSpecifier()
|
||||||
|
*/
|
||||||
|
public IASTClassSpecifier getParentClassSpecifier()
|
||||||
|
throws ASTNotImplementedException
|
||||||
|
{
|
||||||
|
return (IASTClassSpecifier)symbol.getASTExtension().getPrimaryDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getNameOffset()
|
||||||
|
*/
|
||||||
|
public int getNameOffset()
|
||||||
|
{
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences()
|
||||||
|
*/
|
||||||
|
public void processReferences(ISourceElementRequestor requestor) throws ASTNotImplementedException
|
||||||
|
{
|
||||||
|
referenceDelegate.processReferences(requestor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
referenceDelegate.processReferences(requestor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScopedElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTClassReference
|
||||||
|
extends ASTReference
|
||||||
|
implements IASTClassReference
|
||||||
|
{
|
||||||
|
private final IASTClassSpecifier reference;
|
||||||
|
/**
|
||||||
|
* @param i
|
||||||
|
* @param string
|
||||||
|
* @param specifier
|
||||||
|
*/
|
||||||
|
public ASTClassReference(int i, String string, IASTClassSpecifier specifier)
|
||||||
|
{
|
||||||
|
super( i, string );
|
||||||
|
reference = specifier;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
|
||||||
|
*/
|
||||||
|
public IASTScopedElement getReferencedElement()
|
||||||
|
{
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.acceptClassReference( this );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,15 +11,20 @@
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Declaration.ParentWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -27,6 +32,54 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
*/
|
*/
|
||||||
public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public class BaseIterator implements Iterator
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Iterator parents;
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
*/
|
||||||
|
public BaseIterator(IDerivableContainerSymbol symbol)
|
||||||
|
{
|
||||||
|
if( symbol.getParents() != null )
|
||||||
|
parents = symbol.getParents().iterator();
|
||||||
|
else
|
||||||
|
parents = null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#hasNext()
|
||||||
|
*/
|
||||||
|
public boolean hasNext()
|
||||||
|
{
|
||||||
|
if( parents == null )
|
||||||
|
return false;
|
||||||
|
return parents.hasNext();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#next()
|
||||||
|
*/
|
||||||
|
public Object next()
|
||||||
|
{
|
||||||
|
if( ! hasNext() )
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
|
||||||
|
ParserSymbolTable.Declaration.ParentWrapper pw = (ParentWrapper)parents.next();
|
||||||
|
|
||||||
|
return new ASTBaseSpecifier( pw.getParent(), pw.isVirtual(), pw.getAccess(), pw.getOffset(), pw.getReferences() );
|
||||||
|
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Iterator#remove()
|
||||||
|
*/
|
||||||
|
public void remove()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private NamedOffsets offsets = new NamedOffsets();
|
private NamedOffsets offsets = new NamedOffsets();
|
||||||
private final ClassNameType classNameType;
|
private final ClassNameType classNameType;
|
||||||
private final ASTClassKind classKind;
|
private final ASTClassKind classKind;
|
||||||
|
@ -65,8 +118,7 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
||||||
*/
|
*/
|
||||||
public Iterator getBaseClauses()
|
public Iterator getBaseClauses()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
return new BaseIterator( (IDerivableContainerSymbol)getSymbol() );
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisibilityMode()
|
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getCurrentVisibilityMode()
|
||||||
|
@ -116,8 +168,13 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
||||||
*/
|
*/
|
||||||
public void enterScope(ISourceElementRequestor requestor)
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
{
|
{
|
||||||
//TODO Iterate baseClauses and callback on their references
|
|
||||||
requestor.enterClassSpecifier(this);
|
requestor.enterClassSpecifier(this);
|
||||||
|
Iterator i = getBaseClauses();
|
||||||
|
while( i.hasNext() )
|
||||||
|
{
|
||||||
|
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier)i.next();
|
||||||
|
baseSpec.acceptElement(requestor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScopedElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTNamespaceReference
|
||||||
|
extends ASTReference
|
||||||
|
implements IASTNamespaceReference
|
||||||
|
{
|
||||||
|
private final IASTNamespaceDefinition reference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param offset
|
||||||
|
* @param string
|
||||||
|
* @param definition
|
||||||
|
*/
|
||||||
|
public ASTNamespaceReference(int offset, String string, IASTNamespaceDefinition definition)
|
||||||
|
{
|
||||||
|
super(offset, string);
|
||||||
|
reference = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReference#getReferencedElement()
|
||||||
|
*/
|
||||||
|
public IASTScopedElement getReferencedElement()
|
||||||
|
{
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
requestor.acceptNamespaceReference( this );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.complete;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ASTReference implements IASTReference
|
||||||
|
{
|
||||||
|
protected final String name;
|
||||||
|
protected final int offset;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ASTReference(int offset, String name)
|
||||||
|
{
|
||||||
|
this.offset = offset;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReference#getOffset()
|
||||||
|
*/
|
||||||
|
public int getOffset()
|
||||||
|
{
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReference#getName()
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.complete;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTReferenceStore
|
||||||
|
{
|
||||||
|
private List references = new ArrayList();
|
||||||
|
|
||||||
|
public ASTReferenceStore( List assortedReferences )
|
||||||
|
{
|
||||||
|
references.addAll( assortedReferences );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences()
|
||||||
|
*/
|
||||||
|
public void processReferences(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
Iterator i = references.iterator();
|
||||||
|
while( i.hasNext() )
|
||||||
|
((IASTReference)i.next()).acceptElement(requestor);
|
||||||
|
references.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
@ -38,9 +39,9 @@ public abstract class ASTScope extends ASTSymbol implements IASTScope
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
* @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
|
||||||
*/
|
*/
|
||||||
public Iterator getDeclarations()
|
public Iterator getDeclarations() throws ASTNotImplementedException
|
||||||
{
|
{
|
||||||
return new ScopeIterator( getContainerSymbol().getContainedSymbols() );
|
throw new ASTNotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
@ -25,17 +27,19 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
||||||
{
|
{
|
||||||
private final IASTNamespaceDefinition namespace;
|
private final IASTNamespaceDefinition namespace;
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
|
private final ASTReferenceStore referenceDelegate;
|
||||||
/**
|
/**
|
||||||
* @param namespaceDefinition
|
* @param namespaceDefinition
|
||||||
* @param startingOffset
|
* @param startingOffset
|
||||||
* @param endingOffset
|
* @param endingOffset
|
||||||
*/
|
*/
|
||||||
public ASTUsingDirective(IContainerSymbol ownerSymbol, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int endingOffset)
|
public ASTUsingDirective(IContainerSymbol ownerSymbol, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int endingOffset, List references )
|
||||||
{
|
{
|
||||||
super( ownerSymbol );
|
super( ownerSymbol );
|
||||||
namespace = namespaceDefinition;
|
namespace = namespaceDefinition;
|
||||||
setStartingOffset(startingOffset);
|
setStartingOffset(startingOffset);
|
||||||
setEndingOffset(endingOffset);
|
setEndingOffset(endingOffset);
|
||||||
|
referenceDelegate = new ASTReferenceStore( references );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -87,21 +91,20 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
||||||
*/
|
*/
|
||||||
public void acceptElement(ISourceElementRequestor requestor)
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
requestor.acceptUsingDirective( this );
|
||||||
|
referenceDelegate.processReferences(requestor);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
*/
|
*/
|
||||||
public void enterScope(ISourceElementRequestor requestor)
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
*/
|
*/
|
||||||
public void exitScope(ISourceElementRequestor requestor)
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTPointerToFunction;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTPointerToMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplate;
|
||||||
|
@ -99,8 +101,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|
|
||||||
IToken t1 = (IToken)iter.next();
|
IToken t1 = (IToken)iter.next();
|
||||||
IContainerSymbol symbol = null;
|
IContainerSymbol symbol = null;
|
||||||
|
List references = new ArrayList();
|
||||||
|
|
||||||
symbol = getScopeToSearchUpon(scope, t1 );
|
symbol = getScopeToSearchUpon(scope, t1, references );
|
||||||
|
|
||||||
while( iter.hasNext() )
|
while( iter.hasNext() )
|
||||||
{
|
{
|
||||||
|
@ -109,6 +112,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
|
symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
|
||||||
|
references.add( createReference( symbol, t.getImage(), t.getOffset() ));
|
||||||
}
|
}
|
||||||
catch( ParserSymbolTableException pste )
|
catch( ParserSymbolTableException pste )
|
||||||
{
|
{
|
||||||
|
@ -121,14 +125,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
} catch (ParserSymbolTableException pste) {
|
} catch (ParserSymbolTableException pste) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTUsingDirective astUD = new ASTUsingDirective( scopeToSymbol(scope), ((IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration()), startingOffset, endingOffset );
|
IASTUsingDirective astUD = new ASTUsingDirective( scopeToSymbol(scope), ((IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration()), startingOffset, endingOffset, references );
|
||||||
return astUD;
|
return astUD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IContainerSymbol getScopeToSearchUpon(
|
protected IContainerSymbol getScopeToSearchUpon(
|
||||||
IASTScope currentScope,
|
IASTScope currentScope,
|
||||||
IToken firstToken )
|
IToken firstToken, List references ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
IContainerSymbol symbol = null;
|
IContainerSymbol symbol = null;
|
||||||
if( firstToken.getType() == IToken.tCOLONCOLON )
|
if( firstToken.getType() == IToken.tCOLONCOLON )
|
||||||
|
@ -138,6 +142,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
symbol = (IContainerSymbol)scopeToSymbol(currentScope).Lookup( firstToken.getImage() );
|
symbol = (IContainerSymbol)scopeToSymbol(currentScope).Lookup( firstToken.getImage() );
|
||||||
|
references.add( createReference( symbol, firstToken.getImage(), firstToken.getOffset() ));
|
||||||
}
|
}
|
||||||
catch( ParserSymbolTableException pste )
|
catch( ParserSymbolTableException pste )
|
||||||
{
|
{
|
||||||
|
@ -331,6 +336,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
return classSpecifier;
|
return classSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, java.lang.String)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.ASTAccessVisibility, java.lang.String)
|
||||||
*/
|
*/
|
||||||
|
@ -338,10 +345,58 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IASTClassSpecifier astClassSpec,
|
IASTClassSpecifier astClassSpec,
|
||||||
boolean isVirtual,
|
boolean isVirtual,
|
||||||
ASTAccessVisibility visibility,
|
ASTAccessVisibility visibility,
|
||||||
String string)
|
ITokenDuple parentClassName) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
IDerivableContainerSymbol classSymbol = (IDerivableContainerSymbol)scopeToSymbol( astClassSpec);
|
||||||
|
Iterator iterator = parentClassName.iterator();
|
||||||
|
List references = new ArrayList();
|
||||||
|
|
||||||
|
if( ! iterator.hasNext() )
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
|
||||||
|
IToken t1 = (IToken)iterator.next();
|
||||||
|
IContainerSymbol symbol = null;
|
||||||
|
|
||||||
|
symbol = getScopeToSearchUpon(astClassSpec.getOwnerScope(), t1, references );
|
||||||
|
|
||||||
|
while( iterator.hasNext() )
|
||||||
|
{
|
||||||
|
IToken t = (IToken)iterator.next();
|
||||||
|
if( t.getType() == IToken.tCOLONCOLON ) continue;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
|
||||||
|
references.add( createReference( symbol, t.getImage(), t.getOffset() ));
|
||||||
|
}
|
||||||
|
catch( ParserSymbolTableException pste )
|
||||||
|
{
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
classSymbol.addParent( symbol, isVirtual, visibility, parentClassName.getFirstToken().getOffset(), references );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
* @param string
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private IASTReference createReference(ISymbol symbol, String string, int offset ) throws ASTSemanticException
|
||||||
|
{
|
||||||
|
if( symbol.getType() == ParserSymbolTable.TypeInfo.t_namespace )
|
||||||
|
{
|
||||||
|
return new ASTNamespaceReference( offset, string, (IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration());
|
||||||
|
}
|
||||||
|
else if( symbol.getType() == ParserSymbolTable.TypeInfo.t_class ||
|
||||||
|
symbol.getType() == ParserSymbolTable.TypeInfo.t_struct ||
|
||||||
|
symbol.getType() == ParserSymbolTable.TypeInfo.t_union )
|
||||||
|
{
|
||||||
|
return new ASTClassReference( offset, string, (IASTClassSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
|
||||||
|
}
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createElaboratedTypeSpecifier(org.eclipse.cdt.core.parser.ast.ASTClassKind, java.lang.String, int, int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createElaboratedTypeSpecifier(org.eclipse.cdt.core.parser.ast.ASTClassKind, java.lang.String, int, int)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* 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.complete;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ScopeIterator implements Iterator
|
|
||||||
{
|
|
||||||
private final Map sourceMap;
|
|
||||||
private final Iterator keyIter;
|
|
||||||
private Iterator subIterator = null;
|
|
||||||
|
|
||||||
public ScopeIterator( Map in )
|
|
||||||
{
|
|
||||||
sourceMap = in;
|
|
||||||
if( sourceMap != null )
|
|
||||||
keyIter = in.keySet().iterator();
|
|
||||||
else
|
|
||||||
keyIter = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.util.Iterator#hasNext()
|
|
||||||
*/
|
|
||||||
public boolean hasNext() {
|
|
||||||
if( keyIter == null )
|
|
||||||
return false;
|
|
||||||
if( subIterator != null && subIterator.hasNext() )
|
|
||||||
return true;
|
|
||||||
subIterator = null;
|
|
||||||
return keyIter.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.util.Iterator#next()
|
|
||||||
*/
|
|
||||||
public Object next() {
|
|
||||||
if( ! hasNext() )
|
|
||||||
throw new NoSuchElementException();
|
|
||||||
|
|
||||||
if( subIterator != null )
|
|
||||||
return subIterator.next();
|
|
||||||
|
|
||||||
|
|
||||||
ISymbolASTExtension symbol = ((ISymbol)sourceMap.get( keyIter.next() )).getASTExtension();
|
|
||||||
subIterator = symbol.getAllDefinitions();
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.util.Iterator#remove()
|
|
||||||
*/
|
|
||||||
public void remove() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,10 +10,12 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -21,15 +23,17 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
*/
|
*/
|
||||||
public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
||||||
|
|
||||||
private final ASTAccessVisibility visibility;
|
private final int offset;
|
||||||
|
private final ASTAccessVisibility visibility;
|
||||||
private final boolean isVirtual;
|
private final boolean isVirtual;
|
||||||
private final String parentClassName;
|
private final String parentClassName;
|
||||||
|
|
||||||
public ASTBaseSpecifier( String className, boolean v, ASTAccessVisibility a )
|
public ASTBaseSpecifier( String className, boolean v, ASTAccessVisibility a, int o )
|
||||||
{
|
{
|
||||||
parentClassName = className;
|
parentClassName = className;
|
||||||
isVirtual = v;
|
isVirtual = v;
|
||||||
visibility = a;
|
visibility = a;
|
||||||
|
offset = o;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getAccess()
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getAccess()
|
||||||
|
@ -58,5 +62,45 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier {
|
||||||
{
|
{
|
||||||
throw new ASTNotImplementedException();
|
throw new ASTNotImplementedException();
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getNameOffset()
|
||||||
|
*/
|
||||||
|
public int getNameOffset()
|
||||||
|
{
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#addReference(org.eclipse.cdt.core.parser.ast.IASTReference)
|
||||||
|
*/
|
||||||
|
public void addReference(IASTReference reference) throws ASTNotImplementedException
|
||||||
|
{
|
||||||
|
throw new ASTNotImplementedException();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences()
|
||||||
|
*/
|
||||||
|
public void processReferences(ISourceElementRequestor requestor)throws ASTNotImplementedException
|
||||||
|
{
|
||||||
|
throw new ASTNotImplementedException();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#acceptElement(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void acceptElement(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
// no references to process
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void enterScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#exitScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)
|
||||||
|
*/
|
||||||
|
public void exitScope(ISourceElementRequestor requestor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,8 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.AccessVisibility, java.lang.String)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#addBaseSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, boolean, org.eclipse.cdt.core.parser.ast.AccessVisibility, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void addBaseSpecifier(IASTClassSpecifier astClassSpec, boolean isVirtual, ASTAccessVisibility visibility, String string) {
|
public void addBaseSpecifier(IASTClassSpecifier astClassSpec, boolean isVirtual, ASTAccessVisibility visibility, ITokenDuple parentClassName) {
|
||||||
IASTBaseSpecifier baseSpecifier = new ASTBaseSpecifier( string, isVirtual, visibility );
|
IASTBaseSpecifier baseSpecifier = new ASTBaseSpecifier( parentClassName.toString(), isVirtual, visibility, parentClassName.getFirstToken().getOffset() );
|
||||||
((IASTQClassSpecifier)astClassSpec).addBaseClass(baseSpecifier);
|
((IASTQClassSpecifier)astClassSpec).addBaseClass(baseSpecifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
public interface IDerivableContainerSymbol extends IContainerSymbol {
|
public interface IDerivableContainerSymbol extends IContainerSymbol {
|
||||||
|
|
||||||
public void addParent( ISymbol parent );
|
public void addParent( ISymbol parent );
|
||||||
public void addParent( ISymbol parent, boolean virtual, ASTAccessVisibility visibility );
|
public void addParent( ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references );
|
||||||
public List getParents();
|
public List getParents();
|
||||||
public boolean hasParents();
|
public boolean hasParents();
|
||||||
|
|
||||||
|
|
|
@ -2336,14 +2336,14 @@ public class ParserSymbolTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addParent( ISymbol parent ){
|
public void addParent( ISymbol parent ){
|
||||||
addParent( parent, false, ASTAccessVisibility.PUBLIC );
|
addParent( parent, false, ASTAccessVisibility.PUBLIC, -1, null );
|
||||||
}
|
}
|
||||||
public void addParent( ISymbol parent, boolean virtual, ASTAccessVisibility visibility ){
|
public void addParent( ISymbol parent, boolean virtual, ASTAccessVisibility visibility, int offset, List references ){
|
||||||
if( _parentScopes == null ){
|
if( _parentScopes == null ){
|
||||||
_parentScopes = new LinkedList();
|
_parentScopes = new LinkedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
ParentWrapper wrapper = new ParentWrapper( parent, virtual, visibility );
|
ParentWrapper wrapper = new ParentWrapper( parent, virtual, visibility, offset, references );
|
||||||
_parentScopes.add( wrapper );
|
_parentScopes.add( wrapper );
|
||||||
|
|
||||||
Command command = new AddParentCommand( this, wrapper );
|
Command command = new AddParentCommand( this, wrapper );
|
||||||
|
@ -3103,10 +3103,12 @@ public class ParserSymbolTable {
|
||||||
|
|
||||||
public class ParentWrapper implements IDerivableContainerSymbol.IParentSymbol
|
public class ParentWrapper implements IDerivableContainerSymbol.IParentSymbol
|
||||||
{
|
{
|
||||||
public ParentWrapper( ISymbol p, boolean v, ASTAccessVisibility s ){
|
public ParentWrapper( ISymbol p, boolean v, ASTAccessVisibility s, int offset, List r ){
|
||||||
parent = p;
|
parent = p;
|
||||||
isVirtual = v;
|
isVirtual = v;
|
||||||
access = s;
|
access = s;
|
||||||
|
this.offset = offset;
|
||||||
|
this.references = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParent( ISymbol parent ){
|
public void setParent( ISymbol parent ){
|
||||||
|
@ -3128,6 +3130,8 @@ public class ParserSymbolTable {
|
||||||
private boolean isVirtual = false;
|
private boolean isVirtual = false;
|
||||||
private ISymbol parent = null;
|
private ISymbol parent = null;
|
||||||
private final ASTAccessVisibility access;
|
private final ASTAccessVisibility access;
|
||||||
|
private final int offset;
|
||||||
|
private final List references;
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -3135,6 +3139,22 @@ public class ParserSymbolTable {
|
||||||
return access;
|
return access;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int getOffset()
|
||||||
|
{
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public List getReferences()
|
||||||
|
{
|
||||||
|
return references;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue