public abstract class ASScopeBase extends Object implements IASScope
ASProjectScope
for project scopes,
ASFileScope
for file scopes, and ASScope
for class,
interface, function, and with
scopes.
The primary purpose of a lexical scope is to store a set of definitions that are potentially visible if the scope is in the chain of scopes used to resolve an identifier.
Modifier and Type | Class and Description |
---|---|
static class |
ASScopeBase.FilteredCollection<T>
Collection that ignores added items that for which a predicate returns
false.
|
Modifier and Type | Field and Description |
---|---|
static Set<INamespaceDefinition> |
allNamespacesSet |
protected IDefinitionStore |
definitionStore
Storage for definitions in this scope,
organized into sets of definitions with the same base name.
|
Constructor and Description |
---|
ASScopeBase()
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addDefinition(IDefinition definition)
Adds the specified definition to this scope.
|
protected void |
addDefinitionToStore(IDefinition definition)
Helper method called by
addDefinition(org.apache.flex.compiler.definitions.IDefinition) (). |
void |
compact()
Minimizes the memory used by this scope.
|
Collection<IDefinition> |
getAllLocalDefinitions()
Gets all the definitions in this one scope.
|
Collection<IDefinitionSet> |
getAllLocalDefinitionSets()
Gets all the definition sets in this one scope.
|
Collection<String> |
getAllLocalNames()
Gets all the base names of definitions in this one scope.
|
void |
getAllLocalProperties(CompilerProject project,
Collection<IDefinition> defs,
Set<INamespaceDefinition> namespaceSet,
INamespaceDefinition extraNamespace)
Adds all local definitions from this scope to the specified collections
of definitions that have a namespace qualifier in the specified
definition set.
|
IScopedDefinition |
getDefinition()
Gets the scoped definition that produced this scope.
|
IDefinitionSet |
getLocalDefinitionSetByName(String baseName)
Gets the set of definitions in this one scope that have the specified base name.
|
protected void |
getLocalProperty(ICompilerProject project,
Collection<IDefinition> defs,
String baseName,
boolean getContingents)
Adds definitions with the specified base name to the specified collection of definitions.
|
void |
getLocalProperty(ICompilerProject project,
Collection<IDefinition> defs,
String baseName,
Set<INamespaceDefinition> namespaceSet)
Adds definitions with the specified base name whose namespaces match the
specified namespace set to the specified collection of definitions.
|
protected void |
getLocalProperty(ICompilerProject project,
Collection<IDefinition> defs,
String baseName,
Set<INamespaceDefinition> namespaceSet,
boolean getContingents)
Adds definitions with the specified base name whose namespaces match the
specified namespace set to the specified collection of definitions.
|
IScopedNode |
getScopeNode()
Gets the scoped node corresponding to this scope.
|
boolean |
isContingentDefinitionNeeded(ICompilerProject project,
IDefinition definition)
Check whether there is a matching definition in the class hierarchy
already defined in which case the contingent definition is not needed.
|
void |
removeDefinition(IDefinition definition)
Removes the specified definition from this scope.
|
protected void |
removeDefinitionFromStore(IDefinition definition)
Helper method called by
removeDefinition(org.apache.flex.compiler.definitions.IDefinition) (). |
String |
toString()
For debugging only.
|
protected String |
toStringHeader()
For debugging only.
|
boolean |
verify()
Used only in asserts.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getContainingScope
public static final Set<INamespaceDefinition> allNamespacesSet
protected IDefinitionStore definitionStore
public void compact()
The definition store does not get compacted, but subclasses override this to compact other data structures.
public void addDefinition(IDefinition definition)
definition
- The IDefinition
to be added.protected void addDefinitionToStore(IDefinition definition)
addDefinition(org.apache.flex.compiler.definitions.IDefinition)
().
It handles actually adding the definition to the store. It first tries to add it to the current store. If it won't fit, it creates a bigger store and adds it to that.
definition
- The IDefinition
to be added.public void removeDefinition(IDefinition definition)
definition
- The IDefinition
to be removed.protected void removeDefinitionFromStore(IDefinition definition)
removeDefinition(org.apache.flex.compiler.definitions.IDefinition)
().
It handles actually removing the definition from the store. It does not bother to check whether the store could be downgraded with one that has a smaller capacity.
definition
- The IDefinition
to be added.public IScopedNode getScopeNode()
IASScope
getScopeNode
in interface IASScope
IScopedNode
corresponding to this scope.public IScopedDefinition getDefinition()
IASScope
getDefinition
in interface IASScope
IScopedDefinition
that contains this scope.public IDefinitionSet getLocalDefinitionSetByName(String baseName)
IASScope
getLocalDefinitionSetByName
in interface IASScope
baseName
- A String specifying a base name.IDefinitionSet
containing definitions with that base name,
or null
if there are no such definitions.public Collection<String> getAllLocalNames()
IASScope
getAllLocalNames
in interface IASScope
public Collection<IDefinitionSet> getAllLocalDefinitionSets()
IASScope
getAllLocalDefinitionSets
in interface IASScope
IDefinitionSet
objects.public Collection<IDefinition> getAllLocalDefinitions()
IASScope
getAllLocalDefinitions
in interface IASScope
IDefinition
objects.public final void getLocalProperty(ICompilerProject project, Collection<IDefinition> defs, String baseName, Set<INamespaceDefinition> namespaceSet)
If more that one definition is added to the collection by this method, then the reference is ambiguous
project
- ICompilerProject
used to resolve reference to
definitions outside of the ICompilationUnit
that contains this
scope.defs
- Collection that found IDefinition
's are added to.baseName
- Name of property to find.namespaceSet
- Namespace set in which the qualifier of any matching
definition must exist to be considered a match.protected final void getLocalProperty(ICompilerProject project, Collection<IDefinition> defs, String baseName, Set<INamespaceDefinition> namespaceSet, boolean getContingents)
If more that one definition is added to the collection by this method, then the reference is ambiguous
project
- ICompilerProject
used to resolve reference to
definitions outside of the ICompilationUnit
that contains this
scope.defs
- Collection that found IDefinition
's are added to.baseName
- Name of property to find.namespaceSet
- Namespace set in which the qualifier of any matching
definition must exist to be considered a match.getContingents
- If true, non-contingent definitions are ignored. If
false, contingent definitions are ignored.protected final void getLocalProperty(ICompilerProject project, Collection<IDefinition> defs, String baseName, boolean getContingents)
If additional constraints on the definitions are required, then the Collection passed in should
implement those. Most commonly, this will be a ASScopeBase.FilteredCollection
with a NamespaceSetPredicate
as the predicate.
If more that one definition is added to the collection by this method, then the reference is ambiguous
project
- ICompilerProject
used to resolve reference to
definitions outside of the ICompilationUnit
that contains this
scope.defs
- Collection that found IDefinition
's are added to.baseName
- Name of property to find.getContingents
- If true, non-contingent definitions are ignored. If
false, contingent definitions are ignored.public boolean isContingentDefinitionNeeded(ICompilerProject project, IDefinition definition)
project
- The compiler project.definition
- A definition.public void getAllLocalProperties(CompilerProject project, Collection<IDefinition> defs, Set<INamespaceDefinition> namespaceSet, INamespaceDefinition extraNamespace)
project
- CompilerProject
used to resolve reference to
definitions outside of the ICompilationUnit
that contains this
scope.defs
- Collection that found IDefinition
's are added to.namespaceSet
- Namespace set in which the qualifier of any matching
definition must exist to be considered a match.extraNamespace
- A single extra INamespaceDefinition
that is
considered part of the namespace set by this method. This is used when
resolving protected definitions in a class scope.public boolean verify()
public String toString()
protected String toStringHeader()
Copyright © 2016 The Apache Software Foundation. All rights reserved.