refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.generator (parser group)#1429
Conversation
…r (parser group) Migrate parser group (6 files) to hand-written Java; ANTLR StringConcatenation templates byte-verified vs xtend-gen; local gate green. Split of com.avaloq.tools.ddk.xtext.generator: per-module Xtend infra cleanup deferred until both parser+builder PRs merge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…r (builder group) Migrates 12 generator fragment/support classes from Xtend to Java: BundleVersionStripperFragment, DefaultFragmentWithOverride, builder/BuilderIntegrationFragment2, builder/LspBuilderIntegrationFragment2, builder/StandaloneBuilderIntegrationFragment2, formatting/FormatterFragment2, languageconstants/LanguageConstantsFragment2, model/project/ProjectConfig, modelinference/ModelInferenceFragment2, resourceFactory/ResourceFactoryFragment2, ui/compare/CompareFragment2, and ui/contentAssist/AnnotationAwareContentAssistFragment2. Xtend rich-string templates were rewritten as explicit StringConcatenation/string building, implicit getters/extension methods made explicit, and null-safe operators expanded to guarded Java. Behaviour is preserved; only language form changes. This is the builder half of the com.avaloq.tools.ddk.xtext.generator split (parser half tracked in dsldevkit#1429); per-module Xtend infrastructure cleanup is deferred until both halves merge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rubenporras
left a comment
There was a problem hiding this comment.
Note: I have seen that Claude constantly forgets that he should try to use multi-line strings for readability. I use to interject it as steering once the skill has been kicked in, and that has worked fine so far.
|
|
||
| protected CharSequence compileLexerMembers(final Grammar it, final AntlrOptions options) { | ||
| final StringConcatenation builder = new StringConcatenation(); | ||
| builder.append("@members {"); |
There was a problem hiding this comment.
this is clearly a multi line string.
| protected CharSequence compileLexer(final Grammar it, final AntlrOptions options) { | ||
| final StringConcatenation builder = new StringConcatenation(); | ||
| builder.append(codeConfig.getFileHeader()); | ||
| builder.newLineIfNotEmpty(); |
There was a problem hiding this comment.
I think a builder is justified for this case, but it would be better to remove the usage of org.eclipse.xtend2.lib.StringConcatenation, do you agree?
|
|
||
| @Override | ||
| protected String compileParserImports(final Grammar it, final AntlrOptions options) { | ||
| final StringConcatenation builder = new StringConcatenation(); |
There was a problem hiding this comment.
this is clearly a multi line string.
|
|
||
| protected CharSequence compileParserSetTokenStreamMethod() { | ||
| final StringConcatenation builder = new StringConcatenation(); | ||
| builder.append("/**"); |
There was a problem hiding this comment.
this is clearly a multi line string, and so on, I did not continue the review.
Address review feedback (dsldevkit#1429): convert the static and single-statement interpolated grammar-fragment templates to Java text blocks with .formatted() - compileLexerMembers, compileParserImports, compileParserMemberDeclarations, compileParserSetTokenStreamMethod, compileRuleCatch. Builders that compose sub-results via newLineIfNotEmpty (compileLexer), use the two-argument append(value, indent) re-indentation, or contain FOR/IF control flow are left as StringConcatenation, per the skill's "StringBuilder for control flow only" rule - so the org.eclipse.xtend2.lib.StringConcatenation import stays. Separate commit on top of the migration; output proven byte-identical to the prior code for every converted method (verified against the real StringConcatenation runtime). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…textAntlrGeneratorFragment2 Replace the single-line StringConcatenation in the keyword-condition map lambda with String.formatted(); the result is byte-identical. The multi-line condBuilder (which relies on newLine/newLineIfNotEmpty) is left unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| protected CharSequence compileLexer(final Grammar it, final AntlrOptions options) { | ||
| final StringConcatenation builder = new StringConcatenation(); | ||
| builder.append(codeConfig.getFileHeader()); | ||
| builder.newLineIfNotEmpty(); |
| builder.append(_grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.getOriginalElement(it))); | ||
| builder.append("__Impl"); | ||
| builder.newLineIfNotEmpty(); | ||
| builder.append(" "); |
There was a problem hiding this comment.
this for example, I think it would truly benefit from a multi-line string
| builder.append(this._grammarAccessExtensions.getGrammarAccess(it).getSimpleName(), " "); | ||
| builder.append(" grammarAccess, ParserContext parserContext, "); | ||
| builder.append(this.predicatesNaming.getSemanticPredicatesSimpleName(it), " "); | ||
| builder.append(" predicates) {"); |
…eAntlrGrammarGenerator Collapse the pure-static append runs (parser imports block, the @members comment, the constructor body, and the getFirstRuleName/getGrammarAccess methods) into Java text blocks. Single-line two-arg appends (rule name, grammar-access simple name) fold to %s as the re-indent is a no-op for single-line values. Each run proven byte-identical via the StringConcatenation-vs-text-block harness; loops/appendImmediate/dynamic parts are left intact. Generated grammar unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…r (builder group) Migrates 12 generator fragment/support classes from Xtend to Java: BundleVersionStripperFragment, DefaultFragmentWithOverride, builder/BuilderIntegrationFragment2, builder/LspBuilderIntegrationFragment2, builder/StandaloneBuilderIntegrationFragment2, formatting/FormatterFragment2, languageconstants/LanguageConstantsFragment2, model/project/ProjectConfig, modelinference/ModelInferenceFragment2, resourceFactory/ResourceFactoryFragment2, ui/compare/CompareFragment2, and ui/contentAssist/AnnotationAwareContentAssistFragment2. Xtend rich-string templates were rewritten as explicit StringConcatenation/string building, implicit getters/extension methods made explicit, and null-safe operators expanded to guarded Java. Behaviour is preserved; only language form changes. This is the builder half of the com.avaloq.tools.ddk.xtext.generator split (parser half tracked in #1429); per-module Xtend infrastructure cleanup is deferred until both halves merge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrates the parser group of
com.avaloq.tools.ddk.xtext.generator(parser/antlr+parser/common, 6 files) from Xtend to hand-written Java:AbstractAnnotationAwareAntlrGrammarGenerator,AnnotationAwareAntlrContentAssistGrammarGenerator,AnnotationAwareAntlrGrammarGenerator,AnnotationAwareXtextAntlrGeneratorFragment2,GrammarRuleAnnotations,PredicatesNaming.Notes
StringConcatenationcode-generation templates were byte-verified against thextend-genground truth.clean verify checkstyle:check pmd:check pmd:cpd-check spotbugs:check(0 violations).xtext.generator; the per-module Xtend build infra (xtend-gen wiring, MANIFEST, build.properties/.classpath/.project) is intentionally left untouched — it will be cleaned once both the parser and the builder PRs merge (12 sibling.xtendremain).Blind adversarial review verdict: SHIP (only 2 invented-Javadoc nits).