Package com.google.javascript.jscomp
Class CompilerOptions
java.lang.Object
com.google.javascript.jscomp.CompilerOptions
- All Implemented Interfaces:
Serializable,Cloneable
Compiler options
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA Role Specific Interface for the JS Compiler to report aliases used to change the code during a compile.static interfaceA 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.static enumWhen to do the extra sanity checksstatic enumstatic enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionIf set to a non-empty set, those strings literals will be aliased to a single global instance per string, to avoid creating more objects than necessary.booleanAliases all string literals to global instances, to avoid creating more objects than necessary (if true, overrides any set of strings passed in to aliasableStrings)booleanAdds variable aliases for externals to reduce code sizebooleanAliases true, false, and null to variables with shorter names.A blacklist in the form of a regular expression to block strings that contains certain words from being aliased.booleanRename unrelated properties to the same name to reduce code size.Give anonymous functions names for easier debuggingbooleanChecks for invalid control structuresRegex of string literals that may only appear in goog.getCssName arguments.Checks for missing goog.require() callsbooleanChecks for suspicious statements that have no effectbooleanChecks that all symbols are definedbooleanChecks types on expressionsbooleanProcesses goog.provide() and goog.require() callsbooleanMerge two variables together as one.booleanCollapses anonymous function declarations into named function declarationsbooleanFlattens multi-level property names (e.g.booleanCollapses multiple variable declarations into onebooleanUse @nosideeffects annotations, function bodies and name graph to determine if calls have side effects.booleanConverts quoted property accesses to dot syntax (a['b'] -> a.b)booleanMove code to a deeper modulebooleanMove methods to a deeper moduleMap used in the renaming of CSS class names.com.google.common.collect.Multimap<CustomPassExecutionTime,CompilerPass> Custom passesbooleanRemove assignments to values that can not be referencedbooleanDevirtualize prototype method by rewriting them to be static calls that take the this pointer as their first argumentbooleanRename properties to disambiguate between unrelated fields based on type information.booleanWhether to export test functions.booleanExtracts common prototype member declarationsbooleanbooleanFolds constants (e.g.booleanGather CSS names (requires closurePass)booleanbooleanGenerate pseudo names for variables and properties for debugging purposes.booleanConfigures the compiler for use as an IDE backend.booleanInlines constants (symbols that are all CAPS)booleanInlines global functionsbooleanInlines trivial gettersbooleanInlines functions defined in local scopesbooleanInlines variablesThe string to use as the separator for printInputDelimiterInstrumentation template to use with #recordFunctionInformationbooleanProcesses jQuery aliasesbooleanControls label renaming.booleanLine break the output a bit more aggressivelyCompiling localebooleanSets the special "COMPILED" value to truebooleanMark no side effect callsReturns localized replacement for MSG_* variablesbooleanMove top-level function declarations to the topbooleanProvide formal names for elements of arguments array.booleanRemove unused parameters from call sites.booleanRemove unused and constant parameters.booleanRemove unused return values.booleanPrefer line breaks at end of filebooleanOutput in pretty indented formatbooleanPrints a separator comment before each JS scriptControls which properties get renamed.booleanRecord function informationbooleanRemoves code that will never executebooleanRemoves try...catch...finally blocks for easier debuggingbooleanRemoves unused member propertiesbooleanRemoves unused variables in local scope.booleanRemoves unused member prototypesbooleanTells AnalyzePrototypeProperties it can remove externed props.booleanRemoves unused variablesSpecifies a prefix for all globalsSpecifies the name of an object that will be used to store all non-extern globals.booleanReserve property names on the global this object.booleanReduces the size of common function expressions.booleanRemoves code associated with unused global namesThe detail level for the generated source map.The source map file formatThe output path for the source map.Name prefixes that determine which variables and properties to stripName suffixes that determine which variables and properties to stripQualified type name prefixes that determine which types to stripNames of types to stripControls which variables get renamed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWarningsGuard(WarningsGuard guard) Add a guard to the set of warnings guards.booleanbooleanclone()voidvoidenableExternExports(boolean enabled) Deprecated.voidenableRuntimeTypeCheck(String logFunction) Enable run-time type checking, which adds JS type assertions for debugging.booleanReturns the map of define replacements.booleanGets the inferTypes flag.Returns the map of tweak replacements.booleanbooleanvoidReset the warnings guard.voidsetAcceptConstKeyword(boolean value) If true, accept `const' keyword.voidsetAggressiveVarCheck(CheckLevel level) Checks for suspicious variable definitions and undefined variablesvoidsetAliasableGlobals(String names) A comma separated white-list of global names.voidsetAliasableStrings(Set<String> aliasableStrings) voidsetAliasAllStrings(boolean aliasAllStrings) voidsetAliasExternals(boolean aliasExternals) voidsetAliasKeywords(boolean aliasKeywords) voidsetAliasStringsBlacklist(String aliasStringsBlacklist) voidvoidsetAmbiguateProperties(boolean ambiguateProperties) voidsetAngularPass(boolean angularPass) voidsetAnonymousFunctionNaming(AnonymousFunctionNamingPolicy anonymousFunctionNaming) voidsetAppNameStr(String appNameStr) App identifier string for use by the instrumentation template's app_name_setter.voidsetAssumeClosuresOnlyCaptureReferences(boolean enable) Whether to assume closures capture only what they reference.voidsetAssumeStrictThis(boolean enable) If true, enables enables additional optimizations.voidSets the check level for bad Closure require calls.voidsetChainCalls(boolean value) If true, chain calls to functions that return this.voidsetCheckCaja(boolean check) voidsetCheckControlStructures(boolean checkControlStructures) voidsetCheckDeterminism(boolean checkDeterminism) voidChecks the integrity of references to qualified global names.voidChecks for certain uses of thethiskeyword that are considered unsafe because they are likely to reference the globalthisobject unintentionally.voidsetCheckMissingGetCssNameBlacklist(String blackList) voidChecks that certain string literals only appear in strings used as goog.getCssName arguments.voidsetCheckMissingReturn(CheckLevel level) Checks for missing return statementsvoidsetCheckProvides(CheckLevel level) Checks for missing goog.provides() callsvoidsetCheckRequires(CheckLevel level) voidsetCheckSuspiciousCode(boolean checkSuspiciousCode) voidsetCheckSymbols(boolean checkSymbols) voidsetCheckTypes(boolean checkTypes) voidChecks for unreachable codevoidsetClosurePass(boolean closurePass) voidsetCoalesceVariableNames(boolean coalesceVariableNames) voidsetCodingConvention(CodingConvention codingConvention) voidsetCollapseAnonymousFunctions(boolean enabled) voidsetCollapseObjectLiterals(boolean enabled) voidsetCollapseProperties(boolean collapseProperties) voidsetCollapsePropertiesOnExternTypes(boolean collapse) If true, flattens multi-level property names on extern types (e.g.voidsetCollapseVariableDeclarations(boolean enabled) voidsetColorizeErrorOutput(boolean colorizeErrorOutput) voidsetCommonJSModulePathPrefix(String commonJSModulePathPrefix) Sets a path prefix for CommonJS modules.voidsetComputeFunctionSideEffects(boolean computeFunctionSideEffects) voidsetConvertToDottedProperties(boolean convertToDottedProperties) voidsetCrossModuleCodeMotion(boolean crossModuleCodeMotion) voidsetCrossModuleMethodMotion(boolean crossModuleMethodMotion) voidsetCssRenamingMap(CssRenamingMap cssRenamingMap) voidsetCssRenamingWhitelist(Set<String> whitelist) voidsetCustomPasses(com.google.common.collect.Multimap<CustomPassExecutionTime, CompilerPass> customPasses) voidsetDeadAssignmentElimination(boolean deadAssignmentElimination) voidsetDebugFunctionSideEffectsPath(String debugFunctionSideEffectsPath) voidsetDefineReplacements(Map<String, Object> defineReplacements) voidsetDefineToBooleanLiteral(String defineName, boolean value) Sets the value of the@definevariable in JS to a boolean literal.voidsetDefineToDoubleLiteral(String defineName, double value) Sets the value of the@definevariable in JS to a number literal.voidsetDefineToNumberLiteral(String defineName, int value) Sets the value of the@definevariable in JS to a number literal.voidsetDefineToStringLiteral(String defineName, String value) Sets the value of the@definevariable in JS to a String literal.voidsetDependencyOptions(DependencyOptions options) Sets dependency options.voidsetDevirtualizePrototypeMethods(boolean devirtualizePrototypeMethods) voidsetDevMode(com.google.javascript.jscomp.CompilerOptions.DevMode devMode) voidsetDisambiguateProperties(boolean disambiguateProperties) voidsetErrorFormat(ErrorFormat errorFormat) voidsetErrorHandler(ErrorHandler handler) Set a custom handler for warnings and errors.voidsetExportTestFunctions(boolean exportTestFunctions) voidsetExternExports(boolean externExports) voidsetExternExportsPath(String externExportsPath) voidsetExtraAnnotationNames(Iterable<String> extraAnnotationNames) voidsetExtractPrototypeMemberDeclarations(boolean enabled) voidsetFlowSensitiveInlineVariables(boolean enabled) voidsetFoldConstants(boolean foldConstants) voidsetGatherCssNames(boolean gatherCssNames) voidsetGenerateExports(boolean generateExports) voidsetGeneratePseudoNames(boolean generatePseudoNames) voidsetGroupVariableDeclarations(boolean enabled) voidsetIdeMode(boolean ideMode) voidsetIdGenerators(Set<String> idGenerators) Sets the id generators to replace.voidsetIdGeneratorsMap(String previousMappings) A previous map of ids (serialized to a string by a previous compile).voidsetIgnoreCajaProperties(boolean enabled) Add code to skip properties that Caja adds to Object.prototypevoidsetInferTypes(boolean enable) If true, enables type inference.voidsetInlineConstantVars(boolean inlineConstantVars) voidsetInlineFunctions(boolean inlineFunctions) voidSet the function inlining policy for the compiler.voidsetInlineGetters(boolean inlineGetters) voidsetInlineLocalFunctions(boolean inlineLocalFunctions) voidsetInlineLocalVariables(boolean inlineLocalVariables) voidsetInlineProperties(boolean enable) Set the function inlining policy for the compiler.voidsetInlineVariables(boolean inlineVariables) voidSet the variable inlining policy for the compiler.voidvoidsetInputDelimiter(String inputDelimiter) voidsetInputPropertyMap(VariableMap inputPropertyMap) voidsetInputPropertyMapSerialized(byte[] inputPropertyMapSerialized) Deprecated.voidsetInputVariableMap(VariableMap inputVariableMap) voidsetInputVariableMapSerialized(byte[] inputVariableMapSerialized) Deprecated.voidsetInstrumentationTemplate(String instrumentationTemplate) voidsetLabelRenaming(boolean labelRenaming) voidsetLanguageIn(CompilerOptions.LanguageMode languageIn) Sets how goog.tweak calls are processed.voidsetLanguageOut(CompilerOptions.LanguageMode languageOut) voidsetLineBreak(boolean lineBreak) voidsetLineLengthThreshold(int lineLengthThreshold) voidvoidsetLooseTypes(boolean looseTypes) Whether to include "undefined" in the default types.voidsetManageClosureDependencies(boolean newVal) Sort inputs by their goog.provide/goog.require calls, and prune inputs whose symbols are not required.voidsetManageClosureDependencies(List<String> entryPoints) Sort inputs by their goog.provide/goog.require calls.voidsetMarkAsCompiled(boolean markAsCompiled) voidsetMarkNoSideEffectCalls(boolean markNoSideEffectCalls) voidsetMessageBundle(MessageBundle messageBundle) voidsetMoveFunctionDeclarations(boolean moveFunctionDeclarations) voidsetNameAnonymousFunctionsOnly(boolean value) If true, name anonymous functions only.voidsetNameReferenceGraphPath(String filePath) Where to save the name reference graphvoidsetNameReferenceReportPath(String filePath) Where to save a cross-reference report from the name reference graphvoidsetOptimizeArgumentsArray(boolean optimizeArgumentsArray) voidsetOptimizeCalls(boolean optimizeCalls) voidsetOptimizeParameters(boolean optimizeParameters) voidsetOptimizeReturns(boolean optimizeReturns) voidsetOutputCharset(String charsetName) Sets the output charset by name.voidsetOutputJsStringUsage(boolean outputJsStringUsage) voidsetPreferLineBreakAtEndOfFile(boolean lineBreakAtEnd) voidsetPreferSingleQuotes(boolean enabled) Normally, when there are an equal number of single and double quotes in a string, the compiler will use double quotes.voidsetPrettyPrint(boolean prettyPrint) voidsetPrintInputDelimiter(boolean printInputDelimiter) voidsetProcessCommonJSModules(boolean processCommonJSModules) Rewrites CommonJS modules so that modules can be concatenated together, by renaming all globals to avoid conflicting with other modules.voidsetProcessObjectPropertyString(boolean process) If true, process goog.testing.ObjectPropertyString instances.voidsetPropertyAffinity(boolean useAffinity) voidsetPropertyInvalidationErrors(Map<String, CheckLevel> propertyInvalidationErrors) Sets the list of properties that we report property invalidation errors for.voidsetPropertyRenaming(PropertyRenamingPolicy propertyRenaming) voidsetProtectHiddenSideEffects(boolean enable) When enabled, assume that apparently side-effect free code is meaningful.voidsetRecordFunctionInformation(boolean recordFunctionInformation) voidsetRemoveAbstractMethods(boolean remove) voidsetRemoveClosureAsserts(boolean remove) voidsetRemoveDeadCode(boolean removeDeadCode) voidsetRemoveTryCatchFinally(boolean removeTryCatchFinally) voidsetRemoveUnusedClassProperties(boolean removeUnusedClassProperties) voidsetRemoveUnusedLocalVars(boolean removeUnusedLocalVars) voidsetRemoveUnusedPrototypeProperties(boolean enabled) voidsetRemoveUnusedPrototypePropertiesInExterns(boolean enabled) voidDeprecated.voidSet the variable removal policy for the compiler.voidsetRemoveUnusedVars(boolean removeUnusedVars) voidsetRenamePrefix(String renamePrefix) voidsetRenamePrefixNamespace(String renamePrefixNamespace) voidsetRenamingPolicy(VariableRenamingPolicy newVariablePolicy, PropertyRenamingPolicy newPropertyPolicy) Sets the variable and property renaming policies for the compiler, in a way that clears warnings about the renaming policy being uninitialized from flags.voidsetReplaceIdGenerators(boolean replaceIdGenerators) voidsetReplaceMessagesWithChromeI18n(boolean replaceMessagesWithChromeI18n, String tcProjectId) voidsetReplaceStringsConfiguration(String placeholderToken, List<String> functionDescriptors) Sets the functions whose debug strings to replace.voidsetReplaceStringsFunctionDescriptions(List<String> replaceStringsFunctionDescriptions) voidsetReplaceStringsInputMap(VariableMap serializedMap) voidsetReplaceStringsPlaceholderToken(String replaceStringsPlaceholderToken) voidsetReplaceStringsReservedStrings(Set<String> replaceStringsReservedStrings) voidFlags a warning if a property is missing the @override annotation, but it overrides a base class property.voidsetReportPath(String reportPath) Where to save a report of global name usagevoidsetReportUnknownTypes(CheckLevel level) Flags a warning for every node whose type could not be determined.voidsetReserveRawExports(boolean reserveRawExports) voidsetRewriteFunctionExpressions(boolean rewriteFunctionExpressions) voidsetRewriteNewDateGoogNow(boolean rewrite) Deprecated.voidsetRuntimeTypeCheck(boolean runtimeTypeCheck) voidsetRuntimeTypeCheckLogFunction(String runtimeTypeCheckLogFunction) voidsetSaveDataStructures(boolean save) Whether to keep internal data structures around after we're finished compiling.voidsetShadowVariables(boolean shadow) Should shadow outer scope variable name during renaming.voidsetSkipAllPasses(boolean skipAllPasses) voidsetSmartNameRemoval(boolean smartNameRemoval) voidsetSourceMapDetailLevel(SourceMap.DetailLevel sourceMapDetailLevel) voidsetSourceMapFormat(SourceMap.Format sourceMapFormat) voidsetSourceMapLocationMappings(List<SourceMap.LocationMapping> sourceMapLocationMappings) voidsetSourceMapOutputPath(String sourceMapOutputPath) voidsetSpecializeInitialModule(boolean enabled) Specialize the initial module at the cost of later modulesvoidsetStripNamePrefixes(Set<String> stripNamePrefixes) voidsetStripNameSuffixes(Set<String> stripNameSuffixes) voidsetStripTypePrefixes(Set<String> stripTypePrefixes) voidsetStripTypes(Set<String> stripTypes) voidsetSummaryDetailLevel(int summaryDetailLevel) Controls how detailed the compilation summary is.voidsetSyntheticBlockEndMarker(String syntheticBlockEndMarker) voidsetSyntheticBlockStartMarker(String syntheticBlockStartMarker) voidsetTightenTypes(boolean tighten) Tightens types based on a global analysis.voidsetTracer(CompilerOptions.TracerMode tracer) voidvoidsetTransformAMDToCJSModules(boolean transformAMDToCJSModules) Activates transformation of AMD to CommonJS modules.voidsetTrustedStrings(boolean yes) Some people want to put arbitrary user input into strings, which are then run through the compiler.voidsetTweakProcessing(CompilerOptions.TweakProcessing tweakProcessing) Sets how goog.tweak calls are processed.voidsetTweakReplacements(Map<String, Object> tweakReplacements) voidsetTweakToBooleanLiteral(String tweakId, boolean value) Sets the value of the tweak in JS to a boolean literal.voidsetTweakToDoubleLiteral(String tweakId, double value) Sets the value of the tweak in JS to a number literal.voidsetTweakToNumberLiteral(String tweakId, int value) Sets the value of the tweak in JS to a number literal.voidsetTweakToStringLiteral(String tweakId, String value) Sets the value of the tweak in JS to a String literal.voidsetUnaliasableGlobals(String names) A comma separated white-list of global names.voidsetVariableRenaming(VariableRenamingPolicy variableRenaming) voidsetWarningLevel(DiagnosticGroup type, CheckLevel level) Configure the given type of warning to the given level.voidsetWarningsGuard(ComposeWarningsGuard warningsGuard) booleanvoidSkip all possible passes, to make the compiler as fast as possible.
-
Field Details
-
ideMode
public boolean ideModeConfigures the compiler for use as an IDE backend. In this mode:- No optimization passes will run.
- The last time custom passes are invoked is
CustomPassExecutionTime.BEFORE_OPTIMIZATIONS - The compiler will always try to process all inputs fully, even if it encounters errors.
- The compiler may record more information than is strictly needed for codegen.
-
messageBundle
Returns localized replacement for MSG_* variables -
checkSymbols
public boolean checkSymbolsChecks that all symbols are defined -
aggressiveVarCheck
-
checkSuspiciousCode
public boolean checkSuspiciousCodeChecks for suspicious statements that have no effect -
checkControlStructures
public boolean checkControlStructuresChecks for invalid control structures -
checkTypes
public boolean checkTypesChecks types on expressions -
reportMissingOverride
-
checkRequires
Checks for missing goog.require() calls -
checkProvides
-
checkGlobalNamesLevel
-
brokenClosureRequiresLevel
-
checkGlobalThisLevel
-
checkMissingGetCssNameLevel
-
checkMissingGetCssNameBlacklist
Regex of string literals that may only appear in goog.getCssName arguments. -
foldConstants
public boolean foldConstantsFolds constants (e.g. (2 + 3) to 5) -
deadAssignmentElimination
public boolean deadAssignmentEliminationRemove assignments to values that can not be referenced -
inlineConstantVars
public boolean inlineConstantVarsInlines constants (symbols that are all CAPS) -
inlineFunctions
public boolean inlineFunctionsInlines global functions -
inlineLocalFunctions
public boolean inlineLocalFunctionsInlines functions defined in local scopes -
crossModuleCodeMotion
public boolean crossModuleCodeMotionMove code to a deeper module -
coalesceVariableNames
public boolean coalesceVariableNamesMerge two variables together as one. -
crossModuleMethodMotion
public boolean crossModuleMethodMotionMove methods to a deeper module -
inlineGetters
public boolean inlineGettersInlines trivial getters -
inlineVariables
public boolean inlineVariablesInlines variables -
flowSensitiveInlineVariables
public boolean flowSensitiveInlineVariables -
smartNameRemoval
public boolean smartNameRemovalRemoves code associated with unused global names -
removeDeadCode
public boolean removeDeadCodeRemoves code that will never execute -
checkUnreachableCode
-
checkMissingReturn
-
extractPrototypeMemberDeclarations
public boolean extractPrototypeMemberDeclarationsExtracts common prototype member declarations -
removeUnusedPrototypeProperties
public boolean removeUnusedPrototypePropertiesRemoves unused member prototypes -
removeUnusedPrototypePropertiesInExterns
public boolean removeUnusedPrototypePropertiesInExternsTells AnalyzePrototypeProperties it can remove externed props. -
removeUnusedClassProperties
public boolean removeUnusedClassPropertiesRemoves unused member properties -
removeUnusedVars
public boolean removeUnusedVarsRemoves unused variables -
removeUnusedLocalVars
public boolean removeUnusedLocalVarsRemoves unused variables in local scope. -
aliasExternals
public boolean aliasExternalsAdds variable aliases for externals to reduce code size -
collapseVariableDeclarations
public boolean collapseVariableDeclarationsCollapses multiple variable declarations into one -
collapseAnonymousFunctions
public boolean collapseAnonymousFunctionsCollapses anonymous function declarations into named function declarations -
aliasableStrings
If set to a non-empty set, those strings literals will be aliased to a single global instance per string, to avoid creating more objects than necessary. -
aliasStringsBlacklist
A blacklist in the form of a regular expression to block strings that contains certain words from being aliased. If the value is the empty string, no words are blacklisted. -
aliasAllStrings
public boolean aliasAllStringsAliases all string literals to global instances, to avoid creating more objects than necessary (if true, overrides any set of strings passed in to aliasableStrings) -
convertToDottedProperties
public boolean convertToDottedPropertiesConverts quoted property accesses to dot syntax (a['b'] -> a.b) -
rewriteFunctionExpressions
public boolean rewriteFunctionExpressionsReduces the size of common function expressions. -
optimizeParameters
public boolean optimizeParametersRemove unused and constant parameters. -
optimizeReturns
public boolean optimizeReturnsRemove unused return values. -
optimizeCalls
public boolean optimizeCallsRemove unused parameters from call sites. -
optimizeArgumentsArray
public boolean optimizeArgumentsArrayProvide formal names for elements of arguments array. -
variableRenaming
Controls which variables get renamed. -
propertyRenaming
Controls which properties get renamed. -
labelRenaming
public boolean labelRenamingControls label renaming. -
reserveRawExports
public boolean reserveRawExportsReserve property names on the global this object. -
generatePseudoNames
public boolean generatePseudoNamesGenerate pseudo names for variables and properties for debugging purposes. -
renamePrefix
Specifies a prefix for all globals -
renamePrefixNamespace
Specifies the name of an object that will be used to store all non-extern globals. -
aliasKeywords
public boolean aliasKeywordsAliases true, false, and null to variables with shorter names. -
collapseProperties
public boolean collapsePropertiesFlattens multi-level property names (e.g. a$b = x) -
devirtualizePrototypeMethods
public boolean devirtualizePrototypeMethodsDevirtualize prototype method by rewriting them to be static calls that take the this pointer as their first argument -
computeFunctionSideEffects
public boolean computeFunctionSideEffectsUse @nosideeffects annotations, function bodies and name graph to determine if calls have side effects. Requires --check_types. -
disambiguateProperties
public boolean disambiguatePropertiesRename properties to disambiguate between unrelated fields based on type information. -
ambiguateProperties
public boolean ambiguatePropertiesRename unrelated properties to the same name to reduce code size. -
anonymousFunctionNaming
Give anonymous functions names for easier debugging -
exportTestFunctions
public boolean exportTestFunctionsWhether to export test functions. -
syntheticBlockStartMarker
-
syntheticBlockEndMarker
-
locale
Compiling locale -
markAsCompiled
public boolean markAsCompiledSets the special "COMPILED" value to true -
removeTryCatchFinally
public boolean removeTryCatchFinallyRemoves try...catch...finally blocks for easier debugging -
closurePass
public boolean closurePassProcesses goog.provide() and goog.require() calls -
jqueryPass
public boolean jqueryPassProcesses jQuery aliases -
gatherCssNames
public boolean gatherCssNamesGather CSS names (requires closurePass) -
stripTypes
Names of types to strip -
stripNameSuffixes
Name suffixes that determine which variables and properties to strip -
stripNamePrefixes
Name prefixes that determine which variables and properties to strip -
stripTypePrefixes
Qualified type name prefixes that determine which types to strip -
customPasses
public transient com.google.common.collect.Multimap<CustomPassExecutionTime,CompilerPass> customPassesCustom passes -
markNoSideEffectCalls
public boolean markNoSideEffectCallsMark no side effect calls -
moveFunctionDeclarations
public boolean moveFunctionDeclarationsMove top-level function declarations to the top -
instrumentationTemplate
Instrumentation template to use with #recordFunctionInformation -
recordFunctionInformation
public boolean recordFunctionInformationRecord function information -
generateExports
public boolean generateExports -
cssRenamingMap
Map used in the renaming of CSS class names. -
prettyPrint
public boolean prettyPrintOutput in pretty indented format -
lineBreak
public boolean lineBreakLine break the output a bit more aggressively -
preferLineBreakAtEndOfFile
public boolean preferLineBreakAtEndOfFilePrefer line breaks at end of file -
printInputDelimiter
public boolean printInputDelimiterPrints a separator comment before each JS script -
inputDelimiter
The string to use as the separator for printInputDelimiter -
errorFormat
-
sourceMapOutputPath
The output path for the source map. -
sourceMapDetailLevel
The detail level for the generated source map. -
sourceMapFormat
The source map file format -
sourceMapLocationMappings
-
-
Constructor Details
-
CompilerOptions
public CompilerOptions()Initializes compiler options. All options are disabled by default. Command-line frontends to the compiler should set these properties like a builder.
-
-
Method Details
-
setAggressiveVarCheck
Checks for suspicious variable definitions and undefined variables -
setTightenTypes
public void setTightenTypes(boolean tighten) Tightens types based on a global analysis. Experimental. -
setReportMissingOverride
Flags a warning if a property is missing the @override annotation, but it overrides a base class property. -
setReportUnknownTypes
Flags a warning for every node whose type could not be determined. -
setCheckRequires
-
setCheckProvides
Checks for missing goog.provides() calls -
setCheckGlobalNamesLevel
Checks the integrity of references to qualified global names. (e.g. "a.b") -
setBrokenClosureRequiresLevel
Sets the check level for bad Closure require calls. -
setCheckGlobalThisLevel
Checks for certain uses of thethiskeyword that are considered unsafe because they are likely to reference the globalthisobject unintentionally. If this is off, but collapseProperties is on, then the compiler will usually ignore you and run this check anyways. -
setCheckMissingGetCssNameLevel
Checks that certain string literals only appear in strings used as goog.getCssName arguments. -
setCheckCaja
public void setCheckCaja(boolean check) -
setCheckUnreachableCode
Checks for unreachable code -
setCheckMissingReturn
Checks for missing return statements -
setAliasableGlobals
A comma separated white-list of global names. WhenaliasExternalsis enable, if set to a non-empty string, only externals with these names will be considered for aliasing. -
setUnaliasableGlobals
A comma separated white-list of global names. WhenaliasExternalsis enable, these global names will not be aliased. -
setCollapseObjectLiterals
public void setCollapseObjectLiterals(boolean enabled) -
setSpecializeInitialModule
public void setSpecializeInitialModule(boolean enabled) Specialize the initial module at the cost of later modules -
setReplaceMessagesWithChromeI18n
public void setReplaceMessagesWithChromeI18n(boolean replaceMessagesWithChromeI18n, String tcProjectId) -
setIgnoreCajaProperties
public void setIgnoreCajaProperties(boolean enabled) Add code to skip properties that Caja adds to Object.prototype -
setAppNameStr
App identifier string for use by the instrumentation template's app_name_setter. @see #instrumentationTemplate -
setPreferSingleQuotes
public void setPreferSingleQuotes(boolean enabled) Normally, when there are an equal number of single and double quotes in a string, the compiler will use double quotes. Set this to true to prefer single quotes. -
setTrustedStrings
public void setTrustedStrings(boolean yes) Some people want to put arbitrary user input into strings, which are then run through the compiler. These scripts are then put into HTML. By default, we assume strings are untrusted. If the compiler is run from the command-line, we assume that strings are trusted. -
setReportPath
Where to save a report of global name usage -
getTracerMode
-
setTracerMode
-
setNameReferenceReportPath
Where to save a cross-reference report from the name reference graph -
setNameReferenceGraphPath
Where to save the name reference graph -
setProtectHiddenSideEffects
public void setProtectHiddenSideEffects(boolean enable) When enabled, assume that apparently side-effect free code is meaningful. -
isRemoveUnusedClassProperties
public boolean isRemoveUnusedClassProperties()- Returns:
- Whether to attempt to remove unused class properties
-
setRemoveUnusedClassProperties
public void setRemoveUnusedClassProperties(boolean removeUnusedClassProperties) - Parameters:
removeUnusedClassProperties- Whether to attempt to remove unused class properties
-
getDefineReplacements
Returns the map of define replacements. -
getTweakReplacements
Returns the map of tweak replacements. -
setDefineToBooleanLiteral
Sets the value of the@definevariable in JS to a boolean literal. -
setDefineToStringLiteral
Sets the value of the@definevariable in JS to a String literal. -
setDefineToNumberLiteral
Sets the value of the@definevariable in JS to a number literal. -
setDefineToDoubleLiteral
Sets the value of the@definevariable in JS to a number literal. -
setTweakToBooleanLiteral
Sets the value of the tweak in JS to a boolean literal. -
setTweakToStringLiteral
Sets the value of the tweak in JS to a String literal. -
setTweakToNumberLiteral
Sets the value of the tweak in JS to a number literal. -
setTweakToDoubleLiteral
Sets the value of the tweak in JS to a number literal. -
skipAllCompilerPasses
public void skipAllCompilerPasses()Skip all possible passes, to make the compiler as fast as possible. -
setWarningLevel
Configure the given type of warning to the given level. -
resetWarningsGuard
public void resetWarningsGuard()Reset the warnings guard. -
addWarningsGuard
Add a guard to the set of warnings guards. -
setRenamingPolicy
public void setRenamingPolicy(VariableRenamingPolicy newVariablePolicy, PropertyRenamingPolicy newPropertyPolicy) Sets the variable and property renaming policies for the compiler, in a way that clears warnings about the renaming policy being uninitialized from flags. -
setPropertyAffinity
public void setPropertyAffinity(boolean useAffinity) -
setShadowVariables
public void setShadowVariables(boolean shadow) Should shadow outer scope variable name during renaming. -
setCollapsePropertiesOnExternTypes
public void setCollapsePropertiesOnExternTypes(boolean collapse) If true, flattens multi-level property names on extern types (e.g. String$f = x). This should only be used with the typed version of the externs files. -
setProcessObjectPropertyString
public void setProcessObjectPropertyString(boolean process) If true, process goog.testing.ObjectPropertyString instances. -
setReplaceIdGenerators
public void setReplaceIdGenerators(boolean replaceIdGenerators) - Parameters:
replaceIdGenerators- the replaceIdGenerators to set
-
setIdGenerators
Sets the id generators to replace. -
setIdGeneratorsMap
A previous map of ids (serialized to a string by a previous compile). This will be used as a hint during the ReplaceIdGenerators pass, which will attempt to reuse the same ids. -
setInlineFunctions
Set the function inlining policy for the compiler. -
setInlineVariables
Set the variable inlining policy for the compiler. -
setInlineProperties
public void setInlineProperties(boolean enable) Set the function inlining policy for the compiler. -
setRemoveUnusedVariable
Deprecated.Set the variable removal policy for the compiler. -
setRemoveUnusedVariables
Set the variable removal policy for the compiler. -
setReplaceStringsConfiguration
public void setReplaceStringsConfiguration(String placeholderToken, List<String> functionDescriptors) Sets the functions whose debug strings to replace. -
setRewriteNewDateGoogNow
Deprecated. -
setRemoveAbstractMethods
public void setRemoveAbstractMethods(boolean remove) -
setRemoveClosureAsserts
public void setRemoveClosureAsserts(boolean remove) -
setNameAnonymousFunctionsOnly
public void setNameAnonymousFunctionsOnly(boolean value) If true, name anonymous functions only. All other passes will be skipped. -
setColorizeErrorOutput
public void setColorizeErrorOutput(boolean colorizeErrorOutput) -
shouldColorizeErrorOutput
public boolean shouldColorizeErrorOutput() -
setChainCalls
public void setChainCalls(boolean value) If true, chain calls to functions that return this. -
setAcceptConstKeyword
public void setAcceptConstKeyword(boolean value) If true, accept `const' keyword. -
enableRuntimeTypeCheck
Enable run-time type checking, which adds JS type assertions for debugging.- Parameters:
logFunction- A JS function to be used for logging run-time type assertion failures.
-
disableRuntimeTypeCheck
public void disableRuntimeTypeCheck() -
setGenerateExports
public void setGenerateExports(boolean generateExports) -
setAngularPass
public void setAngularPass(boolean angularPass) -
setCodingConvention
-
getCodingConvention
-
setDependencyOptions
Sets dependency options. See the DependencyOptions class for more info. This supersedes manageClosureDependencies. -
setManageClosureDependencies
public void setManageClosureDependencies(boolean newVal) Sort inputs by their goog.provide/goog.require calls, and prune inputs whose symbols are not required. -
setManageClosureDependencies
Sort inputs by their goog.provide/goog.require calls.- Parameters:
entryPoints- Entry points to the program. Must be goog.provide'd symbols. Any goog.provide'd symbols that are not a transitive dependency of the entry points will be deleted. Files without goog.provides, and their dependencies, will always be left in.
-
setSummaryDetailLevel
public void setSummaryDetailLevel(int summaryDetailLevel) Controls how detailed the compilation summary is. Values: 0 (never print summary), 1 (print summary only if there are errors or warnings), 2 (print summary if type checking is on, see --check_types), 3 (always print summary). The default level is 1 -
enableExternExports
Deprecated.replaced bysetExternExports(boolean) -
setExtraAnnotationNames
-
isExternExportsEnabled
public boolean isExternExportsEnabled() -
setOutputCharset
Sets the output charset by name. -
setTweakProcessing
Sets how goog.tweak calls are processed. -
getTweakProcessing
-
setLanguageIn
Sets how goog.tweak calls are processed. -
getLanguageIn
-
getLanguageOut
-
setLooseTypes
public void setLooseTypes(boolean looseTypes) Whether to include "undefined" in the default types. For example: "{Object}" is normally "Object|null" becomes "Object|null|undefined" "{?string}" is normally "string|null" becomes "string|null|undefined" In either case "!" annotated types excluded both null and undefined. -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
setAliasTransformationHandler
-
getAliasTransformationHandler
-
setErrorHandler
Set a custom handler for warnings and errors. This is mostly used for piping the warnings and errors to a file behind the scenes. If you want to filter warnings and errors, you should use a WarningsGuard. If you want to change how warnings and errors are reported to the user, you should set a ErrorManager on the Compiler. An ErrorManager is intended to summarize the errors for a single compile job. -
setInferTypes
public void setInferTypes(boolean enable) If true, enables type inference. If checkTypes is enabled, this flag has no effect. -
getInferTypes
public boolean getInferTypes()Gets the inferTypes flag. Note that if checkTypes is enabled, this flag is ignored when configuring the compiler. -
assumeStrictThis
public boolean assumeStrictThis()- Returns:
- Whether assumeStrictThis is set.
-
setAssumeStrictThis
public void setAssumeStrictThis(boolean enable) If true, enables enables additional optimizations. -
assumeClosuresOnlyCaptureReferences
public boolean assumeClosuresOnlyCaptureReferences()- Returns:
- Whether assumeClosuresOnlyCaptureReferences is set.
-
setAssumeClosuresOnlyCaptureReferences
public void setAssumeClosuresOnlyCaptureReferences(boolean enable) Whether to assume closures capture only what they reference. This allows more aggressive function inlining. -
setPropertyInvalidationErrors
Sets the list of properties that we report property invalidation errors for. -
setLanguageOut
-
setIdeMode
public void setIdeMode(boolean ideMode) -
setSaveDataStructures
public void setSaveDataStructures(boolean save) Whether to keep internal data structures around after we're finished compiling. We do this by default when IDE mode is on. -
setSkipAllPasses
public void setSkipAllPasses(boolean skipAllPasses) -
setDevMode
public void setDevMode(com.google.javascript.jscomp.CompilerOptions.DevMode devMode) -
setCheckDeterminism
public void setCheckDeterminism(boolean checkDeterminism) -
getCheckDeterminism
public boolean getCheckDeterminism() -
setMessageBundle
-
setCheckSymbols
public void setCheckSymbols(boolean checkSymbols) -
setCheckSuspiciousCode
public void setCheckSuspiciousCode(boolean checkSuspiciousCode) -
setCheckControlStructures
public void setCheckControlStructures(boolean checkControlStructures) -
setCheckTypes
public void setCheckTypes(boolean checkTypes) -
setCheckMissingGetCssNameBlacklist
-
setFoldConstants
public void setFoldConstants(boolean foldConstants) -
setDeadAssignmentElimination
public void setDeadAssignmentElimination(boolean deadAssignmentElimination) -
setInlineConstantVars
public void setInlineConstantVars(boolean inlineConstantVars) -
setInlineFunctions
public void setInlineFunctions(boolean inlineFunctions) -
setInlineLocalFunctions
public void setInlineLocalFunctions(boolean inlineLocalFunctions) -
setCrossModuleCodeMotion
public void setCrossModuleCodeMotion(boolean crossModuleCodeMotion) -
setCoalesceVariableNames
public void setCoalesceVariableNames(boolean coalesceVariableNames) -
setCrossModuleMethodMotion
public void setCrossModuleMethodMotion(boolean crossModuleMethodMotion) -
setInlineGetters
public void setInlineGetters(boolean inlineGetters) -
setInlineVariables
public void setInlineVariables(boolean inlineVariables) -
setInlineLocalVariables
public void setInlineLocalVariables(boolean inlineLocalVariables) -
setFlowSensitiveInlineVariables
public void setFlowSensitiveInlineVariables(boolean enabled) -
setSmartNameRemoval
public void setSmartNameRemoval(boolean smartNameRemoval) -
setRemoveDeadCode
public void setRemoveDeadCode(boolean removeDeadCode) -
setExtractPrototypeMemberDeclarations
public void setExtractPrototypeMemberDeclarations(boolean enabled) -
setRemoveUnusedPrototypeProperties
public void setRemoveUnusedPrototypeProperties(boolean enabled) -
setRemoveUnusedPrototypePropertiesInExterns
public void setRemoveUnusedPrototypePropertiesInExterns(boolean enabled) -
setRemoveUnusedVars
public void setRemoveUnusedVars(boolean removeUnusedVars) -
setRemoveUnusedLocalVars
public void setRemoveUnusedLocalVars(boolean removeUnusedLocalVars) -
setAliasExternals
public void setAliasExternals(boolean aliasExternals) -
setCollapseVariableDeclarations
public void setCollapseVariableDeclarations(boolean enabled) -
setGroupVariableDeclarations
public void setGroupVariableDeclarations(boolean enabled) -
setCollapseAnonymousFunctions
public void setCollapseAnonymousFunctions(boolean enabled) -
setAliasableStrings
-
setAliasStringsBlacklist
-
setAliasAllStrings
public void setAliasAllStrings(boolean aliasAllStrings) -
setOutputJsStringUsage
public void setOutputJsStringUsage(boolean outputJsStringUsage) -
setConvertToDottedProperties
public void setConvertToDottedProperties(boolean convertToDottedProperties) -
setRewriteFunctionExpressions
public void setRewriteFunctionExpressions(boolean rewriteFunctionExpressions) -
setOptimizeParameters
public void setOptimizeParameters(boolean optimizeParameters) -
setOptimizeReturns
public void setOptimizeReturns(boolean optimizeReturns) -
setOptimizeCalls
public void setOptimizeCalls(boolean optimizeCalls) -
setOptimizeArgumentsArray
public void setOptimizeArgumentsArray(boolean optimizeArgumentsArray) -
setVariableRenaming
-
setPropertyRenaming
-
setLabelRenaming
public void setLabelRenaming(boolean labelRenaming) -
setReserveRawExports
public void setReserveRawExports(boolean reserveRawExports) -
setGeneratePseudoNames
public void setGeneratePseudoNames(boolean generatePseudoNames) -
setRenamePrefix
-
setRenamePrefixNamespace
-
setAliasKeywords
public void setAliasKeywords(boolean aliasKeywords) -
setCollapseProperties
public void setCollapseProperties(boolean collapseProperties) -
setDevirtualizePrototypeMethods
public void setDevirtualizePrototypeMethods(boolean devirtualizePrototypeMethods) -
setComputeFunctionSideEffects
public void setComputeFunctionSideEffects(boolean computeFunctionSideEffects) -
setDebugFunctionSideEffectsPath
-
setDisambiguateProperties
public void setDisambiguateProperties(boolean disambiguateProperties) -
setAmbiguateProperties
public void setAmbiguateProperties(boolean ambiguateProperties) -
setAnonymousFunctionNaming
-
setInputAnonymousFunctionNamingMap
-
setInputVariableMapSerialized
@Deprecated public void setInputVariableMapSerialized(byte[] inputVariableMapSerialized) throws ParseException Deprecated.- Throws:
ParseException
-
setInputVariableMap
-
setInputPropertyMapSerialized
@Deprecated public void setInputPropertyMapSerialized(byte[] inputPropertyMapSerialized) throws ParseException Deprecated.- Throws:
ParseException
-
setInputPropertyMap
-
setExportTestFunctions
public void setExportTestFunctions(boolean exportTestFunctions) -
setRuntimeTypeCheck
public void setRuntimeTypeCheck(boolean runtimeTypeCheck) -
setRuntimeTypeCheckLogFunction
-
setSyntheticBlockStartMarker
-
setSyntheticBlockEndMarker
-
setLocale
-
setMarkAsCompiled
public void setMarkAsCompiled(boolean markAsCompiled) -
setRemoveTryCatchFinally
public void setRemoveTryCatchFinally(boolean removeTryCatchFinally) -
setClosurePass
public void setClosurePass(boolean closurePass) -
setGatherCssNames
public void setGatherCssNames(boolean gatherCssNames) -
setStripTypes
-
setStripNameSuffixes
-
setStripNamePrefixes
-
setStripTypePrefixes
-
setCustomPasses
public void setCustomPasses(com.google.common.collect.Multimap<CustomPassExecutionTime, CompilerPass> customPasses) -
setMarkNoSideEffectCalls
public void setMarkNoSideEffectCalls(boolean markNoSideEffectCalls) -
setDefineReplacements
-
setTweakReplacements
-
setMoveFunctionDeclarations
public void setMoveFunctionDeclarations(boolean moveFunctionDeclarations) -
setInstrumentationTemplate
-
setRecordFunctionInformation
public void setRecordFunctionInformation(boolean recordFunctionInformation) -
setCssRenamingMap
-
setCssRenamingWhitelist
-
setReplaceStringsFunctionDescriptions
-
setReplaceStringsPlaceholderToken
-
setReplaceStringsReservedStrings
-
setReplaceStringsInputMap
-
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint) -
setLineBreak
public void setLineBreak(boolean lineBreak) -
setPreferLineBreakAtEndOfFile
public void setPreferLineBreakAtEndOfFile(boolean lineBreakAtEnd) -
setPrintInputDelimiter
public void setPrintInputDelimiter(boolean printInputDelimiter) -
setInputDelimiter
-
setTracer
-
setErrorFormat
-
setWarningsGuard
-
setLineLengthThreshold
public void setLineLengthThreshold(int lineLengthThreshold) -
setExternExports
public void setExternExports(boolean externExports) -
setExternExportsPath
-
setSourceMapOutputPath
-
setSourceMapDetailLevel
-
setSourceMapFormat
-
setSourceMapLocationMappings
-
setTransformAMDToCJSModules
public void setTransformAMDToCJSModules(boolean transformAMDToCJSModules) Activates transformation of AMD to CommonJS modules. -
setProcessCommonJSModules
public void setProcessCommonJSModules(boolean processCommonJSModules) Rewrites CommonJS modules so that modules can be concatenated together, by renaming all globals to avoid conflicting with other modules. -
setCommonJSModulePathPrefix
Sets a path prefix for CommonJS modules.
-
setExternExports(boolean)