Summary: | MethodBinding.getJavaElement() returns null | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Juan omínguez <jdomigon> | ||||
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | markus.kell.r | ||||
Version: | 3.1 | ||||||
Target Milestone: | 3.1 M4 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Juan omínguez
2004-11-16 12:57:33 EST
Created attachment 15900 [details]
Modified ASTView showing "Caller" Class IMethodBindings
You can add the following method to class
"org.eclipse.jdt.astview.views.Binding" to show an error image when
IBinding.getJavaElement()==null
public Image getImage()
{
if(getBinding()==null)
{
return new
SharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
}
if(getBinding().getKind()==IBinding.TYPE)
{
ITypeBinding typeBinding = (ITypeBinding) getBinding();
if(typeBinding.isPrimitive())
{
return new
SharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
}
}
if(getBinding().getJavaElement()==null)
{
return new
SharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
}
else
{
return new
SharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
}
}
Reproduced on Eclipse 3.1M3 and Eclipse 3.1M3 with plugins org.eclipse.jdt.core and org.eclipse.jdt.ui from HEAD Simpler examples where method bindings don't know their java element (I20041117): new Integer(1); Integer.parseInt("1"); Juan: IBinding#getJavaElement() is under construction, but will eventually replace Bindings.findMethod(IMethodBinding, IJavaProject). Note that class Bindings is internal and findMethod(..) may be removed at any time. Ooops, I hadn't realized the tag "@since 3.1" in "getJavaElement()" javadoc, and I thought it was and old and stable method (I'm not used to non-workin api in eclipse ;-) I've seen that "Bindings" is internal, but I'm developing a new refactoring (extract enum from public static final constants) and I'm using lots of internal refactoring API, anyway. I will use getJavaElement eventually (as it's much more "elegant"), but I don't intend to make a internals-free plugin... Changed MethodBinding#getJavaElement() to find a similar method to the binding in the parent if there is no AST for it. Added regression test ASTModelBridgeTets#testMethod3() Works for me, thanks |