Skip to content

fix: migration faithfulness follow-ups (generator byte-drift + null-tolerance)#1446

Draft
joaodinissf wants to merge 2 commits into
dsldevkit:masterfrom
joaodinissf:fix/migration-faithfulness-followups
Draft

fix: migration faithfulness follow-ups (generator byte-drift + null-tolerance)#1446
joaodinissf wants to merge 2 commits into
dsldevkit:masterfrom
joaodinissf:fix/migration-faithfulness-followups

Conversation

@joaodinissf

Copy link
Copy Markdown
Collaborator

Context

Follow-up to the Xtend→Java migration campaign. After the migrations merged, every migrated file was audited for generated-output byte-drift (where a code generator's emitted text must be byte-identical to what Xtend produced) and general faithfulness. The audit compared each migrated .java against the authoritative xtend-gen (the Xtend compiler's own output), with executable StringConcatenation harnesses for the non-trivial generators. This PR carries the two generator-code fixes that surfaced; both are verified byte-identical / behaviour-faithful to xtend-gen.

Fixes

1. AnnotationAwareContentAssistFragment2 — restore continuation-line indentation
The generated Abstract…ProposalProvider was built with single-arg append(value); when an assignment's terminal is a multi-line Alternatives, the continuation lines lost their indentation versus the Xtend output (Xtend uses two-arg append(value, indent), which re-indents every continuation line). Restored the Xtext relative + two-arg-reindent pattern.
Verification: an executable StringConcatenation harness ran both the xtend-gen builder and the migrated builder over 10 input shapes (empty / single- & multi-line leaf / options / keywords / stub & non-stub / combined): 7/10 → 10/10 IDENTICAL after the fix.

2. FormatJvmModelInferrer — null-tolerant Arrays.asList in dispatcher throws
The synthesized @Dispatch fall-through throws built the "Unhandled parameter types" message with List.of(...), which throws NullPointerException on a null element; the Xtend-generated code used Arrays.<Object>asList(...).toString() (null-tolerant). On a defensive null path this changed the thrown exception type. Restored Arrays.<Object>asList, matching xtend-gen.

Two additional minor observations (intentionally not changed here)

  • CheckCfgScopeProviderTest: the migration replaced an explicit new NullPointerException("Got null context model") with new IllegalStateException(...) (same message, same test outcome). Kept as-is — an explicit IllegalStateException is preferable to throwing NullPointerException; reverting purely for byte-faithfulness would be a small quality regression.
  • CheckModelUtil.modelWithContexts (test helper): emits a trailing "\n " the Xtend «FOR» did not. Its only caller is an @Disabled test, so it is never exercised; deferred to avoid churn.

🤖 Generated with Claude Code

joaodinissf and others added 2 commits June 25, 2026 01:03
… terminals in AnnotationAwareContentAssistFragment2

The migration generated the proposal-provider via single-arg appends; when an
assignment's terminal is a multi-line Alternatives, the continuation lines lost
their indentation versus the Xtend-generated output (xtend-gen uses two-arg
append(value, indent) which re-indents every continuation line). Restore the
Xtend relative + two-arg-reindent pattern in the content/handleAssignment/
handleAssignmentOptions builders.

Byte-identity verified against xtend-gen via an executable StringConcatenation
harness across 10 input shapes (empty / single & multi-line leaf / options /
keywords / stub & non-stub / combined): 7/10 -> 10/10 IDENTICAL.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cher throws

The synthesized @dispatch fall-through throws built the unhandled-parameter
message with List.of(...), which is null-intolerant (NPE on a null element),
whereas the Xtend-generated code used Arrays.<Object>asList(...).toString().
On the defensive null path (e.g. infer(null, ...)) the migrated code threw
NullPointerException instead of the original IllegalArgumentException. Restore
the null-tolerant Arrays.<Object>asList, matching xtend-gen.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joaodinissf joaodinissf requested a review from rubenporras June 24, 2026 23:07
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.

1 participant