mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer
This patch implements an iterator on all the contents of IContainerSymbol. This is a first step to an iterator on the IAST nodes. Core: Created IExtensibleSymbol, which is a new base class for the symbol interfaces Created IUsingDirectiveSymbol and UsingDirectiveSymbol Modified ASTUsingDirective to use IUsingDirectiveSymbol Modified CompleteParseASTFactory.createUsingDirective Added IContainerSymbol.getContentsIterator() Implemented getContentsIterator in ContainerSymbol Core.tests: Modified CompleteParseASTTest.testUsingClauses Added ParserSymbolTableTest.testIterator_1 & testIterator_2
This commit is contained in:
parent
bcdd0ab7c3
commit
9cac774800
14 changed files with 319 additions and 48 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-01-16 Andrew Niefer
|
||||
Modified CompleteParseASTTest.testUsingClauses
|
||||
Added ParserSymbolTableTest.testIterator_1 & testIterator_2
|
||||
|
||||
2004-01-16 Hoda Amer
|
||||
Modified CModelElementsTest to test for enumerator constant expression
|
||||
Bug#47552
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* Copyright (c) 2002,2003,2004 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
|
||||
|
@ -194,6 +194,7 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
assertQualifiedName( fieldY.getFullyQualifiedName(), new String [] { "A", "B", "C", "y" } );
|
||||
IASTUsingDirective directive = (IASTUsingDirective)declarations.next();
|
||||
assertEquals( directive.getNamespaceDefinition(), namespaceB );
|
||||
assertEquals( directive.getNamespaceName(), "A::B" );
|
||||
IASTUsingDeclaration declaration = (IASTUsingDeclaration)declarations.next();
|
||||
assertEquals( declaration.getUsingType(), variableX );
|
||||
declaration = (IASTUsingDeclaration)declarations.next();
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.StandardSymbolExtension;
|
||||
|
@ -3434,5 +3435,125 @@ public class ParserSymbolTableTest extends TestCase {
|
|||
|
||||
assertEquals( foo1, look );
|
||||
}
|
||||
|
||||
/**
|
||||
* int global;
|
||||
* class A {
|
||||
* A();
|
||||
* int var;
|
||||
* void foo();
|
||||
* };
|
||||
*
|
||||
*/
|
||||
public void testIterator_1() throws Exception{
|
||||
newTable();
|
||||
|
||||
ISymbol global = table.newSymbol( "global", TypeInfo.t_int );
|
||||
table.getCompilationUnit().addSymbol( global );
|
||||
|
||||
IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
|
||||
|
||||
table.getCompilationUnit().addSymbol( cls );
|
||||
|
||||
IParameterizedSymbol constructor = table.newParameterizedSymbol( "A", TypeInfo.t_constructor );
|
||||
cls.addConstructor( constructor );
|
||||
|
||||
ISymbol var = table.newSymbol( "var", TypeInfo.t_int );
|
||||
cls.addSymbol( var );
|
||||
|
||||
IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", TypeInfo.t_function );
|
||||
cls.addSymbol( foo );
|
||||
|
||||
|
||||
Iterator iter = table.getCompilationUnit().getContentsIterator();
|
||||
assertEquals( iter.next(), global );
|
||||
IContainerSymbol symbol = (IContainerSymbol) iter.next();
|
||||
assertEquals( symbol, cls );
|
||||
assertFalse( iter.hasNext() );
|
||||
|
||||
iter = symbol.getContentsIterator();
|
||||
assertEquals( iter.next(), constructor );
|
||||
assertEquals( iter.next(), var );
|
||||
assertEquals( iter.next(), foo );
|
||||
assertFalse( iter.hasNext() );
|
||||
}
|
||||
|
||||
/**
|
||||
* int foo();
|
||||
* namespace A{
|
||||
* int bar();
|
||||
* int bar( int );
|
||||
* };
|
||||
* class B{
|
||||
* void func(){
|
||||
* using namespace A;
|
||||
* }
|
||||
* };
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testIterator_2() throws Exception{
|
||||
newTable();
|
||||
|
||||
IParameterizedSymbol foo = table.newParameterizedSymbol( "foo", TypeInfo.t_function );
|
||||
table.getCompilationUnit().addSymbol( foo );
|
||||
|
||||
IContainerSymbol nsA = table.newContainerSymbol( "A", TypeInfo.t_namespace );
|
||||
table.getCompilationUnit().addSymbol( nsA );
|
||||
|
||||
IParameterizedSymbol bar1 = table.newParameterizedSymbol( "bar", TypeInfo.t_function );
|
||||
nsA.addSymbol( bar1 );
|
||||
|
||||
IParameterizedSymbol bar2 = table.newParameterizedSymbol( "bar", TypeInfo.t_function );
|
||||
bar2.addParameter( TypeInfo.t_int, 0, null, false );
|
||||
nsA.addSymbol( bar2 );
|
||||
|
||||
IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B", TypeInfo.t_class);
|
||||
table.getCompilationUnit().addSymbol( B );
|
||||
|
||||
B.addCopyConstructor();
|
||||
|
||||
IParameterizedSymbol func = table.newParameterizedSymbol( "func", TypeInfo.t_function );
|
||||
B.addSymbol( func );
|
||||
|
||||
IUsingDirectiveSymbol using = func.addUsingDirective( nsA );
|
||||
|
||||
Iterator iter = table.getCompilationUnit().getContentsIterator();
|
||||
|
||||
assertEquals( iter.next(), foo );
|
||||
|
||||
IContainerSymbol s1 = (IContainerSymbol) iter.next();
|
||||
assertEquals( s1, nsA );
|
||||
|
||||
IContainerSymbol s2 = (IContainerSymbol) iter.next();
|
||||
assertEquals( s2, B );
|
||||
|
||||
assertFalse( iter.hasNext() );
|
||||
|
||||
iter = s1.getContentsIterator();
|
||||
assertEquals( iter.next(), bar1 );
|
||||
assertEquals( iter.next(), bar2 );
|
||||
assertFalse( iter.hasNext() );
|
||||
|
||||
iter = s2.getContentsIterator();
|
||||
|
||||
//Copy constructor!!
|
||||
ISymbol copy = (ISymbol) iter.next();
|
||||
assertTrue( copy instanceof IParameterizedSymbol );
|
||||
assertEquals( copy.getName(), "B" );
|
||||
assertEquals( copy.getType(), TypeInfo.t_constructor );
|
||||
|
||||
assertEquals( iter.next(), func );
|
||||
assertFalse( iter.hasNext() );
|
||||
|
||||
iter = func.getContentsIterator();
|
||||
//this pointer!!
|
||||
ISymbol th = (ISymbol) iter.next();
|
||||
assertEquals( th.getName(), "this" );
|
||||
assertEquals( th.getTypeSymbol(), B );
|
||||
|
||||
assertEquals( iter.next(), using );
|
||||
|
||||
assertFalse( iter.hasNext() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2004-01-16 Andrew Niefer
|
||||
Created IExtensibleSymbol, which is a new base class for the symbol interfaces
|
||||
Created IUsingDirectiveSymbol and UsingDirectiveSymbol
|
||||
Modified ASTUsingDirective to use IUsingDirectiveSymbol
|
||||
Modified CompleteParseASTFactory.createUsingDirective
|
||||
Added IContainerSymbol.getContentsIterator()
|
||||
Implemented getContentsIterator in ContainerSymbol
|
||||
|
||||
2004-01-16 John Camelon
|
||||
Changed IASTNode.LookupException to IASTNode.LookupError.
|
||||
Updated IASTElaboratedTypeSpecifier to remove redundant extends relationships.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* Copyright (c) 2002,2003, 2004 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
|
||||
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -24,7 +25,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
|||
*/
|
||||
public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUsingDirective
|
||||
{
|
||||
private final IASTNamespaceDefinition namespace;
|
||||
private final IUsingDirectiveSymbol using;
|
||||
private Offsets offsets = new Offsets();
|
||||
private final ASTReferenceStore referenceDelegate;
|
||||
/**
|
||||
|
@ -32,10 +33,12 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
|||
* @param startingOffset
|
||||
* @param endingOffset
|
||||
*/
|
||||
public ASTUsingDirective(IContainerSymbol ownerSymbol, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int endingOffset, List references )
|
||||
//public ASTUsingDirective(IContainerSymbol ownerSymbol, IASTNamespaceDefinition namespaceDefinition, int startingOffset, int endingOffset, List references )
|
||||
public ASTUsingDirective(IContainerSymbol ownerSymbol, IUsingDirectiveSymbol usingDirective, int startingOffset, int endingOffset, List references )
|
||||
{
|
||||
super( ownerSymbol );
|
||||
namespace = namespaceDefinition;
|
||||
//namespace = namespaceDefinition;
|
||||
using = usingDirective;
|
||||
setStartingOffset(startingOffset);
|
||||
setEndingOffset(endingOffset);
|
||||
referenceDelegate = new ASTReferenceStore( references );
|
||||
|
@ -46,7 +49,8 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
|||
*/
|
||||
public String getNamespaceName()
|
||||
{
|
||||
String [] fqn = namespace.getFullyQualifiedName();
|
||||
IASTNamespaceDefinition namespace = getNamespaceDefinition();
|
||||
String [] fqn = namespace.getFullyQualifiedName();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
for( int i = 0; i < fqn.length; ++i )
|
||||
{
|
||||
|
@ -118,7 +122,9 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
|
|||
*/
|
||||
public IASTNamespaceDefinition getNamespaceDefinition()
|
||||
{
|
||||
return namespace;
|
||||
IContainerSymbol namespaceSymbol = using.getNamespace();
|
||||
|
||||
return (IASTNamespaceDefinition)namespaceSymbol.getASTExtension().getPrimaryDeclaration();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* Copyright (c) 2002,2003, 2004 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
|
||||
|
@ -76,6 +76,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
|||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.NamespaceSymbolExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
|
||||
|
@ -326,13 +327,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
ISymbol symbol = lookupQualifiedName(
|
||||
scopeToSymbol( scope), duple, references, true );
|
||||
|
||||
IUsingDirectiveSymbol usingDirective = null;
|
||||
try {
|
||||
((ASTScope)scope).getContainerSymbol().addUsingDirective( (IContainerSymbol)symbol );
|
||||
usingDirective = ((ASTScope)scope).getContainerSymbol().addUsingDirective( (IContainerSymbol)symbol );
|
||||
} catch (ParserSymbolTableException pste) {
|
||||
throw new ASTSemanticException();
|
||||
}
|
||||
|
||||
IASTUsingDirective astUD = new ASTUsingDirective( scopeToSymbol(scope), ((IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration()), startingOffset, endingOffset, references );
|
||||
IASTUsingDirective astUD = new ASTUsingDirective( scopeToSymbol(scope), usingDirective, startingOffset, endingOffset, references );
|
||||
return astUD;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003 IBM Corporation and others.
|
||||
* Copyright (c) 2003,2004 IBM 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
|
||||
|
@ -139,6 +139,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
obj.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
|
||||
|
||||
getContents().add( obj );
|
||||
|
||||
Command command = new AddSymbolCommand( obj, containing );
|
||||
getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
@ -163,7 +165,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol#addUsingDirective(org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol)
|
||||
*/
|
||||
public void addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException{
|
||||
public IUsingDirectiveSymbol addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException{
|
||||
if( namespace.getType() != TypeInfo.t_namespace ){
|
||||
throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidUsing );
|
||||
}
|
||||
|
@ -180,10 +182,15 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
|
||||
List usingDirectives = getUsingDirectives();
|
||||
|
||||
usingDirectives.add( namespace );
|
||||
IUsingDirectiveSymbol usingDirective = new UsingDirectiveSymbol( getSymbolTable(), namespace );
|
||||
usingDirectives.add( usingDirective );
|
||||
|
||||
Command command = new AddUsingDirectiveCommand( this, namespace );
|
||||
getContents().add( usingDirective );
|
||||
|
||||
Command command = new AddUsingDirectiveCommand( this, usingDirective );
|
||||
getSymbolTable().pushCommand( command );
|
||||
|
||||
return usingDirective;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -749,6 +756,17 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
return instance;
|
||||
}
|
||||
|
||||
protected List getContents(){
|
||||
if(_contents == null ){
|
||||
_contents = new LinkedList();
|
||||
}
|
||||
return _contents;
|
||||
}
|
||||
|
||||
public Iterator getContentsIterator(){
|
||||
return getContents().iterator();
|
||||
}
|
||||
|
||||
static private class AddSymbolCommand extends Command{
|
||||
AddSymbolCommand( ISymbol newDecl, IContainerSymbol context ){
|
||||
_symbol = newDecl;
|
||||
|
@ -776,27 +794,46 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
} else if( obj instanceof BasicSymbol ){
|
||||
_context.getContainedSymbols().remove( _symbol.getName() );
|
||||
}
|
||||
// if( _removeThis && _symbol instanceof IParameterizedSymbol ){
|
||||
// ((IParameterizedSymbol)_symbol).getContainedSymbols().remove( ParserSymbolTable.THIS );
|
||||
// }
|
||||
|
||||
//this is an inefficient way of doing this, we can modify the interfaces if the undo starts
|
||||
//being used often.
|
||||
Iterator iter = _context.getContentsIterator();
|
||||
while( iter.hasNext() ){
|
||||
IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
if( ext == _symbol ){
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ISymbol _symbol;
|
||||
private IContainerSymbol _context;
|
||||
private final ISymbol _symbol;
|
||||
private final IContainerSymbol _context;
|
||||
}
|
||||
|
||||
static private class AddUsingDirectiveCommand extends Command{
|
||||
public AddUsingDirectiveCommand( IContainerSymbol container, IContainerSymbol namespace ){
|
||||
public AddUsingDirectiveCommand( IContainerSymbol container, IUsingDirectiveSymbol directive ){
|
||||
_decl = container;
|
||||
_namespace = namespace;
|
||||
_directive = directive;
|
||||
}
|
||||
public void undoIt(){
|
||||
_decl.getUsingDirectives().remove( _namespace );
|
||||
_decl.getUsingDirectives().remove( _directive );
|
||||
|
||||
//this is an inefficient way of doing this, we can modify the interfaces if the undo starts
|
||||
//being used often.
|
||||
Iterator iter = _decl.getContentsIterator();
|
||||
while( iter.hasNext() ){
|
||||
IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
if( ext == _directive ){
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private IContainerSymbol _decl;
|
||||
private IContainerSymbol _namespace;
|
||||
private final IContainerSymbol _decl;
|
||||
private final IUsingDirectiveSymbol _directive;
|
||||
}
|
||||
|
||||
|
||||
static protected class SymbolTableComparator implements Comparator{
|
||||
public int compare( Object o1, Object o2 ){
|
||||
int result = ((String) o1).compareToIgnoreCase( (String) o2 );
|
||||
|
@ -810,7 +847,8 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
return ( obj instanceof SymbolTableComparator );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private LinkedList _contents; //ordered list of all contents of this symbol
|
||||
private LinkedList _usingDirectives; //collection of nominated namespaces
|
||||
private Map _containedSymbols; //declarations contained by us.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2004 IBM 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
|
||||
|
@ -14,9 +14,9 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -120,6 +120,8 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
constructor.setContainingSymbol( this );
|
||||
addThis( constructor );
|
||||
|
||||
getContents().add( constructor );
|
||||
|
||||
Command command = new AddConstructorCommand( constructor, this );
|
||||
getSymbolTable().pushCommand( command );
|
||||
}
|
||||
|
@ -335,7 +337,7 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
}
|
||||
public void undoIt(){
|
||||
List constructors = _context.getConstructors();
|
||||
ListIterator iter = constructors.listIterator();
|
||||
Iterator iter = constructors.listIterator();
|
||||
|
||||
int size = constructors.size();
|
||||
IParameterizedSymbol item = null;
|
||||
|
@ -346,10 +348,19 @@ public class DerivableContainerSymbol extends ContainerSymbol implements IDeriva
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iter = _context.getContentsIterator();
|
||||
while( iter.hasNext() ){
|
||||
IExtensibleSymbol ext = (IExtensibleSymbol) iter.next();
|
||||
if( ext == _constructor ){
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IParameterizedSymbol _constructor;
|
||||
private IDerivableContainerSymbol _context;
|
||||
private final IParameterizedSymbol _constructor;
|
||||
private final IDerivableContainerSymbol _context;
|
||||
}
|
||||
|
||||
public class ParentWrapper implements IDerivableContainerSymbol.IParentSymbol
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2004 IBM 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
|
||||
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public interface IContainerSymbol extends ISymbol {
|
|||
|
||||
public boolean hasUsingDirectives();
|
||||
public List getUsingDirectives();
|
||||
public void addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException;
|
||||
public IUsingDirectiveSymbol addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException;
|
||||
|
||||
public ISymbol addUsingDeclaration( String name ) throws ParserSymbolTableException;
|
||||
public ISymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException;
|
||||
|
@ -55,4 +56,6 @@ public interface IContainerSymbol extends ISymbol {
|
|||
public TemplateInstance instantiate( List arguments ) throws ParserSymbolTableException;
|
||||
|
||||
public boolean isVisible( ISymbol symbol, IContainerSymbol qualifyingSymbol );
|
||||
|
||||
public Iterator getContentsIterator();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 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.pst;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface IExtensibleSymbol {
|
||||
/**
|
||||
* get the instance of ParserSymbolTable with wich this symbol is associated
|
||||
* @return ParserSymbolTable
|
||||
*/
|
||||
public ParserSymbolTable getSymbolTable();
|
||||
|
||||
/**
|
||||
* get the ISymbolASTExtension attached to this symbol
|
||||
* @return ISymbolASTExtension
|
||||
*/
|
||||
public ISymbolASTExtension getASTExtension();
|
||||
|
||||
/**
|
||||
* attach an ISymbolASTExtension to this symbol
|
||||
* @param obj
|
||||
*/
|
||||
public void setASTExtension( ISymbolASTExtension obj );
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* Copyright (c) 2002,2003, 2004 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
|
||||
|
@ -17,15 +17,11 @@ import java.util.Map;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface ISymbol extends Cloneable {
|
||||
public interface ISymbol extends Cloneable, IExtensibleSymbol {
|
||||
|
||||
public ParserSymbolTable getSymbolTable();
|
||||
|
||||
public Object clone();
|
||||
|
||||
public ISymbolASTExtension getASTExtension();
|
||||
public void setASTExtension( ISymbolASTExtension obj );
|
||||
|
||||
public void setName(String name);
|
||||
public String getName();
|
||||
|
||||
public IContainerSymbol getContainingSymbol();
|
||||
|
@ -56,9 +52,4 @@ public interface ISymbol extends Cloneable {
|
|||
public int getDepth();
|
||||
public boolean getIsInvisible();
|
||||
public void setIsInvisible( boolean invisible );
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 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.pst;
|
||||
|
||||
|
||||
public interface IUsingDirectiveSymbol extends IExtensibleSymbol{
|
||||
public IContainerSymbol getNamespace();
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* Copyright (c) 2002,2003,2004 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
|
||||
|
@ -243,7 +243,7 @@ public class ParserSymbolTable {
|
|||
|
||||
//only consider the transitive using directives if we are an unqualified
|
||||
//lookup, or we didn't find the name in decl
|
||||
if( (!data.qualified || !foundSomething || data.mode == LookupMode.PREFIX ) && temp.getUsingDirectives() != null ){
|
||||
if( (!data.qualified || !foundSomething || data.mode == LookupMode.PREFIX ) && temp.hasUsingDirectives() ){
|
||||
//name wasn't found, add transitive using directives for later consideration
|
||||
transitiveDirectives.addAll( temp.getUsingDirectives() );
|
||||
}
|
||||
|
@ -1091,7 +1091,7 @@ public class ParserSymbolTable {
|
|||
Iterator iter = directives.iterator();
|
||||
|
||||
for( int i = size; i > 0; i-- ){
|
||||
temp = (IContainerSymbol) iter.next();
|
||||
temp = ((IUsingDirectiveSymbol) iter.next()).getNamespace();
|
||||
|
||||
//namespaces are searched at most once
|
||||
if( !data.visited.contains( temp ) ){
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 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.pst;
|
||||
|
||||
|
||||
public class UsingDirectiveSymbol implements IUsingDirectiveSymbol{
|
||||
private final ParserSymbolTable symbolTable;
|
||||
|
||||
public UsingDirectiveSymbol( ParserSymbolTable table, IContainerSymbol ns ){
|
||||
namespace = ns;
|
||||
symbolTable = table;
|
||||
}
|
||||
|
||||
public IContainerSymbol getNamespace(){
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public ISymbolASTExtension getASTExtension() { return extension; }
|
||||
public void setASTExtension( ISymbolASTExtension ext ) { extension = ext; }
|
||||
|
||||
private ISymbolASTExtension extension;
|
||||
private final IContainerSymbol namespace;
|
||||
|
||||
public ParserSymbolTable getSymbolTable() {
|
||||
return symbolTable;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue