Skip to content

Fix wildcard import false positives in Java text blocks - #3160

Open
leeshengis wants to merge 1 commit into
diffplug:mainfrom
leeshengis:fix/2997-java-text-block-wildcard-imports
Open

leeshengis wants to merge 1 commit into
diffplug:mainfrom
leeshengis:fix/2997-java-text-block-wildcard-imports

Conversation

@leeshengis

Copy link
Copy Markdown

Fixes #2997.

Summary

  • Ignore apparent wildcard imports inside Java text blocks, strings, character literals, and comments.
  • Account for Unicode escapes when locating literal/comment boundaries, while retaining the original source text and physical line numbers in diagnostics.
  • Keep the existing import pattern and identity formatting behavior, without adding runtime dependencies.
  • Add 17 tests covering regressions and serialization/equality, and update all three required changelogs.

Validation

Tested in an isolated Linux environment with Temurin 21, compiling to the project's Java 17 target:

  • :lib:test and :testlib:test: 491 passed, 11 skipped by existing test conditions, no failures (JUnit XML counts).
  • ForbidWildcardImportsStepTest: all 19 tests pass; the same tests against the original implementation produce 10 failures.
  • Gradle plugin wildcard-import tests: 2 passed, including toggle support.
  • Maven plugin wildcard-import tests: 2 passed, including aggregation across files.
  • Full spotlessCheck, :lib:spotbugsMain, :testlib:spotbugsMain, and git diff --check: passed.

The full cross-platform/JDK CI matrix has not been run locally. The first plugin-test attempt hit a Gradle distribution-download timeout and one Maven invocation returned no captured stdout. All four integration tests passed on an unchanged rerun after preparing the dependencies. Local cache/proxy routing was configured outside the checkout.

AI assistance

AI tools assisted with the implementation, regression tests, review, and local verification. This PR is opened as a draft for maintainer review.

@leeshengis
leeshengis marked this pull request as ready for review November 4, 2026 06:50

This branch has not been deployed

No deployments
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.

Spotless confuses real code with simulated code in unit tests

1 participant