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

Enhanced the performance & footprint of the parser by reducing number of lists created and getting rid of extraneous cross-reference construction in ParserMode's that do not warrant it.

This commit is contained in:
John Camelon 2004-05-14 19:26:59 +00:00
parent 35b475be54
commit bab1a0f7cf
26 changed files with 123 additions and 148 deletions

View file

@ -277,11 +277,5 @@ public interface IASTFactory
*/
public boolean validateDirectMemberOperation(IASTNode node);
/**
* @param ourScope
* @param newDescriptor TODO
* @return
*/
public IASTNode lookupConstructor(IASTScope ourScope, IASTNewExpressionDescriptor newDescriptor);
}

View file

@ -75,7 +75,6 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
*/
public abstract class Parser extends ExpressionParser implements IParser
{
protected static final List EMPTY_LIST = Collections.unmodifiableList(new ArrayList());
protected ISourceElementRequestor requestor = null;
/**
@ -1880,7 +1879,7 @@ public abstract class Parser extends ExpressionParser implements IParser
consume( IToken.tASSIGN );
simpleDeclarationMark = null;
setCompletionValues(scope,CompletionKind.SINGLE_NAME_REFERENCE,Key.EMPTY);
d.setInitializerClause( cInitializerClause(scope, EMPTY_LIST, constructInitializers ) );
d.setInitializerClause( cInitializerClause(scope, Collections.EMPTY_LIST, constructInitializers ) );
setCompletionValues(scope,CompletionKind.NO_SUCH_KIND,Key.EMPTY);
}
}
@ -1979,7 +1978,7 @@ public abstract class Parser extends ExpressionParser implements IParser
return createInitializerClause(
scope,
IASTInitializerClause.Kind.EMPTY,
null, null, EMPTY_LIST, constructInitializers );
null, null, Collections.EMPTY_LIST, constructInitializers );
}
catch (Exception e)
{
@ -2009,7 +2008,7 @@ public abstract class Parser extends ExpressionParser implements IParser
return createInitializerClause(
scope,
IASTInitializerClause.Kind.INITIALIZER_LIST,
null, initializerClauses == null ? EMPTY_LIST : initializerClauses, EMPTY_LIST, constructInitializers );
null, initializerClauses == null ? Collections.EMPTY_LIST : initializerClauses, Collections.EMPTY_LIST, constructInitializers );
}
catch (Exception e)
{
@ -2031,7 +2030,7 @@ public abstract class Parser extends ExpressionParser implements IParser
return createInitializerClause(
scope,
IASTInitializerClause.Kind.ASSIGNMENT_EXPRESSION,
assignmentExpression, null, EMPTY_LIST, constructInitializers );
assignmentExpression, null, Collections.EMPTY_LIST, constructInitializers );
}
catch (Exception e)
{

View file

@ -10,9 +10,8 @@
package org.eclipse.cdt.internal.core.parser.ast;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.parser.IToken;
@ -49,7 +48,6 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
public class GCCASTExtension implements IASTFactoryExtension {
private final ParserMode mode;
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final List EMPTY_LIST = new ArrayList( 0 );
/**
* @param mode
*/
@ -167,7 +165,7 @@ public class GCCASTExtension implements IASTFactoryExtension {
ASTExpression typeOfExpression = (ASTExpression) extensionParms.get( IASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION );
ISymbol s = pst.newSymbol( EMPTY_STRING );
s.setTypeInfo( typeOfExpression.getResultType().getResult() );
return new ASTGCCSimpleTypeSpecifier( s, isTypename, ( typeName == null ? EMPTY_STRING : typeName.toString()), EMPTY_LIST, typeOfExpression );
return new ASTGCCSimpleTypeSpecifier( s, isTypename, ( typeName == null ? EMPTY_STRING : typeName.toString()), Collections.EMPTY_LIST, typeOfExpression );
}
return null;
}

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
*/
public class ASTBaseSpecifier implements IASTBaseSpecifier
{
private ASTReferenceStore referenceDelegate;
private List references;
private final boolean isVirtual;
private final ISymbol symbol;
private final ASTAccessVisibility visibility;
@ -40,7 +40,7 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier
this.visibility = visibility;
this.symbol = symbol;
this.offset = nameOffset;
referenceDelegate = new ASTReferenceStore( references );
this.references = references;
}
/* (non-Javadoc)
@ -81,20 +81,14 @@ public class ASTBaseSpecifier implements IASTBaseSpecifier
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTReferenceStore#processReferences()
*/
public void processReferences(ISourceElementRequestor requestor)
{
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);
ASTReferenceStore.processReferences( references, requestor );
references = null;
}
/* (non-Javadoc)

View file

@ -89,7 +89,7 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
private final ASTClassKind classKind;
private ASTAccessVisibility currentVisibility;
private final ASTQualifiedNamedElement qualifiedName;
private final ASTReferenceStore references;
private List references;
/**
* @param symbol
@ -104,7 +104,7 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
setNameOffset(nameOffset);
setNameEndOffsetAndLineNumber(nameEndOffset, nameLine);
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), symbol.getName() );
this.references = new ASTReferenceStore( references );
this.references = references;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassNameType()
@ -174,7 +174,8 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
*/
public void enterScope(ISourceElementRequestor requestor)
{
references.processReferences( requestor );
ASTReferenceStore.processReferences( references, requestor );
references = null;
try
{
requestor.enterClassSpecifier(this);

View file

@ -27,7 +27,7 @@ public class ASTConstructorMemberInitializer
private final boolean requireNameResolution;
private final String name;
private final IASTExpression expression;
private final List references;
private List references;
/**
*
*/
@ -58,8 +58,8 @@ public class ASTConstructorMemberInitializer
*/
public void acceptElement(ISourceElementRequestor requestor)
{
ASTReferenceStore store = new ASTReferenceStore( references );
store.processReferences( requestor );
ASTReferenceStore.processReferences( references, requestor );
references = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)

View file

@ -30,7 +30,6 @@ public class ASTElaboratedTypeSpecifier extends ASTSymbol implements IASTElabora
private final ASTClassKind kind;
private final ASTQualifiedNamedElement qualifiedName;
private NamedOffsets offsets = new NamedOffsets();
private final ASTReferenceStore store;
/**
* @param checkSymbol
@ -47,7 +46,6 @@ public class ASTElaboratedTypeSpecifier extends ASTSymbol implements IASTElabora
setNameEndOffsetAndLineNumber(nameEndOffset, nameLine);
setEndingOffsetAndLineNumber( endOffset, endingLine );
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), checkSymbol.getName() );
store = new ASTReferenceStore( references );
isForwardDeclaration = isDecl;
this.references = references;
}
@ -114,7 +112,8 @@ public class ASTElaboratedTypeSpecifier extends ASTSymbol implements IASTElabora
{
/* do nothing */
}
store.processReferences(requestor);
ASTReferenceStore.processReferences( references, requestor );
references = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
public class ASTExceptionSpecification implements IASTExceptionSpecification
{
private final List typeIds;
private final ASTReferenceStore store;
private List references;
/**
* @param newTypeIds
* @param references
@ -32,7 +32,7 @@ public class ASTExceptionSpecification implements IASTExceptionSpecification
public ASTExceptionSpecification(List newTypeIds, List references)
{
this.typeIds = newTypeIds;
store = new ASTReferenceStore( references );
this.references = references;
}
/* (non-Javadoc)
@ -49,7 +49,8 @@ public class ASTExceptionSpecification implements IASTExceptionSpecification
*/
public void acceptElement(ISourceElementRequestor requestor)
{
store.processReferences(requestor);
ASTReferenceStore.processReferences( references, requestor );
references = null;
}
/* (non-Javadoc)

View file

@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
public abstract class ASTExpression extends ASTNode implements IASTExpression
{
private final Kind kind;
private final List references;
private List references;
private ExpressionResult resultType;
/**
@ -75,8 +75,8 @@ public abstract class ASTExpression extends ASTNode implements IASTExpression
{
// will not get thrown
}
if( ! references.isEmpty() )
new ASTReferenceStore( references ).processReferences(requestor);
ASTReferenceStore.processReferences( references, requestor );
references = null;
processCallbacks(requestor);

View file

@ -61,7 +61,9 @@ public class ASTField extends ASTVariable implements IASTField
{
/* do nothing */
}
referenceDelegate.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
if( getInitializerClause() != null )
getInitializerClause().acceptElement(requestor);
if( getAbstractDeclaration() != null )

View file

@ -43,7 +43,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
private NamedOffsets offsets = new NamedOffsets();
private final ASTQualifiedNamedElement qualifiedName;
private final List parameters;
protected final ASTReferenceStore references;
protected List references;
private List declarations = new ArrayList();
/**
* @param symbol
@ -65,7 +65,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
setNameOffset(nameOffset);
setNameEndOffsetAndLineNumber(nameEndOffset, nameLine);
this.ownerTemplate = ownerTemplate;
this.references = new ASTReferenceStore( references );
this.references = references;
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), symbol.getName() );
this.previouslyDeclared =previouslyDeclared;
this.hasFunctionTryBlock = hasFunctionTryBlock;
@ -215,7 +215,8 @@ public class ASTFunction extends ASTScope implements IASTFunction
protected void functionCallbacks(ISourceElementRequestor requestor)
{
references.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
processParameterInitializersAndArrayMods(requestor);
if( getReturnType() != null )
getReturnType().acceptElement(requestor);

View file

@ -83,8 +83,8 @@ public class ASTInitializerClause implements IASTInitializerClause
if( assignmentExpression != null )
assignmentExpression.acceptElement( requestor );
ASTReferenceStore store = new ASTReferenceStore( getReferences() );
store.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
}
/* (non-Javadoc)

View file

@ -27,7 +27,7 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
private NamedOffsets offsets = new NamedOffsets();
private final String alias;
private final IASTNamespaceDefinition namespace;
private final ASTReferenceStore store;
private List references;
/**
* @param scope
* @param symbol
@ -44,7 +44,7 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
setEndingOffsetAndLineNumber(endOffset, endingLine);
setNameOffset(nameOffset);
setNameEndOffsetAndLineNumber(nameEndOffset, nameEndOffset);
store = new ASTReferenceStore( references);
this.references = references;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTNamespaceAlias#getAlias()
@ -65,7 +65,8 @@ public class ASTNamespaceAlias extends ASTSymbol implements IASTNamespaceAlias
*/
public void acceptElement(ISourceElementRequestor requestor)
{
store.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)

View file

@ -10,7 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.complete;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@ -23,18 +23,14 @@ import org.eclipse.cdt.core.parser.ast.IASTReference;
*/
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)
public static void processReferences(List references, ISourceElementRequestor requestor)
{
if( references == null || references == Collections.EMPTY_LIST || references.isEmpty() )
return;
Iterator i = references.iterator();
while( i.hasNext() )
((IASTReference)i.next()).acceptElement(requestor);

View file

@ -192,11 +192,8 @@ public class ASTTypeId implements IASTTypeId
*/
public void acceptElement(ISourceElementRequestor requestor)
{
if( references != null && ! references.isEmpty() )
{
ASTReferenceStore store = new ASTReferenceStore( references );
store.processReferences(requestor);
}
ASTReferenceStore.processReferences(references, requestor);
references = null;
Iterator arrayMods = getArrayModifiers();
while( arrayMods.hasNext() )
{

View file

@ -32,7 +32,7 @@ public class ASTTypedef extends ASTSymbol implements IASTTypedefDeclaration
private final IASTAbstractDeclaration mapping;
private NamedOffsets offsets = new NamedOffsets();
private final ASTQualifiedNamedElement qualifiedName;
private final ASTReferenceStore referenceStore;
private List references;
/**
* @param newSymbol
@ -45,7 +45,7 @@ public class ASTTypedef extends ASTSymbol implements IASTTypedefDeclaration
{
super( newSymbol );
this.mapping = mapping;
this.referenceStore = new ASTReferenceStore( references );
this.references = references;
this.qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), newSymbol.getName());
setStartingOffsetAndLineNumber(startingOffset, startingLine);
setNameOffset(nameOffset);
@ -81,7 +81,8 @@ public class ASTTypedef extends ASTSymbol implements IASTTypedefDeclaration
{
/* do nothing */
}
referenceStore.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
getAbstractDeclarator().acceptElement( requestor );
}

View file

@ -30,7 +30,7 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
private final boolean isTypeName;
private final List declarations = new ArrayList();
private Offsets offsets = new Offsets();
private final ASTReferenceStore delegate;
private List references;
private String name;
/**
@ -44,7 +44,7 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
this.declarations.addAll( declarations );
setStartingOffsetAndLineNumber(startingOffset, startingLine);
setEndingOffsetAndLineNumber(endingOffset, endingLine);
delegate = new ASTReferenceStore( references );
this.references = references;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#isTypename()
@ -108,7 +108,8 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
{
/* do nothing */
}
delegate.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)

