public class CompilerInput extends java.lang.Object implements SourceAst, DependencyInfo
SourceAst and maintain state such as module for the input and
whether the input is an extern. Also calculates provided and required types.| Modifier and Type | Class and Description |
|---|---|
private static class |
CompilerInput.DepsFinder |
DependencyInfo.Base| Modifier and Type | Field and Description |
|---|---|
private SourceAst |
ast |
private AbstractCompiler |
compiler |
private boolean |
generatedDependencyInfoFromSource |
private boolean |
generatedLoadFlags |
private InputId |
id |
private java.util.Map<java.lang.String,java.lang.String> |
loadFlags |
private JSModule |
module |
(package private) static DiagnosticType |
MODULE_CONFLICT |
private java.util.Set<java.lang.String> |
provides |
private java.util.Set<java.lang.String> |
requires |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
CompilerInput(SourceAst ast) |
CompilerInput(SourceAst ast,
boolean isExtern) |
CompilerInput(SourceAst ast,
InputId inputId,
boolean isExtern) |
CompilerInput(SourceAst ast,
java.lang.String inputId,
boolean isExtern) |
CompilerInput(SourceFile file) |
CompilerInput(SourceFile file,
boolean isExtern) |
| Modifier and Type | Method and Description |
|---|---|
void |
addProvide(java.lang.String provide)
Registers a type that this input defines.
|
void |
addRequire(java.lang.String require)
Registers a type that this input depends on.
|
private void |
checkErrorManager() |
void |
clearAst()
Removes any references to root node of the AST.
|
private void |
determineLoadFlagsIfNecessary()
Parses the file to determine the load flags if necessary, which includes the module type and the language
version.
|
Node |
getAstRoot(AbstractCompiler compiler)
Gets the root node of the AST for the source file this represents.
|
java.lang.String |
getCode() |
InputId |
getInputId()
Returns a name for this input.
|
int |
getLineOffset(int lineno) |
com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> |
getLoadFlags()
Gets the loading information for this file.
|
JSModule |
getModule()
Returns the module to which the input belongs.
|
java.lang.String |
getName()
Returns a name for this input.
|
int |
getNumLines() |
java.lang.String |
getPathRelativeToClosureBase()
Gets the path relative to closure-base, if one is available.
|
java.util.Collection<java.lang.String> |
getProvides()
Gets a list of types provided by this input.
|
java.util.Collection<java.lang.String> |
getRequires()
Gets a list of types depended on by this input.
|
SourceFile |
getSourceFile()
Returns the source file the generated AST represents.
|
boolean |
isExtern() |
boolean |
isModule()
Whether the symbol is provided by a module
|
(package private) void |
overrideModule(JSModule module)
Overrides the module to which the input belongs.
|
private void |
regenerateDependencyInfoIfNecessary()
Regenerates the provides/requires if we need to do so.
|
void |
setCompiler(AbstractCompiler compiler)
Sets an abstract compiler for doing parsing.
|
(package private) void |
setIsExtern(boolean isExtern) |
void |
setModule(JSModule module)
Sets the module to which the input belongs.
|
void |
setSourceFile(SourceFile file)
Sets the source file the generated AST represents.
|
java.lang.String |
toString() |
static final DiagnosticType MODULE_CONFLICT
private static final long serialVersionUID
private JSModule module
private final InputId id
private final SourceAst ast
private final java.util.Map<java.lang.String,java.lang.String> loadFlags
private final java.util.Set<java.lang.String> provides
private final java.util.Set<java.lang.String> requires
private boolean generatedDependencyInfoFromSource
private boolean generatedLoadFlags
private transient AbstractCompiler compiler
public CompilerInput(SourceAst ast)
public CompilerInput(SourceAst ast, boolean isExtern)
public CompilerInput(SourceAst ast, java.lang.String inputId, boolean isExtern)
public CompilerInput(SourceFile file)
public CompilerInput(SourceFile file, boolean isExtern)
public InputId getInputId()
getInputId in interface SourceAstpublic java.lang.String getName()
getName in interface DependencyInfopublic java.lang.String getPathRelativeToClosureBase()
getPathRelativeToClosureBase in interface DependencyInfopublic Node getAstRoot(AbstractCompiler compiler)
SourceAstgetAstRoot in interface SourceAstpublic void clearAst()
SourceAstpublic SourceFile getSourceFile()
SourceAstgetSourceFile in interface SourceAstpublic void setSourceFile(SourceFile file)
SourceAstsetSourceFile in interface SourceAstpublic void setCompiler(AbstractCompiler compiler)
private void checkErrorManager()
public java.util.Collection<java.lang.String> getRequires()
getRequires in interface DependencyInfopublic java.util.Collection<java.lang.String> getProvides()
getProvides in interface DependencyInfopublic void addProvide(java.lang.String provide)
public void addRequire(java.lang.String require)
private void regenerateDependencyInfoIfNecessary()
throws java.io.IOException
java.io.IOExceptionprivate void determineLoadFlagsIfNecessary()
throws java.io.IOException
regenerateDependencyInfoIfNecessary() since
non-JsAst inputs don't need any additional parsing, and either
case may add some pre-parse load flags, anyway.java.io.IOExceptionpublic java.lang.String getCode()
throws java.io.IOException
java.io.IOExceptionpublic JSModule getModule()
public void setModule(JSModule module)
void overrideModule(JSModule module)
public boolean isExtern()
void setIsExtern(boolean isExtern)
public int getLineOffset(int lineno)
public int getNumLines()
public java.lang.String toString()
toString in class java.lang.Objectpublic com.google.common.collect.ImmutableMap<java.lang.String,java.lang.String> getLoadFlags()
DependencyInfogetLoadFlags in interface DependencyInfopublic boolean isModule()
DependencyInfoisModule in interface DependencyInfo