• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.javascript.jscomp.parsing.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Config类属于com.google.javascript.jscomp.parsing包,在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCompilerOptions

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
public CompilerOptions getCompilerOptions() {
  final CompilerOptions options = new CompilerOptions();
  options.setClosurePass(true);

  options.setCheckGlobalNamesLevel(CheckLevel.ERROR);
  // Report duplicate definitions, e.g. for accidentally duplicated externs.
  options.setWarningLevel(DiagnosticGroups.DUPLICATE_VARS, CheckLevel.ERROR);

  options.setLanguage(CompilerOptions.LanguageMode.ECMASCRIPT_2015);
  options.setLanguageOut(CompilerOptions.LanguageMode.NO_TRANSPILE);

  // Do not transpile module declarations
  options.setWrapGoogModulesForWhitespaceOnly(false);
  // Stop escaping the characters "=&<>"
  options.setTrustedStrings(true);
  options.setPreferSingleQuotes(true);

  // Compiler passes must be disabled to disable down-transpilation to ES5.
  options.skipAllCompilerPasses();
  // turns off optimizations.
  options.setChecksOnly(true);
  options.setPreserveDetailedSourceInfo(true);
  options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);

  return options;
}
 
开发者ID:angular,项目名称:clutz,代码行数:27,代码来源:Options.java


