Skip to content

refactor: migrate all Xtend files to Java 21#1274

Draft
joaodinissf wants to merge 27 commits into
dsldevkit:masterfrom
joaodinissf:feature/xtend-to-java-migration
Draft

refactor: migrate all Xtend files to Java 21#1274
joaodinissf wants to merge 27 commits into
dsldevkit:masterfrom
joaodinissf:feature/xtend-to-java-migration

Conversation

@joaodinissf
Copy link
Copy Markdown
Collaborator

@joaodinissf joaodinissf commented Mar 1, 2026

Summary

Migrate all 88 Xtend (.xtend) source files to Java 21, leveraging modern language features (text blocks, enhanced switch, pattern matching, records). This eliminates the Xtend compilation step, significantly improving build times.

What's included

  • Xtend-to-Java migration of all .xtend files across check, checkcfg, export, expression, format, scope, and generator modules (Batches 1–9)
  • Xtend build infrastructure removal (maven-xtend-plugin, xtend-maven-plugin configs)
  • Code quality fixes: resolve all PMD, Checkstyle, and SpotBugs violations in migrated code
  • Modern Java idioms: replace StringBuilder patterns with String.format() and text blocks, convert string concatenation to text blocks in test DSL sources
  • Eclipse formatter applied to all migrated files
  • @SuppressWarnings("nls") added to suppress non-externalized string literal warnings

Build impact

Clean Eclipse build ~2.8x faster: from 14.44s down to 5.13s (measured on MacBook).

Test plan

  • CI maven-verify passes
  • CI PMD and Checkstyle checks pass
  • Manual verification in Eclipse IDE

🤖 Generated with Claude Code

