Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321764

Summary: Add getNameRange() to ISourceReference
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, daniel_megert, markus.kell.r
Version: 3.7   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Proposed fix none

Description Olivier Thomann CLA 2010-08-04 13:48:52 EDT
FUP of bug 150980. See bug 150980 comment 15.
Comment 1 Olivier Thomann CLA 2010-08-31 13:52:37 EDT
Due to some inconsistencies between API, I cannot factorize this one without breaking existing clients.
Some definition of getNameRange() is throwing a JavaModelException and some don't.
So I think we are stuck with what we have right now since the JavaModelException is a checked exception, removing the throw clause would break the source compatibility for clients that are calling it since the exception could not be thrown anymore and therefore the corresponding try/catch could never be reached.
If I add it for the one that didn't have it, this is a source breaking change since clients would not have a try/catch around the corresponding call.

The guilty one is the definition in org.eclipse.jdt.core.ILocalVariable.

Should I close it as WONTFIX or you want to introduce a known breakage into the API ?
Comment 2 Olivier Thomann CLA 2010-08-31 14:56:15 EDT
Created attachment 177877 [details]
Proposed fix

This preserves the definition on ILocalVariable and factorize all other definitions on ISourceReference.
Markus, let me know what you think.
Comment 3 Markus Keller CLA 2010-08-31 15:04:43 EDT
Looks mostly good.

I didn't verify the whole Javadoc of ISourceReference#getNameRange(), but I assume you just copy-pasted it. The @return tag should mention null, e.g.:

 * @return the name range associated with this element, or <code>null</code> if not available
Comment 4 Olivier Thomann CLA 2010-08-31 15:09:28 EDT
Created attachment 177879 [details]
Proposed fix

Updated patch.
Comment 5 Olivier Thomann CLA 2010-08-31 15:10:09 EDT
Released for 3.7M2.
Verification must be done by code inspection.
Comment 6 Dani Megert CLA 2010-09-01 06:32:26 EDT
Adopted the new API at two places in JDT Text.
Comment 7 Ayushman Jain CLA 2010-09-15 03:02:04 EDT
Verified for 3.7M2 via code inspection