Grammar-Kit icon indicating copy to clipboard operation
Grammar-Kit copied to clipboard

Added sealed type support

Open brokenhappy opened this issue 3 years ago • 1 comments

https://github.com/JetBrains/Grammar-Kit/issues/305

  • Added inspections for sealed rules
  • Updated default Java version to 17

brokenhappy avatar Nov 25 '22 17:11 brokenhappy

The concept of having rules with interface but without implementations are new to the PSI structure. There are many concepts that rely on this, such as mixin, extends, elementType etc.

So far the behavior presented here pretty much ignores all of them but methods. methods is forwarded down the sealed hierarchy, and all leaves (non-sealed) implement all methods from all of their sealed super-rules. This is not consistent with extends or mixin etc.

Also, if someone accidentally extends a sealed type, the sealed type semantics are dropped. (there's an inspection for this, see org.intellij.grammar.BnfSealedRuleInspectionsTest#testSealedRulesMayNotBeExtendedTo)

Any thoughts on this, and are there any assumptions that are broken by this approach?

brokenhappy avatar Nov 25 '22 21:11 brokenhappy