@joaodinissf joaodinissf changed the title [CLAUDE] Xtend to Java migration [WIP] Xtend to Java migration Mar 1, 2026
* @return the model stub string
*/
public String modelWithGrammar() {
StringBuilder builder = new StringBuilder(512);
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.

@joaodinissf it is not using multi line strings...

Copy link
Copy Markdown
Collaborator Author

@joaodinissf joaodinissf Mar 2, 2026

Choose a reason for hiding this comment

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

Good catch, I'll try to get it to clean this up later today.

@joaodinissf joaodinissf marked this pull request as ready for review March 3, 2026 08:24
@joaodinissf joaodinissf changed the title [WIP] Xtend to Java migration refactor: migrate all Xtend files to Java 21 Mar 3, 2026
@joaodinissf joaodinissf force-pushed the feature/xtend-to-java-migration branch 3 times, most recently from 84de93f to 76087e2 Compare March 3, 2026 18:38
@joaodinissf joaodinissf marked this pull request as draft March 5, 2026 08:41
@joaodinissf joaodinissf force-pushed the feature/xtend-to-java-migration branch 2 times, most recently from dee50e3 to 4163b68 Compare April 4, 2026 11:55
*
* Also see {@link org.eclipse.xtext.xtext.XtextFormatter} as an example
*/
public class «grammar.formatterStub.simpleName» extends «FormatGeneratorUtil::getFormatterName(grammar, "Abstract")» {
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.

I think that for this kind of files were use use Xtend string interpolation, it actually makes sense to keep Xtend.

@joaodinissf joaodinissf force-pushed the feature/xtend-to-java-migration branch from 77c62fd to 169f93c Compare April 17, 2026 23:11
joaodinissf and others added 18 commits April 20, 2026 10:22
Convert all 8 Xtend source files in com.avaloq.tools.ddk.check.core
to plain Java 21, eliminating the org.eclipse.xtend2.lib dependency:

- CheckGeneratorConfig: @accessors → manual getter/setter
- CheckTypeComputer: override → @OverRide, typeof → .class
- CheckGeneratorNaming: static utilities, explicit types
- CheckScopeProvider: dispatch methods → if-instanceof dispatcher
- CheckGeneratorExtensions: 4 dispatch families, switch expressions
- CheckFormatter: dispatch _format methods, extension→explicit calls
- CheckGenerator: template expressions → StringBuilder (no StringConcatenation)
- CheckJvmModelInferrer: extension fields, JvmTypesBuilder lambdas

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Xtend doesn't enforce checked exceptions, but Java does. Moved
file.getContents() call inside try-with-resources block to properly
handle CoreException.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate 28 Xtend files across 14 modules to idiomatic Java 21.
All files are Trivial/Easy complexity (≤100 lines each).

Modules touched: check.core.test, check.test.runtime,
check.test.runtime.tests, check.ui, checkcfg.core,
checkcfg.core.test, sample.helloworld.ui.test,
xtext.check.generator, xtext.expression, xtext.format,
xtext.format.ide, xtext.format.test, xtext.format.ui,
xtext.generator

Progress: 36/94 files migrated (38%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate 13 Xtend files across 8 modules:
- check.core.test: CheckApiAccessValidationsTest, ProjectBasedTests,
  IssueCodeValueTest, BasicModelTest
- check.test.runtime.tests: CheckExecutionEnvironmentProjectTest
- sample.helloworld.ui.test: CheckExecutionEnvironmentProjectTest
- checkcfg.core: PropertiesInferenceHelper
- checkcfg.core.test: CheckCfgScopeProviderTest,
  CheckCfgContentAssistTest, CheckCfgSyntaxTest
- xtext.export.generator: ExportFragment2
- xtext.scope.generator: ScopingFragment2
- xtext.test.core: Tag

Progress: 49/94 files migrated (52%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate all 9 remaining Xtend files in the xtext.export module to
idiomatic Java 21, completing the module. Includes template expressions
converted to StringBuilder, dispatch methods with Java 21 pattern
matching, and @Inject extension rewrites.

Files: ResourceDescriptionConstantsGenerator, ExportFeatureExtensionGenerator,
ResourceDescriptionManagerGenerator, ExportedNamesProviderGenerator,
FragmentProviderGenerator, ExportGenerator, FingerprintComputerGenerator,
ExportGeneratorX, ResourceDescriptionStrategyGenerator.

Progress: 58/94 files migrated (62%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate 10 Xtend files across 5 modules: xtext.expression (3),
xtext.scope (4), xtext.test.core (1), xtext.ui (1), xtext.ui.test (1).

Heavy use of dispatch methods (ExpressionExtensionsX, GenModelUtilX,
CodeGenerationX, ScopeNameProviderGenerator, ScopeProviderX,
ScopeProviderGenerator) converted to Java 21 pattern matching
dispatchers. Template expressions converted to StringBuilder.

Modules fully migrated: xtext.expression, xtext.scope, xtext.test.core,
xtext.ui, xtext.ui.test.

Progress: 68/94 files migrated (72%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mplete!

All 94 Xtend source files have been migrated to Java 21.
Zero .xtend files remain in src/ directories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove all xtend-gen references from .classpath, build.properties,
pom.xml (xtend-maven-plugin, xtend.version property, PMD exclude,
clean plugin fileset), PMD ruleset, Checkstyle config, and .gitignore.
Remove org.eclipse.xtend.lib from MANIFEST.MF where no longer needed
(kept in xtext.generator, check.core.test, sample.helloworld.ui, and
xtext.test.core which still use xtend2.lib runtime classes or xtend.lib
annotations). Remove migration section from AGENTS.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix ~396 violations across 12 files in 5 modules (xtext.expression,
xtext.format, xtext.ui, xtext.ui.test, xtext.check.generator):

- Suppress dispatch method naming and unused params at class level
- Rename underscore-prefixed fields and lambda parameters
- Use char literals in StringBuilder.append for single characters
- Add StringBuilder capacity, extract string constants, fix Javadoc
- Simplify boolean returns, fix loose coupling, remove unnecessary boxing
- Extract long lambdas into private methods, fix varargs array creation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove superfluous instanceof check in CodeGenerationX
- Simplify inferConstants boolean return in FormatJvmModelInferrer
- Add @OverRide on infer() dispatch method
- Cast null to Object[] to clarify varargs intent in test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nd export modules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve ~600 PMD and Checkstyle violations across all modules affected
by the Xtend-to-Java migration: check.core, check.core.test, check.ui,
check.ui.test, checkcfg.core, checkcfg.core.test, format.generator,
export.generator, generator.test, and generator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… MissingOverride, LooseCoupling)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
joaodinissf and others added 9 commits April 20, 2026 10:22
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t blocks

Replace StringBuilder.append() chains with more readable alternatives:
- Text blocks with String.format() for file skeleton generators (CheckNewProject,
  CheckQuickfixProvider, CheckProjectFactory, ExportGenerator)
- String.format() for toString() methods in scope classes and resource descriptions
- Simple string concatenation for trivial cases (EObjectUtil, AbstractLabelProvider,
  ClasspathBasedChecks, DirectLinkingResourceStorageLoadable)
- String.join() for loop-based string building (ScopeTrace)

Also widens toClient() parameter from StringBuilder to CharSequence in
StandaloneBuilderIntegrationFragment2 and LspBuilderIntegrationFragment2,
and removes unused INITIAL_BUFFER_CAPACITY constants.

18 files changed, net -106 lines removed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rces

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… simple concatenation

Replace StringBuilder.append() chains with Java 21 text blocks, String.format(),
and simple concatenation across 11 files where the pattern was a mechanical
artifact of the Xtend-to-Java migration. Remaining StringBuilder instances
(74 across 20 files) are intentionally kept where loops, interleaved
conditionals, or dispatch group consistency make them the better choice.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes PMD UseTryWithResources violation introduced during Xtend-to-Java
migration, now that upstream enabled this rule.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Xtend didn't enforce NLS externalization. Adding @SuppressWarnings("nls")
at class level for all 76 migrated files to silence Eclipse warnings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes PMD UseTryWithResources violation for ByteArrayInputStream.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Plan for landing the completed migration on master in 12 reviewable
weekly slices, cut leaves-to-trunk by plugin family, with a shared
per-file review checklist.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joaodinissf joaodinissf force-pushed the feature/xtend-to-java-migration branch from fddb296 to 5710dd2 Compare April 20, 2026 08:22
joaodinissf added a commit to joaodinissf/dsl-devkit that referenced this pull request May 20, 2026
Add a structured project skill encoding the Xtend → Java conversion
rules and methodology that previously lived only in the stale PR dsldevkit#1274
(`docs/xtend-to-java-conversion-prompt.md` and `docs/xtend-migration.md`).
The skill is split into a 1-line entry point, 10 rule files, 4 workflow
docs, 2 examples, and 1 reference table — Claude (or any LLM) can load
only the parts it needs.

Cross-tool generic location at `.agents/skills/` is the source of truth.
A POSIX shell script `.agents/sync.sh` mirrors it into `.claude/skills/`
(gitignored) for Claude Code's auto-discovery: symlink on macOS/Linux,
recursive copy on Windows where Git symlinks need Developer Mode.

After cloning, run `./.agents/sync.sh` once. Re-run after pulling
changes that touch `.agents/skills/`.

Co-Authored-By: Claude Opus 4.7 <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