View file

@ -27,7 +27,7 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
{
private final IUsingDirectiveSymbol using;
private Offsets offsets = new Offsets();
private final ASTReferenceStore referenceDelegate;
private List references;
/**
* @param namespaceDefinition
* @param startingOffset
@ -41,7 +41,7 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
using = usingDirective;
setStartingOffsetAndLineNumber(startingOffset, startingLine);
setEndingOffsetAndLineNumber(endingOffset, endingLine);
referenceDelegate = new ASTReferenceStore( references );
this.references = references;
}
/* (non-Javadoc)
@ -102,7 +102,8 @@ public class ASTUsingDirective extends ASTAnonymousDeclaration implements IASTUs
{
/* do nothing */
}
referenceDelegate.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate#enterScope(org.eclipse.cdt.core.parser.ISourceElementRequestor)

View file

@ -30,12 +30,12 @@ import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
public class ASTVariable extends ASTSymbol implements IASTVariable
{
private final IASTExpression constructorExpression;
protected final ASTReferenceStore referenceDelegate;
private final ASTQualifiedNamedElement qualifiedName;
private NamedOffsets offsets = new NamedOffsets();
private final IASTExpression bitfieldExpression;
private final IASTInitializerClause initializerClause;
private final IASTAbstractDeclaration abstractDeclaration;
protected List references;
/**
* @param newSymbol
* @param abstractDeclaration
@ -55,7 +55,7 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
setStartingOffsetAndLineNumber( startingOffset, startingLine );
setNameOffset( nameOffset );
setNameEndOffsetAndLineNumber(nameEndOffset, nameLine);
referenceDelegate = new ASTReferenceStore( references );
this.references = references;
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), newSymbol.getName() );
}
/* (non-Javadoc)
@ -169,7 +169,8 @@ public class ASTVariable extends ASTSymbol implements IASTVariable
{
/* do nothing */
}
referenceDelegate.processReferences(requestor);
ASTReferenceStore.processReferences(references, requestor);
references = null;
if( initializerClause != null )
initializerClause.acceptElement(requestor);
if( constructorExpression != null )

