refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.format#1428
Open
joaodinissf wants to merge 3 commits into
Open
refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.format#1428joaodinissf wants to merge 3 commits into
joaodinissf wants to merge 3 commits into
Conversation
Migrates all six Xtend sources in com.avaloq.tools.ddk.xtext.format to Java: FormatRuntimeModule, FormatStandaloneSetup, generator/FormatGenerator, jvmmodel/FormatJvmModelInferrer, scoping/FormatScopeProvider, and validation/FormatValidator. Updates .classpath, .project, MANIFEST.MF, and build.properties to drop the Xtend source folder and per-module Xtend build infrastructure, and removes the generated xtend-gen output. Behaviour is preserved; the translation follows the established DDK Xtend-to-Java conventions.
…n FormatJvmModelInferrer inferConfigureAcsFormatting's body wrapped a single string literal in a StringConcatenation just to feed appendable.append(builder); append the literal directly to the ITreeAppendable instead. The remaining 36 StringConcatenation uses are genuine interpolated/control-flow generator bodies (idiomatic JvmModelInferrer) and are left as-is. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rubenporras
requested changes
Jun 18, 2026
| } | ||
|
|
||
| public void inferRules(final FormatConfiguration format, final JvmGenericType it) { | ||
| jvmTypesBuilder.<JvmMember> operator_add(it.getMembers(), |
Member
There was a problem hiding this comment.
can these not be simplified as
Suggested change
| jvmTypesBuilder.<JvmMember> operator_add(it.getMembers(), | |
| jvmTypesBuilder.operator_add(it.getMembers(), | |
| ```? |
|
|
||
| public void inferLocatorActivators(final FormatConfiguration format, final JvmGenericType it) { | ||
| final List<Rule> rules = new LinkedList<>(); | ||
| Iterables.<Rule> addAll(rules, Iterables.<Rule> concat( |
Member
There was a problem hiding this comment.
Suggested change
| Iterables.<Rule> addAll(rules, Iterables.<Rule> concat( | |
| Iterables.addAll(rules, Iterables.<Rule> concat( |
| public void inferLocatorActivators(final FormatConfiguration format, final JvmGenericType it) { | ||
| final List<Rule> rules = new LinkedList<>(); | ||
| Iterables.<Rule> addAll(rules, Iterables.<Rule> concat( | ||
| Iterables.<GrammarRule> concat(FormatGeneratorUtil.getParserRules(format), FormatGeneratorUtil.getTerminalRules(format)), |
Member
There was a problem hiding this comment.
Suggested change
| Iterables.<GrammarRule> concat(FormatGeneratorUtil.getParserRules(format), FormatGeneratorUtil.getTerminalRules(format)), | |
| Iterables.concat(FormatGeneratorUtil.getParserRules(format), FormatGeneratorUtil.getTerminalRules(format)), |
| for (final Rule rule : rules) { | ||
| final List<EObject> directives = new LinkedList<>(); | ||
| if (rule instanceof GrammarRule grammarRule) { | ||
| Iterables.<EObject> addAll(directives, grammarRule.getDirectives()); |
Member
There was a problem hiding this comment.
Suggested change
| Iterables.<EObject> addAll(directives, grammarRule.getDirectives()); | |
| Iterables.addAll(directives, grammarRule.getDirectives()); |
and so on
| configRules.add(builder.toString()); | ||
| } | ||
| for (final GrammarRule rule : FormatGeneratorUtil.getParserRules(format)) { | ||
| StringConcatenation builder = new StringConcatenation(); |
Member
There was a problem hiding this comment.
are all this not better as multi-line strings with formatted?
| final List<Grammar> grammars = getHierarchyOrderedGrammars(context); | ||
| final Iterable<EList<AbstractRule>> rulesForGrammars = Iterables.transform(grammars, g -> g.getRules()); | ||
| return createScopeForAbstractRules(null, rulesForGrammars); | ||
| } else if (Objects.equals(reference, FormatPackage.Literals.GRAMMAR_ELEMENT_REFERENCE__ASSIGNMENT)) { |
Member
There was a problem hiding this comment.
all of these are correct but since the Literal is guaranteed to be not null, we can simplify all as
Suggested change
| } else if (Objects.equals(reference, FormatPackage.Literals.GRAMMAR_ELEMENT_REFERENCE__ASSIGNMENT)) { | |
| } else if (FormatPackage.Literals.GRAMMAR_ELEMENT_REFERENCE__ASSIGNMENT.equals(reference)) { |
| return FormatQualifiedNameConverter.class; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ |
Member
There was a problem hiding this comment.
remove /** {@inheritdoc} */ which do not add anything
| super.doGenerate(resource, fsa); // Generate the abstract formatter from inferred Jvm models. | ||
|
|
||
| final Iterable<EObject> contents = () -> resource.getAllContents(); | ||
| for (final FormatConfiguration model : Iterables.<FormatConfiguration> filter(contents, FormatConfiguration.class)) { |
Member
There was a problem hiding this comment.
Suggested change
| for (final FormatConfiguration model : Iterables.<FormatConfiguration> filter(contents, FormatConfiguration.class)) { | |
| for (final FormatConfiguration model : Iterables.filter(contents, FormatConfiguration.class)) { |
Readability + idiom pass on dsldevkit#1428 (separate from the audited migration commit): - FormatJvmModelInferrer.listConfigRules: per-rule config statements built via StringConcatenation -> "...".formatted(); output proven byte-identical. - FormatJvmModelInferrer: drop redundant explicit generic witnesses on operator_add / Iterables.addAll / Iterables.concat / Iterables.filter (type is inferred from the target collection / Class arg). - FormatScopeProvider: Objects.equals(reference, Literals.X) -> Literals.X.equals(reference) (the Literal is non-null); drop the now-unused java.util.Objects import. - FormatGenerator: drop the redundant <FormatConfiguration> witness on Iterables.filter. - FormatRuntimeModule: remove 7 empty /** {@inheritdoc} */ comments. Builders with FOR/IF control flow or two-arg append(value, indent) re-indentation are kept as StringConcatenation, per the skill's "StringBuilder for control flow" rule. Behaviour unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was migrated
Migrates all six Xtend sources in
com.avaloq.tools.ddk.xtext.formatto Java:FormatRuntimeModuleFormatStandaloneSetupgenerator/FormatGeneratorjvmmodel/FormatJvmModelInferrerscoping/FormatScopeProvidervalidation/FormatValidatorBehaviour is preserved; the translation follows the established DDK Xtend-to-Java conventions.
Per-module Xtend infrastructure removed
.classpath,.project,MANIFEST.MF, andbuild.propertieswere updated to drop the Xtend source folder and per-module Xtend build infrastructure, and the generatedxtend-genoutput was removed.Validation
Verify self-review
Verdict: CONCERNS. The migration builds green and the local quality gate passes, but the automated self-review flagged concerns that warrant a careful human read of the diff before this is marked ready (kept as a draft for that reason).