Package | Description |
---|---|
com.google.javascript.jscomp |
Provides the core compiler and its public API.
|
com.google.javascript.jscomp.lint |
Modifier and Type | Interface and Description |
---|---|
interface |
HotSwapCompilerPass
Interface for compiler passes that can be used in a hot-swap fashion.
|
Modifier and Type | Class and Description |
---|---|
(package private) class |
AliasStrings
A
Compiler pass for aliasing strings. |
(package private) class |
AmbiguateProperties
Renames unrelated properties to the same name, using type information.
|
(package private) class |
AnalyzePrototypeProperties
Analyzes properties on prototypes.
|
(package private) class |
AngularPass
Compiler pass for AngularJS-specific needs.
|
class |
AstValidator
This class walks the AST and validates that the structure is correct.
|
class |
CallGraph
A pass the uses a
DefinitionProvider to compute a call graph for an
AST. |
(package private) class |
ChainCalls
Chain calls to functions that return this.
|
(package private) class |
CheckAccessControls
A compiler pass that checks that the programmer has obeyed all the access
control restrictions indicated by JSDoc annotations, like
@private and @deprecated . |
class |
CheckConformance
Provides a framework for checking code against a set of user configured
conformance rules.
|
(package private) class |
CheckDebuggerStatement
CheckDebuggerStatement checks for the presence of the "debugger"
statement in JavaScript code. |
class |
CheckEventfulObjectDisposal
Check to ensure there exists a path to dispose of each eventful object
created.
|
(package private) class |
CheckGlobalNames
Checks references to undefined properties of global variables.
|
(package private) class |
CheckJSDoc
Checks for misplaced, misused or deprecated JSDoc annotations.
|
(package private) class |
CheckMissingGetCssName
Ensures string literals matching certain patterns are only used as
goog.getCssName parameters.
|
(package private) class |
CheckProvides
Ensures that '@constructor X' has a 'goog.provide("X")' .
|
(package private) class |
CheckRegExp
Look for references to the global RegExp object that would cause
regular expressions to be unoptimizable, and checks that regular expressions
are syntactically valid.
|
(package private) class |
CheckRequiresForConstructors
This pass walks the AST to create a Collection of 'new' nodes and
'goog.require' nodes.
|
(package private) class |
CheckSideEffects
Checks for non side effecting statements such as
|
(package private) static class |
CheckSideEffects.StripProtection
Remove side-effect sync functions.
|
(package private) class |
CheckUnusedPrivateProperties
This pass looks for properties that are never read.
|
(package private) static class |
CleanupPasses.MemoizedScopeCleanupPass
A CleanupPass implementation that will remove stored scopes from the
MemoizedScopeCreator of the compiler instance for a the hot swapped script.
|
class |
ClosureCheckModule
Checks that goog.module() is used correctly.
|
(package private) class |
ClosureCodeRemoval
Compiler pass that removes Closure-specific code patterns.
|
(package private) class |
ClosureOptimizePrimitives
Compiler pass that converts all calls to:
goog.object.create(key1, val1, key2, val2, ...) where all of the keys
are literals into object literals.
|
(package private) class |
ClosureRewriteClass
Rewrites "goog.defineClass" into a form that is suitable for
type checking and dead code elimination.
|
(package private) class |
ClosureRewriteModule
Process aliases in goog.modules.
|
(package private) class |
CoalesceVariableNames
Reuse variable names if possible.
|
(package private) class |
CollapseAnonymousFunctions
Collapses anonymous function expressions into named function declarations,
i.e.
|
(package private) class |
CollapseProperties
Flattens global objects/namespaces by replacing each '.' with '$' in
their names.
|
(package private) class |
CollapseVariableDeclarations
Collapses multiple variable declarations into a single one.
|
(package private) class |
CollectFileOverviewVisibility
Compiler pass that collects visibility annotations in
@fileoverview
blocks. |
(package private) class |
CombinedCompilerPass
A compiler pass combining multiple
NodeTraversal.Callback
and NodeTraversal.ScopedCallback objects. |
(package private) class |
ConstCheck
Verifies that constants are only assigned a value once.
|
(package private) class |
ConstParamCheck
Enforces that invocations of the method
goog.string.Const.from are
done with an argument which is a string literal. |
(package private) class |
ControlFlowAnalysis
This is a compiler pass that computes a control flow graph.
|
(package private) class |
ConvertToDottedProperties
Converts property accesses from quoted string syntax to dot syntax, where
possible.
|
(package private) class |
CoverageInstrumentationPass
This code implements the instrumentation pass over the AST
(returned by JSCompiler).
|
(package private) class |
CreateSyntheticBlocks
Creates synthetic blocks to optimizations from moving code
past markers in the source.
|
(package private) class |
CrossModuleCodeMotion
A
Compiler pass for moving code to a deeper module if possible. |
(package private) class |
CrossModuleMethodMotion
Move prototype methods into later modules.
|
class |
DartSuperAccessorsPass
Converts
super getter and setter calls in order to support the output
of the Dart Dev Compiler (https://github.com/dart-lang/dev_compiler). |
(package private) class |
DeadAssignmentsElimination
Removes local variable assignments that are useless based on information from
LiveVariablesAnalysis . |
(package private) class |
DeclaredGlobalExternsOnWindow
A compiler pass to normalize externs by declaring global names on
the "window" object, if it is declared in externs.
|
(package private) class |
DefaultPassConfig.ClearTypedScope
A compiler pass that clears the global scope.
|
(package private) class |
DefaultPassConfig.GlobalTypeResolver
A compiler pass that resolves types in the global scope.
|
(package private) class |
Denormalize
The goal with this pass is to reverse the simplifications done in the
normalization pass that are not handled by other passes (such as
CollapseVariableDeclarations) to avoid making the resulting code larger.
|
(package private) class |
DevirtualizePrototypeMethods
Rewrites prototyped methods calls as static calls that take "this"
as their first argument.
|
(package private) class |
DisambiguatePrivateProperties
Disambiguate properties by file, when they are private by naming convention.
|
(package private) class |
DisambiguateProperties
DisambiguateProperties renames properties to disambiguate between unrelated
fields with the same name.
|
(package private) class |
ErrorPass
A compiler pass that just reports an error.
|
class |
Es6ConvertSuper
Converts
super nodes. |
(package private) class |
Es6ExternsCheck
Checks to make sure the required ES6 externs are present.
|
class |
Es6RenameVariablesInParamLists
Renames declarations and references in function bodies to avoid shadowing
names referenced in the parameter list, in default values or computed properties.
|
class |
Es6RewriteArrowFunction
Converts ES6 arrow functions to standard anonymous ES3 functions.
|
class |
Es6RewriteBlockScopedDeclaration
Rewrite "let"s and "const"s as "var"s.
|
class |
Es6RewriteDestructuring
Rewrites ES6 destructuring patterns and default parameters to valid ES3 code.
|
class |
Es6RewriteGenerators
Converts ES6 generator functions to valid ES3 code.
|
class |
Es6SplitVariableDeclarations
Splits variable declarations that declare multiple variables into
separate declarations, if at least one of the declarations is a
destructuring declaration.
|
class |
Es6ToEs3ClassSideInheritance
Rewrites static inheritance to explicitly copy inherited properties from superclass to
subclass so that the typechecker knows the subclass has those properties.
|
class |
Es6ToEs3Converter
Converts ES6 code to valid ES5 code.
|
class |
Es6TypedToEs6Converter
Converts
Node.getDeclaredTypeExpression() to JSDocInfo.getType() type
annotations. |
(package private) class |
ExpandJqueryAliases
Replace known jQuery aliases and methods with standard
conventions so that the compiler recognizes them.
|
class |
ExportTestFunctions
Generates goog.exportSymbol for test functions, so they can be recognized
by the test runner, even if the code is compiled.
|
(package private) class |
ExternExportsPass
Creates an externs file containing all exported symbols and properties
for later consumption.
|
(package private) class |
ExtractPrototypeMemberDeclarations
When there are multiple prototype member declarations to the same class,
use a temp variable to alias the prototype object.
|
class |
FieldCleanupPass
A CleanupPass implementation that will remove all field declarations on
JSTypes contributed by the original file.
|
(package private) class |
FlowSensitiveInlineVariables
Inline variables when possible.
|
(package private) class |
FunctionNames
Extract a list of all function nodes defined in a JavaScript
program, assigns them globally unique ids and computes their fully
qualified names.
|
(package private) class |
FunctionRewriter
Reduces the size of common function expressions.
|
(package private) class |
GatherExternProperties
Gathers property names defined in externs.
|
(package private) class |
GatherRawExports
External references of the form: "window['xx']" indicate names that must
be reserved when variable renaming to avoid conflicts.
|
(package private) class |
GenerateExports
Generates goog.exportSymbol/goog.exportProperty for the @export annotation.
|
(package private) class |
GlobalTypeInfo
Contains information about all scopes; for every variable reference computes
whether it is local, a formal parameter, etc.; and computes information about
the class hierarchy.
|
(package private) static class |
GlobalVarReferenceMap.GlobalVarRefCleanupPass
A CleanupPass implementation that will replace references to old Syntactic
Global Scopes generated in previous compile runs with references to the
Global Typed Scope.
|
class |
ImplicitNullabilityCheck
Warn about types in JSDoc that are implicitly nullable.
|
(package private) class |
InferConsts
Attaches the CONST_VAR annotation to any variable that's
1) Provably well-defined and assigned once in its lifetime.
|
(package private) class |
InferJSDocInfo
Set the JSDocInfo on all types.
|
(package private) class |
InjectEs6RuntimeLibrary
Adds runtime libraries to the beginning of the AST.
|
(package private) class |
InlineAliases
Inline aliases created by exports of modules before type checking.
|
(package private) class |
InlineFunctions
Inlines functions that are divided into two types: "direct call node
replacement" (aka "direct") and as a block of statements (aka block).
|
(package private) class |
InlineObjectLiterals
Using the infrastructure provided by
ReferenceCollectingCallback ,
identify variables that are only ever assigned to object literals
and that are never used in entirety, and expand the objects into
individual variables. |
(package private) class |
InlineProperties
InlineProperties attempts to find references to properties that are known to
be constants and inline the known value.
|
(package private) class |
InlineSimpleMethods
Inlines methods that take no arguments and have only a return statement
returning a property.
|
(package private) class |
InlineVariables
Using the infrastructure provided by VariableReferencePass, identify
variables that are used only once and in a way that is safe to move, and then
inline them.
|
(package private) class |
InstrumentFunctions
Instruments functions for when functions first get called and defined.
|
class |
J2clPass
Rewrites/inlines some J2CL constructs to be more optimizable.
|
class |
J2clPropertyInlinerPass
This pass targets j2cl output.
|
class |
JsdocToEs6TypedConverter
Converts JS with types in jsdocs to an extended JS syntax that includes types.
|
private class |
JsMessageExtractor.ExtractMessagesVisitor
Visitor that collects messages.
|
class |
JsMessageVisitor
Traverses across parsed tree and finds I18N messages.
|
(package private) class |
LineNumberCheck
A simple pass to ensure that all AST nodes have line numbers,
an that the line numbers are monotonically increasing.
|
(package private) static class |
MakeDeclaredNamesUnique.ContextualRenameInverter
Inverts the transformation by
MakeDeclaredNamesUnique.ContextualRenamer , when possible. |
(package private) class |
MarkNoSideEffectCalls
Set the NoSideEffects property for function and constructor calls
that refer to functions that are known to have no side effects.
|
(package private) class |
MethodCompilerPass
Finds all method declarations and pulls them into data structures
for use during cleanups such as arity checks or inlining.
|
(package private) class |
MinimizeExitPoints
Transform the structure of the AST so that the number of explicit exits
are minimized and instead flows to implicit exits conditions.
|
(package private) class |
MoveFunctionDeclarations
Moves top-level function declarations to the top.
|
(package private) class |
NameAnalyzer
This pass identifies all global names, simple (e.g.
|
(package private) class |
NameAnonymousFunctions
Gives anonymous function names.
|
(package private) class |
NameAnonymousFunctionsMapped
Gives anonymous function names that are optimized to be small and provides a
mapping back to the original names.
|
(package private) class |
NameReferenceGraphConstruction
Constructs a name reference graph.
|
(package private) class |
NewTypeInference
New type inference algorithm.
|
(package private) class |
Normalize
The goal with this pass is to simplify the other passes,
by making less complex statements.
|
(package private) static class |
Normalize.PropagateConstantAnnotationsOverVars
Propagate constant annotations over the Var graph.
|
(package private) static class |
Normalize.VerifyConstants
Walk the AST tree and verify that constant names are used consistently.
|
(package private) class |
ObjectLitAssignmentShortening
Shorten a object literal by using following features in ES6 upward:
1.
|
(package private) class |
ObjectPropertyStringPostprocess
Rewrites
new JSCompiler_ObjectPropertyString(window, foo.prototype.bar)
to new JSCompiler_ObjectPropertyString(foo.prototype, 'bar')
Rewrites
new JSCompiler_ObjectPropertyString(window, foo[bar])
to new JSCompiler_ObjectPropertyString(foo, bar)
Rewrites
new JSCompiler_ObjectPropertyString(window, foo$bar$baz) to
new JSCompiler_ObjectPropertyString(window, 'foo$bar$baz') |
class |
ObjectPropertyStringPreprocess
Rewrites
new goog.testing.ObjectPropertyString(foo, 'bar') to
new JSCompiler_ObjectPropertyString(window, foo.bar) . |
(package private) class |
OptimizeArgumentsArray
Optimization for functions that have
var_args or access the
arguments array. |
(package private) class |
OptimizeCalls
A root pass that container for other passes that should run on
with a single call graph (currently a SimpleDefinitionFinder).
|
(package private) class |
OptimizeParameters
Optimize function calls and function signatures.
|
(package private) class |
OptimizeReturns
A compiler pass for optimize function return results.
|
(package private) class |
PeepholeOptimizationsPass
A compiler pass to run various peephole optimizations (e.g.
|
(package private) class |
PhaseOptimizer
An object that optimizes the order of compiler passes.
|
(package private) class |
PhaseOptimizer.Loop
A compound pass that contains atomic passes and runs them until they reach
a fixed point.
|
(package private) class |
PhaseOptimizer.NamedPass
A single compiler pass.
|
(package private) class |
PolymerPass
Rewrites "Polymer({})" calls into a form that is suitable for type checking and dead code
elimination.
|
(package private) class |
PrepareAst
Prepare the AST before we do any checks or optimizations on it.
|
(package private) class |
ProcessClosurePrimitives
Replaces goog.provide calls, removes goog.require calls, verifies that
goog.require has a corresponding goog.provide and some closure specific
simplifications.
|
class |
ProcessCommonJSModules
Rewrites a CommonJS module http://wiki.commonjs.org/wiki/Modules/1.1.1
into a form that can be safely concatenated.
|
(package private) class |
ProcessDefines
Process variables annotated as
@define . |
(package private) class |
ProcessTweaks
Process goog.tweak primitives.
|
(package private) class |
PureFunctionIdentifier
Compiler pass that computes function purity.
|
(package private) static class |
PureFunctionIdentifier.Driver
A compiler pass that constructs a reference graph and drives
the PureFunctionIdentifier across it.
|
(package private) class |
RecordFunctionInformation
Records information about functions and modules.
|
(package private) class |
ReferenceCollectingCallback
A helper class for passes that want to access all information about where a
variable is referenced and declared at once and then make a decision as to
how it should be handled, possibly inlining, reordering, or generating
warnings.
|
(package private) class |
RemoveUnusedClassProperties
This pass looks for properties that are never read and removes them.
|
(package private) class |
RemoveUnusedPrototypeProperties
Removes unused properties from prototypes.
|
(package private) class |
RemoveUnusedVars
Garbage collection for variable and function definitions.
|
(package private) class |
RenameLabels
RenameLabels renames all the labels so that they have short names, to reduce
code size and also to obfuscate the code.
|
(package private) class |
RenameProperties
RenameProperties renames properties (including methods) of all JavaScript
objects.
|
(package private) class |
RenameVars
RenameVars renames all the variables names into short names, to reduce code
size and also to obfuscate the code.
|
(package private) class |
ReplaceCssNames
ReplaceCssNames replaces occurrences of goog.getCssName('foo') with
a shorter version from the passed in renaming map.
|
(package private) class |
ReplaceIdGenerators
Replaces calls to id generators with ids.
|
(package private) class |
ReplaceMessages
ReplaceMessages replaces user-visible messages with alternatives.
|
(package private) class |
ReplaceMessagesForChrome
Replaces user-visible messages with appropriate calls to
chrome.i18n.getMessage.
|
(package private) class |
ReplaceStrings
Replaces JavaScript strings in the list of supplied methods with shortened
forms.
|
(package private) class |
RescopeGlobalSymbols
Finds all references to global symbols and rewrites them to be property
accesses to a special object with the same name as the global symbol.
|
(package private) class |
RewriteBindThis
Rewrite .bind(this) calls on an anonymous functions to arrow functions
(which have implicit this binding).
|
class |
RewritePolyfills
Rewrites calls to ES6 library functions to use compiler-provided polyfills,
e.g.,
var m = new Map(); becomes
$jscomp.Map$install(); var m = new $jscomp.Map(); |
(package private) class |
RuntimeTypeCheck
Inserts run-time type assertions.
|
(package private) class |
SanityCheck
A compiler pass that verifies the structure of the AST conforms
to a number of invariants.
|
(package private) class |
ScopedAliases
Process aliases in goog.scope blocks.
|
(package private) class |
ShadowVariables
Tries to compute a list of variables that can shadow a variable in the
outer scope.
|
(package private) class |
SideEffectsAnalysis
A pass that analyzes side effects to determine when it is safe to move
code from one program point to another.
|
(package private) class |
SimpleDefinitionFinder
Simple name-based definition gatherer that implements
DefinitionProvider . |
(package private) class |
StrictModeCheck
Checks that the code obeys the static restrictions of strict mode:
No use of "with".
|
(package private) class |
StripCode
A pass for stripping a list of provided JavaScript object types.
|
(package private) class |
SubstituteEs6Syntax
An optimization that does peephole optimizations of ES6 code.
|
private class |
SymbolTable.PropertyRefCollector |
private class |
SymbolTable.ThisRefCollector |
class |
TransformAMDToCJSModule
Rewrites an AMD module https://github.com/amdjs/amdjs-api/wiki/AMD to a
CommonJS module.
|
class |
TypeCheck
Checks the types of JS expressions against any declared type
information.
|
private static class |
TypedScopeCreator.FirstOrderFunctionAnalyzer
Does a first-order function analysis that just looks at simple things
like what variables are escaped, and whether 'this' is used.
|
(package private) class |
TypeInferencePass
A compiler pass to run the type inference analysis.
|
(package private) class |
UnreachableCodeElimination
Removes dead code from a parse tree.
|
(package private) class |
VarCheck
Checks that all variables are declared, that file-private variables are
accessed only in the file that declares them, and that any var references
that cross module boundaries respect declared module dependencies.
|
(package private) class |
VariableReferenceCheck
Checks variables to see if they are referenced before their declaration, or
if they are redeclared in a way that is suspicious (i.e.
|
(package private) class |
VariableVisibilityAnalysis
An analysis pass that determines the visibility of variables -- that is,
whether a variable is truly local, a local captured by an inner scope, a
parameter, or a global variable.
|
Modifier and Type | Field and Description |
---|---|
protected com.google.common.collect.Multimap<CustomPassExecutionTime,CompilerPass> |
CompilerOptions.customPasses
Custom passes
|
private java.util.List<CompilerPass> |
PhaseOptimizer.passes |
Modifier and Type | Method and Description |
---|---|
protected abstract CompilerPass |
PassFactory.create(AbstractCompiler compiler)
Creates a new compiler pass to be run.
|
(package private) static CompilerPass |
MakeDeclaredNamesUnique.getContextualRenameInverter(AbstractCompiler compiler) |
private static CompilerPass |
DefaultPassConfig.runInSerial(java.util.Collection<CompilerPass> passes)
Create a compiler pass that runs the given passes in serial.
|
Modifier and Type | Method and Description |
---|---|
void |
CompilerOptions.addCustomPass(CustomPassExecutionTime time,
CompilerPass customPass) |
(package private) abstract void |
AbstractCompiler.process(CompilerPass pass)
Runs a given compiler-pass by calling its
process() method. |
(package private) void |
Compiler.process(CompilerPass p) |
Modifier and Type | Method and Description |
---|---|
private static CompilerPass |
DefaultPassConfig.runInSerial(java.util.Collection<CompilerPass> passes)
Create a compiler pass that runs the given passes in serial.
|
Modifier and Type | Class and Description |
---|---|
class |
CheckDuplicateCase
Check for duplicate case labels in a switch statement
Eg:
switch (foo) {
case 1:
case 1:
}
This is normally an indication of a programmer error.
|
class |
CheckEmptyStatements
Check for empty statements (i.e.
|
class |
CheckEnums
Check for duplicate values in enums.
|
class |
CheckForInOverArray
Checks when the pattern for (x in arr) { ...
|
class |
CheckInterfaces
Checks for errors related to interfaces.
|
class |
CheckJSDocStyle
Checks for various JSDoc-related style issues, such as function definitions without JsDoc, params
with no corresponding
@param annotation, coding conventions not being respected, etc. |
class |
CheckNullableReturn
Checks when a function is annotated as returning {SomeType} (nullable)
but actually always returns {!SomeType}, i.e.
|
class |
CheckPrototypeProperties
Checks when a mutable property is assigned to a prototype.
|
class |
CheckRequiresAndProvidesSorted
Checks that goog.require() and goog.provide() calls are sorted alphabetically.
|
class |
CheckUselessBlocks
Check for useless blocks.
|