Summary: | AST: CompilationUnit.findDeclaringNode only finds bindings from its own ast | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Martin Aeschlimann <martinae> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | jeem |
Version: | 2.0 | ||
Target Milestone: | 2.1 M2 | ||
Hardware: | PC | ||
OS: | All | ||
Whiteboard: |
Description
Martin Aeschlimann
2002-09-18 11:11:28 EDT
TypeBinding equals is using the Object's implementation. I will see how to improve this. This method is only intended to be used to retrieve declaring node from a binding created in the same compilation unit. Jim - we might want to propose a new mecanism to achieve this. Keys are our general mechanism for relating bindings arising from one AST to those from another AST. This suggests adding a new API method CompilationUnit.findDeclaringNode(String key) so that a binding key can be used to do the lookup. Martin: would like solve your problem? That would solve the problem! Added API method; marked it @since 2.1; added other minor clarifications. Ignore previous comment. We won't add the method until implementation is ready. Here is the API spec for the new method: /** * Finds the corresponding AST node in the given compilation unit from * which the binding with the given key originated. Returns * <code>null</code> if the corresponding node cannot be determined. * This method always returns <code>null</code> if bindings were not requested * when this AST was built. * <p> * The following table indicates the expected node type for the various * different kinds of binding keys: * <ul> * <li></li> * <li>package - a <code>PackageDeclaration</code></li> * <li>class or interface - a <code>TypeDeclaration</code> or a * <code>ClassInstanceCreation</code> (for anonymous classes) </li> * <li>primitive type - none</li> * <li>array type - none</li> * <li>field - a <code>VariableDeclarationFragment</code> in a * <code>FieldDeclaration</code> </li> * <li>local variable - a <code>SingleVariableDeclaration</code>, or * a <code>VariableDeclarationFragment</code> in a * <code>VariableDeclarationStatement</code> or * <code>VariableDeclarationExpression</code></li> * <li>method - a <code>MethodDeclaration</code> </li> * <li>constructor - a <code>MethodDeclaration</code> </li> * </ul> * </p> * * @param key the binding key, or <code>null</code> * @return the corresponding node where a binding with the given * key is declared, or <code>null</code> if the key is <code>null</code> * or if the key does not correspond to a node in this compilation unit * or if bindings were not requested when this AST was built * @see IBinding#getKey * @since 2.1 */ public ASTNode findDeclaringNode(String key) When this method is added, the Javadoc for the other method should be changed to add: * Use <code>findDeclaringNode(binding.getKey())</code> when the binding comes * from a different AST. and * @see #findDeclaringNode(java.lang.String) Is this urgent? In the next weeks, I will spend time on the DOM side only if the bug needs to be fixed asap, otherwise I will defer its resolution. Jim - put the previous version of CompilationUnit as an attachement. You had a change to the findDeclaringNode(IBinding) method API as well. As soon as the implementation is ready I will release the version attached to this PR in the same time. Ok, I released it. If you find any problem with it, reopen it or create a new bug. Fixed and released in 2.1 stream. Regression tests added. Verified. |