示例2: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@Override
Config getParserConfig() {
  if (parserConfig == null) {
    Config.LanguageMode mode;
    switch (options.getLanguageIn()) {
      case ECMASCRIPT3:
        mode = Config.LanguageMode.ECMASCRIPT3;
        break;
      case ECMASCRIPT5:
        mode = Config.LanguageMode.ECMASCRIPT5;
        break;
      case ECMASCRIPT5_STRICT:
        mode = Config.LanguageMode.ECMASCRIPT5_STRICT;
        break;
      default:
        throw new IllegalStateException("unexpected language mode");
    }

    parserConfig = ParserRunner.createConfig(
      isIdeMode(),
      mode,
      acceptConstKeyword(),
      options.extraAnnotationNames);
  }
  return parserConfig;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:27,代码来源:Compiler.java


示例3: getParserConfigLanguageMode

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
private Config.LanguageMode getParserConfigLanguageMode(
    CompilerOptions.LanguageMode languageMode) {
  switch (languageMode) {
    case ECMASCRIPT3:
      return Config.LanguageMode.ECMASCRIPT3;
    case ECMASCRIPT5:
    case ECMASCRIPT5_STRICT:
      return Config.LanguageMode.ECMASCRIPT5;
    case ECMASCRIPT_2015:
      return Config.LanguageMode.ECMASCRIPT6;
    case ECMASCRIPT6_TYPED:
      return Config.LanguageMode.TYPESCRIPT;
    case ECMASCRIPT_2016:
      return Config.LanguageMode.ECMASCRIPT7;
    case ECMASCRIPT_2017:
      return Config.LanguageMode.ECMASCRIPT8;
    case ECMASCRIPT_NEXT:
      return Config.LanguageMode.ES_NEXT;
    default:
      throw new IllegalStateException("Unexpected language mode: "
          + options.getLanguageIn());
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:Compiler.java


示例4: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@Override
Config getParserConfig(ConfigContext context) {
  if (parserConfig == null || externsParserConfig == null) {
    synchronized (this) {
      if (parserConfig == null) {
        Config.LanguageMode configLanguageMode = getParserConfigLanguageMode(
            options.getLanguageIn());
        Config.StrictMode strictMode =
            options.expectStrictModeInput() ? Config.StrictMode.STRICT : Config.StrictMode.SLOPPY;
        parserConfig = createConfig(configLanguageMode, strictMode);
        // Externs must always be parsed with at least ES5 language mode.
        externsParserConfig =
            configLanguageMode.equals(Config.LanguageMode.ECMASCRIPT3)
                ? createConfig(Config.LanguageMode.ECMASCRIPT5, strictMode)
                : parserConfig;
      }
    }
  }
  switch (context) {
    case EXTERNS:
      return externsParserConfig;
    default:
      return parserConfig;
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:26,代码来源:Compiler.java


示例5: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@Override
Config getParserConfig() {
  if (parserConfig == null) {
    parserConfig = ParserRunner.createConfig(
        getTypeRegistry(), isIdeMode());
  }
  return parserConfig;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:Compiler.java


示例6: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@Override
Config getParserConfig() {
  if (parserConfig == null) {
    parserConfig = ParserRunner.createConfig(isIdeMode());
  }
  return parserConfig;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:8,代码来源:Compiler.java


示例7: getCompilerOptions

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
public CompilerOptions getCompilerOptions() {
  final CompilerOptions options = new CompilerOptions();
  options.setClosurePass(true);

  DependencyOptions deps = new DependencyOptions();
  deps.setDependencySorting(true);
  options.setDependencyOptions(deps);

  if (!this.entryPoints.isEmpty()) {
    options.setManageClosureDependencies(this.entryPoints);
  }

  // All diagnostics are WARNINGs (or off) and thus ignored unless debug == true.
  // Only report issues (and fail for them) that are specifically causing problems for Clutz.
  // The idea is to not do a general sanity check of Closure code, just make sure Clutz works.
  // Report missing types as errors.
  options.setCheckGlobalNamesLevel(CheckLevel.ERROR);
  // Report duplicate definitions, e.g. for accidentally duplicated externs.
  options.setWarningLevel(DiagnosticGroups.DUPLICATE_VARS, CheckLevel.ERROR);

  // Late Provides are errors by default, but they do not prevent clutz from transpiling.
  options.setWarningLevel(DiagnosticGroups.LATE_PROVIDE, CheckLevel.OFF);

  options.setLanguage(LanguageMode.ECMASCRIPT_2017);
  options.setLanguageOut(LanguageMode.ECMASCRIPT5);
  options.setCheckTypes(true);
  options.setInferTypes(true);
  // turns off optimizations.
  options.setChecksOnly(true);
  options.setPreserveDetailedSourceInfo(true);
  options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
  if (partialInput) {
    options.setAssumeForwardDeclaredForMissingTypes(true);
    options.setWarningLevel(DiagnosticGroups.MISSING_SOURCES_WARNINGS, CheckLevel.OFF);
  }
  return options;
}
 
开发者ID:angular,项目名称:clutz,代码行数:38,代码来源:Options.java


示例8: parse

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * Parses the given JavaScript string into an abstract syntax tree.
 *
 * @param js The JavaScript code.
 * @param inputFileName The source filename to associate with the input JS.
 * @return An abstract syntax tree.
 * @throws JavaScriptParsingException if parse errors were encountered.
 */
private static Node parse(String js, String inputFileName) throws JavaScriptParsingException {
  StaticSourceFile file = new SimpleSourceFile(inputFileName, false);
  Config config = ParserRunner.createConfig(LanguageMode.ECMASCRIPT6, null, StrictMode.SLOPPY);
  JavaScriptErrorReporter errorReporter = new JavaScriptErrorReporter(js);
  Node script = ParserRunner.parse(file, js, config, errorReporter).ast;
  if (script == null) {
    throw new JavaScriptParsingException(errorReporter.getWarningAndErrorOutput());
  }
  return script;
}
 
开发者ID:PolymerLabs,项目名称:PolymerRenamer,代码行数:19,代码来源:JsRenamer.java


示例9: createConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
protected Config createConfig(Config.LanguageMode mode, Config.StrictMode strictMode) {
  Config config =
      ParserRunner.createConfig(
          mode,
          options.isParseJsDocDocumentation(),
          options.canContinueAfterErrors()
              ? Config.RunMode.KEEP_GOING
              : Config.RunMode.STOP_AFTER_ERROR,
          options.extraAnnotationNames,
          options.parseInlineSourceMaps,
          strictMode);
  return config;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:14,代码来源:Compiler.java


示例10: parse

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/** Internal implementation to produce the {@link FileInfo} object. */
private static FileInfo parse(String code, String filename, @Nullable Reporter reporter) {
  ErrorReporter errorReporter = new DelegatingReporter(reporter);
  Compiler compiler = new Compiler();
  compiler.init(
      ImmutableList.<SourceFile>of(), ImmutableList.<SourceFile>of(), new CompilerOptions());

  Config config =
      ParserRunner.createConfig(
          // TODO(sdh): ES8 STRICT, with a non-strict fallback - then give warnings.
          Config.LanguageMode.ECMASCRIPT8,
          Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE,
          Config.RunMode.KEEP_GOING,
          /* extraAnnotationNames */ ImmutableSet.<String>of(),
          /* parseInlineSourceMaps */ true,
          Config.StrictMode.SLOPPY);

  SourceFile source = SourceFile.fromCode(filename, code);
  FileInfo info = new FileInfo(errorReporter);
  ParserRunner.ParseResult parsed = ParserRunner.parse(source, code, config, errorReporter);
  parsed.ast.setInputId(new InputId(filename));
  String version = parsed.features.version();
  if (!version.equals("es3")) {
    info.loadFlags.add(JsArray.of("lang", version));
  }

  for (Comment comment : parsed.comments) {
    if (comment.type == Comment.Type.JSDOC) {
      parseComment(comment, info);
    }
  }
  NodeTraversal.traverseEs6(compiler, parsed.ast, new Traverser(info));
  return info;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:35,代码来源:JsfileParser.java


示例11: getCompilerOptions

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@VisibleForTesting
public static CompilerOptions getCompilerOptions() {
  CompilerOptions options = new CompilerOptions();
  options.setLanguageIn(LanguageMode.ECMASCRIPT_NEXT);
  options.setLanguageOut(LanguageMode.ECMASCRIPT5);
  options.setSummaryDetailLevel(0);

  DependencyOptions deps = new DependencyOptions();
  deps.setDependencySorting(true);
  options.setDependencyOptions(deps);

  options.setChecksOnly(true);
  options.setContinueAfterErrors(true);
  options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
  options.setCheckSuspiciousCode(true);
  options.setCheckSymbols(true);
  options.setCheckTypes(true);
  options.setBrokenClosureRequiresLevel(CheckLevel.OFF);
  // TODO(bangert): Remove this -- we want to rewrite code before closure syntax is removed.
  // Unfortunately, setClosurePass is required, or code doesn't type check.
  options.setClosurePass(true);
  options.setGenerateExports(true);
  options.setPreserveClosurePrimitives(true);

  options.setWarningLevel(DiagnosticGroups.STRICT_MISSING_REQUIRE, CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE, CheckLevel.WARNING);
  options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.WARNING);

  return options;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:31,代码来源:RefactoringDriver.java


示例12: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@Override
Config getParserConfig(ConfigContext context) {
  if (parserConfig == null) {
    switch (options.getLanguageIn()) {
      case ECMASCRIPT3:
        parserConfig = createConfig(Config.LanguageMode.ECMASCRIPT3);
        externsParserConfig = createConfig(Config.LanguageMode.ECMASCRIPT5);
        break;
      case ECMASCRIPT5:
        parserConfig = createConfig(Config.LanguageMode.ECMASCRIPT5);
        externsParserConfig = parserConfig;
        break;
      case ECMASCRIPT5_STRICT:
        parserConfig = createConfig(Config.LanguageMode.ECMASCRIPT5_STRICT);
        externsParserConfig = parserConfig;
        break;
      case ECMASCRIPT6:
        parserConfig = createConfig(Config.LanguageMode.ECMASCRIPT6);
        externsParserConfig = parserConfig;
        break;
      case ECMASCRIPT6_STRICT:
        parserConfig = createConfig(Config.LanguageMode.ECMASCRIPT6_STRICT);
        externsParserConfig = parserConfig;
        break;
      default:
        throw new IllegalStateException("unexpected language mode");
    }
  }
  switch (context) {
    case EXTERNS:
      return externsParserConfig;
    default:
      return parserConfig;
  }
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:36,代码来源:Compiler.java


示例13: createConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
protected Config createConfig(Config.LanguageMode mode) {
  return ParserRunner.createConfig(
    isIdeMode(),
    mode,
    acceptConstKeyword(),
    options.extraAnnotationNames,
    options.useNewParser);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:9,代码来源:Compiler.java


示例14: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * Returns the parser configuration for the default context.
 */
final Config getParserConfig() {
  return getParserConfig(ConfigContext.DEFAULT);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:7,代码来源:AbstractCompiler.java


示例15: provideCompilerOptions

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
@Provides
CompilerOptions provideCompilerOptions(
    AliasTransformListener transformListener,
    ModuleCollectionPass moduleCollectionPass,
    ProvidedSymbolPass providedSymbolPass,
    TypeCollectionPass typeCollectionPass,
    @Modules ImmutableSet<Path> modulePaths)
    throws IOException {
  CompilerOptions options = new CompilerOptions();

  if (modulePaths.isEmpty()) {
    options.setEnvironment(CompilerOptions.Environment.BROWSER);
    options.setModuleResolutionMode(ModuleLoader.ResolutionMode.BROWSER);
  } else {
    options.setEnvironment(CompilerOptions.Environment.CUSTOM);
    options.setModuleResolutionMode(ModuleLoader.ResolutionMode.NODE);
  }

  options.setModuleRoots(ImmutableList.of());

  options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
  options.setLanguageOut(LanguageMode.ECMASCRIPT5);

  options.setCodingConvention(new ClosureCodingConvention());
  CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
  CompilationLevel.ADVANCED_OPTIMIZATIONS.setTypeBasedOptimizationOptions(options);

  options.setChecksOnly(true);
  options.setContinueAfterErrors(true);
  options.setAllowHotswapReplaceScript(true);
  options.setPreserveDetailedSourceInfo(true);
  options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_WITH_WHITESPACE);

  // For easier debugging.
  options.setPrettyPrint(true);

  options.setAliasTransformationHandler(transformListener);

  options.addCustomPass(CustomPassExecutionTime.BEFORE_CHECKS, moduleCollectionPass);
  options.addCustomPass(CustomPassExecutionTime.BEFORE_CHECKS, providedSymbolPass);
  options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, typeCollectionPass);

  return options;
}
 
开发者ID:jleyba,项目名称:js-dossier,代码行数:45,代码来源:CompilerModule.java


示例16: setIdeMode

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * Configures the compiler for use as an IDE backend.  In this mode:
 * <ul>
 *  <li>No optimization passes will run.</li>
 *  <li>The last time custom passes are invoked is
 *      {@link CustomPassExecutionTime#BEFORE_OPTIMIZATIONS}</li>
 *  <li>The compiler will always try to process all inputs fully, even
 *      if it encounters errors.</li>
 *  <li>The compiler may record more information than is strictly
 *      needed for codegen.</li>
 * </ul>
 *
 * @deprecated Some "IDE" clients will need some of these options but not
 * others. Consider calling setChecksOnly, setAllowRecompilation, etc,
 * explicitly, instead of calling this method which does a variety of
 * different things.
 */
@Deprecated
public void setIdeMode(boolean ideMode) {
  setChecksOnly(ideMode);
  setContinueAfterErrors(ideMode);
  setAllowHotswapReplaceScript(ideMode);
  setPreserveDetailedSourceInfo(ideMode);
  setParseJsDocDocumentation(
      ideMode
          ? Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE
          : Config.JsDocParsing.TYPES_ONLY);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:29,代码来源:CompilerOptions.java


示例17: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * Returns the parser configuration.
 */
abstract Config getParserConfig();
 
开发者ID:andyjko,项目名称:feedlack,代码行数:5,代码来源:AbstractCompiler.java


示例18: getParserConfig

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * Returns the parser configuration for the specified context.
 */
abstract Config getParserConfig(ConfigContext context);
 
开发者ID:google,项目名称:closure-compiler,代码行数:5,代码来源:AbstractCompiler.java


示例19: setParseJsDocDocumentation

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * 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 {@literal @license} and
 * {@literal @preserve} blocks,
 *
 */
public void setParseJsDocDocumentation(Config.JsDocParsing parseJsDocDocumentation) {
  this.parseJsDocDocumentation = parseJsDocDocumentation;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:11,代码来源:CompilerOptions.java


示例20: isParseJsDocDocumentation

import com.google.javascript.jscomp.parsing.Config; //导入依赖的package包/类
/**
 * Checks JSDoc documentation will be parsed.
 *
 * @return True when JSDoc documentation will be parsed, false if not.
 */
public Config.JsDocParsing isParseJsDocDocumentation() {
  return this.parseJsDocDocumentation;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:9,代码来源:CompilerOptions.java



注:本文中的com.google.javascript.jscomp.parsing.Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReflectHelper类代码示例发布时间:2022-05-22
下一篇:
Java VTDNav类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap