Dealing with super
As a final feature, we add the mechanism for invoking the implementation of a method in the superclass using the keyword super
. Note that super
should be used only as the receiver of a member selection expression, that is, it cannot be passed as the argument of a method. Following the practice "loose grammar, strict validation", we do not impose this at the grammar level. Thus, we add the rule for super
as a terminal expression:
SJTerminalExpression returns SJExpression: ... {SJSuper} 'super' | ...
We add a validator rule that checks the correct super
usage:
public static val WRONG_SUPER_USAGE = ISSUE_CODE_PREFIX + "WrongSuperUsage" @Check def void checkSuper(SJSuper s) { if (s.eContainingFeature != SmallJavaPackage.eINSTANCE.SJMemberSelection_Receiver) error("'super' can be used only as member selection receiver", null, WRONG_SUPER_USAGE) }
Thanks to the way we implemented the scope provider,...