Package com.google.javascript.jscomp
Class CompilerInput
- java.lang.Object
-
- com.google.javascript.jscomp.CompilerInput
-
- All Implemented Interfaces:
DependencyInfo
public class CompilerInput extends java.lang.Object implements DependencyInfo
A class for the internal representation of an input to the compiler. Wraps aSourceAstand maintain state such as module for the input and whether the input is an extern. Also calculates provided and required types.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompilerInput.ModuleTypeJavaScript module type.-
Nested classes/interfaces inherited from interface com.google.javascript.jscomp.deps.DependencyInfo
DependencyInfo.Require, DependencyInfo.Util
-
-
Constructor Summary
Constructors Constructor Description CompilerInput(SourceAst ast)CompilerInput(SourceAst ast, boolean isExtern)CompilerInput(SourceAst ast, InputId inputId, boolean isExtern)Deprecated.the inputId is read from the SourceAst.CompilerInput(SourceAst ast, java.lang.String inputId, boolean isExtern)Deprecated.the inputId is read from the SourceAst.CompilerInput(SourceFile file)CompilerInput(SourceFile file, boolean isExtern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddDynamicRequire(java.lang.String require)Registers a type that this input depends on in the order seen in the file.booleanaddOrderedRequire(DependencyInfo.Require require)Registers a type that this input depends on in the order seen in the file.voidaddProvide(java.lang.String provide)Registers a type that this input defines.voidaddRequire(DependencyInfo.Require require)Registers a type that this input depends on.voidaddRequireDynamicImports(java.lang.String require)Registers a type that this input depends on in the order seen in the file.voidclearAst()NodegetAstRoot(AbstractCompiler compiler)JSChunkgetChunk()Returns the chunk to which the input belongs.java.lang.StringgetCode()com.google.common.collect.ImmutableList<java.lang.String>getDynamicRequires()Returns the types that this input dynamically depends on in the order seen in the file.booleangetHasExternsAnnotation()Whether the file '@externs' annotation.booleangetHasNoCompileAnnotation()Whether the file has the '@nocompile' annotation.InputIdgetInputId()Returns a name for this input.CompilerInput.ModuleTypegetJsModuleType()intgetLineOffset(int lineno)com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String>getLoadFlags()Gets the loading information for this file.java.lang.StringgetName()Returns a name for this input.ModuleLoader.ModulePathgetPath()java.lang.StringgetPathRelativeToClosureBase()Gets the path relative to closure-base, if one is available.com.google.common.collect.ImmutableList<java.lang.String>getProvides()Gets a list of types provided by this input.com.google.common.collect.ImmutableList<java.lang.String>getRequireDynamicImports()Returns the types that this input dynamically imports by goog.requireDynamic() in the order seen in the file.com.google.common.collect.ImmutableList<DependencyInfo.Require>getRequires()Gets a list of types depended on by this input.SourceFilegetSourceFile()@Nullable TypedScopegetTypedScope()com.google.common.collect.ImmutableList<java.lang.String>getTypeRequires()Gets the symbols type-required by this file (i.e.booleanisEs6Module()Whether the symbol is provided by an ES6 modulebooleanisExtern()booleanisGoogModule()Whether the symbol is provided by a goog modulevoidsetChunk(JSChunk chunk)Sets the chunk to which the input belongs.voidsetCompiler(AbstractCompiler compiler)Sets an abstract compiler for doing parsing.voidsetHasFullParseDependencyInfo(boolean hasFullParseDependencyInfo)voidsetJsModuleType(CompilerInput.ModuleType moduleType)voidsetTypedScope(@Nullable TypedScope typedScope)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.javascript.jscomp.deps.DependencyInfo
getRequiredSymbols
-
-
-
-
Constructor Detail
-
CompilerInput
public CompilerInput(SourceAst ast)
-
CompilerInput
public CompilerInput(SourceAst ast, boolean isExtern)
-
CompilerInput
@Deprecated public CompilerInput(SourceAst ast, java.lang.String inputId, boolean isExtern)
Deprecated.the inputId is read from the SourceAst. Use CompilerInput(ast, isExtern)
-
CompilerInput
@Deprecated public CompilerInput(SourceAst ast, InputId inputId, boolean isExtern)
Deprecated.the inputId is read from the SourceAst. Use CompilerInput(ast, isExtern)
-
CompilerInput
public CompilerInput(SourceFile file)
-
CompilerInput
public CompilerInput(SourceFile file, boolean isExtern)
-
-
Method Detail
-
setTypedScope
public void setTypedScope(@Nullable TypedScope typedScope)
-
getTypedScope
public @Nullable TypedScope getTypedScope()
-
getInputId
public InputId getInputId()
Returns a name for this input. Must be unique across all inputs.
-
getName
public java.lang.String getName()
Returns a name for this input. Must be unique across all inputs.- Specified by:
getNamein interfaceDependencyInfo
-
getPathRelativeToClosureBase
public java.lang.String getPathRelativeToClosureBase()
Gets the path relative to closure-base, if one is available.- Specified by:
getPathRelativeToClosureBasein interfaceDependencyInfo
-
getAstRoot
public Node getAstRoot(AbstractCompiler compiler)
-
clearAst
public void clearAst()
-
getSourceFile
public SourceFile getSourceFile()
-
setCompiler
public void setCompiler(AbstractCompiler compiler)
Sets an abstract compiler for doing parsing.
-
getRequires
public com.google.common.collect.ImmutableList<DependencyInfo.Require> getRequires()
Gets a list of types depended on by this input.- 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
-
getProvides
public com.google.common.collect.ImmutableList<java.lang.String> getProvides()
Gets a list of types provided by this input.- 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
-
addProvide
public void addProvide(java.lang.String provide)
Registers a type that this input defines. Includes both explicitly declared namespaces via goog.provide and goog.module calls as well as implicit namespaces provided by module rewriting.
-
addOrderedRequire
public boolean addOrderedRequire(DependencyInfo.Require require)
Registers a type that this input depends on in the order seen in the file.
-
getDynamicRequires
public com.google.common.collect.ImmutableList<java.lang.String> getDynamicRequires()
Returns the types that this input dynamically depends on in the order seen in the file. The returned types were loaded dynamically so while they are part of the dependency graph, they do not need sorted before this input.
-
addDynamicRequire
public boolean addDynamicRequire(java.lang.String require)
Registers a type that this input depends on in the order seen in the file. The type was loaded dynamically so while it is part of the dependency graph, it does not need sorted before this input.
-
getRequireDynamicImports
public com.google.common.collect.ImmutableList<java.lang.String> getRequireDynamicImports()
Returns the types that this input dynamically imports by goog.requireDynamic() in the order seen in the file. The returned types were loaded dynamically so while they are part of the dependency graph, they do not need sorted before this input.
-
addRequireDynamicImports
public void addRequireDynamicImports(java.lang.String require)
Registers a type that this input depends on in the order seen in the file. The type was loaded by goog.requireDynamic() so while it is part of the dependency graph, it does not need sorted before this input.
-
setHasFullParseDependencyInfo
public void setHasFullParseDependencyInfo(boolean hasFullParseDependencyInfo)
-
getJsModuleType
public CompilerInput.ModuleType getJsModuleType()
-
setJsModuleType
public void setJsModuleType(CompilerInput.ModuleType moduleType)
-
addRequire
public void addRequire(DependencyInfo.Require require)
Registers a type that this input depends on.
-
getCode
public java.lang.String getCode() throws java.io.IOException- Throws:
java.io.IOException
-
getChunk
public JSChunk getChunk()
Returns the chunk to which the input belongs.
-
setChunk
public void setChunk(JSChunk chunk)
Sets the chunk to which the input belongs.
-
isExtern
public boolean isExtern()
-
getLineOffset
public int getLineOffset(int lineno)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isEs6Module
public boolean isEs6Module()
Description copied from interface:DependencyInfoWhether the symbol is provided by an ES6 module- Specified by:
isEs6Modulein interfaceDependencyInfo
-
isGoogModule
public boolean isGoogModule()
Description copied from interface:DependencyInfoWhether the symbol is provided by a goog module- Specified by:
isGoogModulein 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
-
getPath
public ModuleLoader.ModulePath getPath()
-
-