Java Code Examples for com.google.javascript.jscomp.CompilerOptions.LanguageMode#ECMASCRIPT5_STRICT

The following examples show how to use com.google.javascript.jscomp.CompilerOptions.LanguageMode#ECMASCRIPT5_STRICT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultPassConfig.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected CompilerPass create(AbstractCompiler compiler) {
  boolean enableBlockInlining = !isInliningForbidden();
  return new InlineFunctions(
      compiler,
      compiler.getUniqueNameIdSupplier(),
      options.inlineFunctions,
      options.inlineLocalFunctions,
      enableBlockInlining,
      options.assumeStrictThis()
          || options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT,
      true /* assumeMinimumCapture */);
}
 
Example 2
Source File: Closure_59_Compiler_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn()) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}
 
Example 3
Source File: Closure_59_Compiler_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn() &&
      !options.disables(DiagnosticGroups.GLOBAL_THIS)) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}
 
Example 4
Source File: Closure_18_Compiler_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn() &&
      !options.disables(DiagnosticGroups.GLOBAL_THIS)) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}
 
Example 5
Source File: Closure_18_Compiler_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn() &&
      !options.disables(DiagnosticGroups.GLOBAL_THIS)) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}
 
Example 6
Source File: Closure_31_Compiler_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn() &&
      !options.disables(DiagnosticGroups.GLOBAL_THIS)) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}
 
Example 7
Source File: Closure_31_Compiler_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn() &&
      !options.disables(DiagnosticGroups.GLOBAL_THIS)) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}
 
Example 8
Source File: Compiler.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the compiler options. Only necessary if you're not doing
 * a normal compile() job.
 */
public void initOptions(CompilerOptions options) {
  this.options = options;
  if (errorManager == null) {
    if (outStream == null) {
      setErrorManager(
          new LoggerErrorManager(createMessageFormatter(), logger));
    } else {
      PrintStreamErrorManager printer =
          new PrintStreamErrorManager(createMessageFormatter(), outStream);
      printer.setSummaryDetailLevel(options.summaryDetailLevel);
      setErrorManager(printer);
    }
  }

  // DiagnosticGroups override the plain checkTypes option.
  if (options.enables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = true;
  } else if (options.disables(DiagnosticGroups.CHECK_TYPES)) {
    options.checkTypes = false;
  } else if (!options.checkTypes) {
    // If DiagnosticGroups did not override the plain checkTypes
    // option, and checkTypes is enabled, then turn off the
    // parser type warnings.
    options.setWarningLevel(
        DiagnosticGroup.forType(
            RhinoErrorReporter.TYPE_PARSE_ERROR),
        CheckLevel.OFF);
  }

  if (options.checkGlobalThisLevel.isOn() &&
      !options.disables(DiagnosticGroups.GLOBAL_THIS)) {
    options.setWarningLevel(
        DiagnosticGroups.GLOBAL_THIS,
        options.checkGlobalThisLevel);
  }

  if (options.getLanguageIn() == LanguageMode.ECMASCRIPT5_STRICT) {
    options.setWarningLevel(
        DiagnosticGroups.ES5_STRICT,
        CheckLevel.ERROR);
  }

  // Initialize the warnings guard.
  List<WarningsGuard> guards = Lists.newArrayList();
  guards.add(
      new SuppressDocWarningsGuard(
          getDiagnosticGroups().getRegisteredGroups()));
  guards.add(options.getWarningsGuard());

  ComposeWarningsGuard composedGuards = new ComposeWarningsGuard(guards);

  // All passes must run the variable check. This synthesizes
  // variables later so that the compiler doesn't crash. It also
  // checks the externs file for validity. If you don't want to warn
  // about missing variable declarations, we shut that specific
  // error off.
  if (!options.checkSymbols &&
      !composedGuards.enables(DiagnosticGroups.CHECK_VARIABLES)) {
    composedGuards.addGuard(new DiagnosticGroupWarningsGuard(
        DiagnosticGroups.CHECK_VARIABLES, CheckLevel.OFF));
  }

  this.warningsGuard = composedGuards;
}