多数のソースファイルを解析する必要があるEclipseJDTプラグインに取り組んでいるので、バッチメソッドASTParser.createASTs()を使用したいと考えています。解析はエラーなしで実行されますが、生成されるCompilationUnitインスタンス内では、多くのorg.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
インスタンスのscope
フィールドがに設定されていnull
ます。このnullへの設定は、プラグインのコードに関係のないワーカースレッドで呼び出されるメソッドで発生しています(つまり、プラグインのクラスはメソッド呼び出しスタックCompilationUnitDeclaration.cleanUp()
に表示されません)。cleanUp()
私の解析コードは次のようになります(すべてrawSources
同じプロジェクト内にあります):
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
parser.setIgnoreMethodBodies(false);
parser.setProject(project);
parser.createASTs(rawSources.values().toArray(new ICompilationUnit[0]), new String[0], this, deltaAnalyzer.progressMonitor);
または、この方法で解析を実行できますが、そのような問題は発生しません。
for (ICompilationUnit source : rawSources.values())
{
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
parser.setIgnoreMethodBodies(false);
parser.setProject(project);
parser.setSource(source);
CompilationUnit ast = (CompilationUnit)parser.createAST(deltaAnalyzer.progressMonitor);
parsedSources.add(deltaAnalyzer.createParsedSource(source, ast));
}
この問題は、HeliosとIndigo(最新のリリースビルド)の両方で発生します。Eclipse Bugzillaにバグを報告しましたが、これを回避する方法を誰かが知っている場合、またはAPIを間違って使用している場合は、ご協力いただければ幸いです。
バイロン