JetBrains / Grammar-Kit

Grammar files support & parser/PSI generation for IntelliJ IDEA
Other
715 stars 125 forks source link

Added sealed type support #308

Open brokenhappy opened 1 year ago

brokenhappy commented 1 year ago

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

brokenhappy commented 1 year ago

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?