Summary: | [api] have array binding X[][][], want X[][] and X[] | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Martin Aeschlimann <martinae> | ||||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | enhancement | ||||||||
Priority: | P3 | CC: | jeem, markus.kell.r, philippe_mulet | ||||||
Version: | 3.2 | ||||||||
Target Milestone: | 3.2 M5 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Martin Aeschlimann
2005-12-11 06:19:05 EST
Indeed ITypeBinding#getElementType() answers the leaf component type. In compiler land, elementType denotes the direct element type, and leafComponentType denotes what DOMAST calls the element type. Maybe we can define: getImmediateElementType() ? getComponentType() ? What if we fixed the API using component in place of element ? Then we deprecate getElementType(), and add: [@deprecated - use getLeafComponentType instead] getElementType() [add] getLeafComponentType() [add] getComponentType() ? Jim - do you have an opinion ? org.eclipse.jdt.core.dom.ArrayType already has the two different variants: /** * Returns the element type of this array type. The element type is * never an array type. * <p> * This is a convenience method that descends a chain of nested array types * until it reaches a non-array type. * </p> * * @return the component type node */ public Type getElementType() ------------------- /** * Returns the component type of this array type. The component type * may be another array type. * * @return the component type node */ public Type getComponentType() I propose to keep the same API on the binding and on the node. So getElementType() to return the leaf component type of the compiler binding and getComponentType() to return the type with dimension equals to receiver's dimensions - 1. /** * Returns the component type of this array type. The component type * may be another array type. * Returns the binding representing the component type of this array type, * or <code>null</code> if this is not an array type binding. The component * type of an array may be another array type. * * @return the component type binding, or <code>null</code> if this is * not an array type */ public ITypeBinding getComponentType(); Created attachment 31905 [details]
Proposed fix
Created attachment 31906 [details]
Regression test
/** * Returns the binding representing the component type of this array type, * or <code>null</code> if this is not an array type binding. The component * type of an array might be an array type. * * @return the component type binding, or <code>null</code> if this is * not an array type */ public ITypeBinding getComponentType(); Fixed and released in HEAD. Regression test in org.eclipse.jdt.core.tests.dom.ASTConverter15Test.test0131/0132 Verified for 3.2 M5 using build I20060215-0010. |