Class CompilerOptions

java.lang.Object
com.google.javascript.jscomp.CompilerOptions

public class CompilerOptions extends Object
Compiler options
  • Field Details Link icon

    • messageBundle Link icon

      public @Nullable MessageBundle messageBundle
      Returns localized replacement for MSG_* variables
    • checkSymbols Link icon

      public boolean checkSymbols
      Checks that all symbols are defined
    • checkSuspiciousCode Link icon

      public boolean checkSuspiciousCode
      Checks for suspicious statements that have no effect
    • checkTypes Link icon

      public boolean checkTypes
      Checks types on expressions
    • foldConstants Link icon

      public boolean foldConstants
      Folds constants (e.g. (2 + 3) to 5)
    • deadAssignmentElimination Link icon

      public boolean deadAssignmentElimination
      Remove assignments to values that can not be referenced
    • inlineConstantVars Link icon

      public boolean inlineConstantVars
      Inlines constants (symbols that are all CAPS)
    • coalesceVariableNames Link icon

      public boolean coalesceVariableNames
      Merge two variables together as one.
    • inlineVariables Link icon

      public boolean inlineVariables
      Inlines variables
    • flowSensitiveInlineVariables Link icon

      public boolean flowSensitiveInlineVariables
    • smartNameRemoval Link icon

      public boolean smartNameRemoval
      Removes code associated with unused global names
    • removeUnusedPrototypeProperties Link icon

      public boolean removeUnusedPrototypeProperties
      Removes unused member prototypes
    • removeUnusedClassProperties Link icon

      public boolean removeUnusedClassProperties
      Removes unused member properties
    • removeUnusedVars Link icon

      public boolean removeUnusedVars
      Removes unused variables
    • removeUnusedLocalVars Link icon

      public boolean removeUnusedLocalVars
      Removes unused variables in local scope.
    • collapseVariableDeclarations Link icon

      public boolean collapseVariableDeclarations
      Collapses multiple variable declarations into one
    • collapseAnonymousFunctions Link icon

      public boolean collapseAnonymousFunctions
      Collapses anonymous function declarations into named function declarations
    • convertToDottedProperties Link icon

      public boolean convertToDottedProperties
      Converts quoted property accesses to dot syntax (a['b'] → a.b)
    • rewriteFunctionExpressions Link icon

      public boolean rewriteFunctionExpressions
      Reduces the size of common function expressions.
    • optimizeCalls Link icon

      public boolean optimizeCalls
      Remove unused function arguments, remove unused return values, and inlines constant parameters.
    • variableRenaming Link icon

      public VariableRenamingPolicy variableRenaming
      Controls which variables get renamed.
    • labelRenaming Link icon

      public boolean labelRenaming
      Controls label renaming.
    • reserveRawExports Link icon

      public boolean reserveRawExports
      Reserve property names on the global this object.
    • generatePseudoNames Link icon

      public boolean generatePseudoNames
      Generate pseudo names for variables and properties for debugging purposes.
    • renamePrefix Link icon

      public @Nullable String renamePrefix
      Specifies a prefix for all globals
    • renamePrefixNamespace Link icon

      public String renamePrefixNamespace
      Specifies the name of an object that will be used to store all non-extern globals.
    • devirtualizeMethods Link icon

      public boolean devirtualizeMethods
      Devirtualize prototype method by rewriting them to be static calls that take the this pointer as their first argument
    • computeFunctionSideEffects Link icon

      public boolean computeFunctionSideEffects
      Use @nosideeffects annotations, function bodies and name graph to determine if calls have side effects.
    • exportTestFunctions Link icon

      public boolean exportTestFunctions
      Whether to export test functions.
    • syntheticBlockStartMarker Link icon

      public @Nullable String syntheticBlockStartMarker
    • syntheticBlockEndMarker Link icon

      public @Nullable String syntheticBlockEndMarker
    • locale Link icon

      public @Nullable String locale
      Compiling locale
    • markAsCompiled Link icon

      public boolean markAsCompiled
      Sets the special "COMPILED" value to true
    • closurePass Link icon

      public boolean closurePass
      Processes goog.provide() and goog.require() calls
    • gatherCssNames Link icon

      public boolean gatherCssNames
      Gather CSS names (requires closurePass)
    • customPasses Link icon

      protected transient @Nullable com.google.common.collect.Multimap<CustomPassExecutionTime,CompilerPass> customPasses
      Custom passes
    • rewriteGlobalDeclarationsForTryCatchWrapping Link icon

      public boolean rewriteGlobalDeclarationsForTryCatchWrapping
      Move top-level function declarations to the top
    • generateExports Link icon

      public boolean generateExports
    • cssRenamingMap Link icon

      public @Nullable CssRenamingMap cssRenamingMap
      Map used in the renaming of CSS class names.
    • preserveTypeAnnotations Link icon

      public boolean preserveTypeAnnotations
      Do not strip closure-style type annotations from code.
    • gentsMode Link icon

      public boolean gentsMode
      To distinguish between gents and non-gents mode so that we can turn off checking the sanity of the source location of comments, and also provide a different mode for comment printing between those two.
    • lineBreak Link icon

      public boolean lineBreak
      Line break the output a bit more aggressively
    • printInputDelimiter Link icon

      public boolean printInputDelimiter
      Prints a separator comment before each JS script
    • inputDelimiter Link icon

      public String inputDelimiter
      The string to use as the separator for printInputDelimiter
    • errorFormat Link icon

      public ErrorFormat errorFormat
    • sourceMapDetailLevel Link icon

      public SourceMap.DetailLevel sourceMapDetailLevel
      The detail level for the generated source map.
    • sourceMapFormat Link icon

      public SourceMap.Format sourceMapFormat
      The source map file format
    • sourceMapLocationMappings Link icon

      public List<? extends SourceMap.LocationMapping> sourceMapLocationMappings
  • Constructor Details Link icon

    • CompilerOptions Link icon

      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 Link icon

    • getAngularPropertyReservedFirstChars Link icon

      public static com.google.common.collect.ImmutableSet<Character> getAngularPropertyReservedFirstChars()
    • shouldRunCrossChunkCodeMotion Link icon

      public boolean shouldRunCrossChunkCodeMotion()
    • shouldRunCrossChunkMethodMotion Link icon

      public boolean shouldRunCrossChunkMethodMotion()
    • getSourceMapOutputPath Link icon

      public String getSourceMapOutputPath()
    • shouldGatherSourceMapInfo Link icon

      public boolean shouldGatherSourceMapInfo()
    • setAlwaysGatherSourceMapInfo Link icon

      public void setAlwaysGatherSourceMapInfo(boolean shouldAlwaysGatherSourceMapInfo)
    • setBrowserFeaturesetYear Link icon

      public void setBrowserFeaturesetYear(int year)
    • setBrowserFeaturesetYear Link icon

      public void setBrowserFeaturesetYear(com.google.javascript.jscomp.CompilerOptions.BrowserFeaturesetYear year)
    • setInstrumentForCoverageOnly Link icon

      public void setInstrumentForCoverageOnly(boolean instrumentForCoverageOnly)
    • getInstrumentForCoverageOnly Link icon

      public boolean getInstrumentForCoverageOnly()
    • setTypedAstOutputFile Link icon

      public void setTypedAstOutputFile(@Nullable Path file)
      Sets file to output in-progress TypedAST format to. DO NOT USE!

      The "TypedAST format" is currently a gzipped TypedAst proto but this is not stable.

    • getMergedPrecompiledLibraries Link icon

      public boolean getMergedPrecompiledLibraries()
    • setSkipTranspilationAndCrash Link icon

      @Deprecated public void setSkipTranspilationAndCrash(boolean value)
      Deprecated.
    • setInputSourceMaps Link icon

      public void setInputSourceMaps(com.google.common.collect.ImmutableMap<String,SourceMapInput> inputSourceMaps)
      Sets the input sourcemap files, indexed by the JS files they refer to.
      Parameters:
      inputSourceMaps - the collection of input sourcemap files
    • setInferConst Link icon

      public void setInferConst(boolean value)
    • setIncrementalChecks Link icon

      public void setIncrementalChecks(CompilerOptions.IncrementalCheckMode value)
    • shouldGenerateTypedExterns Link icon

      public boolean shouldGenerateTypedExterns()
    • setCheckGlobalThisLevel Link icon

      @Deprecated public void setCheckGlobalThisLevel(CheckLevel level)
      Deprecated.
      Deprecated. Please use setWarningLevel(DiagnosticGroups.GLOBAL_THIS, level) instead.
    • setNumParallelThreads Link icon

      public void setNumParallelThreads(int parallelism)
      Sets the level of parallelism for compilation passes that can exploit multi-threading.

      Some compiler passes may take advantage of multi-threading, for example, parsing inputs. This sets the level of parallelism. The compiler will not start more than this number of threads.

      Parameters:
      parallelism - up to this number of parallel threads may be created.
    • setRenamePrefixNamespaceAssumeCrossChunkNames Link icon

      public void setRenamePrefixNamespaceAssumeCrossChunkNames(boolean assume)
      Useful for tests to avoid having to declare two chunks
    • shouldCollapseProperties Link icon

      @Deprecated public boolean shouldCollapseProperties()
      Deprecated.
      use getPropertyCollapseLevel
      Flattens multi-level property names (e.g. a$b = x)
    • getPropertyCollapseLevel Link icon

      public CompilerOptions.PropertyCollapseLevel getPropertyCollapseLevel()
    • setCollapseObjectLiterals Link icon

      public void setCollapseObjectLiterals(boolean enabled)
    • getCollapseObjectLiterals Link icon

      public boolean getCollapseObjectLiterals()
    • setNameGenerator Link icon

      public void setNameGenerator(NameGenerator nameGenerator)
    • setReplaceMessagesWithChromeI18n Link icon

      public void setReplaceMessagesWithChromeI18n(boolean replaceMessagesWithChromeI18n, String tcProjectId)
    • shouldRunReplaceMessagesForChrome Link icon

      public boolean shouldRunReplaceMessagesForChrome()
      Should we run the pass that does replacement of the chrome-specific `chrome.i18n.getMessage()` translatable message definitions?

      This form of l10n is incompatible with our standard `goog.getMsg()` messages.

    • setAssumeForwardDeclaredForMissingTypes Link icon

      public void setAssumeForwardDeclaredForMissingTypes(boolean assumeForwardDeclaredForMissingTypes)
      If true, considers all missing types to be forward declared (useful for partial compilation).
    • setPreferSingleQuotes Link icon

      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 Link icon

      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.
    • setPrintSourceAfterEachPass Link icon

      public void setPrintSourceAfterEachPass(boolean printSource)
    • setFilesToPrintAfterEachPassRegexList Link icon

      public void setFilesToPrintAfterEachPassRegexList(List<String> filePathRegexList)
    • setChunksToPrintAfterEachPassRegexList Link icon

      public void setChunksToPrintAfterEachPassRegexList(List<String> chunkPathRegexList)
    • setQnameUsesToPrintAfterEachPassList Link icon

      public void setQnameUsesToPrintAfterEachPassList(List<String> qnameRegexList)
    • getTracerMode Link icon

      public CompilerOptions.TracerMode getTracerMode()
    • setTracerMode Link icon

      public void setTracerMode(CompilerOptions.TracerMode mode)
    • setTracerOutput Link icon

      public void setTracerOutput(Path out)
    • setProtectHiddenSideEffects Link icon

      public void setProtectHiddenSideEffects(boolean enable)
      When enabled, assume that apparently side-effect free code is meaningful.
    • shouldProtectHiddenSideEffects Link icon

      public boolean shouldProtectHiddenSideEffects()
      Whether or not the compiler should wrap apparently side-effect free code to prevent it from being removed
    • setAssumeGettersArePure Link icon

      public void setAssumeGettersArePure(boolean x)
    • getAssumeGettersArePure Link icon

      public boolean getAssumeGettersArePure()
    • setAssumeStaticInheritanceIsNotUsed Link icon

      public void setAssumeStaticInheritanceIsNotUsed(boolean x)
    • getAssumeStaticInheritanceIsNotUsed Link icon

      public boolean getAssumeStaticInheritanceIsNotUsed()
    • getConformanceReportingMode Link icon

      public CompilerOptions.ConformanceReportingMode getConformanceReportingMode()
    • setConformanceReportingMode Link icon

      public void setConformanceReportingMode(CompilerOptions.ConformanceReportingMode mode)
    • setConformanceRemoveRegexFromPath Link icon

      public void setConformanceRemoveRegexFromPath(com.google.common.base.Optional<Pattern> pattern)
    • getConformanceRemoveRegexFromPath Link icon

      public com.google.common.base.Optional<Pattern> getConformanceRemoveRegexFromPath()
    • setWrapGoogModulesForWhitespaceOnly Link icon

      public void setWrapGoogModulesForWhitespaceOnly(boolean enable)
    • setBadRewriteModulesBeforeTypecheckingThatWeWantToGetRidOf Link icon

      public void setBadRewriteModulesBeforeTypecheckingThatWeWantToGetRidOf(boolean b)
      Whether to enable the bad module rewriting before typechecking that we want to get rid of
    • setEnableModuleRewriting Link icon

      public void setEnableModuleRewriting(boolean enable)
      Experimental option to disable all Closure and ES module and goog.provide rewriting

      Use at your own risk - disabling module rewriting is not fully tested yet.

    • setPrintConfig Link icon

      public void setPrintConfig(boolean printConfig)
      Should the compiler print its configuration options to stderr when they are initialized?

      Default false.

    • setAllowDynamicImport Link icon

      public void setAllowDynamicImport(boolean value)
      Whether to enable support for dynamic import expressions
    • getDynamicImportAlias Link icon

      public String getDynamicImportAlias()
      Set the alias name for dynamic import expressions
    • setDynamicImportAlias Link icon

      public void setDynamicImportAlias(String value)
      Set the alias name for dynamic import expressions
    • isRemoveUnusedClassProperties Link icon

      public boolean isRemoveUnusedClassProperties()
      Returns:
      Whether to attempt to remove unused class properties
    • setRemoveUnusedClassProperties Link icon

      public void setRemoveUnusedClassProperties(boolean removeUnusedClassProperties)
      Parameters:
      removeUnusedClassProperties - Whether to attempt to remove unused class properties
    • getDefineReplacements Link icon

      public com.google.common.collect.ImmutableMap<String,Node> getDefineReplacements()
      Returns the map of define replacements.
    • setDefineToBooleanLiteral Link icon

      public void setDefineToBooleanLiteral(String defineName, boolean value)
      Sets the value of the @define variable in JS to a boolean literal.
    • setDefineToStringLiteral Link icon

      public void setDefineToStringLiteral(String defineName, String value)
      Sets the value of the @define variable in JS to a String literal.
    • setDefineToNumberLiteral Link icon

      public void setDefineToNumberLiteral(String defineName, int value)
      Sets the value of the @define variable in JS to a number literal.
    • setDefineToDoubleLiteral Link icon

      public void setDefineToDoubleLiteral(String defineName, double value)
      Sets the value of the @define variable in JS to a number literal.
    • skipAllCompilerPasses Link icon

      public void skipAllCompilerPasses()
      Skip all possible passes, to make the compiler as fast as possible.
    • setUnknownDefinesToIgnore Link icon

      public void setUnknownDefinesToIgnore(com.google.common.collect.ImmutableList<String> unknownDefinesToIgnore)
    • addUnknownDefinesToIgnore Link icon

      public void addUnknownDefinesToIgnore(com.google.common.collect.ImmutableList<String> unknownDefinesToIgnore)
    • setWarningLevel Link icon

      public void setWarningLevel(DiagnosticGroup type, CheckLevel level)
      Configure the given type of warning to the given level.
    • resetWarningsGuard Link icon

      public void resetWarningsGuard()
      Reset the warnings guard.
    • addWarningsGuard Link icon

      public void addWarningsGuard(WarningsGuard guard)
      Add a guard to the set of warnings guards.
    • setRenamingPolicy Link icon

      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.
    • setReplaceIdGenerators Link icon

      public void setReplaceIdGenerators(boolean replaceIdGenerators)
      Parameters:
      replaceIdGenerators - the replaceIdGenerators to set
    • setIdGenerators Link icon

      public void setIdGenerators(Set<String> idGenerators)
      Sets the id generators to replace.
    • setIdGenerators Link icon

      public void setIdGenerators(Map<String,RenamingMap> idGenerators)
      Sets the id generators to replace.
    • setIdGeneratorsMap Link icon

      public void setIdGeneratorsMap(String previousMappings)
      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.
    • setXidHashFunction Link icon

      public void setXidHashFunction(Xid.HashFunction xidHashFunction)
      Sets the hash function to use for Xid
    • setChunkIdHashFunction Link icon

      public void setChunkIdHashFunction(Xid.HashFunction chunkIdHashFunction)
      Sets the hash function to use for chunk ID generation
    • setInlineFunctions Link icon

      public void setInlineFunctions(CompilerOptions.Reach reach)
      Set the function inlining policy for the compiler.
    • getInlineFunctionsLevel Link icon

      public CompilerOptions.Reach getInlineFunctionsLevel()
      Get the function inlining policy for the compiler.
    • setMaxFunctionSizeAfterInlining Link icon

      public void setMaxFunctionSizeAfterInlining(int funAstSize)
    • setInlineVariables Link icon

      public void setInlineVariables(boolean inlineVariables)
    • setInlineVariables Link icon

      public void setInlineVariables(CompilerOptions.Reach reach)
      Set the variable inlining policy for the compiler.
    • setInlineProperties Link icon

      public void setInlineProperties(boolean enable)
      Set the function inlining policy for the compiler.
    • shouldInlineProperties Link icon

      public boolean shouldInlineProperties()
    • setRemoveUnusedVariables Link icon

      public void setRemoveUnusedVariables(CompilerOptions.Reach reach)
      Set the variable removal policy for the compiler.
    • setReplaceStringsConfiguration Link icon

      public void setReplaceStringsConfiguration(String placeholderToken, List<String> functionDescriptors)
      Sets the functions whose debug strings to replace.
    • setRemoveAbstractMethods Link icon

      public void setRemoveAbstractMethods(boolean remove)
    • setRemoveClosureAsserts Link icon

      public void setRemoveClosureAsserts(boolean remove)
    • setRemoveJ2clAsserts Link icon

      public void setRemoveJ2clAsserts(boolean remove)
    • setColorizeErrorOutput Link icon

      public void setColorizeErrorOutput(boolean colorizeErrorOutput)
    • shouldColorizeErrorOutput Link icon

      public boolean shouldColorizeErrorOutput()
    • setChecksOnly Link icon

      public void setChecksOnly(boolean checksOnly)
    • setOutputJs Link icon

      public void setOutputJs(CompilerOptions.OutputJs outputJs)
    • setGenerateExports Link icon

      public void setGenerateExports(boolean generateExports)
    • setExportLocalPropertyDefinitions Link icon

      public void setExportLocalPropertyDefinitions(boolean export)
    • shouldExportLocalPropertyDefinitions Link icon

      public boolean shouldExportLocalPropertyDefinitions()
    • setAngularPass Link icon

      public void setAngularPass(boolean angularPass)
    • setPolymerVersion Link icon

      public void setPolymerVersion(Integer polymerVersion)
    • setChromePass Link icon

      public void setChromePass(boolean chromePass)
    • isChromePassEnabled Link icon

      public boolean isChromePassEnabled()
    • setJ2clPass Link icon

      public void setJ2clPass(CompilerOptions.J2clPassMode j2clPassMode)
    • setJ2clMinifierEnabled Link icon

      public void setJ2clMinifierEnabled(boolean enabled)
    • setJ2clMinifierPruningManifest Link icon

      public void setJ2clMinifierPruningManifest(String j2clMinifierPruningManifest)
    • setCodingConvention Link icon

      public void setCodingConvention(CodingConvention codingConvention)
    • getCodingConvention Link icon

      public CodingConvention getCodingConvention()
    • setDependencyOptions Link icon

      public void setDependencyOptions(DependencyOptions dependencyOptions)
      Sets the dependency management options.
    • getDependencyOptions Link icon

      public DependencyOptions getDependencyOptions()
    • setSummaryDetailLevel Link icon

      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), 3 (always print summary). The default level is 1
    • setExtraAnnotationNames Link icon

      public void setExtraAnnotationNames(Iterable<String> extraAnnotationNames)
    • setOutputCharset Link icon

      public void setOutputCharset(Charset charset)
      Sets the output charset.
    • setTweakProcessing Link icon

      public void setTweakProcessing(CompilerOptions.TweakProcessing tweakProcessing)
      Sets how goog.tweak calls are processed.
    • getTweakProcessing Link icon

      public CompilerOptions.TweakProcessing getTweakProcessing()
    • setLanguage Link icon

      public void setLanguage(CompilerOptions.LanguageMode language)
      Sets ECMAScript version to use.
    • setLanguageIn Link icon

      public void setLanguageIn(CompilerOptions.LanguageMode languageIn)
      Sets ECMAScript version to use for the input. If you are not transpiling from one version to another, use #setLanguage instead.
    • getLanguageIn Link icon

      public CompilerOptions.LanguageMode getLanguageIn()
    • setLanguageOut Link icon

      public void setLanguageOut(CompilerOptions.LanguageMode languageOut)
      Sets ECMAScript version to use for the output.

      If you are not transpiling from one version to another, use #setLanguage instead.

      If you you need something more fine grained (e.g. "ES2017 without modules") use #setOutputFeatureSet.

    • legacySetOutputFeatureSet Link icon

      public void legacySetOutputFeatureSet(FeatureSet featureSet)
    • getOutputFeatureSet Link icon

      public FeatureSet getOutputFeatureSet()
      Gets the set of features that can appear in the output.
    • setExperimentalForceTranspiles Link icon

      public void setExperimentalForceTranspiles(CompilerOptions.ExperimentalForceTranspile... experimentalForceTranspile)
    • getExperimentalForceTranspiles Link icon

      public com.google.common.collect.ImmutableList<CompilerOptions.ExperimentalForceTranspile> getExperimentalForceTranspiles()
    • needsTranspilationFrom Link icon

      public boolean needsTranspilationFrom(FeatureSet languageLevel)
    • needsTranspilationOf Link icon

      public boolean needsTranspilationOf(FeatureSet.Feature feature)
    • setEnvironment Link icon

      public void setEnvironment(CompilerOptions.Environment environment)
      Set which set of builtin externs to use.
    • getEnvironment Link icon

      public CompilerOptions.Environment getEnvironment()
    • setAliasTransformationHandler Link icon

      public void setAliasTransformationHandler(CompilerOptions.AliasTransformationHandler changes)
    • getAliasTransformationHandler Link icon

      public CompilerOptions.AliasTransformationHandler getAliasTransformationHandler()
    • setErrorHandler Link icon

      public void setErrorHandler(ErrorHandler handler)
      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 Link icon

      public void setInferTypes(boolean enable)
      If true, enables type inference. If checkTypes is enabled, this flag has no effect.
    • getInferTypes Link icon

      public boolean getInferTypes()
      Gets the inferTypes flag. Note that if checkTypes is enabled, this flag is ignored when configuring the compiler.
    • setNewTypeInference Link icon

      @Deprecated public void setNewTypeInference(boolean enable)
      Deprecated.
      This is a no-op.
    • isTypecheckingEnabled Link icon

      public boolean isTypecheckingEnabled()
      Returns:
      true if either typechecker is ON.
    • assumeStrictThis Link icon

      public boolean assumeStrictThis()
      Returns:
      Whether assumeStrictThis is set.
    • setAssumeStrictThis Link icon

      public void setAssumeStrictThis(boolean enable)
      If true, enables enables additional optimizations.
    • assumeClosuresOnlyCaptureReferences Link icon

      public boolean assumeClosuresOnlyCaptureReferences()
      Returns:
      Whether assumeClosuresOnlyCaptureReferences is set.
    • setAssumeClosuresOnlyCaptureReferences Link icon

      public void setAssumeClosuresOnlyCaptureReferences(boolean enable)
      Whether to assume closures capture only what they reference. This allows more aggressive function inlining.
    • setPropertiesThatMustDisambiguate Link icon

      public void setPropertiesThatMustDisambiguate(Set<String> names)
      Sets the list of properties that we report property invalidation errors for.
    • getPropertiesThatMustDisambiguate Link icon

      public com.google.common.collect.ImmutableSet<String> getPropertiesThatMustDisambiguate()
    • setPreserveDetailedSourceInfo Link icon

      public void setPreserveDetailedSourceInfo(boolean preserveDetailedSourceInfo)
    • setPreserveNonJSDocComments Link icon

      public void setPreserveNonJSDocComments(boolean preserveNonJSDocComments)
    • setContinueAfterErrors Link icon

      public void setContinueAfterErrors(boolean continueAfterErrors)
    • setParseJsDocDocumentation Link icon

      public void setParseJsDocDocumentation(Config.JsDocParsing parseJsDocDocumentation)
      Enables or disables the parsing of JSDoc documentation, and optionally also the preservation of all whitespace and formatting within a JSDoc comment. By default, whitespace is collapsed for all comments except @license and @preserve blocks,
    • isParseJsDocDocumentation Link icon

      public Config.JsDocParsing isParseJsDocDocumentation()
      Checks JSDoc documentation will be parsed.
      Returns:
      True when JSDoc documentation will be parsed, false if not.
    • setSkipNonTranspilationPasses Link icon

      public void setSkipNonTranspilationPasses(boolean skipNonTranspilationPasses)
      Skip all passes (other than transpilation, if requested). Don't inject any runtime libraries (unless explicitly requested) or do any checks/optimizations (this is useful for per-file transpilation).
    • setDevMode Link icon

      public void setDevMode(CompilerOptions.DevMode devMode)
    • setCheckDeterminism Link icon

      public void setCheckDeterminism(boolean checkDeterminism)
    • getCheckDeterminism Link icon

      public boolean getCheckDeterminism()
    • setMessageBundle Link icon

      public void setMessageBundle(MessageBundle messageBundle)
    • setCheckSymbols Link icon

      public void setCheckSymbols(boolean checkSymbols)
    • setCheckSuspiciousCode Link icon

      public void setCheckSuspiciousCode(boolean checkSuspiciousCode)
    • setCheckTypes Link icon

      public void setCheckTypes(boolean checkTypes)
    • setFoldConstants Link icon

      public void setFoldConstants(boolean foldConstants)
    • setDeadAssignmentElimination Link icon

      public void setDeadAssignmentElimination(boolean deadAssignmentElimination)
    • setInlineConstantVars Link icon

      public void setInlineConstantVars(boolean inlineConstantVars)
    • setCrossChunkCodeMotion Link icon

      public void setCrossChunkCodeMotion(boolean crossChunkCodeMotion)
    • setCrossChunkCodeMotionNoStubMethods Link icon

      public void setCrossChunkCodeMotionNoStubMethods(boolean crossChunkCodeMotionNoStubMethods)
    • setParentChunkCanSeeSymbolsDeclaredInChildren Link icon

      public void setParentChunkCanSeeSymbolsDeclaredInChildren(boolean parentChunkCanSeeSymbolsDeclaredInChildren)
    • setCrossChunkMethodMotion Link icon

      public void setCrossChunkMethodMotion(boolean crossChunkMethodMotion)
    • setCoalesceVariableNames Link icon

      public void setCoalesceVariableNames(boolean coalesceVariableNames)
    • setInlineLocalVariables Link icon

      public void setInlineLocalVariables(boolean inlineLocalVariables)
    • setFlowSensitiveInlineVariables Link icon

      public void setFlowSensitiveInlineVariables(boolean enabled)
    • setSmartNameRemoval Link icon

      public void setSmartNameRemoval(boolean smartNameRemoval)
    • setExtractPrototypeMemberDeclarations Link icon

      public void setExtractPrototypeMemberDeclarations(boolean enabled)
    • setExtractPrototypeMemberDeclarations Link icon

      public void setExtractPrototypeMemberDeclarations(CompilerOptions.ExtractPrototypeMemberDeclarationsMode mode)
    • setRemoveUnusedPrototypeProperties Link icon

      public void setRemoveUnusedPrototypeProperties(boolean enabled)
    • setCollapseVariableDeclarations Link icon

      public void setCollapseVariableDeclarations(boolean enabled)
    • setCollapseAnonymousFunctions Link icon

      public void setCollapseAnonymousFunctions(boolean enabled)
    • setAliasStringsMode Link icon

      public void setAliasStringsMode(CompilerOptions.AliasStringsMode aliasStringsMode)
    • getAliasStringsMode Link icon

      public CompilerOptions.AliasStringsMode getAliasStringsMode()
    • setOutputJsStringUsage Link icon

      public void setOutputJsStringUsage(boolean outputJsStringUsage)
    • setConvertToDottedProperties Link icon

      public void setConvertToDottedProperties(boolean convertToDottedProperties)
    • setUseTypesForLocalOptimization Link icon

      public void setUseTypesForLocalOptimization(boolean useTypesForLocalOptimization)
    • shouldUseTypesForLocalOptimization Link icon

      public boolean shouldUseTypesForLocalOptimization()
    • setUseTypesForOptimization Link icon

      @Deprecated public void setUseTypesForOptimization(boolean useTypesForOptimization)
      Deprecated.
    • setRewriteFunctionExpressions Link icon

      public void setRewriteFunctionExpressions(boolean rewriteFunctionExpressions)
    • setOptimizeCalls Link icon

      public void setOptimizeCalls(boolean optimizeCalls)
    • getOptimizeESClassConstructors Link icon

      public boolean getOptimizeESClassConstructors()
    • setOptimizeESClassConstructors Link icon

      public void setOptimizeESClassConstructors(boolean optimizeESClassConstructors)
    • setVariableRenaming Link icon

      public void setVariableRenaming(VariableRenamingPolicy variableRenaming)
    • setPropertyRenaming Link icon

      public void setPropertyRenaming(PropertyRenamingPolicy propertyRenaming)
    • getPropertyRenaming Link icon

      public PropertyRenamingPolicy getPropertyRenaming()
    • setLabelRenaming Link icon

      public void setLabelRenaming(boolean labelRenaming)
    • setReserveRawExports Link icon

      public void setReserveRawExports(boolean reserveRawExports)
    • setPreferStableNames Link icon

      public void setPreferStableNames(boolean preferStableNames)
    • setGeneratePseudoNames Link icon

      public void setGeneratePseudoNames(boolean generatePseudoNames)
    • setPropertyRenamingOnlyCompilationMode Link icon

      public void setPropertyRenamingOnlyCompilationMode(boolean propertyRenamingOnlyCompilationMode)
    • isPropertyRenamingOnlyCompilationMode Link icon

      public boolean isPropertyRenamingOnlyCompilationMode()
    • setRenamePrefix Link icon

      public void setRenamePrefix(String renamePrefix)
    • getRenamePrefixNamespace Link icon

      public String getRenamePrefixNamespace()
    • setRenamePrefixNamespace Link icon

      public void setRenamePrefixNamespace(String renamePrefixNamespace)
    • setCollapsePropertiesLevel Link icon

      public void setCollapsePropertiesLevel(CompilerOptions.PropertyCollapseLevel level)
    • setCollapseProperties Link icon

      @Deprecated public void setCollapseProperties(boolean fullyCollapse)
      Deprecated.
    • setDevirtualizeMethods Link icon

      public void setDevirtualizeMethods(boolean devirtualizeMethods)
    • setComputeFunctionSideEffects Link icon

      public void setComputeFunctionSideEffects(boolean computeFunctionSideEffects)
    • setDisambiguateProperties Link icon

      public void setDisambiguateProperties(boolean disambiguateProperties)
    • shouldDisambiguateProperties Link icon

      public boolean shouldDisambiguateProperties()
    • setAmbiguateProperties Link icon

      public void setAmbiguateProperties(boolean ambiguateProperties)
    • shouldAmbiguateProperties Link icon

      public boolean shouldAmbiguateProperties()
    • setInputVariableMap Link icon

      public void setInputVariableMap(VariableMap inputVariableMap)
    • setInputPropertyMap Link icon

      public void setInputPropertyMap(VariableMap inputPropertyMap)
    • setExportTestFunctions Link icon

      public void setExportTestFunctions(boolean exportTestFunctions)
    • setSyntheticBlockStartMarker Link icon

      public void setSyntheticBlockStartMarker(String syntheticBlockStartMarker)
    • setSyntheticBlockEndMarker Link icon

      public void setSyntheticBlockEndMarker(String syntheticBlockEndMarker)
    • setLocale Link icon

      public void setLocale(String locale)
    • setDoLateLocalization Link icon

      public void setDoLateLocalization(boolean doLateLocalization)
    • doLateLocalization Link icon

      public boolean doLateLocalization()
    • shouldRunReplaceMessagesPass Link icon

      public boolean shouldRunReplaceMessagesPass()
      Should we run any form of the `ReplaceMessages` pass?
    • setMarkAsCompiled Link icon

      public void setMarkAsCompiled(boolean markAsCompiled)
    • setClosurePass Link icon

      public void setClosurePass(boolean closurePass)
    • setPreserveClosurePrimitives Link icon

      public void setPreserveClosurePrimitives(boolean preserveClosurePrimitives)
      Preserve closure primitives.

      For now, this only preserves goog.provide(), goog.require() and goog.module() calls.

    • shouldPreservesGoogProvidesAndRequires Link icon

      public boolean shouldPreservesGoogProvidesAndRequires()
    • shouldPreserveGoogModule Link icon

      public boolean shouldPreserveGoogModule()
    • shouldPreserveGoogLibraryPrimitives Link icon

      public boolean shouldPreserveGoogLibraryPrimitives()
      Do not process goog. intrinsics, such as goog.getCssName().
    • setPreserveTypeAnnotations Link icon

      public void setPreserveTypeAnnotations(boolean preserveTypeAnnotations)
    • setGentsMode Link icon

      public void setGentsMode(boolean gentsMode)
    • setGatherCssNames Link icon

      public void setGatherCssNames(boolean gatherCssNames)
    • setStripTypes Link icon

      @Deprecated public void setStripTypes(Set<String> stripTypes)
      Deprecated.
      StripCode is deprecated. Code should be designed to be removed by other means.
    • getStripTypes Link icon

      @Deprecated public com.google.common.collect.ImmutableSet<String> getStripTypes()
      Deprecated.
      StripCode is deprecated. Code should be designed to be removed by other means.
    • setStripNameSuffixes Link icon

      @Deprecated public void setStripNameSuffixes(Set<String> stripNameSuffixes)
      Deprecated.
      StripCode is deprecated. Code should be designed to be removed by other means.
    • setStripNamePrefixes Link icon

      @Deprecated public void setStripNamePrefixes(Set<String> stripNamePrefixes)
      Deprecated.
      StripCode is deprecated. Code should be designed to be removed by other means.
    • addCustomPass Link icon

      public void addCustomPass(CustomPassExecutionTime time, CompilerPass customPass)
    • setDefineReplacements Link icon

      public void setDefineReplacements(Map<String,Object> defineReplacements)
    • getEnableZonesDefineName Link icon

      public @Nullable String getEnableZonesDefineName()
    • setEnableZonesDefineName Link icon

      public void setEnableZonesDefineName(@Nullable String enableZonesDefineName)
    • getZoneInputPattern Link icon

      public @Nullable Pattern getZoneInputPattern()
    • setZoneInputPattern Link icon

      public void setZoneInputPattern(@Nullable Pattern zoneInputPattern)
    • setRewriteGlobalDeclarationsForTryCatchWrapping Link icon

      public void setRewriteGlobalDeclarationsForTryCatchWrapping(boolean rewrite)
    • setCssRenamingMap Link icon

      public void setCssRenamingMap(CssRenamingMap cssRenamingMap)
    • setCssRenamingSkiplist Link icon

      public void setCssRenamingSkiplist(Set<String> skiplist)
    • setReplaceStringsFunctionDescriptions Link icon

      public void setReplaceStringsFunctionDescriptions(List<String> replaceStringsFunctionDescriptions)
    • setReplaceStringsPlaceholderToken Link icon

      public void setReplaceStringsPlaceholderToken(String replaceStringsPlaceholderToken)
    • setPrettyPrint Link icon

      public void setPrettyPrint(boolean prettyPrint)
    • isPrettyPrint Link icon

      public boolean isPrettyPrint()
    • setLineBreak Link icon

      public void setLineBreak(boolean lineBreak)
    • setPrintInputDelimiter Link icon

      public void setPrintInputDelimiter(boolean printInputDelimiter)
    • setInputDelimiter Link icon

      public void setInputDelimiter(String inputDelimiter)
    • setDebugLogDirectory Link icon

      public void setDebugLogDirectory(@Nullable Path dir)
    • getDebugLogDirectory Link icon

      public @Nullable Path getDebugLogDirectory()
    • setDebugLogFilter Link icon

      public void setDebugLogFilter(String filter)
    • getDebugLogFilter Link icon

      public String getDebugLogFilter()
    • setQuoteKeywordProperties Link icon

      public void setQuoteKeywordProperties(boolean quoteKeywordProperties)
    • shouldQuoteKeywordProperties Link icon

      public boolean shouldQuoteKeywordProperties()
    • setErrorFormat Link icon

      public void setErrorFormat(ErrorFormat errorFormat)
    • getErrorFormat Link icon

      public ErrorFormat getErrorFormat()
    • setWarningsGuard Link icon

      public void setWarningsGuard(ComposeWarningsGuard warningsGuard)
    • setLineLengthThreshold Link icon

      public void setLineLengthThreshold(int lineLengthThreshold)
    • getLineLengthThreshold Link icon

      public int getLineLengthThreshold()
    • setUseOriginalNamesInOutput Link icon

      public void setUseOriginalNamesInOutput(boolean useOriginalNamesInOutput)
    • getUseOriginalNamesInOutput Link icon

      public boolean getUseOriginalNamesInOutput()
    • setExternExportsPath Link icon

      public void setExternExportsPath(@Nullable String externExportsPath)
    • getExternExportsPath Link icon

      public @Nullable String getExternExportsPath()
    • setSourceMapOutputPath Link icon

      public void setSourceMapOutputPath(String sourceMapOutputPath)
    • setApplyInputSourceMaps Link icon

      public void setApplyInputSourceMaps(boolean applyInputSourceMaps)
    • setResolveSourceMapAnnotations Link icon

      public void setResolveSourceMapAnnotations(boolean resolveSourceMapAnnotations)
    • setSourceMapIncludeSourcesContent Link icon

      public void setSourceMapIncludeSourcesContent(boolean sourceMapIncludeSourcesContent)
    • setParseInlineSourceMaps Link icon

      public void setParseInlineSourceMaps(boolean parseInlineSourceMaps)
    • setSourceMapDetailLevel Link icon

      public void setSourceMapDetailLevel(SourceMap.DetailLevel sourceMapDetailLevel)
    • setSourceMapFormat Link icon

      public void setSourceMapFormat(SourceMap.Format sourceMapFormat)
    • setSourceMapLocationMappings Link icon

      public void setSourceMapLocationMappings(List<? extends SourceMap.LocationMapping> sourceMapLocationMappings)
    • setProcessCommonJSModules Link icon

      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.
    • getProcessCommonJSModules Link icon

      public boolean getProcessCommonJSModules()
    • setEs6ModuleTranspilation Link icon

      public void setEs6ModuleTranspilation(CompilerOptions.Es6ModuleTranspilation value)
    • getEs6ModuleTranspilation Link icon

      public CompilerOptions.Es6ModuleTranspilation getEs6ModuleTranspilation()
    • setCommonJSModulePathPrefix Link icon

      public void setCommonJSModulePathPrefix(String commonJSModulePathPrefix)
      Sets a path prefix for CommonJS modules (maps to setModuleRoots(List)).
    • setModuleRoots Link icon

      public void setModuleRoots(List<String> moduleRoots)
      Sets the module roots.
    • setRewritePolyfills Link icon

      public void setRewritePolyfills(boolean rewritePolyfills)
      Sets whether to rewrite polyfills.
    • getRewritePolyfills Link icon

      public boolean getRewritePolyfills()
    • setIsolatePolyfills Link icon

      public void setIsolatePolyfills(boolean isolatePolyfills)
      Sets whether to isolate polyfills from the global scope.
    • getIsolatePolyfills Link icon

      public boolean getIsolatePolyfills()
    • setInjectPolyfillsNewerThan Link icon

      public void setInjectPolyfillsNewerThan(CompilerOptions.LanguageMode injectPolyfillsNewerThan)
    • setInstrumentAsyncContext Link icon

      public void setInstrumentAsyncContext(boolean instrumentAsyncContext)
      Sets whether to transpile async functions and generators for AsyncContext.
    • getInstrumentAsyncContext Link icon

      public boolean getInstrumentAsyncContext()
    • setDiagnoseAsyncContextSafariCrash Link icon

      public void setDiagnoseAsyncContextSafariCrash(boolean diagnose)
      Sets whether to diagnose the Safari crash in async context instrumentation.
    • setForceLibraryInjection Link icon

      public void setForceLibraryInjection(Iterable<String> libraries)
      Sets list of libraries to always inject, even if not needed.
    • setPreventLibraryInjection Link icon

      public void setPreventLibraryInjection(boolean preventLibraryInjection)
      Sets the set of libraries to never inject, even if required.
    • setUnusedImportsToRemove Link icon

      public void setUnusedImportsToRemove(@Nullable com.google.common.collect.ImmutableSet<String> unusedImportsToRemove)
    • getUnusedImportsToRemove Link icon

      public @Nullable com.google.common.collect.ImmutableSet<String> getUnusedImportsToRemove()
    • setInstrumentForCoverageOption Link icon

      public void setInstrumentForCoverageOption(CompilerOptions.InstrumentOption instrumentForCoverageOption)
    • getInstrumentForCoverageOption Link icon

      public CompilerOptions.InstrumentOption getInstrumentForCoverageOption()
    • setProductionInstrumentationArrayName Link icon

      public void setProductionInstrumentationArrayName(String productionInstrumentationArrayName)
      Sets the name for the global array which is used by PRODUCTION instrumentation. The array is declared during the instrumentation pass with the name provided through this setter.
    • getProductionInstrumentationArrayName Link icon

      public String getProductionInstrumentationArrayName()
    • getConformanceConfigs Link icon

      public final com.google.common.collect.ImmutableList<com.google.javascript.jscomp.ConformanceConfig> getConformanceConfigs()
    • setConformanceConfig Link icon

      @Deprecated public void setConformanceConfig(com.google.javascript.jscomp.ConformanceConfig conformanceConfig)
      Deprecated.
      See go/binary-level-conformance-deprecated.
      Both enable and configure conformance checks, if non-null.
    • setConformanceConfigs Link icon

      @Deprecated public void setConformanceConfigs(List<com.google.javascript.jscomp.ConformanceConfig> configs)
      Deprecated.
      See go/binary-level-conformance-deprecated.
      Both enable and configure conformance checks, if non-null.
    • clearConformanceConfigs Link icon

      public void clearConformanceConfigs()
    • shouldEmitUseStrict Link icon

      public boolean shouldEmitUseStrict()
      Whether the output should contain a 'use strict' directive.
    • setEmitUseStrict Link icon

      @CanIgnoreReturnValue public CompilerOptions setEmitUseStrict(boolean emitUseStrict)
    • getModuleResolutionMode Link icon

      public ModuleLoader.ResolutionMode getModuleResolutionMode()
    • setModuleResolutionMode Link icon

      public void setModuleResolutionMode(ModuleLoader.ResolutionMode moduleResolutionMode)
    • getBrowserResolverPrefixReplacements Link icon

      public com.google.common.collect.ImmutableMap<String,String> getBrowserResolverPrefixReplacements()
    • setBrowserResolverPrefixReplacements Link icon

      public void setBrowserResolverPrefixReplacements(com.google.common.collect.ImmutableMap<String,String> browserResolverPrefixReplacements)
    • setPathEscaper Link icon

      public void setPathEscaper(ModuleLoader.PathEscaper pathEscaper)
    • getPathEscaper Link icon

      public ModuleLoader.PathEscaper getPathEscaper()
    • getPackageJsonEntryNames Link icon

      public List<String> getPackageJsonEntryNames()
    • setPackageJsonEntryNames Link icon

      public void setPackageJsonEntryNames(List<String> names)
    • setUseSizeHeuristicToStopOptimizationLoop Link icon

      public void setUseSizeHeuristicToStopOptimizationLoop(boolean mayStopEarly)
    • setMaxOptimizationLoopIterations Link icon

      public void setMaxOptimizationLoopIterations(int maxIterations)
    • getChunkOutputType Link icon

      public CompilerOptions.ChunkOutputType getChunkOutputType()
    • setChunkOutputType Link icon

      public void setChunkOutputType(CompilerOptions.ChunkOutputType chunkOutputType)
    • setStrictMessageReplacement Link icon

      public void setStrictMessageReplacement(boolean strictMessageReplacement)
    • getStrictMessageReplacement Link icon

      public boolean getStrictMessageReplacement()
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • expectStrictModeInput Link icon

      public boolean expectStrictModeInput()
    • setStrictModeInput Link icon

      @CanIgnoreReturnValue public CompilerOptions setStrictModeInput(boolean isStrictModeInput)
    • getPropertyReservedNamingFirstChars Link icon

      public char[] getPropertyReservedNamingFirstChars()
    • getPropertyReservedNamingNonFirstChars Link icon

      public char[] getPropertyReservedNamingNonFirstChars()