Class JSChunk

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

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

      • JSChunk

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

      • getName

        public java.lang.String getName()
        Gets the chunk name.
        Specified by:
        getName in interface DependencyInfo
      • 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 chunk.
      • add

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

        public void addDependency​(JSChunk dep)
        Adds a dependency on another chunk.
      • remove

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

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

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

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

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

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

        public CompilerInput getFirst()
        Returns the first source code input.
      • getInputs

        public java.util.List<CompilerInput> getInputs()
        Gets this chunk'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 chunk is synthetic (i.e. one of the special strong or weak chunks created by the compiler.
      • isWeak

        public boolean isWeak()
      • toString

        public java.lang.String toString()
        Returns the chunk 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()