Class JSChunk

java.lang.Object
com.google.javascript.jscomp.JSChunk
All Implemented Interfaces:
DependencyInfo, Serializable

public final class JSChunk extends Object implements Serializable, DependencyInfo
A JavaScript chunk has a unique name, consists of a list of compiler inputs, and can depend on other chunks.
See Also:
  • Field Details

  • Constructor Details

    • JSChunk

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

    • getName

      public String getName()
      Gets the chunk name.
      Specified by:
      getName in interface DependencyInfo
    • getProvides

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

      public boolean getHasExternsAnnotation()
      Description copied from interface: DependencyInfo
      Whether the file '@externs' annotation.
      Specified by:
      getHasExternsAnnotation in interface DependencyInfo
    • getHasNoCompileAnnotation

      public boolean getHasNoCompileAnnotation()
      Description copied from interface: DependencyInfo
      Whether the file has the '@nocompile' annotation.
      Specified by:
      getHasNoCompileAnnotation in interface DependencyInfo
    • getRequires

      public com.google.common.collect.ImmutableList<DependencyInfo.Require> getRequires()
      Description copied from interface: DependencyInfo
      Gets the symbols required by this file.
      Specified by:
      getRequires in interface DependencyInfo
    • getTypeRequires

      public com.google.common.collect.ImmutableList<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
    • getPathRelativeToClosureBase

      public String getPathRelativeToClosureBase()
      Description copied from interface: DependencyInfo
      Gets the path of this file relative to Closure's base.js file.
      Specified by:
      getPathRelativeToClosureBase in interface DependencyInfo
    • getLoadFlags

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

      public boolean isGoogModule()
      Description copied from interface: DependencyInfo
      Whether the symbol is provided by a goog module
      Specified by:
      isGoogModule in interface DependencyInfo
    • isEs6Module

      public boolean isEs6Module()
      Description copied from interface: DependencyInfo
      Whether the symbol is provided by an ES6 module
      Specified by:
      isEs6Module 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 Set<JSChunk> getAllDependencies()
      Returns the transitive closure of dependencies starting from the dependencies of this chunk.
    • getThisAndAllDependencies

      public 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 com.google.common.collect.ImmutableList<CompilerInput> getInputs()
      Gets this chunk's list of source code inputs.
      Returns:
      A list that may be empty but not null
    • getInputsIterable

      public Iterable<CompilerInput> getInputsIterable()
    • getByName

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

      public boolean removeByName(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 String toString()
      Returns the chunk name (primarily for debugging).
      Overrides:
      toString in class 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()