Package com.google.javascript.jscomp
Class JSModule
java.lang.Object
com.google.javascript.jscomp.JSModule
- All Implemented Interfaces:
DependencyInfo,Serializable
A JavaScript module has a unique name, consists of a list of compiler inputs,
and can depend on other modules.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(CompilerInput input) Adds a source code input to this module.voidadd(SourceFile file) Adds a source file input to this module.voidaddAfter(CompilerInput input, CompilerInput other) Adds a source code input to this module directly after other.voidaddDependency(JSModule dep) Adds a dependency on another module.voidaddFirst(CompilerInput input) Adds a source code input to this module.voidaddFirst(SourceFile file) Adds a source file input to this module.voidRemoves any references to nodes of the AST.Returns the transitive closure of dependencies starting from the dependencies of this module.Returns the input with the given name or null if none.Gets the list of modules that this module depends on.intgetDepth()Gets this module's list of source code inputs.getName()Gets the module name.Gets the path of this file relative to Closure's base.js file.Gets the symbols provided by this file.Gets the symbols required by this file.Returns this module and all of its dependencies in one list.voidremove(CompilerInput input) Removes an input from this module.voidRemoves all of the inputs from this module.booleanremoveByName(String name) Removes any input with the given name.voidsetDepth(int dep) voidsortInputsByDeps(Compiler compiler) Puts the JS files into a topologically sorted order by their dependencies.static JSModule[]sortJsModules(Collection<JSModule> modules) Returns the given collection of modules in topological order.toString()Returns the module name (primarily for debugging).
-
Constructor Details
-
JSModule
Creates an instance.- Parameters:
name- A unique name for the module
-
-
Method Details
-
getName
Gets the module name.- Specified by:
getNamein interfaceDependencyInfo
-
getProvides
Description copied from interface:DependencyInfoGets the symbols provided by this file.- Specified by:
getProvidesin interfaceDependencyInfo
-
getRequires
Description copied from interface:DependencyInfoGets the symbols required by this file.- Specified by:
getRequiresin interfaceDependencyInfo
-
getPathRelativeToClosureBase
Description copied from interface:DependencyInfoGets the path of this file relative to Closure's base.js file.- Specified by:
getPathRelativeToClosureBasein interfaceDependencyInfo
-
add
Adds a source file input to this module. -
addFirst
Adds a source file input to this module. -
add
Adds a source code input to this module. -
addFirst
Adds a source code input to this module. -
addAfter
Adds a source code input to this module directly after other. -
addDependency
Adds a dependency on another module. -
remove
Removes an input from this module. -
removeAll
public void removeAll()Removes all of the inputs from this module. -
getDependencies
Gets the list of modules that this module depends on.- Returns:
- A list that may be empty but not null
-
getAllDependencies
Returns the transitive closure of dependencies starting from the dependencies of this module. -
getThisAndAllDependencies
Returns this module and all of its dependencies in one list. -
getInputs
Gets this module's list of source code inputs.- Returns:
- A list that may be empty but not null
-
getByName
Returns the input with the given name or null if none. -
removeByName
Removes any input with the given name. Returns whether any were removed. -
toString
Returns the module name (primarily for debugging). -
clearAsts
public void clearAsts()Removes any references to nodes of the AST. This method is needed to allow the ASTs to be garbage collected if the modules are kept around. -
sortInputsByDeps
Puts the JS files into a topologically sorted order by their dependencies. -
sortJsModules
public static JSModule[] sortJsModules(Collection<JSModule> modules) throws SortedDependencies.CircularDependencyException Returns the given collection of modules in topological order. Note that this will return the modules in the same order if they are already sorted, and in general, will only change the order as necessary to satisfy the ordering dependencies. This can be important for cases where the modules do not properly specify all dependencies. -
setDepth
public void setDepth(int dep) - Parameters:
dep- the depth to set
-
getDepth
public int getDepth()- Returns:
- the depth
-