Bug 515246 - Introduce SourceFile#hBuildSourceStructure method
Summary: Introduce SourceFile#hBuildSourceStructure method
Status: RESOLVED FIXED
Alias: None
Product: Handly
Classification: Technology
Component: Core (show other bugs)
Version: 0.7   Edit
Hardware: All All
: P3 enhancement
Target Milestone: 0.7   Edit
Assignee: Vladimir Piskarev CLA
QA Contact:
URL:
Whiteboard: breakingchange
Keywords: api
Depends on:
Blocks:
 
Reported: 2017-04-13 07:43 EDT by Vladimir Piskarev CLA
Modified: 2017-04-13 08:21 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 2017-04-13 07:43:11 EDT
Currently, SourceFile's subclasses need to override the abstract hBuildStructure method. This method is specified in SourceFile to have at least one of SOURCE_AST or SOURCE_CONTENTS properties available in the given context. Unfortunately, this violates Liskov Substitution Principle as this method overrides hBuildStructure in Element, which makes no such guarantee. More generally, a method that overrides another method cannot strengthen preconditions (things that a caller must arrange) of the overridden method. [The current implementation relies on the (unspecified and, generally speaking, incorrect) assumption that hBuildStructure is always called internally, from within hBuildStructure0 method that arranges for a correct invocation.]

We'll fix that by introducing an abstract SourceFile#hBuildSourceStructure method in place of the current SourceFile#hBuildStructure method. We'll revert the current contract of SourceFile#hBuildStructure to the one specified for Element#hBuildStructure. We'll then implement SourceFile#hBuildStructure to arrange an invocation of hBuildSourceStructure.

Obviously, this is a breaking change: SourceFile's subclasses will have to implement hBuildSourceStructure instead of hBuildStructure. Fortunately, the compiler would notify implementors of the breakage.
Comment 1 Vladimir Piskarev CLA 2017-04-13 08:21:14 EDT
Pushed to master:
http://git.eclipse.org/c/handly/org.eclipse.handly.git/commit/?id=e8dc2f545d1415f3f70857197056d5b2e2523c87

Breaking change:
SourceFile's subclasses will have to implement hBuildSourceStructure instead of hBuildStructure.