Skip to content

refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.format#1428

Open
joaodinissf wants to merge 3 commits into
dsldevkit:masterfrom
joaodinissf:migrate/xtend-to-java/xtext-format
Open

refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.format#1428
joaodinissf wants to merge 3 commits into
dsldevkit:masterfrom
joaodinissf:migrate/xtend-to-java/xtext-format

Conversation

@joaodinissf

Copy link
Copy Markdown
Collaborator

What was migrated

Migrates all six Xtend sources in com.avaloq.tools.ddk.xtext.format to Java:

  • FormatRuntimeModule
  • FormatStandaloneSetup
  • generator/FormatGenerator
  • jvmmodel/FormatJvmModelInferrer
  • scoping/FormatScopeProvider
  • validation/FormatValidator

Behaviour is preserved; the translation follows the established DDK Xtend-to-Java conventions.

Per-module Xtend infrastructure removed

.classpath, .project, MANIFEST.MF, and build.properties were updated to drop the Xtend source folder and per-module Xtend build infrastructure, and the generated xtend-gen output was removed.

Validation

  • Local gate is green: checkstyle, PMD, and SpotBugs all pass.
  • Full module build: GREEN.

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).

joaodinissf and others added 2 commits June 17, 2026 00:27
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>
@joaodinissf joaodinissf marked this pull request as ready for review June 17, 2026 16:16
@joaodinissf joaodinissf requested a review from rubenporras June 17, 2026 16:16
}

public void inferRules(final FormatConfiguration format, final JvmGenericType it) {
jvmTypesBuilder.<JvmMember> operator_add(it.getMembers(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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} */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
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