Package com.google.javascript.jscomp
package com.google.javascript.jscomp
-
ClassDescriptionImplementations of AbstractCommandLineRunner translate flags into Java API calls on the Compiler.Configurations for the command line configs.Set of options that can be used with the --formatting flag.A pair from flag to its value.Represents a specification for a serving chunk.Representation of a source file from an encoded json stream inputFlag types for JavaScript source files.An abstract compiler, to help remove the circular dependency of passes on JSCompiler.What point in optimizations we're in.Abstract message formatter providing default behavior for implementations of
MessageFormatter
needing aSourceExcerptProvider
.Scope contains information about a variable scope in JavaScript.Used byScope
to store information about variables.Helper functions for computing the visibility of names and properties in JavaScript source code.An extension ofWarningsGuard
that provides functionality to maintain a list of warnings (allowlist).Logic for answering questions about portions of the AST.Utilities to abstract away certain common AST manipulationsThis class walks the AST and validates that the structure is correct.Violation handlerDeprecated.An ErrorManager that silently swallows all messages.An implementation of aWarningsGuard
that can modify theCheckLevel
based on the file that caused the warning, and whether this file matches a set of paths (specified either as include or exclude of path name parts).A Class to assist in AST change tracking verification.Provides a framework for checking code against a set of user configured conformance rules.A condition that must be true for a rule to possibly match a node.A PassConfig to only run the CheckExtraRequires linter rule.Controls checking levels of certain options.A pass to detect references to fully qualified Closure namespaces.Checks for invalid code references to type-only imports (i.e., goog.requireType).Coding convention used by the Chrome team to compile Chrome's JS.Compiler pass for Chrome-specific needs.Checks that goog.module() is used correctly.This describes the Closure-specific JavaScript coding conventions.Common errors for Closure primitives that are reported in multiple passses.A warnings guard that suppresses warnings that are spurious for code that is unaware of Closure compiler's requirements.Abstracted consumer of the CodeGenerator output.CodeGenerator generates codes from a parse tree, sending it to the specified CodeConsumer.Information on the current context.CodePrinter prints out JS code in either pretty format or compact format.Specifies a format for code generation.License Trackers are responsible for ensuring that any licensing information attached to nodes is retained in the final output of JSCompiler.SourceAndMappings bundles together the source and generated SourceMap Mappings for that source.CodingConvention defines a set of hooks to customize the behavior of the Compiler for a specific team/company.This stores a relation from either name or Closure Primitive to assertion functionA description of a JavaScript function that will throw an exception when either: One of its parameters does not match the return type of the function One of its parameters is falsy.Bind classCache classDelegates provides a mechanism and structure for identifying where classes can call out to optional code to augment their functionality.An object literal cast provides a mechanism to cast object literals to other types without a warning.Record subclass relationsSpecify the kind of inheritanceHelper classes for dealing with coding conventions.A convention that wraps another.CommandLineRunner translates flags into Java API calls on the Compiler.Set of options that can be used with the --formatting flag.A CompilationLevel represents the level of optimization that should be applied when compiling JavaScript code.Interface used by `AbstractCompilerRunner` to report metrics about the compilation action it performs.Compiler (and the other classes in this package) does the following: parses JS code checks for undefined variables performs optimizations such as constant folding and constants inlining renames variables (to short names) outputs compact JavaScript code External variables are declared in 'externs' files.An implementation of a license tracker to be used when licenses can be de-duped among Chunks (because licenses might be loaded by a chunk's transitive dependencies.Stores a buffer of text to which more can be appended.Serializable state of the compiler specific to multistage binary buildsSubclasses are responsible for loading sources that were not provided as explicit inputs to the compiler.A license tracker implementation that emits all licenses attached to script nodes, regardless of if the content of that script is used anywhere in the compilation.A license tracker implementation that only retains licenses for which there are useful nodes in a binary.A class for the internal representation of an input to the compiler.JavaScript module type.A provider mapping a InputId to a CompilerInput.Compiler optionsA mode enum used to indicate the alias strings policy for the AliasStrings passA Role Specific Interface for the JS Compiler to report aliases used to change the code during a compile.A Role Specific Interface for JS Compiler that represents a data holder object which is used to store goog.scope alias code changes to code made during a compile.Format for compiler output when multiple chunks are requested.When to do the extra validity checksAn environment specifies the built-in externs that are loaded for a given compilation.How ES modules should be transformed.Options to force transpile specific features for performance experiments.An option to determine what level of code instrumentation is performed, if anyWhat kind of isolation is going to be usedA mode enum used to indicate whether J2clPass should be enabled, disabled, or enabled automatically if there is any J2cl source file (i.e.A language mode applies to the whole compilation job.What type of JS file should be output by this compilationA common enum for compiler passes that can run either globally or locally.How much tracing we want to doOption for the ProcessTweaks passChecks for combinations of options that are incompatible, i.e.Exception to indicate incompatible options in the CompilerOptions.Interface for classes that can compile JS.WarningsGuard that represents just a chain of other guards.Rewrites static inheritance to explicitly copy inherited properties from superclass to subclass so that the optimizer knows the subclass has those properties.Creates or updates conformance allowlist/whitelist entries.Runs only the user-supplied conformance checks and any earlier passes required by conformance.Standard conformance rules.A conformance rule implementation to support things common to all rules such as allowlisting and reporting.Bangoog.dom.createDom
andgoog.dom.DomHelper#createDom
with parameters specified invalue
in the format tagname.attribute, e.g.Bansdocument.createElement
and similar methods with string literal parameter specified invalue
, e.g.BanElement#setAttribute
with attribute names specified invalue
or any dynamic string.BanDocument#execCommand
with command names specified invalue
or any dynamic string.Banned for/of loopsBanned global var declarations.Checks that file does not include an @enhance annotation for a banned namespace.Checks that file does not include an @mods annotation for a banned namespace regex.Banned non-literal arguments passed togoog.string.Const.from
.Banned dereferencing null or undefined types.Can be used to ban any function likeElement#setAttribute
which takes two parameters, an attribute name and a value.Checks thatthis
is not being referenced directly within a static member function.Banned throw of non-error object types.Banned unknown type references of the form "this.prop" unless it is immediately cast, it is a @template type (until template type restricts are enabled) or the value is unused.Banned unknown "this" types.Banned unknown type references of the form "instance.prop" unless (a) it is immediately cast/asserted, or (b) it is a @template type (until template type restrictions are enabled), or (c) the value is unused, or (d) the source object type is unknown (to avoid error cascades)Banned accessing properties from objects that are unresolved forward-declared type names.Possible check check resultsClasses extending AbstractRule must return ConformanceResult from their checkConformance implementation.Require "use strict" ruleChecks nodes for conformance with banning the setting of attributes that are on the blocklist.Ban any use of unresolved forward-declared typesThis class computes aControlFlowGraph
for a given ASTConfigures aControlFlowAnalysis
instance then computes theControlFlowGraph
Control flow graph.Abstract callback to visit a control flow graph node without going into subtrees of the node that are also represented by other control flow graph nodes.The edge object for the control flow graph.Move prototype methods into later chunks.Collects global variable references for use byCrossChunkCodeMotion
.Interface used byReplaceCssNames
to substitute CSS class names.ByPart renaming mapByWhole renaming mapKind of renaming mapCustom pass type.An optimization pass that finds and removes dead property assignments within functions and classes.Contains information on default externs files.A simple class for generating unique JavaScript variable/property names.Pass factories and meta-data for native JSCompiler passes.Options for how to manage dependencies between input files.Describes how the compiler should manage dependencies.Represents a single target inside a destructuring pattern, whether another pattern or a lhs expression.Group a set of related diagnostic types together, so that they can be toggled on and off as one unit.A warnings guard that suppresses warnings for a particular diagnostic group for a file that contains the specified substring.Named groups of DiagnosticTypes exposed by Compiler.Sets the level for a particular DiagnosticGroup.Used to print a map from diagnostic id to suppression.The type of a compile or analysis error.DotFormatter prints out a dot file of the Abstract Syntax Tree.A do-nothing metrics recorder that `AbstractCompilerRunner` uses by default.An implementation of MessageBundle that has no translations.Error formats available.The error handler is any generic sink for warnings and errors, after they've passed through any filteringWarningsGuard
s.The error manager is in charge of storing, organizing and displaying errors and warnings generated by the compiler.Checks that ES6 Modules are used correctly, and do not reference undefined keywords or features.Convertssuper.method()
calls and adds constructors to any classes that lack them.Convertssuper()
calls.Extracts ES6 classes defined in function calls to local constants.Converts ES6 "for of" loops to ES5.Normalizes shorthand object properties.Rewrites ES6 import paths to be relative after resolving according to the compiler's module resolver.Renames variables declared in function bodies so they don't shadow any variable referenced in the param list.Converts ES6 arrow functions to standard anonymous ES3 functions.Rewrite "let"s and "const"s as "var"s.Rewrite block-scoped function declarations as "let"s.Converts ES6 classes to valid ES5 or ES3 code.Extracts ES6 class extends expressions and creates an alias.Rewrites destructuring patterns and default parameters to valid ES3 code or to a different form of destructuring.Rewrites a ES6 module into a form that can be safely concatenated.Rewrites an ES6 module to a CommonJS-like module for the sake of per-file transpilation + bunlding (e.g.Converts REST parameters and SPREAD expressions.Rewrites a script which was imported as a module into an ES6 module.Splits variable declarations that declare multiple variables into separate declarations, if at least one of the declarations is a destructuring declaration.Replaces the ES7 `**` and `**=` operators to calls to `Math.pow`.Generates goog.exportSymbol for test functions, so they can be recognized by the test runner, even if the code is compiled.Walks the AST looking for usages of qualified names, and 'goog.require's of those names.Find and update any direct dependencies of an input.An exception thrown when command-line flags are used incorrectly.Warns at any usage of Dynamic Import expressions that they are unable to be transpiled.Finds getter and setter properties in the AST.Gathers metadata around modules that is useful for checking imports / requires and creates aModuleMetadataMap
.Generates goog.exportSymbol/goog.exportProperty for the @export annotation.This describes the Google-specific JavaScript coding conventions.AnJsMessage.IdGenerator
designed to play nicely with Google's Translation systems.Contains aJsMessage
representing an ICU template message and information about thegoog.i18n.messages.declareIcuTemplate()
call from which it was extracted.Id generator used in CrossModuleMotion.A utility class for generating and parsing id mappings held byReplaceIdGenerators
.Warn about types in JSDoc that are implicitly nullable.Represents the types of implicit nullability errors caught by this pass: a) implicitly nonnull (missing a "!"), and b) implicitly nullable (missing a "?").Information to represent a single "implicit nullability result", including the JSDoc string node that needs a "!" or "?" to be explicit, as well as an enum indicating which of the two nullability cases were found ("!" or "?").Injects JS library code that may be needed by the transpiled form of the input source code.Instrumentsawait
andyield
for theAsyncContext
polyfill.Keeps track of "invalidating types" that force type-based optimizations to back off.BuilderAn optimization pass to remove J2CL Asserts.$assert.Performs correctness checks which are specific to J2CL-generated patterns.An optimization pass to prune J2CL clinits.An optimization pass for J2CL-generated code to hoist some constant assignments out clinit method to declaration phase so they could be used by other optimization passes for static evaluation.An optimization pass to re-write J2CL Equality.$same.A normalization pass to inline some J2CL calls to enable other optimizations.This pass targets J2CL output.A warnings guard that suppresses some warnings incompatible with J2CL.A normalization pass to re-write Util.$getDefine calls to make them work in compiled mode.A JavaScript chunk has a unique name, consists of a list of compiler inputs, and can depend on other chunks.AJSChunk
dependency graph that assigns a depth to each chunk and can answer depth-related queries about them.Exception class for declaring when the chunks being fed into a JSChunkGraph as input aren't in dependence order, and so can't be processed for caching of various dependency-related queries.Another exception classPrints a JSDocInfo, used for preserving type annotations in ES6 transpilation.Compile error description.A representation of a translatable message in JavaScript source code.Contains functionality for creating JS messages.ID generatorRepresents part of a message.Thrown when parsing a message string into parts fails because of a misformatted place holder.A reference to a placeholder in a translatable message.Represents a literal string part of a message.Container class that holds aJsMessage
and information about thegoog.getMsg()
call it was built from.Extracts messages and message comments from JS code.Locates JS code that is intended to declare localizable messages.Represents the contents of a object literal Node in the AST.An error report generator that prints error and warning data to the print stream as an array of JSON objects.Converts ES6 code to valid ES5 code.A DependencyInfo class that determines load flags by parsing the AST just-in-time.Lightweight message formatter.Tool for running just the lint checks which can be run on a single file at a time.Builder for a Linter that allows some customization.Minimal binary that just runs the "lint" checks which can be run on a single file at a time.An error manager that logs errors and warnings using a logger in addition to collecting them in memory.Prints out a map from diagnostic id to suppression.An interface for providing alternative values for user-visible messages in JavaScript code.Format warnings and errors.Basic information on an entry point module.A class that generates unique JavaScript variable/property names.NodeTraversal allows an iteration through the nodes in the parse tree, and facilitates the optimizations on the parse tree.An traversal base class that tracks and caches the ControlFlowGraph (CFG) during the traversal.Callback that fires on changed scopes.Abstract callback that knows when a global script, goog.provide file, goog.module, goog.loadModule, ES module or CommonJS module is entered or exited.Abstract callback to visit all nodes in postorder.Abstract callback to visit all nodes in postorder.Abstract callback to visit all nodes in preorder.Abstract scoped callback to visit all nodes in postorder.Abstract callback to visit all nodes but not traverse into function bodies.Abstract callback to visit all structure and statement nodes but doesn't traverse into functions or expressions.BuilderCallback for tree-based traversalsAbstract callback to visit all non-extern nodes in postorder.Callback that also knows about scope changesNodeUtil contains generally useful AST utilities.Represents a goog.require'd namespace and property inside a module.Interface for use with the visit method.Pass factories and meta-data for native Compiler passes.Different ways to split optimization passes.An implementation of PassConfig that just proxies all its method calls into an inner class.A factory for creating JSCompiler passes based on the Options injected.A builder for aPassFactory
.This class exists to funnel the list of passes through a central mechanism to ensure that the PassFactory can define and enforce conditions that much be met in order for the pass they create to be added to the compilation process.If the name of a pass is used in more than one place in the source, it's good to create a symbolic name here.A PerformanceTracker collects statistics about the runtime of each pass, and how much a pass impacts the size of the compiled output, before and after gzip.A Stats object contains statistics about a pass run, such as running time, size changes, etcDeprecated., Please use the {#SortingErrorManger} with a {#PrintStreamErrorReportGenerator} instead.An error report generator that prints errors and warnings to the print stream provided.Rewrites a CommonJS module http://wiki.commonjs.org/wiki/Modules/1.1.1 into a form that can be safely concatenated.Policies to determine how properties should be renamed.A class for generating unique, randomized JavaScript variable/property names.Represents a single declaration or reference to a variable.A collection of references.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.Way for callers to add specific behavior during traversal that utilizes the built-up reference information.MapsVar
s to their references.Source code region.Normalizes all CAST nodes out of the AST.Interface used by to substitute names.A decoder for strings encoded by the ReplaceStrings JS compiler pass.ReplaceMessages replaces user-visible messages with alternatives.Holds information about the protected form of a translatable message that appears in the AST.Constants that need to be shared between `ReplaceMessages` and other passes.Looks for presence of features that are not supported for transpilation (mostly new RegExp features and bigint literal).Compilation resultsConverts async functions to valid ES6 generator functions code.Converts async generator functions into a function returning a new $jscomp.AsyncGenWrapper around the original block and awaits/yields converted to yields of ActionRecords.Replaces the ES2022 class fields and class static blocks with constructor declaration.Rewrite dynamic import expressions to account for bundling and module rewriting.Looks for references to Closure's goog.js file and globalizes.Possible traversal modes - either linting or linting+rewriting.Rewrites a JSON file to be a module export.Replaces the ES2020 `||=`, `invalid input: '&'invalid input: '&'=`, and `??=` operators.Replaces the ES2020 `??` operator with conditional (?:).Converts object spread to valid ES2017 code.Injects polyfill libraries to ensure that ES6+ library functions are available.Scope contains information about a variable scope in JavaScript.Control whether warnings should be restricted or suppressed for specified paths.Controls whether warnings should be restricted to a specified path or suppressed within the specified path.Simple region.A customizable error manager that sorts all errors and warnings reported to it, and has customizable output through theSortingErrorManager.ErrorReportGenerator
interface.Strategy for customizing the output format of the error reportA source excerpt provider is responsible for building source code excerpt of specific locations, such as a specific line or a region around a given line number.A excerpt formatter is responsible of formatting source excerpts.Source excerpt variety.An abstract representation of a source file that provides access to language-neutral features.A builder interface for source files.A SourceFileMapping maps a source file, line, and column into anMapping.OriginalMapping
.Annotates nodes with information from their original input file before the compiler performs work that changes this information (such as its original location, its original name, etc).Collects information mapping the generated (compiled) source back to its original source for debugging purposes.Source maps can be very large different levels of detail can be specified.An enumeration of available source map formatsFunction that mape a "destination" location to use within the source map.Maintains a mapping from a given node to the position in the source code at which its generated form was placed.SimpleSourceMap.LocationMapping
that strips a prefix from a location.A lazy-loaded SourceMapConsumerV3 instance.Utility class for resolving source maps and files referenced in source maps.All warnings should be reported as errors.A symbol table for people that want to use Closure Compiler as an indexer.ReferenceA symbol-table entryScope of a symbolThe syntactic scope creator scans the parse tree to create a Scope object containing all the variable declarations in that scope.A matcher that can take an arbitrary AST and use it as a template to find matches in another.A simple delegatingErrorManager
that provides a thread-safe wrapper for the one being delegated.Provides a single place to manage transpilation passes.Util functions for transpilation passesChecks the types of JS expressions against any declared type information.TypedScope contains information about variables and their types.AbstractVar
subclass for use withTypedScope
.The different strategies for matching theJSType
of nodes.The result of comparing two differentJSType
instances.Signals that the first type and the second type have been used interchangeably.Generates unique String Ids when requested via a compiler instance.Used byScope
to store information about variables.Stores the mapping from original variable name to new variable names.Policies to determine which variables should be renamed.Convert the warnings level to an Options object.Class that allows to flexibly manage what to do with a reported warning/error.PriorityReplicates the effect of ClosureBundler in whitespace-only mode and wraps goog.modules in goog.loadModule calls.A simple utility for shortening identifiers in a stable way.Strategy for selecting the underlying hash code function to be used by Xid.A MessageBundle that parses messages from an XML Translation Bundle (XTB) file.