Skip to content

fix: Java source inspection for non-Java projects - #1120

Merged
wenyt (wenytang-ms) merged 1 commit into
mainfrom
wenytang-ms-java-source-inspection-error
Nov 4, 2026
Merged

wenyt (wenytang-ms) merged 1 commit into
mainfrom
wenytang-ms-java-source-inspection-error

Conversation

@wenytang-ms

@wenytang-ms wenyt (wenytang-ms) commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1119.

Root cause

JavaCore.create(IProject) returns a Java-model handle even when the Eclipse project has no Java nature. The source-folder filtering added in 0.27.7 consequently calls getOutputLocation() on a non-Java Maven packaging=pom parent and logs Failed to inspect Java source entries with Java model error 969. The parent project exists; it is the Java-model project that does not exist.

Changes

  • Use the existing ProjectUtils.getJavaProject() helper to validate Java nature before inspecting source classpath entries.
  • Keep ordinary folders visible for non-Java projects and preserve the existing exception logging for genuine Java-project failures.
  • Add an AutoTest regression plan using the existing test/maven and test/multi-module fixtures. It expands the Maven parent's physical folders, refreshes Java Projects, and checks the full copied language-server log for both reported errors.

Reproduction

  1. Open test/maven with non-Java resources shown in Java Projects.
  2. Add test/multi-module to the workspace and wait for Maven import.
  3. Expand multi-module > de.myorg.myservice > src and refresh Java Projects.
  4. Open the Java language-server log. The published 0.27.7 VSIX logs the inspection failure and error 969 without deleting or renaming any project.

The parent retains only Maven nature throughout verification; the fix does not add Java nature or change the fixture.

Verification

Local Windows x64 runs used VS Code 1.144.1, Red Hat Java 1.58.0, JDT LS 1.63.0.202610161533, and AutoTest 0.7.28.

Extension under test Reproduction steps passed Inspection failures Parent model error 969
Published 0.27.7 20/22 (the two error-absence assertions fail) 10 10
Published 0.27.6 control 22/22 0 0
Fresh local VSIX with this fix 22/22 0 0
  • Existing java-dep-view-modes.yaml: 36/36 passed, covering flat/hierarchical presentation, refresh, non-Java resource visibility, retained application.yml, and hidden redundant empty physical source ancestors.
  • Java OSGi bundle build, TypeScript compilation, production webpack build, and VSIX packaging passed.
  • Verified that the packaged and actually installed Java bundle match the freshly compiled JAR.
  • Error absence is checked against the full language-server log, not just visible Output-channel lines or screenshots.

The fixed VSIX is a local build of 0.27.7, not a new Marketplace release.

Validation screenshots

Before: published 0.27.7

The Maven parent and its physical folders exist, but browsing them logs the inspection failure and Java model error 969.

Published 0.27.7 reproduces the inspection failure and Java model error 969 for the existing Maven parent

After: freshly built fixed VSIX

The same Maven parent's src/main and src/test folders remain visible. This run passes all 22/22 steps, including both full-log error-absence assertions; the screenshot illustrates the retained folder display rather than serving as the error-absence assertion.

Fixed VSIX preserves the non-Java Maven parent's physical source folders in Java Projects

Folder-view regression: resource file retained and redundant physical ancestor hidden (36/36 passed)

src/main/resources/application.yml remains visible, while the duplicate empty physical src ancestor stays hidden.

Fixed VSIX retains application.yml under the resources source root without showing the duplicate physical src ancestor

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟢 Approval recommended

No active review issues are recorded for the Java-nature guard and its regression-test plan.

No open issues 🎉

What changed in this PR

Fixes #1119 by checking Java nature before inspecting source classpath entries, preventing Java-model errors for non-Java Maven parent projects while preserving their ordinary folders.

Changes:

  • Uses ProjectUtils.getJavaProject() to skip source-entry inspection for non-Java projects while retaining existing error handling.
  • Adds an AutoTest regression plan that checks Maven parent folder visibility and verifies the full language-server log contains neither reported error.
File Description
test/​e2e-plans/​java-dep-source-entry-inspection.yaml Adds deterministic folder-visibility and full-log error-absence checks.
jdtls.ext/​com.microsoft.jdtls.ext.core/​src/​com/​microsoft/​jdtls/​ext/​core/​parser/​ResourceSet.java Validates Java nature before inspecting source classpath entries.

Review effort: Balanced

@wenytang-ms wenyt (wenytang-ms) changed the title Fix Java source inspection for non-Java projects fix: Java source inspection for non-Java projects Nov 4, 2026
@wenytang-ms
wenyt (wenytang-ms) merged commit 4b6386c into main Nov 4, 2026
68 of 72 checks passed
@wenytang-ms
wenyt (wenytang-ms) deleted the wenytang-ms-java-source-inspection-error branch November 4, 2026 08:23
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.

New error on 0.27.7 - Failed to inspect Java source entries

3 participants