Package gw.internal.gosu.parser
Class FileSystemGosuClassRepository
- java.lang.Object
-
- gw.internal.gosu.parser.FileSystemGosuClassRepository
-
- All Implemented Interfaces:
IFileSystemGosuClassRepository,IGosuClassRepository
public class FileSystemGosuClassRepository extends java.lang.Object implements IFileSystemGosuClassRepository
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileSystemGosuClassRepository.ClassFileInfostatic classFileSystemGosuClassRepository.FileSystemSourceFileHandle-
Nested classes/interfaces inherited from interface gw.lang.reflect.gs.IFileSystemGosuClassRepository
IFileSystemGosuClassRepository.ClassPathEntry, IFileSystemGosuClassRepository.IClassFileInfo, IFileSystemGosuClassRepository.Util
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.String>_allTypeNamesprivate java.util.Set<IDirectory>_excludedPathprivate java.lang.String[]_extensionsprivate java.util.Map<java.lang.String,FqnCache>_missCachesprivate IModule_moduleprivate PackageToClassPathEntryTreeMap_rootNodeprivate java.util.List<IFileSystemGosuClassRepository.ClassPathEntry>_sourcePathstatic java.lang.StringRESOURCE_LOCATED_W_CLASSES
-
Constructor Summary
Constructors Constructor Description FileSystemGosuClassRepository(IModule module)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddToMissCache(java.lang.String strQualifiedClassName, java.lang.String[] extensions)private voidaddToPackageCache(java.lang.String fqn, IResource file)private voidaddTypeNames(IDirectory root, IDirectory path, java.util.Set<java.lang.String> classNames, java.lang.String[] fileExts)private booleanareDifferent(IDirectory[] cp1, java.util.List<IFileSystemGosuClassRepository.ClassPathEntry> cp2)ISourceFileHandlefindClass(java.lang.String strQualifiedClassName, java.lang.String[] extensions)Finds the ISourceFileHandle for a given fully-qualified class name, or null if no such source file existsprivate IFileSystemGosuClassRepository.ClassPathEntryfindClassPathEntry(IResource file)private FileSystemGosuClassRepository.ClassFileInfofindFileInfoOnDisk(java.lang.String strQualifiedClassName, java.lang.String[] extensions)IFilefindFirstFile(java.lang.String resourceName)private IFilefindFirstFile(java.lang.String resourceName, java.util.List<? extends IDirectory> searchPath)java.net.URLfindResource(java.lang.String resourceName)Finds the given resource in this repository.java.util.Set<java.lang.String>getAllTypeNames()java.util.Set<java.lang.String>getAllTypeNames(java.lang.String... extensions)Returns the names of all types in this repository that end with one of the specified file extensionsprivate PackageToClassPathEntryTreeMapgetCachedPackage(java.lang.String fullyQualifiedName)private PackageToClassPathEntryTreeMapgetCachedPackageCorrectly(java.lang.String fullyQualifiedName)private PackageToClassPathEntryTreeMapgetChildPackage(PackageToClassPathEntryTreeMap parent, java.lang.String strRelativeName)java.lang.StringgetClassNameFromFile(IDirectory root, IFile file, java.lang.String[] fileExts)IDirectory[]getExcludedPath()private FqnCachegetMissCacheForExtension(java.lang.String extension)IModulegetModule()The module having this repositoryprivate java.lang.StringgetPackageName(java.lang.String strQualifiedClassName)IDirectory[]getSourcePath()java.util.Set<TypeName>getTypeNames(java.lang.String namespace, java.util.Set<java.lang.String> extensions, ITypeLoader loader)Returns all type names in the given namespace and with the given extensions.inthasNamespace(java.lang.String namespace)Returns the number of namespaces this repository has matching the given name.private booleaninMissCache(java.lang.String strQualifiedClassName, java.lang.String[] extensions)private static booleanisTestFolder(IDirectory file)private booleanisValidDirectory(IDirectory dir)private PackageToClassPathEntryTreeMaploadPackageRoots()voidnamespaceRefreshed(java.lang.String namespace, IDirectory dir, RefreshKind kind)Called when a namespace is refreshedprivate voidprocessDirectory(PackageToClassPathEntryTreeMap node, IFileSystemGosuClassRepository.ClassPathEntry entry, IDirectory path)private voidremoveFromPackageCache(java.lang.String fqn, IDirectory dir)private voidreset()voidsetExcludedPath(IDirectory[] excludedPath)voidsetSourcePath(IDirectory[] sourcePath)java.lang.StringtoString()voidtypesRefreshed(RefreshRequest request)Called when a type is refreshed
-
-
-
Field Detail
-
_missCaches
private final java.util.Map<java.lang.String,FqnCache> _missCaches
-
RESOURCE_LOCATED_W_CLASSES
public static final java.lang.String RESOURCE_LOCATED_W_CLASSES
- See Also:
- Constant Field Values
-
_module
private final IModule _module
-
_sourcePath
private java.util.List<IFileSystemGosuClassRepository.ClassPathEntry> _sourcePath
-
_excludedPath
private java.util.Set<IDirectory> _excludedPath
-
_extensions
private java.lang.String[] _extensions
-
_rootNode
private PackageToClassPathEntryTreeMap _rootNode
-
_allTypeNames
private java.util.Set<java.lang.String> _allTypeNames
-
-
Constructor Detail
-
FileSystemGosuClassRepository
public FileSystemGosuClassRepository(IModule module)
-
-
Method Detail
-
getModule
public IModule getModule()
Description copied from interface:IGosuClassRepositoryThe module having this repository- Specified by:
getModulein interfaceIGosuClassRepository
-
getSourcePath
public IDirectory[] getSourcePath()
- Specified by:
getSourcePathin interfaceIFileSystemGosuClassRepository
-
setSourcePath
public void setSourcePath(IDirectory[] sourcePath)
- Specified by:
setSourcePathin interfaceIFileSystemGosuClassRepository
-
getExcludedPath
public IDirectory[] getExcludedPath()
- Specified by:
getExcludedPathin interfaceIFileSystemGosuClassRepository
-
setExcludedPath
public void setExcludedPath(IDirectory[] excludedPath)
- Specified by:
setExcludedPathin interfaceIFileSystemGosuClassRepository
-
findClass
public ISourceFileHandle findClass(java.lang.String strQualifiedClassName, java.lang.String[] extensions)
Description copied from interface:IGosuClassRepositoryFinds the ISourceFileHandle for a given fully-qualified class name, or null if no such source file exists- Specified by:
findClassin interfaceIGosuClassRepository- Parameters:
strQualifiedClassName- the fully-qualified name of the class- Returns:
- The source file handle for the given class, or null if no such source file exists.
-
findResource
public java.net.URL findResource(java.lang.String resourceName)
Description copied from interface:IGosuClassRepositoryFinds the given resource in this repository.The name of a resource is a '/'-separated path name that identifies the resource.
- Specified by:
findResourcein interfaceIGosuClassRepository- Parameters:
resourceName- the name of the resource- Returns:
- the URL of the resource or null if the resource cannot be found.
-
getAllTypeNames
public java.util.Set<java.lang.String> getAllTypeNames()
- Specified by:
getAllTypeNamesin interfaceIGosuClassRepository- Returns:
- A set containing all type names in this repository (includes enhancement names)
-
getAllTypeNames
public java.util.Set<java.lang.String> getAllTypeNames(java.lang.String... extensions)
Description copied from interface:IGosuClassRepositoryReturns the names of all types in this repository that end with one of the specified file extensions- Specified by:
getAllTypeNamesin interfaceIGosuClassRepository- Parameters:
extensions- the set of file name extensions to consider- Returns:
- A set containing all the type names in this repository.
-
getClassNameFromFile
public java.lang.String getClassNameFromFile(IDirectory root, IFile file, java.lang.String[] fileExts)
- Specified by:
getClassNameFromFilein interfaceIFileSystemGosuClassRepository
-
typesRefreshed
public void typesRefreshed(RefreshRequest request)
Description copied from interface:IGosuClassRepositoryCalled when a type is refreshed- Specified by:
typesRefreshedin interfaceIGosuClassRepository
-
reset
private void reset()
-
addToPackageCache
private void addToPackageCache(java.lang.String fqn, IResource file)
-
findClassPathEntry
private IFileSystemGosuClassRepository.ClassPathEntry findClassPathEntry(IResource file)
-
removeFromPackageCache
private void removeFromPackageCache(java.lang.String fqn, IDirectory dir)
-
getCachedPackageCorrectly
private PackageToClassPathEntryTreeMap getCachedPackageCorrectly(java.lang.String fullyQualifiedName)
-
getCachedPackage
private PackageToClassPathEntryTreeMap getCachedPackage(java.lang.String fullyQualifiedName)
-
getChildPackage
private PackageToClassPathEntryTreeMap getChildPackage(PackageToClassPathEntryTreeMap parent, java.lang.String strRelativeName)
-
loadPackageRoots
private PackageToClassPathEntryTreeMap loadPackageRoots()
-
processDirectory
private void processDirectory(PackageToClassPathEntryTreeMap node, IFileSystemGosuClassRepository.ClassPathEntry entry, IDirectory path)
-
isValidDirectory
private boolean isValidDirectory(IDirectory dir)
-
findFileInfoOnDisk
private FileSystemGosuClassRepository.ClassFileInfo findFileInfoOnDisk(java.lang.String strQualifiedClassName, java.lang.String[] extensions)
-
getPackageName
private java.lang.String getPackageName(java.lang.String strQualifiedClassName)
-
inMissCache
private boolean inMissCache(java.lang.String strQualifiedClassName, java.lang.String[] extensions)
-
getMissCacheForExtension
private FqnCache getMissCacheForExtension(java.lang.String extension)
-
addToMissCache
private void addToMissCache(java.lang.String strQualifiedClassName, java.lang.String[] extensions)
-
addTypeNames
private void addTypeNames(IDirectory root, IDirectory path, java.util.Set<java.lang.String> classNames, java.lang.String[] fileExts)
-
getTypeNames
public java.util.Set<TypeName> getTypeNames(java.lang.String namespace, java.util.Set<java.lang.String> extensions, ITypeLoader loader)
Description copied from interface:IGosuClassRepositoryReturns all type names in the given namespace and with the given extensions.- Specified by:
getTypeNamesin interfaceIGosuClassRepository
-
hasNamespace
public int hasNamespace(java.lang.String namespace)
Description copied from interface:IGosuClassRepositoryReturns the number of namespaces this repository has matching the given name. Note a namespace can span multiple source roots, hence the integer return value -- one per source root.- Specified by:
hasNamespacein interfaceIGosuClassRepository
-
namespaceRefreshed
public void namespaceRefreshed(java.lang.String namespace, IDirectory dir, RefreshKind kind)Description copied from interface:IGosuClassRepositoryCalled when a namespace is refreshed- Specified by:
namespaceRefreshedin interfaceIGosuClassRepository
-
areDifferent
private boolean areDifferent(IDirectory[] cp1, java.util.List<IFileSystemGosuClassRepository.ClassPathEntry> cp2)
-
isTestFolder
private static boolean isTestFolder(IDirectory file)
-
findFirstFile
public IFile findFirstFile(java.lang.String resourceName)
- Specified by:
findFirstFilein interfaceIFileSystemGosuClassRepository
-
findFirstFile
private IFile findFirstFile(java.lang.String resourceName, java.util.List<? extends IDirectory> searchPath)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-