Class CompilerInput

java.lang.Object
com.google.javascript.jscomp.CompilerInput
All Implemented Interfaces:
DependencyInfo

public class CompilerInput extends Object implements DependencyInfo
A class for the internal representation of an input to the compiler. Wraps a CompilerInput.JsAst and maintain state such as module for the input and whether the input is an extern. Also calculates provided and required types.
  • Constructor Details

    • CompilerInput

      public CompilerInput(SourceFile file, InputId inputId)
    • CompilerInput

      @Deprecated public CompilerInput(SourceFile sourceFile, String inputId, boolean isExtern)
      Deprecated.
      the inputId is read from the SourceFile. Use CompilerInput(file, isExtern)
    • CompilerInput

      @Deprecated public CompilerInput(SourceFile sourceFile, InputId inputId, boolean isExtern)
      Deprecated.
      the inputId is read from the SourceFile. Use CompilerInput(file, isExtern)
    • CompilerInput

      public CompilerInput(SourceFile file)
    • CompilerInput

      public CompilerInput(SourceFile file, boolean isExtern)
  • Method Details

    • 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 String getName()
      Returns a name for this input. Must be unique across all inputs.
      Specified by:
      getName in interface DependencyInfo
    • getPathRelativeToClosureBase

      public String getPathRelativeToClosureBase()
      Gets the path relative to closure-base, if one is available.
      Specified by:
      getPathRelativeToClosureBase in interface DependencyInfo
    • 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:
      getRequires in interface DependencyInfo
    • getTypeRequires

      public com.google.common.collect.ImmutableList<String> getTypeRequires()
      Description copied from interface: DependencyInfo
      Gets the symbols type-required by this file (i.e. for typechecking only).
      Specified by:
      getTypeRequires in interface DependencyInfo
    • getProvides

      public com.google.common.collect.ImmutableList<String> getProvides()
      Gets a list of types provided by this input.
      Specified by:
      getProvides in interface DependencyInfo
    • getHasExternsAnnotation

      public boolean getHasExternsAnnotation()
      Description copied from interface: DependencyInfo
      Whether the file '@externs' annotation.
      Specified by:
      getHasExternsAnnotation in interface DependencyInfo
    • getHasNoCompileAnnotation

      public boolean getHasNoCompileAnnotation()
      Description copied from interface: DependencyInfo
      Whether the file has the '@nocompile' annotation.
      Specified by:
      getHasNoCompileAnnotation in interface DependencyInfo
    • addProvide

      public void addProvide(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<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(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<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(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 String getCode() throws IOException
      Throws:
      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 String toString()
      Overrides:
      toString in class Object
    • isEs6Module

      public boolean isEs6Module()
      Description copied from interface: DependencyInfo
      Whether the symbol is provided by an ES6 module
      Specified by:
      isEs6Module in interface DependencyInfo
    • isGoogModule

      public boolean isGoogModule()
      Description copied from interface: DependencyInfo
      Whether the symbol is provided by a goog module
      Specified by:
      isGoogModule in interface DependencyInfo
    • getLoadFlags

      public com.google.common.collect.ImmutableMap<String,String> getLoadFlags()
      Description copied from interface: DependencyInfo
      Gets the loading information for this file.
      Specified by:
      getLoadFlags in interface DependencyInfo
    • getPath

      public ModuleLoader.ModulePath getPath()
    • getFeatures

      public FeatureSet getFeatures(AbstractCompiler compiler)