Bug 461262 - ISourceElement: remove hard dependency on ISourceFile
Summary: ISourceElement: remove hard dependency on ISourceFile
Status: RESOLVED FIXED
Alias: None
Product: Handly
Classification: Technology
Component: Core (show other bugs)
Version: 0.3   Edit
Hardware: All All
: P3 enhancement
Target Milestone: 0.3   Edit
Assignee: Vladimir Piskarev CLA
QA Contact:
URL:
Whiteboard: breakingchange
Keywords: api
Depends on:
Blocks:
 
Reported: 2015-03-03 02:45 EST by Vladimir Piskarev CLA
Modified: 2015-03-18 09:42 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Piskarev CLA 2015-03-03 02:45:21 EST
In the JDT Java model, both ICompilationUnit and IClassFile consist of pretty much the same elements: ITypes, IMethods and IFields. The interface ITypeRoot is the common protocol for ICompilationUnit and IClassFile. It is important to note that, unlike a compilation unit, a class file might not have a corresponding workspace file (for example, it may reside in a jar file outside the workspace).
 
In Handly, the existing design is that ISourceElements must be contained in a ISourceFile that is located in the Eclipse workspace (ISourceElement#getSourceFile and ISourceFile#getFile never return null according to their contracts). This makes it impossible to implement models like the Java model that describe (the contents of) "binary modules" in roughly the same terms as "source modules".
 
This design flaw should be addressed as early as possible, i.e. in Handly 0.3.
 
To that end, a new interface, IModule, is proposed that roughly corresponds to ITypeRoot in JDT. IModule will extend ISourceElement, and will be extended by ISourceFile.

ISourceElement will get a new method #getModule() that never returns null. The existing #getSourceFile() method will be removed (this is the only breaking change in the proposed redesign).

See https://dev.eclipse.org/mhonarc/lists/handly-dev/msg00087.html for the original discussion.
Comment 2 Vladimir Piskarev CLA 2015-03-13 05:21:00 EDT
Pushed to master.
Comment 3 Vladimir Piskarev CLA 2015-03-16 07:49:20 EDT
Reopened due to a discussion on handly-dev:
https://dev.eclipse.org/mhonarc/lists/handly-dev/msg00102.html
Comment 4 Vladimir Piskarev CLA 2015-03-16 10:09:07 EDT
Reverted commit ddea315852a5915434205bc2205899c19ae5335a.
Comment 5 Eclipse Genie CLA 2015-03-16 11:12:44 EDT
New Gerrit change created: https://git.eclipse.org/r/43942
Comment 7 Vladimir Piskarev CLA 2015-03-18 09:42:43 EDT
Here's the complete list of breaking changes:

* ISourceElement#getSourceFile() got removed

* ISourceElementInfo#getSnapshot() may now return null (if no source
  is available)

* ISourceElementInfo#getFullRange() and #getIdentifyingRange()
  may now return null, but may no more return a NULL_RANGE (see below)

* TextRange#isNull() and #NULL_RANGE got removed. The special source range
  with a -1 offset and a 0 length is a JDT legacy that I did not readily
  identified as such. It would be very painful to deprecate it (JDT couldn't):
  that's why we have to do it as soon as possible. For reference, see
  bug 130161