Bug 130161 - [spec] Java Model returns ISourceRanges [-1, 0] if source not available
Summary: [spec] Java Model returns ISourceRanges [-1, 0] if source not available
Status: VERIFIED DUPLICATE of bug 18311
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-02 12:40 EST by Markus Keller CLA
Modified: 2007-08-03 10:21 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2006-03-02 12:40:45 EST
I20060301-0800

Several queries of the JavaModel return an ISourceRange with [offset=-1, length=0] when sources are not available (IMember#getSourceRange(), ISourceReference#getSourceRange(), but not IMember#getJavadocRange()).

But the javadocs of these methods say that they will return null if sources are not available. And ISourceRange#getOffset() says it returns the 0-based offset, so -1 cannot be correct.

I'm pretty sure many clients would be broken if the implementation was just fixed now, so I guess either this change should be announced, or the javadoc should be adapted to the reality.
Comment 1 Jerome Lanneluc CLA 2006-03-10 06:24:15 EST
Spec would need to say that both (null and [-1, 0] should be expected to not break existing clients.
Comment 2 Markus Keller CLA 2006-03-24 05:33:32 EST
I just found a reference to duplicate bug 18311 in our code.
Comment 3 Markus Keller CLA 2006-09-08 18:17:33 EDT
One of us just fell over this again and forgot to use our internal helper org.eclipse.jdt.internal.corext.SourceRange.isAvailable(ISourceRange).
Comment 4 Martin Aeschlimann CLA 2006-09-10 03:21:50 EDT
*** Bug 156688 has been marked as a duplicate of this bug. ***
Comment 5 Jerome Lanneluc CLA 2007-07-03 11:00:12 EDT
Marking as a dup of the oldest bug

*** This bug has been marked as a duplicate of bug 18311 ***
Comment 6 Frederic Fusier CLA 2007-08-03 10:21:20 EDT
Verified for 3.4M1 using build I20070802-0800.