Class ResourceFileTypeManifold<M extends IModel>

    • Constructor Detail

      • ResourceFileTypeManifold

        public ResourceFileTypeManifold()
    • Method Detail

      • init

        public void init​(IModule module)
        Description copied from interface: ITypeManifold
        Initialize this type manifold. Avoid defining types in the scope of this method.
        Specified by:
        init in interface ITypeManifold
        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 constructor
        modelMapper - A function to provide a model given a qualified name and resource file
      • isFileBacked

        public boolean isFileBacked()
        Description copied from interface: IFileConnected
        Are the types produced from this type manifold backed by project files such as resource files?
        Specified by:
        isFileBacked in interface IFileConnected
      • isDuplicate

        protected boolean isDuplicate​(IFile file,
                                      Set<IFile> files)
      • 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 from defaultFqn.
        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 null if there is no primary type for file but there may be additional types via getAdditionalTypes(String, IFile)
      • getAdditionalTypes

        protected Set<String> getAdditionalTypes​(String fqnForFile,
                                                 IFile file)
        Additional types derived from file. 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 to file
        file - 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 type
        relativeInner - 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 a ContributorKind.Primary contributor.
        model - The model your manifold uses to generate the source.
        Returns:
        The combined source code for the specified top-level type.
      • getModel

        protected M getModel​(String topLevel)
      • handlesFile

        public boolean handlesFile​(IFile file)
        Specified by:
        handlesFile in interface IFileConnected
        Returns:
        True if the type manifold handles the given file
      • getTypesForFile

        public String[] getTypesForFile​(IFile file)
        Description copied from interface: IFileConnected
        Returns 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:
        getTypesForFile in interface IFileConnected
        Parameters:
        file - The file in question
        Returns:
        All known types derived from that file
      • refreshedFile

        public RefreshKind refreshedFile​(IFile file,
                                         String[] types,
                                         RefreshKind kind)
        Description copied from interface: IFileConnected
        Notifies 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:
        refreshedFile in interface IFileConnected
        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: ITypeManifold
        Does this producer supply source for the specified fqn?
        Specified by:
        isType in interface ITypeManifold
      • isPackage

        public boolean isPackage​(String pkg)
        Description copied from interface: ITypeManifold
        Verifies whether or not the specified package may be provided by this source producer
        Specified by:
        isPackage in interface ITypeManifold
      • findTopLevelFqn

        public String findTopLevelFqn​(String fqn)
        This method avoids initializing all the files
      • getContent

        public static String getContent​(IFile file)