में एएसटी प्रसंस्करण के साथ हल नहीं कर रहा है मैं कुछ जावा कोड को संसाधित करने के लिए ग्रहण जेडीटी एएसटी पार्सर का उपयोग कर रहा हूं और फ़ील्ड और विधि घोषणाओं के लिए टाइप बाइंडिंग निकालने का प्रयास कर रहा हूं। ऐसा करने के लिए तर्क मेरे आगंतुक वर्ग के अंदर है (नीचे देखें)। दुर्भाग्य से, मुझे कोई भाग्य नहीं है और बाइंडिंग में से कोई भी हल नहीं कर रहा है (वे लगातार शून्य हैं)। दिलचस्प बात यह है कि बाइंडिंग ग्रहण एएसटीवीव प्लगइन के साथ एक ही कोड पर काम करती है। मैं क्या गलत कर रहा हूं?बाइंडिंग ग्रहण
यहां कुछ प्रासंगिक कोड स्निपेट हैं जो उम्मीद करेंगे कि किसी को यह पता लगाने में मदद मिलेगी कि क्या हो रहा है!
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(source);
parser.setResolveBindings(true);
CompilationUnit unit = (CompilationUnit) parser.createAST(null);
GenericVisitor visitor = new GenericVisitor(outDir + "//" + file.getName() + ".xml");
visitor.process(unit);
public class GenericVisitor extends ASTVisitor
{
public void endVisit(FieldDeclaration node)
{
String bindingInfo = "";
ITypeBinding binding = node.getType().resolveBinding();
if(binding == null)
{
System.out.println("field declaration binding = null");
}
else
{
bindingInfo = binding.getQualifiedName();
}
endVisitNode(node, bindingInfo);
}
public void endVisit(MethodInvocation node)
{
String bindingInfo = "";
IMethodBinding binding = node.resolveMethodBinding();
if(binding == null)
{
System.out.println("method binding = null");
}
else
{
bindingInfo = binding.toString();
}
endVisitNode(node, bindingInfo);
}
}
एक भी parser.setEnvironment (...) का उपयोग कर सकते हैं: "। वातावरण है कि जब कोई IJavaProject उपलब्ध हैं इस्तेमाल किया जा सकता सेट" – roesslerj