refactor: migrate Xtend to Java - com.avaloq.tools.ddk.xtext.export - #1518
Merged
Merged
Conversation
rubenporras
previously approved these changes
Sep 7, 2026
joaodinissf
marked this pull request as ready for review
September 7, 2026 10:37
Base automatically changed from
migrate/xtend-to-java/expression-step-1
to
master
September 7, 2026 21:28
joaodinissf
force-pushed
the
migrate/xtend-to-java/export-step-2
branch
from
September 7, 2026 21:28
45056db to
c5c406b
Compare
rubenporras
approved these changes
Sep 8, 2026
rubenporras
approved these changes
Sep 8, 2026
…1/2: rename sources) Pure `git mv` of ExportGeneratorX.xtend to ExportGeneratorX.java with the file content unchanged, so Git's rename detection permanently connects the Java history to its Xtend past (`git log --follow`, `git blame`). This commit intentionally does not compile: the renamed file still holds Xtend syntax. The following commit translates it in place. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…2/2: translate to Java 21) In-place translation of the renamed ExportGeneratorX, faithful to the Xtend compiler's own xtend-gen output (fresh ground-truth build off the base commit, byte-identical to the reference). Public API is unchanged: every method keeps its name, parameter types and order, and return type, including the `allUserData(Export)` dispatcher over `_allUserData(Export)` / `_allUserData(Void)` with the same branch order (non-null first, null sentinel second). The sole caller, ExportJvmModelInferrer.xtend, still binds against it as an `@Inject extension`; the -amd build recompiles it. Faithfulness notes: - `@Inject extension Naming` becomes `@Inject private Naming naming` with explicit-receiver calls (getResourceDescriptionManager(Grammar)). - getGrammar keeps IterableExtensions.head semantics exactly via Guava `Iterables.getFirst(contents, null)`: empty contents yield null, and a null contents (only reachable if the `?.` guard fires) throws, as before. - Xtend `==` on objects becomes `Objects.equals`, matching xtend-gen. - `newArrayList()` becomes `new ArrayList<>()` — the results stay modifiable, which _allUserData and getInterfacesForType rely on. - Class/member Javadoc is preserved verbatim; the only additions are the `@param`/`@return` tags and two sentence-ending periods that checkstyle JavadocMethod/SummaryJavadoc require on Javadoc that already exists. No Javadoc was invented for previously undocumented methods. - The literal 3 in getPrefix becomes the named constant FIRST_PACKAGE_SEGMENT (checkstyle MagicNumber) rather than a suppression comment. Documented deviations (behaviour-identical): - exportForType uses Stream filter/findFirst instead of IterableExtensions.findFirst; both stop at the first match. getInterfacesForType collects the filtered stream eagerly, matching the compiler output: Interface.getType() resolves EMF proxies in place, so evaluating the predicate over every declaration is an observable side effect and not merely wasted work. - The Guava Function lambdas of sortedExportsByEPackage/typeMap become the `Export::getType` method reference. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
joaodinissf
force-pushed
the
migrate/xtend-to-java/export-step-2
branch
from
September 8, 2026 07:36
c5c406b to
57da560
Compare
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.
Summary
Migrates the last legacy Xtend source of
com.avaloq.tools.ddk.xtext.exportto Java 21:generator/ExportGeneratorX— the naming, prefix, supertype/interface lookup and user-data helpers the export inferrer uses.The module keeps its Xbase layer in
jvmmodel/*.xtend, so the Xtend build infrastructure (xtend-gen,.classpath,build.properties) is untouched.Stacked on the
xtext.expressionmigration (this class injects itsNaming).Public API is unchanged. The sole consumer is
ExportJvmModelInferrer.xtend, which binds through@Inject extension—allUserData(...),constantName(...),typeMap(...),sortedExportsByEPackage(...),getSuperInterfaces(...),exportForType(...)and theget*provider-name helpers. It compiles unchanged against the Java. (superTypeandgetName(ExportModel)are reached only from inside this class;model.namein the inferrer resolves toExportModel's own EMF getter, which takes priority over a same-named extension.)Faithfulness notes
allUserData(Export)keeps the compiler's shape:protected _allUserData(Export)/_allUserData(Void), non-null branch first,Voidsentinel second, no terminal exception (as in the compiler output); the recursion through the public dispatcher is preserved.constantName(EAttribute, EClass)/constantName(UserData, EClass)andgetResourceDescriptionManager(ExportModel)/(Grammar)stay plain overloads.getGrammarkeepsIterableExtensions.headsemantics via GuavaIterables.getFirst(contents, null)(Guava is already a dependency throughListMultimap): empty contents yieldnull, the vestigial?.guard is preserved.exportForTypeusesStream.filter(...).findFirst(), matchingIterableExtensions.findFirst.getInterfacesForTypecollects eagerly, matching the compiler output:Interface.getType()resolves EMF proxies in place, so evaluating the predicate over every declaration is an observable side effect rather than wasted work.Functionlambdas →Export::getTypemethod references;newArrayList()→new ArrayList<>()(results stay mutable, as the callers rely on). Xtend==→Objects.equals, matching the compiler output.@param/@returntags and two sentence-ending periods were added to Javadoc that already existed, because Checkstyle enforces them on.javaand never saw the.xtend. No Javadoc was invented for undocumented methods. The literal3ingetPrefixbecame the named constantFIRST_PACKAGE_SEGMENT.Known deltas
@XbaseGeneratedon the generated dispatchers; the migrated Java does not. The annotation is runtime-retained on public methods in an exported package, so it is a reflectively observable delta — but nothing in the target platform reads it (onlyJvmModelGeneratoremits it), and re-applying a "machine-generated" marker to hand-written code would be false.Verification
xtend-genfrom a clean build of the base commit.getInterfacesForTypehad been left short-circuiting where the compiler output evaluates the predicate over every declaration — which is fixed above; the other translation had it right. Remaining differences between the two were style.-amdcompile (rebuilds the Xtend caller against the Java) ✅;pmd:check checkstyle:check spotbugs:check✅; full reactorclean verifywith the CI static-analysis goals ✅ (354 tests, 0 failures, 2 skipped). No version bump needed: the bundle is already at 17.3.3, ahead of the baseline.🤖 Generated with Claude Code