Package gw.internal.gosu.parser
Class TypeUsesMap
- java.lang.Object
-
- gw.internal.gosu.parser.TypeUsesMap
-
- All Implemented Interfaces:
ITypeUsesMap,java.io.Serializable
public class TypeUsesMap extends java.lang.Object implements ITypeUsesMap
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean_bSupportRelativePackageResolutionprivate DynamicArray<java.lang.String>_defaultNamespacesprivate DynamicArray<IFeatureInfo>_featureLiteralsprivate DynamicArray<java.lang.String>_featureSpacesprivate boolean_lockedprivate DynamicArray<java.lang.String>_namespacesprivate DynamicArray<java.lang.String>_specialNamespacesprivate java.util.HashMap<java.lang.String,java.lang.String>_specialTypeUsesByRelativeNameprivate java.util.HashMap<java.lang.String,java.lang.String>_typeUsesByRelativeNameprivate java.util.HashMap<java.lang.String,IUsesStatement>_usesStmts
-
Constructor Summary
Constructors Constructor Description TypeUsesMap()TypeUsesMap(java.util.List<java.lang.String> specialTypeUses)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToDefaultTypeUses(java.lang.String strType)Add the specified type to the set of default types.voidaddToFeatureLiterals(IFeatureInfo fi)voidaddToFeatureSpaces(java.lang.String strType)voidaddToSpecialTypeUses(java.lang.String strType)voidaddToTypeUses(IUsesStatement usesSmt)Adds a type to the current set of types.voidaddToTypeUses(java.lang.String strType)Adds a type to the current set of types.private voidaddToTypeUses(java.lang.String strQualifiedType, java.util.Map<java.lang.String,java.lang.String> mapQualifiedNameByRelativeName, java.util.List<java.lang.String> namespacesSet)private voidcheckLocked()voidclearNonDefaultTypeUses()Clears all types not in the default set of types;booleancontainsType(java.lang.String typeName)ITypeUsesMapcopy()Returns a shallow copy of this map.ITypeUsesMapcopyLocalScope()Copies the type uses map but alias the global map from this.java.util.Set<IFeatureInfo>getFeatureLiterals()java.util.Set<java.lang.String>getFeatureSpaces()java.util.Set<java.lang.String>getNamespaces()Returns the set of strings representing the namespaces that are currently used by this parser.java.util.Set<java.lang.String>getTypeUses()Returns the set of strings representing the types that are currently used by this parser.java.util.Set<IUsesStatement>getUsesStatements()Return the set of uses-statements that participate in this map.booleanisSupportRelativePackageResolution()ITypeUsesMaplock()Locks this ITypeUsesMap so that it cannot be mutated in the futureINamespaceTyperesolveRelativeNamespaceInAllNamespaces(java.lang.String strRelativeName)private ITyperesolveSubType(java.lang.String strRelativeName)ITyperesolveType(java.lang.String strRelativeName)Resolve the type of a relative name via the type uses.private ITyperesolveType(java.lang.String strRelativeName, java.lang.String strNs)private ITyperesolveTypesInAllNamespaces(java.lang.String strRelativeName)voidsetSupportRelativePackageResolution(boolean bSupportRelativePackageResolution)private ITypeverifyTypeNameDoesNotHaveRelativePackage(IType type, java.lang.String strNs, java.lang.String strRelativeName)
-
-
-
Field Detail
-
_bSupportRelativePackageResolution
private boolean _bSupportRelativePackageResolution
-
_specialTypeUsesByRelativeName
private java.util.HashMap<java.lang.String,java.lang.String> _specialTypeUsesByRelativeName
-
_typeUsesByRelativeName
private java.util.HashMap<java.lang.String,java.lang.String> _typeUsesByRelativeName
-
_defaultNamespaces
private DynamicArray<java.lang.String> _defaultNamespaces
-
_namespaces
private DynamicArray<java.lang.String> _namespaces
-
_specialNamespaces
private DynamicArray<java.lang.String> _specialNamespaces
-
_featureSpaces
private DynamicArray<java.lang.String> _featureSpaces
-
_featureLiterals
private DynamicArray<IFeatureInfo> _featureLiterals
-
_usesStmts
private java.util.HashMap<java.lang.String,IUsesStatement> _usesStmts
-
_locked
private boolean _locked
-
-
Method Detail
-
copy
public ITypeUsesMap copy()
Description copied from interface:ITypeUsesMapReturns a shallow copy of this map.- Specified by:
copyin interfaceITypeUsesMap
-
copyLocalScope
public ITypeUsesMap copyLocalScope()
Description copied from interface:ITypeUsesMapCopies the type uses map but alias the global map from this.- Specified by:
copyLocalScopein interfaceITypeUsesMap- Returns:
- a copy of this type uses map.
-
lock
public ITypeUsesMap lock()
Description copied from interface:ITypeUsesMapLocks this ITypeUsesMap so that it cannot be mutated in the future- Specified by:
lockin interfaceITypeUsesMap- Returns:
- this ITypeUsesMap, so that this method can be used in a builder-like manner.
-
containsType
public boolean containsType(java.lang.String typeName)
- Specified by:
containsTypein interfaceITypeUsesMap- Returns:
- if a type wit the given name can be resolved via this type uses map.
-
getTypeUses
public java.util.Set<java.lang.String> getTypeUses()
Description copied from interface:ITypeUsesMapReturns the set of strings representing the types that are currently used by this parser. The set of types includes both those declared in #uses statements and those set via setDefaultTypeUses.- Specified by:
getTypeUsesin interfaceITypeUsesMap
-
getNamespaces
public java.util.Set<java.lang.String> getNamespaces()
Description copied from interface:ITypeUsesMapReturns the set of strings representing the namespaces that are currently used by this parser.- Specified by:
getNamespacesin interfaceITypeUsesMap
-
getFeatureSpaces
public java.util.Set<java.lang.String> getFeatureSpaces()
- Specified by:
getFeatureSpacesin interfaceITypeUsesMap
-
getFeatureLiterals
public java.util.Set<IFeatureInfo> getFeatureLiterals()
- Specified by:
getFeatureLiteralsin interfaceITypeUsesMap
-
addToTypeUses
public void addToTypeUses(java.lang.String strType)
Description copied from interface:ITypeUsesMapAdds a type to the current set of types. Can be a complete type or a wildcard namespace e.g., java.util.HashMap and java.util.* are both legal.- Specified by:
addToTypeUsesin interfaceITypeUsesMap
-
addToFeatureSpaces
public void addToFeatureSpaces(java.lang.String strType)
- Specified by:
addToFeatureSpacesin interfaceITypeUsesMap
-
addToFeatureLiterals
public void addToFeatureLiterals(IFeatureInfo fi)
- Specified by:
addToFeatureLiteralsin interfaceITypeUsesMap
-
addToTypeUses
public void addToTypeUses(IUsesStatement usesSmt)
Description copied from interface:ITypeUsesMapAdds a type to the current set of types. Can be a complete type or a wildcard namespace e.g., java.util.HashMap and java.util.* are both legal.- Specified by:
addToTypeUsesin interfaceITypeUsesMap
-
getUsesStatements
public java.util.Set<IUsesStatement> getUsesStatements()
Description copied from interface:ITypeUsesMapReturn the set of uses-statements that participate in this map. Note these are the uses-statements compiled from source.- Specified by:
getUsesStatementsin interfaceITypeUsesMap
-
addToDefaultTypeUses
public void addToDefaultTypeUses(java.lang.String strType)
Description copied from interface:ITypeUsesMapAdd the specified type to the set of default types. NOTE: The type is always treated as a package. If it ends in .* then it will be stripped- Specified by:
addToDefaultTypeUsesin interfaceITypeUsesMap
-
checkLocked
private void checkLocked()
-
addToSpecialTypeUses
public void addToSpecialTypeUses(java.lang.String strType)
- Specified by:
addToSpecialTypeUsesin interfaceITypeUsesMap
-
resolveType
public IType resolveType(java.lang.String strRelativeName)
Description copied from interface:ITypeUsesMapResolve the type of a relative name via the type uses. if the relative type matches uses-type, resolves the type as such. If the type matches, but does not resove, throws an exception, otherwise returns null if there is no match.- Specified by:
resolveTypein interfaceITypeUsesMap
-
resolveSubType
private IType resolveSubType(java.lang.String strRelativeName)
-
clearNonDefaultTypeUses
public void clearNonDefaultTypeUses()
Description copied from interface:ITypeUsesMapClears all types not in the default set of types;- Specified by:
clearNonDefaultTypeUsesin interfaceITypeUsesMap
-
resolveTypesInAllNamespaces
private IType resolveTypesInAllNamespaces(java.lang.String strRelativeName)
-
resolveType
private IType resolveType(java.lang.String strRelativeName, java.lang.String strNs)
-
verifyTypeNameDoesNotHaveRelativePackage
private IType verifyTypeNameDoesNotHaveRelativePackage(IType type, java.lang.String strNs, java.lang.String strRelativeName)
-
resolveRelativeNamespaceInAllNamespaces
public INamespaceType resolveRelativeNamespaceInAllNamespaces(java.lang.String strRelativeName)
- Specified by:
resolveRelativeNamespaceInAllNamespacesin interfaceITypeUsesMap- Parameters:
strRelativeName- A relative path name. E.g., "lang" is a relative package name of "java.lang"- Returns:
- The absolute namespace type for the relative name or null if not found.
-
isSupportRelativePackageResolution
public boolean isSupportRelativePackageResolution()
- Specified by:
isSupportRelativePackageResolutionin interfaceITypeUsesMap
-
setSupportRelativePackageResolution
public void setSupportRelativePackageResolution(boolean bSupportRelativePackageResolution)
- Specified by:
setSupportRelativePackageResolutionin interfaceITypeUsesMap
-
addToTypeUses
private void addToTypeUses(java.lang.String strQualifiedType, java.util.Map<java.lang.String,java.lang.String> mapQualifiedNameByRelativeName, java.util.List<java.lang.String> namespacesSet) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
-