public final class Es6SortedDependencies<INPUT extends DependencyInfo> extends java.lang.Object implements SortedDependencies<INPUT>
Orders such than for each input always comes after its dependencies. Circular references are allowed by emitting the current input in the moment before a loop would complete.
The resulting order is not the same as the user-provided order but is influenced by it since it may take more than one graph traversal to account for all provided inputs and the graph traversals start with the first user provided input and continue from there.
Also exposes other information about the inputs, like which inputs do not provide symbols.
SortedDependencies.CircularDependencyException, SortedDependencies.MissingProvideException
Modifier and Type | Field and Description |
---|---|
private java.util.Set<INPUT> |
completedInputs |
private java.util.Map<java.lang.String,INPUT> |
exportingInputBySymbolName |
private com.google.common.collect.Multimap<INPUT,INPUT> |
importedInputByImportingInput |
private java.util.List<INPUT> |
importOrderedInputs |
private java.util.Map<java.lang.String,INPUT> |
nonExportingInputs |
private java.util.List<INPUT> |
userOrderedInputs |
Constructor and Description |
---|
Es6SortedDependencies(java.util.List<INPUT> userOrderedInputs) |
Modifier and Type | Method and Description |
---|---|
private static URI |
createUri(java.lang.String input)
Copied from ES6ModuleLoader because our BUILD rules are written in such a way that we can't
depend on ES6ModuleLoader from here.
|
java.util.List<INPUT> |
getDependenciesOf(java.util.List<INPUT> rootInputs,
boolean sorted)
Gets all the dependencies of the given roots.
|
INPUT |
getInputProviding(java.lang.String symbolName)
Return the input that gives us the given symbol.
|
java.util.List<INPUT> |
getInputsWithoutProvides() |
java.util.List<INPUT> |
getSortedDependenciesOf(java.util.List<INPUT> roots)
Gets all the dependencies of the given roots.
|
java.util.List<INPUT> |
getSortedList() |
INPUT |
maybeGetInputProviding(java.lang.String symbol)
Return the input that gives us the given symbol, or null.
|
private void |
orderInput(INPUT input) |
private void |
processInputs() |
private static java.lang.String |
toModuleName(URI filename)
Turns a filename into a JS identifier that is used for moduleNames in
rewritten code.
|
private final java.util.List<INPUT extends DependencyInfo> userOrderedInputs
private final java.util.List<INPUT extends DependencyInfo> importOrderedInputs
private final java.util.Set<INPUT extends DependencyInfo> completedInputs
private final java.util.Map<java.lang.String,INPUT extends DependencyInfo> nonExportingInputs
private final java.util.Map<java.lang.String,INPUT extends DependencyInfo> exportingInputBySymbolName
private final com.google.common.collect.Multimap<INPUT extends DependencyInfo,INPUT extends DependencyInfo> importedInputByImportingInput
public Es6SortedDependencies(java.util.List<INPUT> userOrderedInputs)
public java.util.List<INPUT> getDependenciesOf(java.util.List<INPUT> rootInputs, boolean sorted)
SortedDependencies
getDependenciesOf
in interface SortedDependencies<INPUT extends DependencyInfo>
sorted
- If true, get them in topologically sorted order. If false,
get them in the original order they were passed to the compiler.public INPUT getInputProviding(java.lang.String symbolName) throws SortedDependencies.MissingProvideException
SortedDependencies
getInputProviding
in interface SortedDependencies<INPUT extends DependencyInfo>
SortedDependencies.MissingProvideException
- An exception if there is no
input for this symbol.public java.util.List<INPUT> getInputsWithoutProvides()
getInputsWithoutProvides
in interface SortedDependencies<INPUT extends DependencyInfo>
public java.util.List<INPUT> getSortedDependenciesOf(java.util.List<INPUT> roots)
SortedDependencies
getSortedDependenciesOf
in interface SortedDependencies<INPUT extends DependencyInfo>
public java.util.List<INPUT> getSortedList()
getSortedList
in interface SortedDependencies<INPUT extends DependencyInfo>
public INPUT maybeGetInputProviding(java.lang.String symbol)
SortedDependencies
maybeGetInputProviding
in interface SortedDependencies<INPUT extends DependencyInfo>
private static java.lang.String toModuleName(URI filename)
private static URI createUri(java.lang.String input)
private void orderInput(INPUT input)
private void processInputs()