当前位置: 首页>>代码示例>>Java>>正文


Java CompilerOptions.setSourceMapOutputPath方法代码示例

本文整理汇总了Java中com.google.javascript.jscomp.CompilerOptions.setSourceMapOutputPath方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerOptions.setSourceMapOutputPath方法的具体用法?Java CompilerOptions.setSourceMapOutputPath怎么用?Java CompilerOptions.setSourceMapOutputPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.jscomp.CompilerOptions的用法示例。


在下文中一共展示了CompilerOptions.setSourceMapOutputPath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initCompilationResources

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private CompilerOptions initCompilationResources() {
  CompilerOptions options = new CompilerOptions();
  CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel( options );

  options.setSourceMapOutputPath( "." );

  WarningLevel.QUIET.setOptionsForWarningLevel( options );
  options.setWarningLevel( DiagnosticGroups.LINT_CHECKS, CheckLevel.OFF );

  options.setLanguageIn( CompilerOptions.LanguageMode.ECMASCRIPT5 );

  // make sure these are clear
  this.lastPrefix = null;
  this.lastLocationMapping = null;

  return options;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:18,代码来源:WebjarsURLConnection.java

示例2: setOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected void setOptions(CompilerOptions options) {
  options.setLanguageIn(LanguageMode.ECMASCRIPT_NEXT);
  // TODO(sdh): It would be nice to allow people to output code in
  // strict mode.  But currently we swallow all the input language
  // strictness checks, and there are various tests that are never
  // compiled and so are broken when we output 'use strict'.  We
  // could consider adding some sort of logging/warning/error in
  // cases where the input was not strict, though there could still
  // be semantic differences even if syntax is strict.  Possibly
  // the first step would be to allow the option of outputting strict
  // and then change the default and see what breaks.  b/33005948
  options.setLanguageOut(LanguageMode.ECMASCRIPT5);
  options.setQuoteKeywordProperties(true);
  options.setSkipNonTranspilationPasses(true);
  options.setVariableRenaming(VariableRenamingPolicy.OFF);
  options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
  options.setWrapGoogModulesForWhitespaceOnly(false);
  options.setPrettyPrint(true);
  options.setSourceMapOutputPath("/dev/null");
  options.setSourceMapIncludeSourcesContent(true);
  options.setWarningLevel(ES5_WARNINGS, CheckLevel.OFF);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:BaseTranspiler.java

示例3: setOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
protected void setOptions(CompilerOptions options) {
  options.coalesceVariableNames = false;
  options.setLanguageOut(CompilerOptions.LanguageMode.ECMASCRIPT5);
  // The next two options together sum to the deprecated ECMASCRIPT6, and
  // mimic historical behavior of this class.
  options.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT_2015);
  options.setStrictModeInput(false);
  options.setShadowVariables(false);
  // Setting the path to any non-null value will trigger source map generation.
  // CompilerBasedTransformer attachs the sourcemap to the result.
  options.setSourceMapOutputPath("/dev/null");
  options.setVariableRenaming(VariableRenamingPolicy.OFF);
  options.instrumentForCoverage = true;
  options.setInstrumentForCoverageOnly(true);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:CoverageInstrumenter.java

示例4: setOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected void setOptions(CompilerOptions options) {
  options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
    // TODO(sdh): It would be nice to allow people to output code in
    // strict mode.  But currently we swallow all the input language
    // strictness checks, and there are various tests that are never
    // compiled and so are broken when we output 'use strict'.  We
    // could consider adding some sort of logging/warning/error in
    // cases where the input was not strict, though there could still
    // be semantic differences even if syntax is strict.  Possibly
    // the first step would be to allow the option of outputting strict
    // and then change the default and see what breaks.  b/33005948
    options.setLanguageOut(LanguageMode.ECMASCRIPT5);
    options.setQuoteKeywordProperties(true);
    options.setSkipNonTranspilationPasses(true);
    options.setVariableRenaming(VariableRenamingPolicy.OFF);
    options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
    options.setWrapGoogModulesForWhitespaceOnly(false);
    options.setPrettyPrint(true);
    options.setSourceMapOutputPath("/dev/null");
    options.setSourceMapIncludeSourcesContent(true);
    options.setWarningLevel(ES5_WARNINGS, CheckLevel.OFF);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:CompilerBasedTransformer.java

示例5: compile

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
public CompileResult compile(Path path, String code) {
  CompilerOptions options = new CompilerOptions();
  options.setSourceMapOutputPath("/dev/null");
  options.setSourceMapIncludeSourcesContent(true);
  options.setPrettyPrint(true);

  // Create a compiler and run specifically this one pass on it.
  Compiler compiler = compiler();
  compiler.init(
      ImmutableList.of(),
      ImmutableList.of(SourceFile.fromCode(path.toString(), code)),
      options);
  compiler.parseForCompilation();

  boolean transpiled = false;

  if (!compiler.hasErrors()
      && compiler.getRoot().getSecondChild().getFirstFirstChild().isModuleBody()) {
    new Es6RewriteModulesToCommonJsModules(compiler)
        .process(null, compiler.getRoot().getSecondChild());
    compiler.getRoot().getSecondChild().getFirstChild().putBooleanProp(Node.TRANSPILED, true);
    transpiled = true;
  }

  Result result = compiler.getResult();
  String source = compiler.toSource();
  StringBuilder sourceMap = new StringBuilder();
  if (result.sourceMap != null) {
    try {
      result.sourceMap.appendTo(sourceMap, path.toString());
    } catch (IOException e) {
      // impossible, and not a big deal even if it did happen.
    }
  }
  if (result.errors.length > 0) {
    throw new TranspilationException(compiler, result.errors, result.warnings);
  }
  return new CompileResult(source, transpiled, transpiled ? sourceMap.toString() : "");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:41,代码来源:BaseTranspiler.java

示例6: getCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected CompilerOptions getCompilerOptions() {
  CompilerOptions options = new CompilerOptions();
  options.setLanguageIn(LanguageMode.ECMASCRIPT3);
  options.setSourceMapOutputPath("testcode_source_map.out");
  options.setSourceMapFormat(getSourceMapFormat());
  options.setSourceMapDetailLevel(detailLevel);
  options.setSourceMapIncludeSourcesContent(sourceMapIncludeSourcesContent);
  return options;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:10,代码来源:SourceMapTestCase.java

示例7: outputSource

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
/**
 * Outputs the source equivalent of the abstract syntax tree, optionally generating a sourcemap.
 *
 * @param node The JavaScript abstract syntax tree.
 * @param outputFormat The source output format options.
 * @param inputFileName The source file name to associate with the input node, used for sourcemap
 *     generation.
 * @param inputSourceMap The content of the input sourcemap.
 * @param sourceMapOutputFileName The name of the output sourcemap.
 * @return The equivalent JavaScript source.
 */
private static String outputSource(
    Node node,
    ImmutableSet<OutputFormat> outputFormat,
    String inputFileName,
    String inputSourceMap,
    String sourceMapOutputFileName) {
  CompilerOptions options = new CompilerOptions();
  options.setPrettyPrint(outputFormat.contains(OutputFormat.PRETTY));
  options.setPreferSingleQuotes(outputFormat.contains(OutputFormat.SINGLE_QUOTE_STRINGS));
  // The Closure Compiler treats the 'use strict' directive as a property of a node. CodeBuilder
  // doesn't consider directives during its code generation. Instead, it inserts the 'use strict'
  // directive if it is in a strict language mode.
  Set<String> directives = node.getDirectives();
  if ((directives != null) && directives.contains("use strict")) {
    options.setLanguage(CompilerOptions.LanguageMode.ECMASCRIPT_2015);
    options.setEmitUseStrict(true);
  }
  options.skipAllCompilerPasses();

  if (inputSourceMap != null) {
    SourceFile sourceMapSourceFile = SourceFile.fromCode("input.sourcemap", inputSourceMap);
    ImmutableMap<String, SourceMapInput> inputSourceMaps =
        ImmutableMap.of(inputFileName, new SourceMapInput(sourceMapSourceFile));
    options.setInputSourceMaps(inputSourceMaps);
    options.setApplyInputSourceMaps(true);
    // Simply setting the path to any non-null value will trigger source map generation.
    // Since sourceMapOutputPath is handled by AbstractCommandLineRunner and not the Compiler
    // itself, we manually output the final sourcemap below.
    options.setSourceMapOutputPath("/dev/null");
  }

  Compiler compiler = new Compiler();
  compiler.disableThreads();
  compiler.initOptions(options);
  compiler.initBasedOnOptions();
  Compiler.CodeBuilder cb = new Compiler.CodeBuilder();
  compiler.toSource(cb, 0, node);

  if (inputFileName != null && inputSourceMap != null && sourceMapOutputFileName != null) {
    try {
      FileOutputStream fileOut = new FileOutputStream(sourceMapOutputFileName);
      OutputStreamWriter out = new OutputStreamWriter(fileOut, UTF_8);
      compiler.getSourceMap().appendTo(out, "renamed.js");
      out.close();
    } catch (Exception e) {
      System.err.println(e + "Error writing output sourcemap.");
    }
  }

  return cb.toString();
}
 
开发者ID:PolymerLabs,项目名称:PolymerRenamer,代码行数:63,代码来源:JsRenamer.java

示例8: createCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private CompilerOptions createCompilerOptions() {
  CompilerOptions options = new CompilerOptions();

  this.compilationLevel.setOptionsForCompilationLevel(options);
  if (this.debugOptions) {
    this.compilationLevel.setDebugOptionsForCompilationLevel(options);
  }

  options.setEnvironment(this.environment);

  options.setPrettyPrint(this.prettyPrint);
  options.setPrintInputDelimiter(this.printInputDelimiter);
  options.setPreferSingleQuotes(this.preferSingleQuotes);
  options.setGenerateExports(this.generateExports);

  options.setLanguageIn(this.languageIn);
  options.setLanguageOut(this.languageOut);
  options.setOutputCharset(this.outputEncoding);

  this.warningLevel.setOptionsForWarningLevel(options);
  options.setManageClosureDependencies(manageDependencies);
  convertEntryPointParameters(options);
  options.setTrustedStrings(true);
  options.setAngularPass(angularPass);

  if (replaceProperties) {
    convertPropertiesMap(options);
  }

  convertDefineParameters(options);

  for (Warning warning : warnings) {
    CheckLevel level = warning.getLevel();
    String groupName = warning.getGroup();
    DiagnosticGroup group = new DiagnosticGroups().forName(groupName);
    if (group == null) {
      throw new BuildException(
          "Unrecognized 'warning' option value (" + groupName + ")");
    }
    options.setWarningLevel(group, level);
  }

  if (!Strings.isNullOrEmpty(sourceMapFormat)) {
    options.setSourceMapFormat(Format.valueOf(sourceMapFormat));
  }

  if (!Strings.isNullOrEmpty(sourceMapLocationMapping)) {
    String[] tokens = sourceMapLocationMapping.split("\\|", -1);
    LocationMapping lm = new LocationMapping(tokens[0], tokens[1]);
    options.setSourceMapLocationMappings(Arrays.asList(lm));
  }

  options.setApplyInputSourceMaps(applyInputSourceMaps);

  if (sourceMapOutputFile != null) {
    File parentFile = sourceMapOutputFile.getParentFile();
    if (parentFile.mkdirs()) {
      log("Created missing parent directory " + parentFile, Project.MSG_DEBUG);
    }
    options.setSourceMapOutputPath(parentFile.getAbsolutePath());
  }
  return options;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:64,代码来源:CompileTask.java


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