View file

@ -114,6 +114,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
private final static List SUBSCRIPT;
private final static IProblemFactory problemFactory = new ASTProblemFactory();
private final IFilenameProvider fileProvider;
private final ParserMode mode;
static
{
@ -139,6 +140,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
super(extension);
pst = new ParserSymbolTable( language, mode );
fileProvider = filenameProvider;
this.mode = mode;
}
/*
@ -319,8 +321,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
else
((ITemplateFactory)startingScope).pushSymbol( result );
}
if( references != null )
addReference( references, createReference( result, image, name.getStartOffset() ));
if( args != null )
if( args != null && references != null )
addTemplateIdReferences( references, templateArgLists[0] );
}
else
@ -385,8 +388,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
else
((ITemplateFactory)startingScope).pushSymbol( result );
}
if( references != null )
addReference( references, createReference( result, image, offset ));
if( templateArgLists != null && templateArgLists[idx] != null )
if( references != null && templateArgLists != null && templateArgLists[idx] != null )
addTemplateIdReferences( references, templateArgLists[idx] );
}
else
@ -558,10 +562,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
Iterator i = endResult.getReferencedSymbols().iterator();
while( i.hasNext() )
{
IASTReference reference = createReference( (ISymbol) i.next(), name.getLastToken().getImage(), name.getLastToken().getOffset() );
addReference( references, reference );
}
addReference( references, createReference( (ISymbol) i.next(), name.getLastToken().getImage(), name.getLastToken().getOffset() ) );
}
ASTUsingDeclaration using = new ASTUsingDeclaration( scope, name.getLastToken().getImage(),
endResult.getReferencedSymbols(), isTypeName, startingOffset, startingLine, endingOffset, endingLine, references );
@ -903,11 +905,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
*/
protected IASTReference createReference(ISymbol symbol, String referenceElementName, int offset ) throws ASTSemanticException
{
if( symbol.getASTExtension() == null ){
if( mode != ParserMode.COMPLETE_PARSE )
return null;
//referenced symbol doesn't have an attached AST node, could happen say for the copy constructor added
//by the symbol table.
if( symbol.getASTExtension() == null )
return null;
}
Iterator i = symbol.getASTExtension().getAllDefinitions();
ASTSymbol declaration = i.hasNext() ? (ASTSymbol) i.next() : null;
@ -2083,7 +2087,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IParameterizedSymbol functionDeclaration = null;
functionDeclaration =
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getImage(), TypeInfo.t_function, functionParameters, 0, new ArrayList(), false, LookupType.FORDEFINITION );
(IParameterizedSymbol) lookupQualifiedName(ownerScope, name.getFirstToken().getImage(), TypeInfo.t_function, functionParameters, 0, null, false, LookupType.FORDEFINITION );
if( functionDeclaration != null && symbol.isType( TypeInfo.t_function )){
previouslyDeclared = true;
@ -2230,7 +2234,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
newReferences = new ArrayList();
newReferences.addAll( elab.getReferences() );
if( xrefSymbol != null )
newReferences.add( createReference( xrefSymbol, elab.getName(), elab.getNameOffset()) );
addReference( newReferences, createReference( xrefSymbol, elab.getName(), elab.getNameOffset()) );
}
String paramName = EMPTY_STRING;
@ -2451,8 +2455,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
functionDeclaration.setTypeSymbol( symbol );
// set the definition visibility = declaration visibility
ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity();
// ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
visibility = ((IASTMethod)(functionDeclaration.getASTExtension().getPrimaryDeclaration())).getVisiblity();
}
}
@ -2601,7 +2605,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
newSymbol.setIsForwardDeclaration( isStatic || isExtern );
boolean previouslyDeclared = false;
if(!isStatic){
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name.toString(), new ArrayList(), false, LookupType.UNQUALIFIED);
ISymbol variableDeclaration = lookupQualifiedName(ownerScope, name.toString(), null, false, LookupType.UNQUALIFIED);
if( variableDeclaration != null && newSymbol.getType() == variableDeclaration.getType() )
{
@ -2670,7 +2674,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
try
{
if( lookup != null )
clause.getReferences().add( createReference( lookup, designator.fieldName(), designator.fieldOffset() ));
addReference( clause.getReferences(), createReference( lookup, designator.fieldName(), designator.fieldOffset() ));
}
catch (ASTSemanticException e1)
{
@ -2728,6 +2732,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( abstractDeclaration.getTypeSpecifier() instanceof ASTSimpleTypeSpecifier )
{
symbolToBeCloned = ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
if( references != null )
references.addAll( ((ASTSimpleTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getReferences() );
}
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTClassSpecifier )
@ -2740,8 +2745,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTElaboratedTypeSpecifier elab = ((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier());
symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type);
symbolToBeCloned.setTypeSymbol(elab.getSymbol());
if( elab.getSymbol() != null )
references.add( createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
if( elab.getSymbol() != null && references != null )
addReference( references, createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
}
else if ( abstractDeclaration.getTypeSpecifier() instanceof ASTEnumerationSpecifier )
{
@ -2829,9 +2834,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
previouslyDeclared = true;
fieldDeclaration.setTypeSymbol( newSymbol );
// set the definition visibility = declaration visibility
ASTReference reference = (ASTReference) fieldReferences.iterator().next();
visibility = ((IASTField)reference.getReferencedElement()).getVisiblity(); }
// // set the definition visibility = declaration visibility
// ASTReference reference = (ASTReference) fieldReferences.iterator().next();
visibility = ((IASTField)fieldDeclaration.getASTExtension().getPrimaryDeclaration()).getVisiblity();
}
}
}
@ -2978,7 +2984,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
int startingLine, int nameOffset, int nameEndOffset, int nameLine) throws ASTSemanticException
{
IContainerSymbol containerSymbol = scopeToSymbol(scope);
ISymbol typeSymbol = cloneSimpleTypeSymbol( name, mapping, new ArrayList() );
ISymbol typeSymbol = cloneSimpleTypeSymbol( name, mapping, null );
if( typeSymbol == null )
handleProblem( scope, IProblem.SEMANTICS_RELATED, name, nameOffset, nameEndOffset, nameLine );
@ -3161,7 +3167,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
protected ParserSymbolTable pst;
protected static final List DUD_LIST = new ArrayList( 64 );
/*
@ -3258,7 +3263,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
lookupQualifiedName(
scopeToSymbol(scope),
nameInQuestion,
new ArrayList(),
null,
false);
} catch (ASTSemanticException e) {
// won't get thrown
@ -3406,7 +3411,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ISymbol s = null;
if( reference == null ) {
try {
s = lookupQualifiedName( scopeToSymbol( scope ), duple, new ArrayList(), false );
s = lookupQualifiedName( scopeToSymbol( scope ), duple, null, false );
} catch (ASTSemanticException e) {
}
}
@ -3418,7 +3423,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION )
{
try {
s = lookupQualifiedName( scopeToSymbol( scope ), duple, new ArrayList(), false );
s = lookupQualifiedName( scopeToSymbol( scope ), duple, null, false );
} catch (ASTSemanticException e1) {
}
}
@ -3427,7 +3432,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
IContainerSymbol classSymbol = null;
try {
classSymbol = (IContainerSymbol) lookupQualifiedName(scopeToSymbol( scope ), duple, DUD_LIST, false );
classSymbol = (IContainerSymbol) lookupQualifiedName(scopeToSymbol( scope ), duple, null, false );
} catch (ASTSemanticException e) {
}
if( classSymbol != null && classSymbol.getTypeInfo().checkBit( TypeInfo.isTypedef ) ){
@ -3463,7 +3468,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( ownerExpression.getExpressionKind().isPostfixMemberReference() )
{
try {
s = lookupQualifiedName( getSearchScope(ownerExpression.getExpressionKind(), ownerExpression.getLHSExpression(), scopeToSymbol(scope)), duple, new ArrayList(), false );
s = lookupQualifiedName( getSearchScope(ownerExpression.getExpressionKind(), ownerExpression.getLHSExpression(), scopeToSymbol(scope)), duple, null, false );
} catch (ASTSemanticException e) {
return null;
}
@ -3471,7 +3476,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
else
{
try {
s = lookupQualifiedName( scopeToSymbol( scope ), duple, new ArrayList(), false );
s = lookupQualifiedName( scopeToSymbol( scope ), duple, null, false );
} catch (ASTSemanticException e1) {
}
}
@ -3571,11 +3576,4 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return expression;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#lookupConstructor(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor)
*/
public IASTNode lookupConstructor(IASTScope ourScope, IASTNewExpressionDescriptor newDescriptor) {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -914,12 +914,4 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
return ExpressionFactory.createExpression( kind, literal, isHex );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#lookupConstructor(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ITokenDuple)
*/
public IASTNode lookupConstructor(IASTScope ourScope, IASTNewExpressionDescriptor newDescriptor) {
return null;
}
}

View file

@ -390,11 +390,4 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
public IASTExpression createExpression(Kind kind, long literal, boolean isHex) throws ASTSemanticException {
return ExpressionFactory.createExpression(kind, literal, isHex );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#lookupConstructor(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ITokenDuple)
*/
public IASTNode lookupConstructor(IASTScope ourScope, IASTNewExpressionDescriptor newDescriptor) {
return null;
}
}

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.cdt.core.parser.IMacroDescriptor;
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.parser.IMacroDescriptor;
*/
public class DynamicMacroDescriptor implements IMacroDescriptor {
private final List EMPTY_LIST = new ArrayList();
private final String name;
private final DynamicMacroEvaluator proxy;
@ -43,14 +42,14 @@ public class DynamicMacroDescriptor implements IMacroDescriptor {
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getParameters()
*/
public List getParameters() {
return EMPTY_LIST;
return Collections.EMPTY_LIST;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getTokenizedExpansion()
*/
public List getTokenizedExpansion() {
return EMPTY_LIST;
return Collections.EMPTY_LIST;
}
/* (non-Javadoc)

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.parser.scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -76,9 +77,8 @@ public class GCCScannerExtension implements IScannerExtension {
private static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
private static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$
private static final List EMPTY_LIST = new ArrayList();
protected static final FunctionMacroDescriptor DECLSPEC_MACRO = new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, EMPTY_LIST, "" ); //$NON-NLS-1$
protected static final FunctionMacroDescriptor ATTRIBUTE_MACRO = new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersAttribute, EMPTY_LIST, "" ); //$NON-NLS-1$
protected static final FunctionMacroDescriptor DECLSPEC_MACRO = new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, Collections.EMPTY_LIST, "" ); //$NON-NLS-1$
protected static final FunctionMacroDescriptor ATTRIBUTE_MACRO = new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersAttribute, Collections.EMPTY_LIST, "" ); //$NON-NLS-1$
private static final String __EXTENSION__ = "__extension__"; //$NON-NLS-1$
private static final String EMPTY_STRING = ""; //$NON-NLS-1$

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.parser.scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@ -22,7 +23,6 @@ import org.eclipse.cdt.core.parser.IToken;
*/
public class ObjectMacroDescriptor implements IMacroDescriptor {
private static final ArrayList EMPTY_LIST = new ArrayList(0);
private final String expansionSignature;
private final String name;
private final IToken token;
@ -54,14 +54,14 @@ public class ObjectMacroDescriptor implements IMacroDescriptor {
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getParameters()
*/
public List getParameters() {
return EMPTY_LIST;
return Collections.EMPTY_LIST;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IMacroDescriptor#getTokenizedExpansion()
*/
public List getTokenizedExpansion() {
if( token == null ) return EMPTY_LIST;
if( token == null ) return Collections.EMPTY_LIST;
if( tokenizedExpansion == null )
{
tokenizedExpansion = new ArrayList(1);

View file

@ -19,7 +19,6 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -690,6 +689,7 @@ public class Scanner implements IScanner {
private boolean tokenizingMacroReplacementList = false;
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
private Map tempMap = new HashMap(); //$NON-NLS-1$
public void setTokenizingMacroReplacementList( boolean mr ){
tokenizingMacroReplacementList = mr;
}
@ -2092,8 +2092,8 @@ public class Scanner implements IScanner {
IScanner subScanner = new Scanner(
new StringReader(expression),
SCRATCH,
EMPTY_MAP,
EMPTY_LIST,
getTemporaryHashtable(),
Collections.EMPTY_LIST,
NULL_REQUESTOR,
ParserMode.QUICK_PARSE,
scannerData.getLanguage(),
@ -2137,6 +2137,14 @@ public class Scanner implements IScanner {
throwEOF( node );
}
/**
* @return
*/
private Map getTemporaryHashtable() {
tempMap.clear();
return tempMap = new HashMap();
}
protected void handleInvalidCompletion() throws EndOfFileException
{
throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.UNREACHABLE_CODE, null, null, EMPTY_STRING, KeywordSets.getKeywords(KeywordSets.Key.EMPTY, scannerData.getLanguage()) , EMPTY_STRING, null));
@ -2638,14 +2646,12 @@ public class Scanner implements IScanner {
handleInclusion(directive.getFilename().trim(), directive.useIncludePaths(), beginningOffset, startLine, directive.getStartOffset(), nameLine, directive.getEndOffset(), endLine);
}
protected static final Hashtable EMPTY_MAP = new Hashtable();
protected static final List EMPTY_LIST = new ArrayList();
protected Map definitionsBackupMap = null;
protected void temporarilyReplaceDefinitionsMap()
{
definitionsBackupMap = scannerData.getPublicDefinitions();
scannerData.setDefinitions( EMPTY_MAP );
scannerData.setDefinitions( Collections.EMPTY_MAP );
}
protected void restoreDefinitionsMap()
@ -2676,7 +2682,7 @@ public class Scanner implements IScanner {
helperScanner = new Scanner(
new StringReader(replacementString),
SCRATCH,
EMPTY_MAP, EMPTY_LIST,
getTemporaryHashtable(), Collections.EMPTY_LIST,
NULL_REQUESTOR,
scannerData.getParserMode(),
scannerData.getLanguage(),
@ -2811,7 +2817,7 @@ public class Scanner implements IScanner {
macroReplacementTokens = ( ! replacementString.equals( "" ) ) ? //$NON-NLS-1$
tokenizeReplacementString( beginning, key, replacementString, parameterIdentifiers ) :
EMPTY_LIST;
Collections.EMPTY_LIST;
descriptor = new FunctionMacroDescriptor(
key,
@ -2951,7 +2957,7 @@ public class Scanner implements IScanner {
new StringReader((String)parameters.elementAt(i)),
TEXT,
scannerData.getPublicDefinitions(),
EMPTY_LIST,
Collections.EMPTY_LIST,
NULL_REQUESTOR,
scannerData.getParserMode(),
scannerData.getLanguage(),