Package com.google.javascript.jscomp
Class JSChunk
- java.lang.Object
-
- com.google.javascript.jscomp.deps.DependencyInfo.Base
-
- com.google.javascript.jscomp.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.javascript.jscomp.deps.DependencyInfo
DependencyInfo.Base, DependencyInfo.Require, DependencyInfo.Util
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSTRONG_CHUNK_NAMEstatic java.lang.StringWEAK_CHUNK_NAME
-
Constructor Summary
Constructors Constructor Description JSChunk(java.lang.String name)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(CompilerInput input)Adds a source code input to this chunk.voidadd(SourceFile file)Adds a source file input to this chunk.voidaddDependency(JSChunk dep)Adds a dependency on another chunk.java.util.Set<JSChunk>getAllDependencies()Returns the transitive closure of dependencies starting from the dependencies of this chunk.CompilerInputgetByName(java.lang.String name)Returns the input with the given name or null if none.com.google.common.collect.ImmutableList<JSChunk>getDependencies()Gets the list of chunks that this chunk depends on.intgetDepth()CompilerInputgetFirst()Returns the first source code input.booleangetHasExternsAnnotation()Whether the file '@externs' annotation.booleangetHasNoCompileAnnotation()Whether the file has the '@nocompile' annotation.intgetIndex()intgetInputCount()Returns the number of source code inputs.java.util.List<CompilerInput>getInputs()Gets this chunk's list of source code inputs.com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String>getLoadFlags()Gets the loading information for this file.java.lang.StringgetName()Gets the chunk name.java.lang.StringgetPathRelativeToClosureBase()Gets the path of this file relative to Closure's base.js file.com.google.common.collect.ImmutableList<java.lang.String>getProvides()Gets the symbols provided by this file.com.google.common.collect.ImmutableList<DependencyInfo.Require>getRequires()Gets the symbols required by this file.java.util.Set<JSChunk>getThisAndAllDependencies()Returns this chunk and all of its dependencies in one list.com.google.common.collect.ImmutableList<java.lang.String>getTypeRequires()Gets the symbols type-required by this file (i.e.booleanisModule()Whether the symbol is provided by a modulebooleanisSynthetic()Returns whether this chunk is synthetic (i.e.booleanisWeak()voidremove(CompilerInput input)Removes an input from this chunk.voidremoveAll()Removes all of the inputs from this chunk.booleanremoveByName(java.lang.String name)Removes any input with the given name.voidsetDepth(int dep)voidsetIndex(int index)voidsortInputsByDeps(AbstractCompiler compiler)Puts the JS files into a topologically sorted order by their dependencies.java.lang.StringtoString()Returns the chunk name (primarily for debugging).-
Methods inherited from class com.google.javascript.jscomp.deps.DependencyInfo.Base
getRequiredSymbols
-
-
-
-
Field Detail
-
STRONG_CHUNK_NAME
public static final java.lang.String STRONG_CHUNK_NAME
- See Also:
- Constant Field Values
-
WEAK_CHUNK_NAME
public static final java.lang.String WEAK_CHUNK_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the chunk name.- Specified by:
getNamein interfaceDependencyInfo
-
getProvides
public com.google.common.collect.ImmutableList<java.lang.String> getProvides()
Description copied from interface:DependencyInfoGets the symbols provided by this file.- Specified by:
getProvidesin interfaceDependencyInfo
-
getHasExternsAnnotation
public boolean getHasExternsAnnotation()
Description copied from interface:DependencyInfoWhether the file '@externs' annotation.- Specified by:
getHasExternsAnnotationin interfaceDependencyInfo
-
getHasNoCompileAnnotation
public boolean getHasNoCompileAnnotation()
Description copied from interface:DependencyInfoWhether the file has the '@nocompile' annotation.- Specified by:
getHasNoCompileAnnotationin interfaceDependencyInfo
-
getRequires
public com.google.common.collect.ImmutableList<DependencyInfo.Require> getRequires()
Description copied from interface:DependencyInfoGets the symbols required by this file.- Specified by:
getRequiresin interfaceDependencyInfo
-
getTypeRequires
public com.google.common.collect.ImmutableList<java.lang.String> getTypeRequires()
Description copied from interface:DependencyInfoGets the symbols type-required by this file (i.e. for typechecking only).- Specified by:
getTypeRequiresin interfaceDependencyInfo
-
getPathRelativeToClosureBase
public java.lang.String getPathRelativeToClosureBase()
Description copied from interface:DependencyInfoGets the path of this file relative to Closure's base.js file.- Specified by:
getPathRelativeToClosureBasein interfaceDependencyInfo
-
getLoadFlags
public com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> getLoadFlags()
Description copied from interface:DependencyInfoGets the loading information for this file.- Specified by:
getLoadFlagsin interfaceDependencyInfo
-
isModule
public boolean isModule()
Description copied from interface:DependencyInfoWhether the symbol is provided by a module- Specified by:
isModulein interfaceDependencyInfo- Overrides:
isModulein classDependencyInfo.Base
-
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:
toStringin classjava.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()
-
-