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


Java CompilerOptions.setLanguageIn方法代码示例

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


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

示例1: initCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected CompilerOptions initCompilerOptions() {
    CompilerOptions opts = new CompilerOptions();
    opts.setSummaryDetailLevel(1);
    opts.prettyPrint = true;

    // MIT-LL's integrated demo script requires this setting since
    // it uses trailing commas in object literals.
    opts.setLanguageIn(LanguageMode.ECMASCRIPT5);
    opts.setGenerateExports(false);
    opts.setPreferLineBreakAtEndOfFile(false);
    opts.setTrustedStrings(true);

    /*
    DependencyOptions dopts = new DependencyOptions();
    dopts.setDependencyPruning(true);
    dopts.setMoocherDropping(true);
    opts.setDependencyOptions(dopts);
    */

    return opts;
}
 
开发者ID:blackoutjack,项目名称:jamweaver,代码行数:22,代码来源:JSSourceManager.java

示例2: map

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
public Resource<String> map(Resource<String> resource) {
    try {
        CompilerOptions options = new CompilerOptions();
        config.getCompilationLevel().setOptionsForCompilationLevel(options);
        options.setOutputCharset("UTF-8");
        options.setLanguageIn(config.getLanguage());

        SourceFile input = SourceFile.fromInputStream("dummy.js",
                new ByteArrayInputStream(resource.getContent().getBytes(Charsets.UTF_8)));
        List<SourceFile> externs = config.getExterns();

        Compiler compiler = new Compiler();
        compiler.compile(externs, Lists.newArrayList(input), options);

        if (compiler.hasErrors()) {
            throw new EvaluatorException(compiler.getErrors()[0].description);
        }

        return new Resource<String>(resource.getMimeType(), compiler.toSource(), StringHasher.instance);
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:rjnichols,项目名称:visural-web-resources,代码行数:25,代码来源:ClosureMinifyJavascript.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: compile

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private String compile(HtmlLibrary library, ClosureOptimizationLevel opt, InputStream js) throws IOException {
	CompilationLevel compilationLevel = opt.toCompilationLevel();
	if (null == compilationLevel) {
		// return original input
		return IOUtils.toString(js);
	}
	SourceFile input = SourceFile.fromInputStream(getLibraryName(library), js);
	// TODO externs not supported, should avoid ADVANCED compilation
	SourceFile extern = SourceFile.fromCode("TODO", StringUtils.EMPTY);
	CompilerOptions options = new CompilerOptions();
	compilationLevel.setOptionsForCompilationLevel(options);
	// ES5 assumption to allow getters/setters
	options.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT5);
	Compiler compiler = new Compiler();
	compiler.compile(extern, input, options);
	return compiler.toSource();
}
 
开发者ID:steeleforge,项目名称:aemin,代码行数:18,代码来源:HtmlLibraryManagerDelegateImpl.java

示例8: toCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
/** Does just enough to enable parsing of source files. */
public CompilerOptions toCompilerOptions() {
  CompilerOptions compilerOptions = new CompilerOptions();
  if (this.languageIn != null) {
    compilerOptions.setLanguageIn(this.languageIn);
  }
  if (this.languageOut != null) {
    compilerOptions.setLanguageOut(this.languageOut);
  }
  compilerOptions.setClosurePass(true);
  return compilerOptions;
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:13,代码来源:JsOptions.java

示例9: minify

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
/**
 * Minifies the JS contents from the given merged file into the minified file
 *
 * <p>
 * Minification is performed using the Google Closure compiler, using
 * com.google.javascript.jscomp.CompilationLevel#WHITESPACE_ONLY and EcmaScript5 language level
 * </p>
 *
 * @see ThemeFilesProcessor#minify(java.io.File, java.io.File)
 * @see com.google.javascript.jscomp.Compiler
 */
@Override
protected void minify(File mergedFile, File minifiedFile) throws IOException {
    InputStream in = null;
    OutputStream out = null;
    OutputStreamWriter writer = null;
    InputStreamReader reader = null;

    LOG.info("Populating minified JS file: " + minifiedFile.getPath());

    try {
        out = new FileOutputStream(minifiedFile);
        writer = new OutputStreamWriter(out);

        in = new FileInputStream(mergedFile);
        reader = new InputStreamReader(in);

        CompilerOptions options = new CompilerOptions();
        CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(options);
        options.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT6);
        options.setExtraAnnotationNames(ignoredAnnotations());

        SourceFile input = SourceFile.fromInputStream(mergedFile.getName(), in);
        List<SourceFile> externs = Collections.emptyList();

        Compiler compiler = new Compiler();
        compiler.compile(externs, Arrays.asList(input), options);

        writer.append(compiler.toSource());
        writer.flush();
    } finally {
        if (in != null) {
            in.close();
        }

        if (out != null) {
            out.close();
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:51,代码来源:ThemeJsFilesProcessor.java

示例10: overrideOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
protected void overrideOptions(final CompilerOptions options) {
    super.overrideOptions(options);
    WarningLevel.QUIET.setOptionsForWarningLevel(options);
    //http://stackoverflow.com/questions/13261325/how-can-i-set-the-language-in-option-for-the-closure-compiler
    options.setLanguageIn(LanguageMode.ECMASCRIPT5);
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:8,代码来源:ConfiguredGoogleClosureJavaScriptCompressor.java

示例11: 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.prettyPrint = this.prettyPrint;
  options.printInputDelimiter = this.printInputDelimiter;
  options.generateExports = this.generateExports;

  options.setLanguageIn(this.languageIn);

  this.warningLevel.setOptionsForWarningLevel(options);
  options.setManageClosureDependencies(manageDependencies);

  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);
  }

  return options;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:37,代码来源:CompileTask.java

示例12: getCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的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

示例13: parse

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private Node parse(String source, String expected, LanguageMode languageIn) {
  CompilerOptions options = new CompilerOptions();
  options.setLanguageIn(languageIn);
  options.setLanguageOut(LanguageMode.ECMASCRIPT6_TYPED);
  options.setPreserveTypeAnnotations(true);
  options.setPrettyPrint(true);
  options.setLineLengthThreshold(80);
  options.setPreferSingleQuotes(true);

  Compiler compiler = new Compiler();
  compiler.setErrorManager(testErrorManager);
  compiler.initOptions(options);

  Node script = compiler.parse(SourceFile.fromCode("[test]", source));

  // Verifying that all warnings were seen
  assertTrue("Missing an error", testErrorManager.hasEncounteredAllErrors());
  assertTrue("Missing a warning", testErrorManager.hasEncounteredAllWarnings());

  if (script != null && testErrorManager.getErrorCount() == 0) {
    // if it can be parsed, it should round trip.
    String actual = new CodePrinter.Builder(script)
        .setCompilerOptions(options)
        .setTypeRegistry(compiler.getTypeIRegistry())
        .build() // does the actual printing.
        .trim();
    assertThat(actual).isEqualTo(expected);
  }

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

示例14: 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

示例15: execute

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    File theBaseDirectory = new File(buldDirectory);
    File theBytecoderDirectory = new File(theBaseDirectory, "bytecoder");
    theBytecoderDirectory.mkdirs();

    try {
        ClassLoader theLoader = prepareClassLoader();
        Class theTargetClass = theLoader.loadClass(mainClass);

        CompileTarget theCompileTarget = new CompileTarget(theLoader, CompileTarget.BackendType.valueOf(backend));
        File theBytecoderFileName = new File(theBytecoderDirectory, theCompileTarget.generatedFileName());

        BytecodeMethodSignature theSignature = new BytecodeMethodSignature(BytecodePrimitiveTypeRef.VOID,
                new BytecodeTypeRef[] { new BytecodeArrayTypeRef(BytecodeObjectTypeRef.fromRuntimeClass(TString.class), 1) });

        CompileOptions theOptions = new CompileOptions(new Slf4JLogger(), debugOutput, KnownOptimizer.ALL, relooperEnabled);
        CompileResult theCode = theCompileTarget.compileToJS(theOptions, theTargetClass, "main", theSignature);
        try (PrintWriter theWriter = new PrintWriter(new FileWriter(theBytecoderFileName))) {
            theWriter.println(theCode.getData());
        }

        if (optimizeWithGoogleClosure) {
            Compiler theCompiler = new Compiler();
            CompilerOptions theClosureOptions = new CompilerOptions();
            theClosureOptions.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT5_STRICT);
            theClosureOptions.setLanguageOut(CompilerOptions.LanguageMode.ECMASCRIPT5_STRICT);

            CompilationLevel.valueOf(closureOptimizationLevel).setOptionsForCompilationLevel(theClosureOptions);

            List<SourceFile> theSourceFiles = CommandLineRunner.getBuiltinExterns(CompilerOptions.Environment.BROWSER);
            theSourceFiles.add(SourceFile.fromCode("bytecoder.js", (String) theCode.getData()));
            theCompiler.compile(new ArrayList<>(), theSourceFiles, theClosureOptions);
            String theClosureCode = theCompiler.toSource();

            File theBytecoderClosureFileName = new File(theBytecoderDirectory, "bytecoder-closure.js");

            try (PrintWriter theWriter = new PrintWriter(new FileWriter(theBytecoderClosureFileName))) {
                theWriter.println(theClosureCode);
            }
        }

        if (theCode instanceof WASMCompileResult) {
            WASMCompileResult theWASMCompileResult = (WASMCompileResult) theCode;
            int[] theWASM = wat2wasm(theWASMCompileResult);
            File theBytecoderWASMFileName = new File(theBytecoderDirectory, "bytecoder.wasm");
            try (FileOutputStream theFos = new FileOutputStream(theBytecoderWASMFileName)) {
                for (int aTheWASM : theWASM) {
                    theFos.write(aTheWASM);
                }
            }

        }

    } catch (Exception e) {
        throw new MojoExecutionException("Error running bytecoder", e);
    }
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:59,代码来源:BytecoderMavenMojo.java


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