Community
Participate
Working Groups
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.
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.