Class JSModule

  • All Implemented Interfaces:
    DependencyInfo, java.io.Serializable

    public final class JSModule
    extends DependencyInfo.Base
    implements java.io.Serializable
    A JavaScript module has a unique name, consists of a list of compiler inputs, and can depend on other modules.
    See Also:
    Serialized Form
    • Field Detail

      • STRONG_MODULE_NAME

        public static final java.lang.String STRONG_MODULE_NAME
        See Also:
        Constant Field Values
      • WEAK_MODULE_NAME

        public static final java.lang.String WEAK_MODULE_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • JSModule

        public JSModule​(java.lang.String name)
        Creates an instance.
        Parameters:
        name - A unique name for the module
    • Method Detail

      • getName

        public java.lang.String getName()
        Gets the module name.
        Specified by:
        getName in interface DependencyInfo
      • setName

        public void setName​(java.lang.String name)
        Sets the module name.
      • getProvides

        public com.google.common.collect.ImmutableList<java.lang.String> getProvides()
        Description copied from interface: DependencyInfo
        Gets the symbols provided by this file.
        Specified by:
        getProvides in interface DependencyInfo
      • getTypeRequires

        public com.google.common.collect.ImmutableList<java.lang.String> getTypeRequires()
        Description copied from interface: DependencyInfo
        Gets the symbols type-required by this file (i.e. for typechecking only).
        Specified by:
        getTypeRequires in interface DependencyInfo
      • getLoadFlags

        public com.google.common.collect.ImmutableMap<java.lang.String,​java.lang.String> getLoadFlags()
        Description copied from interface: DependencyInfo
        Gets the loading information for this file.
        Specified by:
        getLoadFlags in interface DependencyInfo
      • add

        public void add​(SourceFile file)
        Adds a source file input to this module.
      • add

        public void add​(CompilerInput input)
        Adds a source code input to this module.
      • addAfter

        public void addAfter​(CompilerInput input,
                             CompilerInput other)
        Adds a source code input to this module directly after other.
      • addDependency

        public void addDependency​(JSModule dep)
        Adds a dependency on another module.
      • remove

        public void remove​(CompilerInput input)
        Removes an input from this module.
      • removeAll

        public void removeAll()
        Removes all of the inputs from this module.
      • getDependencies

        public com.google.common.collect.ImmutableList<JSModule> getDependencies()
        Gets the list of modules that this module depends on.
        Returns:
        A list that may be empty but not null
      • getAllDependencies

        public java.util.Set<JSModule> getAllDependencies()
        Returns the transitive closure of dependencies starting from the dependencies of this module.
      • getThisAndAllDependencies

        public java.util.Set<JSModule> getThisAndAllDependencies()
        Returns this module and all of its dependencies in one list.
      • getInputCount

        public int getInputCount()
        Returns the number of source code inputs.
      • getInput

        public CompilerInput getInput​(int i)
        Returns the i-th source code input.
      • getInputs

        public java.util.List<CompilerInput> getInputs()
        Gets this module's list of source code inputs.
        Returns:
        A list that may be empty but not null
      • getByName

        public CompilerInput getByName​(java.lang.String name)
        Returns the input with the given name or null if none.
      • removeByName

        public boolean removeByName​(java.lang.String name)
        Removes any input with the given name. Returns whether any were removed.
      • isSynthetic

        public boolean isSynthetic()
        Returns whether this module is synthetic (i.e. one of the special strong or weak modules created by the compiler.
      • isWeak

        public boolean isWeak()
      • toString

        public java.lang.String toString()
        Returns the module name (primarily for debugging).
        Overrides:
        toString in class java.lang.Object
      • sortInputsByDeps

        public void sortInputsByDeps​(AbstractCompiler compiler)
        Puts the JS files into a topologically sorted order by their dependencies.
      • setDepth

        public void setDepth​(int dep)
        Parameters:
        dep - the depth to set
      • getDepth

        public int getDepth()
        Returns:
        the depth
      • setIndex

        public void setIndex​(int index)
      • getIndex

        public int getIndex()