org.mozilla.javascript

## Class CompilerEnvirons

- java.lang.Object
- - org.mozilla.javascript.CompilerEnvirons

-     public class CompilerEnvirons
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompilerEnvirons()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Set<java.lang.String>` | `getActivationNames()`
    `boolean` | `getAllowSharpComments()`
    `ErrorReporter` | `getErrorReporter()`
    `int` | `getLanguageVersion()`
    `int` | `getOptimizationLevel()`
    `boolean` | `getWarnTrailingComma()`
    `static CompilerEnvirons` | `ideEnvirons()` Returns a `CompilerEnvirons` suitable for using Rhino in an IDE environment.
    `void` | `initFromContext(Context cx)`
    `boolean` | `isAllowMemberExprAsFunctionName()` Extension to ECMA: if 'function <name>' is not followed by '(', assume <name> starts a `memberExpr`
    `boolean` | `isGenerateDebugInfo()`
    `boolean` | `isGenerateObserverCount()`
    `boolean` | `isGeneratingSource()`
    `boolean` | `isIdeMode()`
    `boolean` | `isRecordingComments()`
    `boolean` | `isRecordingLocalJsDocComments()`
    `boolean` | `isReservedKeywordAsIdentifier()`
    `boolean` | `isStrictMode()`
    `boolean` | `isXmlAvailable()`
    `boolean` | `recoverFromErrors()`
    `boolean` | `reportWarningAsError()`
    `void` | `setActivationNames(java.util.Set<java.lang.String> activationNames)`
    `void` | `setAllowMemberExprAsFunctionName(boolean flag)`
    `void` | `setAllowSharpComments(boolean allow)` Mozilla sources use the C preprocessor.
    `void` | `setErrorReporter(ErrorReporter errorReporter)`
    `void` | `setGenerateDebugInfo(boolean flag)`
    `void` | `setGenerateObserverCount(boolean generateObserverCount)` Turn on or off generation of code with callbacks to track the count of executed instructions.
    `void` | `setGeneratingSource(boolean generatingSource)` Specify whether or not source information should be generated.
    `void` | `setIdeMode(boolean ide)` Puts the parser in "IDE" mode.
    `void` | `setLanguageVersion(int languageVersion)`
    `void` | `setOptimizationLevel(int level)`
    `void` | `setRecordingComments(boolean record)`
    `void` | `setRecordingLocalJsDocComments(boolean record)`
    `void` | `setRecoverFromErrors(boolean recover)` Turn on or off full error recovery.
    `void` | `setReservedKeywordAsIdentifier(boolean flag)`
    `void` | `setStrictMode(boolean strict)`
    `void` | `setWarnTrailingComma(boolean warn)`
    `void` | `setXmlAvailable(boolean flag)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CompilerEnvirons

          public CompilerEnvirons()

  - ### Method Detail

    - #### initFromContext

          public void initFromContext(Context cx)

    - #### getErrorReporter

          public final ErrorReporter getErrorReporter()

    - #### setErrorReporter

          public void setErrorReporter(ErrorReporter errorReporter)

    - #### getLanguageVersion

          public final int getLanguageVersion()

    - #### setLanguageVersion

          public void setLanguageVersion(int languageVersion)

    - #### isGenerateDebugInfo

          public final boolean isGenerateDebugInfo()

    - #### setGenerateDebugInfo

          public void setGenerateDebugInfo(boolean flag)

    - #### isReservedKeywordAsIdentifier

          public final boolean isReservedKeywordAsIdentifier()

    - #### setReservedKeywordAsIdentifier

          public void setReservedKeywordAsIdentifier(boolean flag)

    - #### isAllowMemberExprAsFunctionName

          public final boolean isAllowMemberExprAsFunctionName()

      Extension to ECMA: if 'function <name>' is not followed by '(', assume <name> starts a `memberExpr`

    - #### setAllowMemberExprAsFunctionName

          public void setAllowMemberExprAsFunctionName(boolean flag)

    - #### isXmlAvailable

          public final boolean isXmlAvailable()

    - #### setXmlAvailable

          public void setXmlAvailable(boolean flag)

    - #### getOptimizationLevel

          public final int getOptimizationLevel()

    - #### setOptimizationLevel

          public void setOptimizationLevel(int level)

    - #### isGeneratingSource

          public final boolean isGeneratingSource()

    - #### getWarnTrailingComma

          public boolean getWarnTrailingComma()

    - #### setWarnTrailingComma

          public void setWarnTrailingComma(boolean warn)

    - #### isStrictMode

          public final boolean isStrictMode()

    - #### setStrictMode

          public void setStrictMode(boolean strict)

    - #### reportWarningAsError

          public final boolean reportWarningAsError()

    - #### setGeneratingSource

          public void setGeneratingSource(boolean generatingSource)

      Specify whether or not source information should be generated.

      Without source information, evaluating the "toString" method on JavaScript functions produces only "[native code]" for the body of the function. Note that code generated without source is not fully ECMA conformant.

    - #### isGenerateObserverCount

          public boolean isGenerateObserverCount()

      Returns:
        true iff code will be generated with callbacks to enable instruction thresholds

    - #### setGenerateObserverCount

          public void setGenerateObserverCount(boolean generateObserverCount)

      Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.
      Parameters:
        `generateObserverCount` - if true, generated code will contain calls to accumulate an estimate of the instructions executed.

    - #### isRecordingComments

          public boolean isRecordingComments()

    - #### setRecordingComments

          public void setRecordingComments(boolean record)

    - #### isRecordingLocalJsDocComments

          public boolean isRecordingLocalJsDocComments()

    - #### setRecordingLocalJsDocComments

          public void setRecordingLocalJsDocComments(boolean record)

    - #### setRecoverFromErrors

          public void setRecoverFromErrors(boolean recover)

      Turn on or off full error recovery. In this mode, parse errors do not throw an exception, and the parser attempts to build a full syntax tree from the input. Useful for IDEs and other frontends.

    - #### recoverFromErrors

          public boolean recoverFromErrors()

    - #### setIdeMode

          public void setIdeMode(boolean ide)

      Puts the parser in "IDE" mode. This enables some slightly more expensive computations, such as figuring out helpful error bounds.

    - #### isIdeMode

          public boolean isIdeMode()

    - #### getActivationNames

          public java.util.Set<java.lang.String> getActivationNames()

    - #### setActivationNames

          public void setActivationNames(java.util.Set<java.lang.String> activationNames)

    - #### setAllowSharpComments

          public void setAllowSharpComments(boolean allow)

      Mozilla sources use the C preprocessor.

    - #### getAllowSharpComments

          public boolean getAllowSharpComments()

    - #### ideEnvirons

          public static CompilerEnvirons ideEnvirons()

      Returns a `CompilerEnvirons` suitable for using Rhino in an IDE environment. Most features are enabled by default. The `ErrorReporter` is set to an `ErrorCollector`.