com.sun.tools.javac.main.JavaCompiler.parseFiles()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中com.sun.tools.javac.main.JavaCompiler.parseFiles()方法的一些代码示例,展示了JavaCompiler.parseFiles()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JavaCompiler.parseFiles()方法的具体详情如下:
包路径:com.sun.tools.javac.main.JavaCompiler
类名称:JavaCompiler
方法名:parseFiles

JavaCompiler.parseFiles介绍

[英]Parses a list of files.
[中]解析文件列表。

代码示例

代码示例来源:origin: cincheo/jsweet

/**
 * Parses and attributes the given files within this compilation
 * environment.
 */
public List<JCCompilationUnit> parseAndAttributeJavaFiles(List<File> javaFiles) throws IOException {
  List<JavaFileObject> sources = toJavaFileObjects(fileManager, javaFiles);
  List<JCCompilationUnit> compilationUnits = compiler.enterTrees(compiler.parseFiles(sources));
  compiler.attribute(compiler.todo);
  return compilationUnits;
}

代码示例来源:origin: cincheo/jsweet

transpilationHandler.setDisabled(isIgnoreJavaErrors());
List<JCCompilationUnit> compilationUnits = compiler.enterTrees(compiler.parseFiles(fileObjects));
if (transpilationHandler.getErrorCount() > 0) {
  logger.warn("errors during parse tree");

代码示例来源:origin: cincheo/jsweet

List<JCCompilationUnit> compilationUnits = compiler.enterTrees(compiler.parseFiles(fileObjects));
MainMethodFinder mainMethodFinder = new MainMethodFinder();
try {

代码示例来源:origin: konsoletyper/teavm-javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}

代码示例来源:origin: sc.fiji/javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

/**
 * Parse the specified files returning a list of abstract syntax trees.
 *
 * @throws java.io.IOException TODO
 * @return a list of abstract syntax trees
 */
public Iterable<? extends CompilationUnitTree> parse() throws IOException {
  try {
    prepareCompiler();
    List<JCCompilationUnit> units = compiler.parseFiles(fileObjects);
    for (JCCompilationUnit unit: units) {
      JavaFileObject file = unit.getSourceFile();
      if (notYetEntered.containsKey(file))
        notYetEntered.put(file, unit);
    }
    return units;
  }
  finally {
    parsed = true;
    if (compiler != null && compiler.log != null)
      compiler.log.flush();
  }
}

代码示例来源:origin: sc.fiji/javac

private List<JCCompilationUnit> sourcesToParsedFiles(JavaCompiler compiler)
  throws IOException {
  List<JavaFileObject> fileObjects = List.nil();
  for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
    fileObjects = fileObjects.prepend(jfo);
  }
  return compiler.parseFiles(fileObjects);
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

delegateCompiler = processAnnotations(enterTrees(stopIfError(parseFiles(sourceFileObjects))),
                   classnames);

代码示例来源:origin: sc.fiji/javac

enterTrees(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))),
classnames);

代码示例来源:origin: konsoletyper/teavm-javac

enterTrees(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))),
classnames);

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

enterTrees(stopIfError(CompileState.PARSE, parseFiles(sourceFileObjects))),
classnames);

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

/** Create a new round. */
private Round(Round prev,
    Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
  this(prev.nextContext(),
      prev.number+1,
      prev.compiler.log.nerrors,
      prev.compiler.log.nwarnings,
      null);
  this.genClassFiles = prev.genClassFiles;
  List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
  roots = cleanTrees(prev.roots).appendList(parsedFiles);
  // Check for errors after parsing
  if (unrecoverableError())
    return;
  enterClassFiles(genClassFiles);
  List<ClassSymbol> newClasses = enterClassFiles(newClassFiles);
  genClassFiles.putAll(newClassFiles);
  enterTrees(roots);
  if (unrecoverableError())
    return;
  topLevelClasses = join(
      getTopLevelClasses(parsedFiles),
      getTopLevelClassesFromClasses(newClasses));
  packageInfoFiles = join(
      getPackageInfoFiles(parsedFiles),
      getPackageInfoFilesFromClasses(newClasses));
  findAnnotationsPresent();
}

代码示例来源:origin: konsoletyper/teavm-javac

/** Create a new round. */
private Round(Round prev,
    Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
  this(prev.nextContext(),
      prev.number+1,
      prev.compiler.log.nerrors,
      prev.compiler.log.nwarnings,
      null);
  this.genClassFiles = prev.genClassFiles;
  List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
  roots = cleanTrees(prev.roots).appendList(parsedFiles);
  // Check for errors after parsing
  if (unrecoverableError())
    return;
  enterClassFiles(genClassFiles);
  List<ClassSymbol> newClasses = enterClassFiles(newClassFiles);
  genClassFiles.putAll(newClassFiles);
  enterTrees(roots);
  if (unrecoverableError())
    return;
  topLevelClasses = join(
      getTopLevelClasses(parsedFiles),
      getTopLevelClassesFromClasses(newClasses));
  packageInfoFiles = join(
      getPackageInfoFiles(parsedFiles),
      getPackageInfoFilesFromClasses(newClasses));
  findAnnotationsPresent();
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

roots = roots.appendList(compiler.parseFiles(newSourceFiles));

代码示例来源:origin: konsoletyper/teavm-javac

roots = roots.appendList(compiler.parseFiles(newSourceFiles));

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

List<JCCompilationUnit> parsedFiles = compiler.parseFiles(fileObjects);
  roots = cleanTrees(roots).reverse();
  fileObjects = fileObjects.prepend(unit.getSourceFile());
roots = null;
compiler.enterTrees(compiler.parseFiles(fileObjects.reverse()));

代码示例来源:origin: sc.fiji/javac

fileObjects = fileObjects.prepend(unit.getSourceFile());
roots = null;
compiler.enterTrees(compiler.parseFiles(fileObjects.reverse()));

相关文章