Bug 321764 - Add getNameRange() to ISourceReference
Summary: Add getNameRange() to ISourceReference
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-04 13:48 EDT by Olivier Thomann CLA
Modified: 2010-09-15 03:02 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix (12.14 KB, patch)
2010-08-31 14:56 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (12.18 KB, patch)
2010-08-31 15:09 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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