Skip to content

Replace Google Format unused imports with JavaParser scanning - #12622

Open
Alan Zimmer (alzimmermsft) wants to merge 2 commits into
mainfrom
RemoveGoogleFormat
Open

Alan Zimmer (alzimmermsft) wants to merge 2 commits into
mainfrom
RemoveGoogleFormat

Conversation

@alzimmermsft

Copy link
Copy Markdown
Member

Replaces the usage of Google Java Format's unused import removal with JavaParser's scanning and validation to reduce dependencies in the Java TypeSpec generator and to allow shrinking shipped package size.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved merge-conflict markers leave the core module’s POM invalid XML, preventing Maven from loading the module or building the generator.

1 open issue
What changed in this PR

Replaces Google Java Format’s unused-import removal with JavaParser analysis in the Java client generator, aiming to reduce runtime dependencies and shipped package size while retaining Eclipse formatting.

Changes:

  • Adds JavaParser-based import cleanup, Javadoc reference scanning, and batch syntax validation.
  • Removes Google Java Format’s JVM export options.
  • Expands regression tests and updates contributor documentation and the changelog.
File Description
packages/​http-client-java/​generator/​pom.xml Removes JVM export options from test configuration.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​test/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​postprocessor/​PostprocessorBatchTests.java Tests batch error reporting before files are written.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​test/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​postprocessor/​implementation/​CodeFormatterUtilTests.java Adds import-cleanup and source-preservation regression tests.
packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​postprocessor/​implementation/​CodeFormatterUtil.java Implements JavaParser-based import analysis and diagnostics.
packages/​http-client-java/​generator/​http-client-generator-core/​pom.xml Attempts dependency removal but contains an unresolved merge conflict.
packages/​http-client-java/​emitter/​src/​emitter.ts Removes Google Java Format’s runtime JVM export options.
packages/​http-client-java/​CONTRIBUTING.md Documents the revised formatting pipeline.
.chronus/​changes/​http-client-java-javaparser-unused-imports-2026-11-10.md Records the dependency-cleanup change.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-java
Show changes

@typespec/http-client-java - dependencies ✏️

Use JavaParser for unused-import removal, eliminating Google Java Format and its runtime dependencies along with the generator's --add-exports JVM options.

@azure-sdk-automation

azure-sdk-automation Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copilot AI balanced review requested due to automatic review settings November 19, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The formatter can remove imports needed by nested Javadoc references or declaration comments separated by blank lines, leaving unresolved links that can fail doclint.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Preserve Javadoc references across blank lines

packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​postprocessor/​implementation/​CodeFormatterUtil.java:133

With import java.util.List; and /** {@link List} */ separated from the following class declaration by a blank line, this check drops the import and leaves an unresolved Javadoc link: JavaParser's default configuration leaves that comment unattributed. Preserve references in declaration Javadoc across blank lines, without retaining actual orphan comments or mutating the caller's parser settings, and add a regression case.

Medium severity Inspect nested references in Javadoc tags

packages/​http-client-java/​generator/​http-client-generator-core/​src/​main/​java/​com/​microsoft/​typespec/​http/​client/​generator/​core/​postprocessor/​implementation/​CodeFormatterUtil.java:346

A valid comment such as /** {@summary Uses {@link List}.} */ loses its List import because only the outer summary tag is examined; these inline tags are preserved by model/javamodel/JavaJavadocComment.java:30–32. Please inspect nested references in tags that allow them (without interpreting code or literal contents as references) and add a regression case, otherwise generated or customized Javadoc can acquire unresolved links and fail doclint.

1 resolved since last review

Review effort: Balanced

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

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants