Summary: | Find declaring node doesn't work for methods/fields using type parameters | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dirk Baeumer <dirk_baeumer> |
Component: | Core | Assignee: | Jim des Rivieres <jeem> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | jeem, markus.kell.r, martinae, Olivier_Thomann, tobias_widmer |
Version: | 3.1 | ||
Target Milestone: | 3.1 M7 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Dirk Baeumer
2005-03-04 14:19:26 EST
IMO this is not a bug: You can only use the declaration binding for root.findDeclaringNode(methodBinding) -> get the method binding decl with methodBinding.getMethodDeclaration IMO it is a bug. The doc says that the result is the declaration node for the binding iff the decl is in the same AST. So the method should apply the various get*Declaration methods. I think that when the binding is a parameterized binding (method or type), then the declaring binding should be used transparently for the user. In this case, I should call getMethodDeclaration() on the binding you passed to the findDeclaringNode(...) method. Doing this, I would get the binding I stored when processing the method declaration. Does this change sound reasonable? If yes, I will release the code. Fixed and released in HEAD. Regression test added in ASTConverter15Test.test0144 Olivier, did you consider variable bindings as well. They have to be normalized as well with the method Jeem added. Thanks, Dirk. I added the same support for IVariable binding. See ASTConverter15Test.test0141. I think also CompilationUnit.findDeclaringNode(String bindingKey) should be updated Reopen for API update. Jim, Could you please check if the API needs to be updated. The problem itself is already fixed in HEAD. Added following para to specs for CompilationUnit.findDeclaringNode({IBinding, String}): * For parameterized or raw type bindings, the declaring node is * that of the corresponding generic type. And for parameterized or raw * method bindings, the declaring node is that of the corresponding * generic method. Verified in I20050510-0010. |