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

Java CompilerInput类代码示例

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

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



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

示例1: addExterns

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
/**
 * The compiler isn't aware of the React* symbols that are exported from
 * React, inform it via an extern.
 *
 * TODO(mihai): figure out a way to do this without externs, so that the
 * symbols can get renamed.
 */
private void addExterns() {
  CompilerInput externsInput =
      CompilerAccessor.getSynthesizedExternsInputAtEnd(compiler);
  externsRoot = externsInput.getAstRoot(compiler);
  for (Map.Entry<String, String> entry : React.REACT_MODULES.entrySet()) {
    String moduleName = entry.getKey();
    String moduleType = entry.getValue();
    addExternModule(moduleName, moduleType, externsRoot);
  }
  if (!options.renameReactApi) {
    Node typesNode = createTypesNode();
    typesNode.useSourceInfoFromForTree(externsRoot);
    Node typesChildren = typesNode.getFirstChild();
    typesNode.removeChildren();
    externsRoot.addChildrenToBack(typesChildren);
  }
  compiler.reportChangeToEnclosingScope(externsRoot);
}
 
开发者ID:mihaip,项目名称:react-closure-compiler,代码行数:26,代码来源:ReactCompilerPass.java


示例2: compile

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public void compile(JsonML source) {
  if (report != null) {
    throw new IllegalStateException(COMPILATION_ALREADY_COMPLETED_MSG);
  }

  sourceAst = new JsonMLAst(source);

  CompilerInput input = new CompilerInput(
      sourceAst, "[[jsonmlsource]]", false);

  JSModule module = new JSModule("[[jsonmlmodule]]");
  module.add(input);

  Result result = compiler.compileModules(
      ImmutableList.<SourceFile>of(),
      ImmutableList.of(module),
      options);

  report = generateReport(result);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:SecureCompiler.java


示例3: cloneParsedInputs

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
/** Loop over all the inputs and clone their ASTs into this.parsedInputs. */
private void cloneParsedInputs() {
  for (CompilerInput ci : getInputsById().values()) {
    Node n = ci.getAstRoot(this);
    parsedInputs.add(n.cloneTree());
  }
}
 
开发者ID:angular,项目名称:clutz,代码行数:8,代码来源:InitialParseRetainingCompiler.java


示例4: testLocateNodeModuleBrowser

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public void testLocateNodeModuleBrowser() throws Exception {
  ImmutableList<CompilerInput> compilerInputs =
      inputs(
          "/A/index.js",
          "/A/index.json",
          "/node_modules/A/index.js",
          "/node_modules/A/foo.js",
          "/node_modules/A/node_modules/A/index.json",
          "/B/package.json",
          "/B/lib/b.js",
          "/node_modules/B/package.json",
          "/node_modules/B/lib/b.js");

  ModuleLoader loader =
      new ModuleLoader(
          null,
          (new ImmutableList.Builder<String>()).build(),
          compilerInputs,
          ModuleLoader.ResolutionMode.BROWSER);

  assertNull(loader.resolve("/foo.js").resolveJsModule("/A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A/index.js"));
  assertNull(loader.resolve("/foo.js").resolveJsModule("./A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("./A/index.js"));
  assertNull(loader.resolve("/foo.js").resolveJsModule("/A"));
  assertNull(loader.resolve("/foo.js").resolveJsModule("/A/index"));
  assertUri("/A/index.json", loader.resolve("/foo.js").resolveJsModule("/A/index.json"));

  assertNull(loader.resolve("/foo.js").resolveJsModule("A"));
  assertNull(loader.resolve("/node_modules/A/foo.js").resolveJsModule("A"));
  assertNull(loader.resolve("/node_modules/A/index.js").resolveJsModule("./foo"));
  assertUri(
      "/node_modules/A/foo.js",
      loader.resolve("/node_modules/A/index.js").resolveJsModule("./foo.js"));

  assertNull(loader.resolve("/app.js").resolveJsModule("/B"));

  assertNull(loader.resolve("/app.js").resolveJsModule("B"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:40,代码来源:ModuleLoaderTest.java


示例5: inputs

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
ImmutableList<CompilerInput> inputs(String... names) {
  ImmutableList.Builder<CompilerInput> builder = ImmutableList.builder();
  for (String name : names) {
    builder.add(input(name));
  }
  return builder.build();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:ModuleLoaderTest.java


示例6: compile

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public Result compile(Node script) throws IOException {
  CompilerInput input = new CompilerInput(new SyntheticAst(script));
  JSModule jsModule = new JSModule("fuzzedModule");
  jsModule.add(input);

  Compiler.setLoggingLevel(level.getLevel());
  Compiler compiler = new Compiler();
  compiler.setTimeout(30);
  compiler.disableThreads();
  return compiler.compileModules(
      CommandLineRunner.getDefaultExterns(),
      Arrays.asList(jsModule), getOptions());
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:14,代码来源:Driver.java


示例7: compile

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public Result compile(Node script) throws IOException {
  CompilerInput input = new CompilerInput(new SyntheticAst(script));
  JSModule jsModule = new JSModule("fuzzedModule");
  jsModule.add(input);

  Compiler compiler = new Compiler();
  compiler.setTimeout(30);
  return compiler.compileModules(
      CommandLineRunner.getDefaultExterns(),
      Arrays.asList(jsModule), getOptions());
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:12,代码来源:Driver.java


示例8: computeDepInfo

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
@VisibleForTesting
static ImmutableMap<Source, Metadata<DepInfo>> computeDepInfo(
    Log log,
    ImmutableMap<Source, Metadata<DepInfo>> oldDepInfoMap,
    JsOptions options,
    Function<Source, ByteSource> loader,
    Iterable<? extends Source> sources)
throws IOException {
  final Compiler parsingCompiler = new Compiler(
      new MavenLogJSErrorManager(log));
  parsingCompiler.initOptions(options.toCompilerOptions());

  return SourceMetadataMapBuilder.updateFromSources(
      oldDepInfoMap,
      loader,
      new Extractor<DepInfo>() {
        @Override
        public DepInfo extractMetadata(Source source, byte[] content)
        throws IOException {
          String code = new String(content, Charsets.UTF_8);

          SourceFile sourceFile = new SourceFile.Builder()
              .withCharset(Charsets.UTF_8)
              .withOriginalPath(source.relativePath.getPath())
              .buildFromCode(source.canonicalPath.getPath(), code);

          CompilerInput inp = new CompilerInput(sourceFile);
          inp.setCompiler(parsingCompiler);

          Collection<String> provides = inp.getProvides();
          Collection<String> requires = inp.getRequires();

          if (provides.isEmpty() && requires.isEmpty()) {
            // closure/goog/base.js provides basic definitions for things like
            // goog.require and goog.provide.
            // Anything that calls a goog.* method implicitly requires goog.

            // closure/goog/base.js gets around this by using the special
            // "@provideGoog" annotation.

            // That seems to be specially handled by JSCompiler but not via
            // the CompilerInput API.
            CStyleLexer lexer = new CStyleLexer(
                sourceFile.getCode(),
                true /* Need doc comments. */);
            for (CStyleLexer.Token headerToken : lexer) {
              if (headerToken.type != CStyleLexer.TokenType.DOC_COMMENT) {
                break;
              }
              if (headerToken.containsText("@provideGoog")) {
                provides = ImmutableSet.of("goog");
                break;
              }
            }
          }

          return new DepInfo(
              inp.isModule(),
              inp.getName(),
              googNamespaces(provides),
              googNamespaces(requires));
        }
      },
      sources);
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:66,代码来源:ComputeJsDepInfo.java


示例9: processUnprovidedTypes

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
/**
 * Closure does not require all types to be explicitly provided, if they are only used in type
 * positions. However, our emit phases only emits goog.provided symbols and namespaces, so this
 * extra pass is required, in order to have valid output.
 */
private void processUnprovidedTypes(Set<String> provides, Set<String> transitiveProvides) {
  /**
   * A new set of types can be discovered while visiting unprovided types. To prevent an infinite
   * loop in a pathological case, limit to a number of passes.
   *
   * <p>TODO(rado): investigate https://github.com/angular/clutz/pull/246 and removing this pass
   * altogether.
   */
  int maxTypeUsedDepth = 5;
  Set<String> typesEmitted = new LinkedHashSet<>();
  while (maxTypeUsedDepth > 0) {
    int typesUsedCount = typesUsed.size();
    // AFAICT, there is no api for going from type to symbol, so iterate all symbols first.
    for (TypedVar symbol : compiler.getTopScope().getAllSymbols()) {
      String name = symbol.getName();
      String namespace = getNamespace(name);
      // skip unused symbols, symbols already emitted or symbols whose namespace is emitted
      // (unless the symbols have their own provide).
      if (!typesUsed.contains(name)
          || typesEmitted.contains(name)
          || (!transitiveProvides.contains(name) && typesEmitted.contains(namespace))) {
        continue;
      }

      // skip provided symbols (as default or in an namespace).
      if (provides.contains(name)
          || (!transitiveProvides.contains(name) && provides.contains(namespace))) {
        continue;
      }

      // skip extern symbols (they have a separate pass).
      CompilerInput symbolInput = this.compiler.getInput(new InputId(symbol.getInputName()));
      if (symbolInput != null && symbolInput.isExtern()) continue;

      if (shouldSkipVar(symbol)) {
        continue;
      }

      // Symbols in partial_goog_base.js are just stand ins for the real symbols, so don't emit
      if (symbol.getInputName().endsWith("partial_goog_base.js")) {
        continue;
      }

      declareNamespace(
          namespace,
          symbol,
          name,
          /* isDefault */ true,
          Collections.<String>emptySet(),
          /* isExtern */ false);
      typesEmitted.add(name);
    }
    // if no new types seen, safely break out.
    if (typesUsed.size() == typesUsedCount) break;
    maxTypeUsedDepth--;
  }
}
 
开发者ID:angular,项目名称:clutz,代码行数:63,代码来源:DeclarationGenerator.java


示例10: testLocateNodeModuleNode

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public void testLocateNodeModuleNode() throws Exception {
  ImmutableList<CompilerInput> compilerInputs =
      inputs(
          "/A/index.js",
          "/A/index.json",
          "/node_modules/A/index.js",
          "/node_modules/A/foo.js",
          "/node_modules/A/node_modules/A/index.json",
          "/B/package.json",
          "/B/lib/b.js",
          "/node_modules/B/package.json",
          "/node_modules/B/lib/b.js");

  ModuleLoader loader =
      new ModuleLoader(
          null,
          (new ImmutableList.Builder<String>()).build(),
          compilerInputs,
          ModuleLoader.PathResolver.RELATIVE,
          ModuleLoader.ResolutionMode.NODE,
          packageJsonMainEntries);

  assertUri("/A/index.js", loader.resolve(" /foo.js").resolveJsModule("/A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A/index.js"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("./A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("./A/index.js"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A/index"));
  assertUri("/A/index.json", loader.resolve("/foo.js").resolveJsModule("/A/index.json"));

  assertUri("/node_modules/A/index.js", loader.resolve("/foo.js").resolveJsModule("A"));
  assertUri(
      "/node_modules/A/node_modules/A/index.json",
      loader.resolve("/node_modules/A/foo.js").resolveJsModule("A"));
  assertUri(
      "/node_modules/A/foo.js",
      loader.resolve("/node_modules/A/index.js").resolveJsModule("./foo"));

  assertUri("/B/lib/b.js", loader.resolve("/app.js").resolveJsModule("/B"));
  assertUri("/B/lib/b.js", loader.resolve("/app.js").resolveJsModule("/B/"));

  assertUri("/node_modules/B/lib/b.js", loader.resolve("/app.js").resolveJsModule("B"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:44,代码来源:ModuleLoaderTest.java


示例11: testLocateNodeModulesNoLeadingSlash

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public void testLocateNodeModulesNoLeadingSlash() throws Exception {
  ImmutableList<CompilerInput> compilerInputs =
      inputs(
          "/A/index.js",
          "/A/index.json",
          "node_modules/A/index.js",
          "node_modules/A/foo.js",
          "node_modules/A/node_modules/A/index.json",
          "/B/package.json",
          "/B/lib/b.js",
          "node_modules/B/package.json",
          "node_modules/B/lib/b.js");

  ModuleLoader loader =
      new ModuleLoader(
          null,
          (new ImmutableList.Builder<String>()).build(),
          compilerInputs,
          ModuleLoader.PathResolver.RELATIVE,
          ModuleLoader.ResolutionMode.NODE,
          packageJsonMainEntries);

  assertUri("/A/index.js", loader.resolve(" /foo.js").resolveJsModule("/A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A/index.js"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("./A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("./A/index.js"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A"));
  assertUri("/A/index.js", loader.resolve("/foo.js").resolveJsModule("/A/index"));
  assertUri("/A/index.json", loader.resolve("/foo.js").resolveJsModule("/A/index.json"));

  assertUri("/node_modules/A/index.js", loader.resolve("/foo.js").resolveJsModule("A"));
  assertUri(
      "/node_modules/A/node_modules/A/index.json",
      loader.resolve("node_modules/A/foo.js").resolveJsModule("A"));
  assertUri(
      "node_modules/A/foo.js",
      loader.resolve("node_modules/A/index.js").resolveJsModule("./foo"));

  assertUri("/B/lib/b.js", loader.resolve("/app.js").resolveJsModule("/B"));

  assertUri("/node_modules/B/lib/b.js", loader.resolve("/app.js").resolveJsModule("B"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:43,代码来源:ModuleLoaderTest.java


示例12: testLocateNodeModulesBrowserFieldAdvancedUsage

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
public void testLocateNodeModulesBrowserFieldAdvancedUsage() throws Exception {
  // case where the package.json looks like the following:
  //   {"main": "server.js",
  //    "browser": {"server.js": "client.js",
  //                "exclude/this.js": false,
  //                "replace/other.js": "with/alternative.js"}}
  ImmutableMap<String, String> packageJsonMainEntries =
      ImmutableMap.of(
          "/node_modules/mymodule/package.json", "/node_modules/mymodule/server.js",
          "/node_modules/mymodule/server.js", "/node_modules/mymodule/client.js",
          "/node_modules/mymodule/override/relative.js", "/node_modules/mymodule/./with/this.js",
          "/node_modules/mymodule/exclude/this.js",
              ModuleLoader.JSC_BROWSER_BLACKLISTED_MARKER,
          "/node_modules/mymodule/replace/other.js",
          "/node_modules/mymodule/with/alternative.js");

  ImmutableList<CompilerInput> compilerInputs =
      inputs(
          "/node_modules/mymodule/package.json",
          "/node_modules/mymodule/client.js",
          "/node_modules/mymodule/with/alternative.js",
          "/node_modules/mymodule/with/this.js",
          "/foo.js");

  ModuleLoader loader =
      new ModuleLoader(
          null,
          (new ImmutableList.Builder<String>()).build(),
          compilerInputs,
          ModuleLoader.PathResolver.RELATIVE,
          ModuleLoader.ResolutionMode.NODE,
          packageJsonMainEntries);

  assertUri(
      "/node_modules/mymodule/client.js", loader.resolve("/foo.js").resolveJsModule("mymodule"));
  assertUri(
      "/node_modules/mymodule/with/alternative.js",
      loader.resolve("/foo.js").resolveJsModule("mymodule/replace/other.js"));
  assertUri(
      "/node_modules/mymodule/with/alternative.js",
      loader.resolve("/node_modules/mymodule/client.js").resolveJsModule("./replace/other.js"));
  assertUri(
      "/node_modules/mymodule/with/this.js",
      loader.resolve("/foo.js").resolveJsModule("mymodule/override/relative.js"));
  assertUri(
      "/node_modules/mymodule/with/this.js",
      loader.resolve("/node_modules/mymodule/client.js").resolveJsModule("./override/relative.js"));
  assertNull(
      loader.resolve("/node_modules/mymodule/client.js").resolveJsModule("./exclude/this.js"));
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:51,代码来源:ModuleLoaderTest.java


示例13: input

import com.google.javascript.jscomp.CompilerInput; //导入依赖的package包/类
CompilerInput input(String name) {
  return new CompilerInput(SourceFile.fromCode(name, ""), false);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:4,代码来源:ModuleLoaderTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java LayoutManager类代码示例发布时间:2022-05-22
下一篇:
Java FFmpeg类代码示例发布时间: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