Skip to content

cleanup: hoist duplicated generator state and helpers into Generator - #461

Merged
Max Medvedev (maxmedvedev) merged 1 commit into
JetBrains:masterfrom
goto1134:cleanup/generator-base-dedup
Aug 25, 2026
Merged

Max Medvedev (maxmedvedev) merged 1 commit into
JetBrains:masterfrom
goto1134:cleanup/generator-base-dedup

Conversation

@goto1134

Copy link
Copy Markdown
Contributor

JavaParserGenerator and KotlinParserGenerator declare myExpressionHelper, myJavaHelper and myTokensUsedInGrammar with the same initializers, and carry byte-identical copies of getRuleConsumeType, getEffectiveConsumeType, collectMetaParametersFormatted and isIgnoredWhitespaceToken. Move all of them to the shared base.

Generator is sealed, so protected exposes nothing outside the hierarchy.

JavaParserGenerator also shadowed Generator.myGrammarRoot with the same expression the base already evaluates; drop the shadow. myGrammarRootParser stays: the base computes it from the root attribute while the subclass takes it from RuleInfo, so the two generators disagree once the root rule declares its own parserClass. Unifying that changes generated output.

BnfGeneratorPsiTest reads myJavaHelper through getDeclaredField, which only sees fields of the exact class, so it now asks Generator for it.

JavaParserGenerator and KotlinParserGenerator declare myExpressionHelper,
myJavaHelper and myTokensUsedInGrammar with the same initializers, and
carry byte-identical copies of getRuleConsumeType, getEffectiveConsumeType,
collectMetaParametersFormatted and isIgnoredWhitespaceToken. Move all of
them to the shared base.

Generator is sealed, so protected exposes nothing outside the hierarchy.

JavaParserGenerator also shadowed Generator.myGrammarRoot with the same
expression the base already evaluates; drop the shadow. myGrammarRootParser
stays: the base computes it from the root attribute while the subclass
takes it from RuleInfo, so the two generators disagree once the root rule
declares its own parserClass. Unifying that changes generated output.

BnfGeneratorPsiTest reads myJavaHelper through getDeclaredField, which only
sees fields of the exact class, so it now asks Generator for it.
@maxmedvedev
Max Medvedev (maxmedvedev) merged commit d6ae193 into JetBrains:master Aug 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants