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

Java JsFileParser类代码示例

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

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



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

示例1: getDependency

import com.google.javascript.jscomp.deps.JsFileParser; //导入依赖的package包/类
private DependencyInfo getDependency(File file) {
	SourceFile sourceFile = SourceFile.fromFile(file.toString());

	JsFileParser parser = new JsFileParser(null);
	try {
		return parser.parseFile(sourceFile.getName(), null,
				sourceFile.getCode());
	} catch (IOException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:DigiArea,项目名称:closurefx-builder,代码行数:13,代码来源:JSBuildpathContainerResolver.java


示例2: regenerateDependencyInfoIfNecessary

import com.google.javascript.jscomp.deps.JsFileParser; //导入依赖的package包/类
/**
 * Regenerates the provides/requires if we need to do so.
 */
private void regenerateDependencyInfoIfNecessary() throws IOException {
  // If the code is NOT a JsAst, then it was not originally JS code.
  // Look at the Ast for dependency info.
  if (!(ast instanceof JsAst)) {
    Preconditions.checkNotNull(compiler,
        "Expected setCompiler to be called first");
    DepsFinder finder = new DepsFinder();
    Node root = getAstRoot(compiler);
    if (root == null) {
      return;
    }

    finder.visitTree(getAstRoot(compiler));

    // TODO(nicksantos|user): This caching behavior is a bit
    // odd, and only works if you assume the exact call flow that
    // clients are currently using.  In that flow, they call
    // getProvides(), then remove the goog.provide calls from the
    // AST, and then call getProvides() again.
    //
    // This won't work for any other call flow, or any sort of incremental
    // compilation scheme. The API needs to be fixed so callers aren't
    // doing weird things like this, and then we should get rid of the
    // multiple-scan strategy.

    provides.addAll(finder.provides);
    requires.addAll(finder.requires);
  } else {
    // Otherwise, look at the source code.
    if (!generatedDependencyInfoFromSource) {
      // Note: it's ok to use getName() instead of
      // getPathRelativeToClosureBase() here because we're not using
      // this to generate deps files. (We're only using it for
      // symbol dependencies.)
      DependencyInfo info = (new JsFileParser(errorManager)).parseFile(
          getName(), getName(), getCode());

      provides.addAll(info.getProvides());
      requires.addAll(info.getRequires());

      generatedDependencyInfoFromSource = true;
    }
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:48,代码来源:CompilerInput.java


示例3: regenerateDependencyInfoIfNecessary

import com.google.javascript.jscomp.deps.JsFileParser; //导入依赖的package包/类
/**
 * Regenerates the provides/requires if we need to do so.
 */
private void regenerateDependencyInfoIfNecessary() throws IOException {
  // If the code is NOT a JsAst, then it was not originally JS code.
  // Look at the Ast for dependency info.
  if (!(ast instanceof JsAst)) {
    Preconditions.checkNotNull(compiler,
        "Expected setCompiler to be called first");
    DepsFinder finder = new DepsFinder();
    Node root = getAstRoot(compiler);
    if (root == null) {
      return;
    }

    finder.visitTree(getAstRoot(compiler));

    // TODO(nicksantos|user): This caching behavior is a bit
    // odd, and only works if you assume the exact call flow that
    // clients are currently using.  In that flow, they call
    // getProvides(), then remove the goog.provide calls from the
    // AST, and then call getProvides() again.
    //
    // This won't work for any other call flow, or any sort of incremental
    // compilation scheme. The API needs to be fixed so callers aren't
    // doing weird things like this, and then we should get rid of the
    // multiple-scan strategy.

    provides.addAll(finder.provides);
    requires.addAll(finder.requires);
  } else {
    // Otherwise, look at the source code.
    if (!generatedDependencyInfoFromSource) {
      // Note: it's OK to use getName() instead of
      // getPathRelativeToClosureBase() here because we're not using
      // this to generate deps files. (We're only using it for
      // symbol dependencies.)
      DependencyInfo info =
          (new JsFileParser(compiler.getErrorManager()))
          .setIncludeGoogBase(true)
          .parseFile(getName(), getName(), getCode());

      provides.addAll(info.getProvides());
      requires.addAll(info.getRequires());

      generatedDependencyInfoFromSource = true;
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:50,代码来源:CompilerInput.java


示例4: generateDependencyInfo

import com.google.javascript.jscomp.deps.JsFileParser; //导入依赖的package包/类
/**
 * Generates the DependencyInfo by scanning and/or parsing the file.
 * This is called lazily by getDependencyInfo, and does not take into
 * account any extra requires/provides added by {@link #addRequire}
 * or {@link #addProvide}.
 */
private DependencyInfo generateDependencyInfo() {
  Preconditions.checkNotNull(compiler, "Expected setCompiler to be called first: %s", this);
  Preconditions.checkNotNull(
      compiler.getErrorManager(), "Expected compiler to call an error manager: %s", this);

  // If the code is a JsAst, then it was originally JS code, and is compatible with the
  // regex-based parsing of JsFileParser.
  if (ast instanceof JsAst && JsFileParser.isSupported()) {
    // Look at the source code.
    // Note: it's OK to use getName() instead of
    // getPathRelativeToClosureBase() here because we're not using
    // this to generate deps files. (We're only using it for
    // symbol dependencies.)
    try {
      DependencyInfo info =
          (new JsFileParser(compiler.getErrorManager()))
          .setIncludeGoogBase(true)
          .parseFile(getName(), getName(), getCode());
      return new LazyParsedDependencyInfo(info, (JsAst) ast, compiler);
    } catch (IOException e) {
      compiler.getErrorManager().report(CheckLevel.ERROR,
          JSError.make(AbstractCompiler.READ_ERROR, getName(), e.getMessage()));
      return SimpleDependencyInfo.EMPTY;
    }
  } else {
    // Otherwise, just look at the AST.

    DepsFinder finder = new DepsFinder(getPath());
    Node root = getAstRoot(compiler);
    if (root == null) {
      return SimpleDependencyInfo.EMPTY;
    }

    finder.visitTree(root);

    // TODO(nicksantos|user): This caching behavior is a bit
    // odd, and only works if you assume the exact call flow that
    // clients are currently using.  In that flow, they call
    // getProvides(), then remove the goog.provide calls from the
    // AST, and then call getProvides() again.
    //
    // This won't work for any other call flow, or any sort of incremental
    // compilation scheme. The API needs to be fixed so callers aren't
    // doing weird things like this, and then we should get rid of the
    // multiple-scan strategy.
    return SimpleDependencyInfo.builder("", "")
        .setProvides(finder.provides)
        .setRequires(finder.requires)
        .setLoadFlags(finder.loadFlags)
        .build();
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:59,代码来源:CompilerInput.java


示例5: main

import com.google.javascript.jscomp.deps.JsFileParser; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Flags flags = new Flags();

  CmdLineParser parser = new CmdLineParser(flags);
  parser.setUsageWidth(79);
  parser.parseArgument(args);

  FileSystem fs = FileSystems.getDefault();
  final Path closure = fs.getPath(flags.closure).toAbsolutePath();

  ErrorManager errorManager = new PrintStreamErrorManager(System.err);
  JsFileParser jsFileParser = new JsFileParser(errorManager);

  List<DependencyInfo> info = new ArrayList<>(flags.inputs.size());
  for (String path : flags.inputs) {
    Path absPath = fs.getPath(path).toAbsolutePath();
    Path closureRelativePath = closure.relativize(absPath);
    info.add(
        jsFileParser.parseFile(
            absPath.toString(),
            closureRelativePath.toString(),
            new String(Files.readAllBytes(absPath), UTF_8)));
  }

  List<DependencyInfo> allDeps = new LinkedList<>(info);
  allDeps.addAll(
      new DepsFileParser(errorManager).parseFile(closure.resolve("deps.js").toString()));

  List<String> compilerFlags =
      new ClosureSortedDependencies<>(allDeps)
          .getSortedDependenciesOf(info)
          .stream()
          .map(input -> closure.resolve(input.getPathRelativeToClosureBase()))
          .map(Path::toAbsolutePath)
          .map(Path::normalize)
          .map(path -> "--js=" + path)
          .collect(toList());
  compilerFlags.add("--js=" + closure.resolve("base.js"));
  compilerFlags.addAll(flags.flags);

  CommandLineRunner.main(compilerFlags.toArray(new String[compilerFlags.size()]));
}
 
开发者ID:jleyba,项目名称:js-dossier,代码行数:43,代码来源:Compile.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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