use of org.eclipse.jdt.core.dom.FileASTRequestor in project j2objc by google.
the class JdtParser method parseFiles.
@Override
public void parseFiles(Collection<String> paths, final Handler handler, SourceVersion sourceVersion) {
ASTParser parser = newASTParser(true, sourceVersion);
FileASTRequestor astRequestor = new FileASTRequestor() {
@Override
public void acceptAST(String sourceFilePath, CompilationUnit ast) {
logger.fine("acceptAST: " + sourceFilePath);
if (checkCompilationErrors(sourceFilePath, ast)) {
RegularInputFile file = new RegularInputFile(sourceFilePath);
try {
String source = options.fileUtil().readFile(file);
ParserEnvironment parserEnv = new JdtParserEnvironment(ast.getAST());
TranslationEnvironment env = new TranslationEnvironment(options, parserEnv);
com.google.devtools.j2objc.ast.CompilationUnit unit = TreeConverter.convertCompilationUnit(env, ast, sourceFilePath, FileUtil.getMainTypeName(file), source);
handler.handleParsedUnit(sourceFilePath, unit);
} catch (IOException e) {
ErrorUtil.error("Error reading file " + file.getOriginalLocation() + ": " + e.getMessage());
}
}
}
};
// JDT fails to resolve all secondary bindings unless there are the same
// number of "binding key" strings as source files. It doesn't appear to
// matter what the binding key strings should be (as long as they're non-
// null), so the paths array is reused.
String[] pathsArray = paths.toArray(new String[paths.size()]);
parser.createASTs(pathsArray, getEncodings(pathsArray.length), pathsArray, astRequestor, null);
}
Aggregations