fix: align Java LSP navigation tool contracts - #1099
Merged
Merged
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The breaking experimental contract migration still requires live JDT and Native/CLI reader integration validation.
Pull request overview
Aligns experimental Java navigation tools with actual provider behavior and source-range semantics.
Changes:
- Separates navigation ranges from full declaration read ranges.
- Adds URI/access/error/truncation handling and telemetry.
- Updates contracts, guidance, and isolated tests.
File summaries
| File | Description |
|---|---|
src/copilot/tools/javaContextTools.ts |
Revises navigation contracts and error handling. |
package.json |
Updates schemas and test scripts. |
resources/skills/java-lsp-tools/SKILL.md |
Documents revised workflow and fallbacks. |
resources/instruments/javaLspContext.instructions.md |
Aligns Java navigation guidance. |
test/lsp-tools-suite/javaContextTools.test.ts |
Adds contract coverage. |
test/lsp-tools-suite/index.ts |
Adds Mocha suite runner. |
test/runLspToolsTests.ts |
Adds isolated VS Code test launcher. |
test/index.ts |
Integrates tests into npm test. |
CONTRIBUTING.md |
Documents testing and telemetry. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wenyt (wenytang-ms)
marked this pull request as ready for review
September 18, 2026 07:15
wenyt (wenytang-ms)
requested review from
Changyong Gong (chagong) and
Jinbo Wang (testforstephen)
as code owners
September 18, 2026 07:15
Changyong Gong (chagong)
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Align the two experimental Java navigation tools with the capabilities and ranges actually returned by their providers. This fixes misleading tool contracts; it does not introduce a new LSP protocol or claim improved token savings.
Motivation
java.symbols.includeSourceMethodDeclarations(off by default); there is no corresponding field-search branch.NAME_RANGE. Turning that navigation location intoreadFileInputcan return only a declaration name rather than its implementation.Changes
selectionRange(1-based inclusive navigation lines); document outlines retain full declarationreadFileRangevalues. Resolve an outline only after selecting a candidate, not eagerly for every search result.documentUriand provide absolutefilepaths only for eligible workspace file locations. ReportoutlineSupportedandunsupportedReasonfor dependency, virtual, remote and outside-workspace locations. Reject ambiguous multi-root display-name paths.indexingInProgressreason withserverNotFullyReady, and explicitly report count/depth truncation.initialQueryDurationMsandretryQueryDurationMsalongside total duration, without recording query text, source paths or symbol names.npm run test-lsp-toolsentry point; also wire the suite intonpm test.Experimental output migration
findSymbolremovesreadFileInputand the old top-levelstartLine,endLine, and formattedrangefields. UseselectionRangeonly for navigation. For implementation reads, usedocumentUri-> file outline -> selected member'sreadFileRange.filepaths are absolute rather than workspace-display-relative. Unsupported outline locations have nofilefield.{ symbols: [], reason, message }; expected file-access errors return{ error, errorCode, hint }.serverNotFullyReadyinstead ofindexingInProgress.Validation
npm run compilepassed (TypeScript and webpack).npm run tslintpassed.npm run test-lsp-toolspassed: 21 tests on Windows in a VS Code 1.138.0 test host.git diff --checkpassed.Tests use real VS Code URI, range, filesystem-error and tool-result types while mocking providers, workspace membership, readiness and telemetry. They cover URI/path round trips, multi-root ambiguity, unsupported locations, full member ranges, known and unexpected errors, initialization states, normalization/retry behavior, provider timing fields, and count/depth truncation.
The full Java-project integration suite and live JDT/agent scenarios have not been run for this draft.
Follow-up / not included
Keeping this as a draft for review of the experimental contract migration and the remaining integration work.