Community
Participate
Working Groups
I20031209 ILocalVariable should provide more methods: - all methods from IMember - a new method isParameter. ILocalVariable represent parameters and locals. We need to distinguish between them. For example you can't inline a parameter but you can inline a local.
Will reconsider post 3.0
boolean isParameter() would be quite useful. Currently, we have to get the parent of the ILocalVariable, check whether it is an IMethod, and if yes, look for the variable name in IMethod#getParameterNames().
Could this be reconsidered? It seems a trivial addition to do, but quite helpful and will improve the performance of our code.
Martin, how much would you gain if we made the change ? Do you have numbers ? Just checking to know if this worth asking for an API change at this stage.
This call isn't on a critical path, so it will be hard to see a performance improvement with the new API. 3.4 is good enough.
Thanks Martin. Setting the priority accordingly.
(In reply to comment #0) > - all methods from IMember Instead of 'IType getDeclaringType()' as in IMember, ILocalVariable should offer 'IMember getDeclaringMember()' as in ITypeParameter.
I just missed getTypeRoot() in ILocalVariable and ITypeParameter. Could we schedule this for 3.7?
(In reply to comment #8) > I just missed getTypeRoot() in ILocalVariable and ITypeParameter. > Could we schedule this for 3.7? Could you please list all methods you want for ILocalVariable and ITypeParameter? I want to make sure that all new methods will be used.
ILocalVariable: boolean isParameter(); // can currently only be 'final', can also throw JME if necessary int getFlags(); /** * Returns the declaring member of this local variable. * <p> * This is a handle-only method. * </p> * * @return the declaring member of this local variable * @since 3.7 */ IMember getDeclaringMember(); /** * Returns the Java type root in which this local variable is declared. * <p> * This is a handle-only method. * </p> * * @return the Java type root in which this local variable is declared * @since 3.7 */ ITypeRoot getTypeRoot(); ITypeParameter: /** * Returns the Java type root in which this type parameter is declared. * <p> * This is a handle-only method. * </p> * * @return the Java type root in which this type parameter is declared * @since 3.7 */ ITypeRoot getTypeRoot(); JDT/UI reminder: Workarounds that can immediately be replaced are - in JavaModelUtil#is*(ILocalVariable), - in JavadocView 1.102, - and some calls to ILocalVariable#getParent() can be replaced with getDeclaringMember().
Released for 3.7M2. Added regression test in ASTModelBridgeTests. Updated some existing regression tests.
Verified for 3.7M2 through code inspection