Add GrepResultService and RegionContextProviderService implementations - #333727
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 10
New issues introduced by this change (10)
| Severity | Finding |
|---|---|
extensions/copilot/src/extension/typescriptContext/vscode-node/regionContextProvider.ts — Only the initial provider is registered in disposables. After updateProvider() replaces it,… |
|
extensions/copilot/src/extension/typescriptContext/vscode-node/ts7/regionContextProvider.ts — This rejects typescriptreact and javascriptreact. The new debug command is explicitly enabled… |
|
extensions/copilot/src/extension/typescriptContext/vscode-node/ts6/regionContextProvider.ts — The TS6 provider also rejects the React language IDs, even though the command handler supports them… |
|
extensions/copilot/src/extension/tools/node/readFileTool.tsx — This gate bypasses the new grep/region correlation for every .tsx and .jsx read, despite the… |
|
extensions/copilot/package.json — The registered handler accepts JavaScript and JavaScript React editors… |
|
extensions/copilot/src/extension/typescriptContext/vscode-node/ts7/regionContextProvider.ts — The optional requested range is silently ignored whenever there is exactly one match. In… |
|
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/common/regionContextProvider.ts — The server-plugin implementation also drops requested for a single range, so TS6 behaves… |
|
extensions/copilot/src/extension/typescriptContext/vscode-node/ts7/regionContextProvider.ts — For an object-literal property such as handler: () => {}, this adds a function region for the… |
|
extensions/copilot/src/extension/tools/node/grepResultService.ts — TextSearchMatch2.ranges may contain multiple source matches, but initial cache population keeps… |
|
extensions/copilot/src/extension/typescriptContext/vscode-node/ts7/regionContextProvider.ts — When requested covers the whole parent, assigning continueWith: parent.parent makes the for… |
What changed in this PR
Adds grep-result caching and TypeScript structural-region discovery, wiring both into read-file telemetry and diagnostics.
Changes:
- Adds request-scoped grep-result storage.
- Implements TS6/TS7 region providers and protocol support.
- Registers services, diagnostics, and tests.
| File | Description |
|---|---|
extensions/copilot/src/platform/test/node/services.ts |
Registers null test services. |
extensions/copilot/src/platform/languageContextProvider/common/regionContextProvider.ts |
Defines region service contracts. |
extensions/copilot/src/extension/typescriptContext/vscode-node/ts7/test/regionContext.spec.ts |
Tests TS7 regions. |
extensions/copilot/src/extension/typescriptContext/vscode-node/ts7/regionContextProvider.ts |
Implements native TS7 regions. |
extensions/copilot/src/extension/typescriptContext/vscode-node/ts6/tsContextService.ts |
Provides relocated TS6 context service. |
extensions/copilot/src/extension/typescriptContext/vscode-node/ts6/regionContextProvider.ts |
Bridges TS6 region requests. |
extensions/copilot/src/extension/typescriptContext/vscode-node/ts6/nesRenameService.ts |
Provides relocated TS6 rename service. |
extensions/copilot/src/extension/typescriptContext/vscode-node/regionContextProvider.ts |
Switches active region provider. |
extensions/copilot/src/extension/typescriptContext/vscode-node/nesRenameService.ts |
Updates TS6 import path. |
extensions/copilot/src/extension/typescriptContext/vscode-node/languageContextService.ts |
Adds region logging command. |
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/node/test/regionContext.spec.ts |
Tests server-plugin regions. |
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/node/create.ts |
Registers region protocol handler. |
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/common/regionContextProvider.ts |
Implements TS6 AST regions. |
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/common/protocol.ts |
Adds server region protocol types. |
extensions/copilot/src/extension/typescriptContext/common/serverProtocol.ts |
Adds client region protocol types. |
extensions/copilot/src/extension/tools/node/test/grepResultService.spec.ts |
Tests grep-result lookup. |
extensions/copilot/src/extension/tools/node/test/findTextInFilesTool.spec.tsx |
Normalizes file ending. |
extensions/copilot/src/extension/tools/node/test/findTextInFilesResult.spec.tsx |
Adds URIs to fixtures. |
extensions/copilot/src/extension/tools/node/readFileTool.tsx |
Correlates reads with grep regions. |
extensions/copilot/src/extension/tools/node/grepResultService.ts |
Implements grep-result cache. |
extensions/copilot/src/extension/tools/node/findTextInFilesTool.tsx |
Records grouped grep results. |
extensions/copilot/src/extension/extension/vscode-node/services.ts |
Registers production services. |
extensions/copilot/package.nls.json |
Localizes the debug command. |
extensions/copilot/package.json |
Contributes the debug command. |
Suppressed comments (4)
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/common/regionContextProvider.ts:153
- Object-literal arrow properties are emitted twice here as well: once by this arrow-function case and again when the loop reaches the same
PropertyAssignment. Mark the parent as already represented withcontinueWith.
case ts.SyntaxKind.ArrowFunction:
if (ts.isPropertyAssignment(parent) && ts.isIdentifier(parent.name)) {
name = parent.name.text;
return { kind: 'function', name, rangeNode: parent };
extensions/copilot/src/extension/tools/node/readFileTool.tsx:196
- This records
readFileRegionAdjusted, whose schema says these are the lines after adjustment, butrangesis never changed and the original bounds are still rendered at line 230. The telemetry therefore reports a clipping that did not occur. Either apply the computed region before rendering or rename the event/schema to explicitly describe a hypothetical candidate.
if (regions !== undefined && regions.length > 0 && documentSnapshot.version === documentSnapshot.document.version) {
this.sendAdjustedRegionTelemetry(options, startLine, endLine, regions[0].range.start, regions[0].range.end);
extensions/copilot/src/extension/typescriptContext/serverPlugin/src/common/regionContextProvider.ts:222
- This has the same extra parent skip in the TS6/server implementation: after assigning
current = parent.parent, the loop increment advances past it, which drops the enclosing source-file region for a fully requested top-level parent. Continue withparentinstead.
continueWith: parent.parent
extensions/copilot/src/extension/tools/node/grepResultService.ts:66
- Incremental cache updates also inspect only
ranges[0], so additional ranges carried by each search match are lost even after the initial insertion path is fixed. Iterate every range before applying the existing per-line deduplication.
matches.files.set(file.uri.toString(), file.matches.map(m => m.ranges[0].sourceRange));
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Ladislau Szomoru (lszomoru)
previously approved these changes
Sep 1, 2026
Alex Ross (alexr00)
approved these changes
Sep 1, 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.

Introduce the GrepResultService and its null implementation, along with the RegionContextProviderService and its null counterpart. These services enhance the functionality related to text searching and region context management. The implementation includes tests to verify the behavior of the GrepResultService.