Package com.google.javascript.jscomp
Class JSChunkGraph
- java.lang.Object
-
- com.google.javascript.jscomp.JSChunkGraph
-
- All Implemented Interfaces:
java.io.Serializable
public final class JSChunkGraph extends java.lang.Object implements java.io.Serializable
AJSChunk
dependency graph that assigns a depth to each chunk and can answer depth-related queries about them. For the purposes of this class, a chunk's depth is defined as the number of hops in the longest (non cyclic) path from the chunk to a chunk with no dependencies.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
JSChunkGraph.ChunkDependenceException
Exception class for declaring when the chunks being fed into a JSChunkGraph as input aren't in dependence order, and so can't be processed for caching of various dependency-related queries.static class
JSChunkGraph.MissingChunkException
Another exception class
-
Constructor Summary
Constructors Constructor Description JSChunkGraph(JSChunk[] chunksInDepOrder)
Creates a chunk graph from a list of chunks in dependency order.JSChunkGraph(java.util.List<JSChunk> chunksInDepOrder)
Creates a chunk graph from a list of chunks in dependency order.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
dependsOn(JSChunk src, JSChunk m)
Determines whether this chunk depends on a given chunk.JSChunk
getDeepestCommonDependencyInclusive(JSChunk m1, JSChunk m2)
Finds the deepest common dependency of two chunks, including the chunks themselves.JSChunk
getDeepestCommonDependencyInclusive(java.util.Collection<JSChunk> chunks)
Returns the deepest common dependency of the given chunks.JSChunk
getSmallestCoveringSubtree(JSChunk parentTree, java.util.BitSet dependentChunks)
Finds the chunk with the fewest transitive dependents on which all of the given chunks depend and that is a subtree of the given parent chunk tree.com.google.common.collect.ImmutableList<CompilerInput>
manageDependencies(AbstractCompiler compiler, DependencyOptions dependencyOptions)
Apply the dependency options to the list of sources, returning a new source list re-ordering and dropping files as necessary.
-
-
-
Method Detail
-
dependsOn
public boolean dependsOn(JSChunk src, JSChunk m)
Determines whether this chunk depends on a given chunk. Note that a chunk never depends on itself, as that dependency would be cyclic.
-
getSmallestCoveringSubtree
public JSChunk getSmallestCoveringSubtree(JSChunk parentTree, java.util.BitSet dependentChunks)
Finds the chunk with the fewest transitive dependents on which all of the given chunks depend and that is a subtree of the given parent chunk tree.If no such subtree can be found, the parent chunk is returned.
If multiple candidates have the same number of dependents, the chunk farthest down in the total ordering of chunks will be chosen.
- Parameters:
parentTree
- chunk on which the result must dependdependentChunks
- indices of chunks to consider- Returns:
- A chunk on which all of the argument chunks depend
-
getDeepestCommonDependencyInclusive
public JSChunk getDeepestCommonDependencyInclusive(JSChunk m1, JSChunk m2)
Finds the deepest common dependency of two chunks, including the chunks themselves.- Parameters:
m1
- A chunk in this graphm2
- A chunk in this graph- Returns:
- The deepest common dep of
m1
andm2
, or null if they have no common dependencies
-
getDeepestCommonDependencyInclusive
public JSChunk getDeepestCommonDependencyInclusive(java.util.Collection<JSChunk> chunks)
Returns the deepest common dependency of the given chunks.
-
manageDependencies
public com.google.common.collect.ImmutableList<CompilerInput> manageDependencies(AbstractCompiler compiler, DependencyOptions dependencyOptions) throws SortedDependencies.MissingProvideException, JSChunkGraph.MissingChunkException
Apply the dependency options to the list of sources, returning a new source list re-ordering and dropping files as necessary. This chunk graph will be updated to reflect the new list.See
DependencyOptions
for more information on how this works.- Throws:
SortedDependencies.MissingProvideException
- if an entry point was not provided by any of the inputs.JSChunkGraph.MissingChunkException
-
-