Package manifold.api.type
Class ResourceFileTypeManifold<M extends IModel>
- java.lang.Object
-
- manifold.api.service.BaseService
-
- manifold.api.type.ResourceFileTypeManifold<M>
-
- Type Parameters:
M- The model you derive backing contributions of source code.
- All Implemented Interfaces:
IPluginHost,IService,IFileConnected,ISelfCompiled,ITypeManifold
- Direct Known Subclasses:
JavaTypeManifold
public abstract class ResourceFileTypeManifold<M extends IModel> extends BaseService implements ITypeManifold
A base class for a type manifold that is based on a resource file type, typically discernible by the file extension.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classResourceFileTypeManifold.CacheClearer
-
Field Summary
-
Fields inherited from interface manifold.api.type.ITypeManifold
ARG_DUMP_SOURCE
-
-
Constructor Summary
Constructors Constructor Description ResourceFileTypeManifold()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all cached dataStringcontribute(JavaFileManager.Location location, String fqn, boolean genStubs, String existing, DiagnosticListener<JavaFileObject> errorHandler)Contribute source corresponding with the fqn.protected abstract Stringcontribute(JavaFileManager.Location location, String topLevelFqn, boolean genStubs, String existing, M model, DiagnosticListener<JavaFileObject> errorHandler)Contribute source code for the specified type and model.protected ResourceFileTypeManifold.CacheClearercreateCacheClearer()List<IFile>findFilesForType(String fqn)StringfindTopLevelFqn(String fqn)This method avoids initializing all the filesprotected Set<String>getAdditionalTypes(String fqnForFile, IFile file)Additional types derived fromfile.Collection<String>getAllTypeNames()static StringgetContent(IFile file)protected MgetModel(String topLevel)IModulegetModule()The module to which this producer is scopedStringgetPackage(String fqn)What is the package name for the specified fqn?protected Map<String,manifold.util.concurrent.LocklessLazyVar<M>>getPeripheralTypes()A map of name-to-model peripheral to the main map of name-to-model, possibly including types that are not file-based.StringgetTypeNameForFile(String defaultFqn, IFile file)Provide the type name that corresponds with the resource file, if different fromdefaultFqn.Collection<TypeName>getTypeNames(String namespace)String[]getTypesForFile(IFile file)Returns ALL type names associated with the given file whether or not the types have been loaded yet.booleanhandlesFile(IFile file)voidinit(IModule module)Initialize this type manifold.protected voidinit(IModule module, BiFunction<String,Set<IFile>,M> modelMapper)protected booleanisDuplicate(IFile file, Set<IFile> files)booleanisFileBacked()Are the types produced from this type manifold backed by project files such as resource files?abstract booleanisInnerType(String topLevelFqn, String relativeInner)booleanisPackage(String pkg)Verifies whether or not the specified package may be provided by this source producerbooleanisTopLevelType(String fqn)booleanisType(String fqn)Does this producer supply source for the specified fqn?RefreshKindrefreshedFile(IFile file, String[] types, RefreshKind kind)Notifies that a file has been refreshed.-
Methods inherited from class manifold.api.service.BaseService
doInit, doUninit, init, isInited, uninit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface manifold.api.type.IFileConnected
handlesFileExtension
-
Methods inherited from interface manifold.api.service.IPluginHost
getInterface
-
Methods inherited from interface manifold.api.type.ISelfCompiled
compile, isSelfCompile, parse
-
Methods inherited from interface manifold.api.type.ITypeManifold
accept, enterPostJavaCompilation, getClassType, getContributorKind, getSourceKind
-
-
-
-
Method Detail
-
init
public void init(IModule module)
Description copied from interface:ITypeManifoldInitialize this type manifold. Avoid defining types in the scope of this method.- Specified by:
initin interfaceITypeManifold- Parameters:
module- The module to which this type manifold exclusively belongs
-
init
protected void init(IModule module, BiFunction<String,Set<IFile>,M> modelMapper)
- Parameters:
module- The module passed into the {@code ITypeManifold) implementation constructormodelMapper- A function to provide a model given a qualified name and resource file
-
isFileBacked
public boolean isFileBacked()
Description copied from interface:IFileConnectedAre the types produced from this type manifold backed by project files such as resource files?- Specified by:
isFileBackedin interfaceIFileConnected
-
createCacheClearer
protected ResourceFileTypeManifold.CacheClearer createCacheClearer()
-
getPeripheralTypes
protected Map<String,manifold.util.concurrent.LocklessLazyVar<M>> getPeripheralTypes()
A map of name-to-model peripheral to the main map of name-to-model, possibly including types that are not file-based. Optional.
-
getTypeNameForFile
public String getTypeNameForFile(String defaultFqn, IFile file)
Provide the type name that corresponds with the resource file, if different fromdefaultFqn.- Parameters:
defaultFqn- The default name derived from the resource file name.file- The resource file corresponding with the type name.- Returns:
- A valid type name corresponding with the type or
nullif there is no primary type forfilebut there may be additional types viagetAdditionalTypes(String, IFile)
-
getAdditionalTypes
protected Set<String> getAdditionalTypes(String fqnForFile, IFile file)
Additional types derived fromfile. These can be supporting classes, interfaces, extension classes, what have you. In the case of extension classes, this type manifold must implement IExtensionClassProducer.- Parameters:
fqnForFile- The primary type this type manifold assigned tofilefile- The resource file from which types may be derived
-
isInnerType
public abstract boolean isInnerType(String topLevelFqn, String relativeInner)
- Parameters:
topLevelFqn- Qualified name of top-level typerelativeInner- Top-level relative name of inner class- Returns:
- true if relativeInner is an inner class of topLevel
-
contribute
protected abstract String contribute(JavaFileManager.Location location, String topLevelFqn, boolean genStubs, String existing, M model, DiagnosticListener<JavaFileObject> errorHandler)
Contribute source code for the specified type and model.- Parameters:
location- (Experimental) The location of the use-site in the Java compiler. Provides javac module context. Optional and only relevant at compile-time when executed within a Javac compiler.topLevelFqn- The qualified name of the top-level type to contribute.genStubs-existing- The source produced from other manifolds so far; if not empty, this manifold must not be aContributorKind.Primarycontributor.model- The model your manifold uses to generate the source.- Returns:
- The combined source code for the specified top-level type.
-
handlesFile
public boolean handlesFile(IFile file)
- Specified by:
handlesFilein interfaceIFileConnected- Returns:
- True if the type manifold handles the given
file
-
getTypesForFile
public String[] getTypesForFile(IFile file)
Description copied from interface:IFileConnectedReturns ALL type names associated with the given file whether or not the types have been loaded yet. Type loading should NOT be used in the implementation of this method.- Specified by:
getTypesForFilein interfaceIFileConnected- Parameters:
file- The file in question- Returns:
- All known types derived from that file
-
getModule
public IModule getModule()
Description copied from interface:ITypeManifoldThe module to which this producer is scoped- Specified by:
getModulein interfaceITypeManifold
-
refreshedFile
public RefreshKind refreshedFile(IFile file, String[] types, RefreshKind kind)
Description copied from interface:IFileConnectedNotifies that a file has been refreshed. The implementor should return all types that it knows need to be refreshed based on the given file.- Specified by:
refreshedFilein interfaceIFileConnected- Parameters:
file- The file that was refreshed- Returns:
- All known types affected by the file change
-
isType
public boolean isType(String fqn)
Description copied from interface:ITypeManifoldDoes this producer supply source for the specified fqn?- Specified by:
isTypein interfaceITypeManifold
-
isPackage
public boolean isPackage(String pkg)
Description copied from interface:ITypeManifoldVerifies whether or not the specified package may be provided by this source producer- Specified by:
isPackagein interfaceITypeManifold
-
findTopLevelFqn
public String findTopLevelFqn(String fqn)
This method avoids initializing all the files
-
isTopLevelType
public boolean isTopLevelType(String fqn)
- Specified by:
isTopLevelTypein interfaceITypeManifold
-
getPackage
public String getPackage(String fqn)
Description copied from interface:ITypeManifoldWhat is the package name for the specified fqn?- Specified by:
getPackagein interfaceITypeManifold
-
contribute
public String contribute(JavaFileManager.Location location, String fqn, boolean genStubs, String existing, DiagnosticListener<JavaFileObject> errorHandler)
Description copied from interface:ITypeManifoldContribute source corresponding with the fqn.- Specified by:
contributein interfaceITypeManifold
-
getAllTypeNames
public Collection<String> getAllTypeNames()
- Specified by:
getAllTypeNamesin interfaceITypeManifold
-
getTypeNames
public Collection<TypeName> getTypeNames(String namespace)
- Specified by:
getTypeNamesin interfaceITypeManifold
-
findFilesForType
public List<IFile> findFilesForType(String fqn)
- Specified by:
findFilesForTypein interfaceITypeManifold
-
clear
public void clear()
Description copied from interface:ITypeManifoldClear all cached data- Specified by:
clearin interfaceITypeManifold
-
-