Skip to content

chore: suppress discouraged access to Xtext friend packages - #1615

Merged
joaodinissf merged 1 commit into
masterfrom
chore/suppress-xtext-friend-access
Nov 6, 2026
Merged

joaodinissf merged 1 commit into
masterfrom
chore/suppress-xtext-friend-access

Conversation

@joaodinissf

@joaodinissf joaodinissf commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Suppresses the 201 Discouraged access warnings Eclipse reports on Xtext packages exported only to named friend bundles.

The problem

The Export, Scope, Expression and Format languages and two test bundles use packages such as org.eclipse.xtext.xbase.compiler, org.eclipse.xtext.xbase.compiler.output, org.eclipse.xtext.common.types.util, org.eclipse.xtext.xtext and org.eclipse.xtext.builder.resourceloader. Xtext exports these with x-friends lists, which the DDK bundles aren't on.

The use is deliberate. Both generators subclass JvmModelGenerator, and the Export one also overrides methods that take ITreeAppendable. The inferrers pass ITreeAppendable to JvmTypesBuilder.setBody, the Format inferrer uses RuleNames, and the test classes use IResourceLoader and ReferenceSearchResult directly.

The change

Adds "restriction" to @SuppressWarnings on the 16 affected classes, which matches how Xtext handles this in its own code. New classes using these packages still get the warning, except in xtext.format, whose existing access rules already cover xbase/** and common/types/util/**. unusedWarningToken reports a suppression once it's no longer needed.

  • Why not access rules: 22 projects already have narrower rules in .classpath, including xtext.format, whose rules don't cover org.eclipse.xtext.xtext. A new rule would silently allow new uses across the whole project.
  • Why not JvmTypeReferenceBuilder instead of TypeReferences: it calls TypeReferences internally, and it returns an unknown reference where these callers check for null.
  • Why not StringConcatenationClient instead of ITreeAppendable: the generator subclasses would still need ITreeAppendable, and JavaBodyAppender controls imports and blank lines closely enough that generated output could change.

This also bumps the four affected bundles in the released features: xtext.export, xtext.expression, xtext.format and xtext.scope.

Testing

  • Eclipse 2026-09 with Temurin 21: the same annotation changes, on a workspace with other warning fixes applied, took a clean build from 301 to 100 entries. All 201 Discouraged access warnings went, and no new warnings appeared.
  • Maven on this branch, with Temurin 21: clean verify with checkstyle:check, pmd:check, pmd:cpd-check and spotbugs:check passes, including the version baseline check. 451 tests ran with no failures or errors, and 2 were skipped.

🤖 Generated with Claude Code

These classes use Xtext packages exported only to named friend bundles,
such as org.eclipse.xtext.xbase.compiler and its output package, which
Eclipse reports as 201 discouraged access warnings. The use is deliberate:
both generators subclass JvmModelGenerator, the inferrers pass
ITreeAppendable to JvmTypesBuilder, the Format inferrer uses RuleNames, and
the test classes use IResourceLoader and ReferenceSearchResult directly.

Suppress "restriction" on these 16 classes. New classes using these
packages still get the warning, except in xtext.format, whose existing
access rules already cover xbase and common.types.util. unusedWarningToken
reports a suppression once it is no longer needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joaodinissf
joaodinissf force-pushed the chore/suppress-xtext-friend-access branch from 4a86083 to c68b210 Compare November 6, 2026 00:53
@joaodinissf
joaodinissf marked this pull request as ready for review November 6, 2026 07:46
@joaodinissf
joaodinissf added this pull request to the merge queue Nov 6, 2026
Merged via the queue into master with commit 8cf2ae2 Nov 6, 2026
4 checks passed
@joaodinissf
joaodinissf deleted the chore/suppress-xtext-friend-access branch November 6, 2026 08:06
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