Bug 48420 - [API] ILocalVariable and ITypeParameter should provide more methods
Summary: [API] ILocalVariable and ITypeParameter should provide more methods
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, performance
Depends on:
Blocks:
 
Reported: 2003-12-10 12:24 EST by Dirk Baeumer CLA
Modified: 2010-09-13 07:23 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2003-12-10 12:24:56 EST
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.
Comment 1 Philipe Mulet CLA 2004-05-10 05:38:32 EDT
Will reconsider post 3.0
Comment 2 Markus Keller CLA 2005-11-22 09:39:35 EST
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().
Comment 3 Martin Aeschlimann CLA 2006-10-18 06:21:56 EDT
Could this be reconsidered? It seems a trivial addition to do, but quite helpful and will improve the performance of our code.
Comment 4 Jerome Lanneluc CLA 2007-04-02 07:45:42 EDT
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.
Comment 5 Martin Aeschlimann CLA 2007-04-02 08:19:04 EDT
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.
Comment 6 Jerome Lanneluc CLA 2007-04-02 09:11:26 EDT
Thanks Martin. Setting the priority accordingly.
Comment 7 Markus Keller CLA 2008-08-21 09:44:20 EDT
(In reply to comment #0)
> - all methods from IMember

Instead of 'IType getDeclaringType()' as in IMember, ILocalVariable should offer 'IMember getDeclaringMember()' as in ITypeParameter.
Comment 8 Markus Keller CLA 2010-04-24 10:28:57 EDT
I just missed getTypeRoot() in ILocalVariable and ITypeParameter.
Could we schedule this for 3.7?
Comment 9 Olivier Thomann CLA 2010-09-02 13:11:05 EDT
(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.
Comment 10 Markus Keller CLA 2010-09-03 11:03:33 EDT
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().
Comment 11 Olivier Thomann CLA 2010-09-07 15:15:30 EDT
Released for 3.7M2.
Added regression test in ASTModelBridgeTests.
Updated some existing regression tests.
Comment 12 Ayushman Jain CLA 2010-09-13 07:23:47 EDT
Verified for 3.7M2 through code inspection