Reapply parser-backed AppHost resource parsing#17480
Open
davidfowl wants to merge 2 commits into
Open
Conversation
This reverts the revert of #17361 and keeps the Yarn-only extension restore behavior from main. The tree-sitter dependencies resolve through the internal npm feed and package-lock.json remains deleted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17480Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17480" |
Keep the parser dependency lockfile update limited to the tree-sitter entries needed by the unrevert while preserving internal npm feed URLs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Reapplies parser-backed AppHost resource parsing in the VS Code extension so commented-out Add*/add* calls and resource-like strings no longer produce active CodeLens/gutter UI, while keeping the Yarn-only restore workflow.
Changes:
- Reintroduced syntax-based parsing: C# AppHost parsing via
web-tree-sitter+tree-sitter-c-sharp(WASM), JS/TS AppHost parsing via TypeScript AST traversal. - Updated CodeLens, gutter decorations, and AppHost file presence detection to use async parser APIs and added/updated tests for comment/string filtering and stale-update handling.
- Updated webpack config and extension dependencies/lockfile to bundle/load
.wasmassets needed by Tree-sitter, and adjusted VS Code launch/tasks to runyarn installbefore watch/launch.
Show a summary per file
| File | Description |
|---|---|
| extension/yarn.lock | Updates lockfile for Tree-sitter-related dependencies and other resolution reshaping under Yarn. |
| extension/webpack.config.js | Adds webpack handling to emit .wasm files as resources for runtime loading. |
| extension/src/types/web-tree-sitter.d.ts | Adds type augmentation needed to pass locateFile to Tree-sitter init in TS. |
| extension/src/test/vscodeWorkspaceConfig.test.ts | Adds tests ensuring launch/tasks run yarn install before launching the extension. |
| extension/src/test/parsers.test.ts | Updates parser tests for async APIs and validates comment/string filtering behavior. |
| extension/src/test/aspireCodeLensProvider.test.ts | Expands CodeLens + gutter decoration tests, including stale-result suppression scenarios. |
| extension/src/test/appHostFilePresenceWatcher.test.ts | Updates presence watcher tests for async behavior and debounced updates. |
| extension/src/editor/parsers/parserUtils.ts | Removes regex-based statement/comment utilities superseded by parser-backed implementations. |
| extension/src/editor/parsers/jsTsAppHostParser.ts | Replaces regex scanning with TypeScript AST traversal for JS/TS AppHost detection and resource parsing. |
| extension/src/editor/parsers/csharpAppHostParser.ts | Reintroduces Tree-sitter-backed C# parsing with WASM loading and AST-based filtering of inactive code. |
| extension/src/editor/parsers/AppHostResourceParser.ts | Makes parser contract async and updates registry lookup to await isAppHostFile. |
| extension/src/editor/AspireGutterDecorationProvider.ts | Switches gutter decoration computation to async parsing and adds per-editor versioning to ignore stale results. |
| extension/src/editor/AspireCodeLensProvider.ts | Updates CodeLens provider to async parsing and adds cancellation handling. |
| extension/src/editor/AppHostFilePresenceWatcher.ts | Converts AppHost visibility detection to async parsing with coalesced queued updates. |
| extension/package.json | Adds tree-sitter-c-sharp and web-tree-sitter dependencies required for C# parsing. |
| extension/.vscode/tasks.json | Adds a Yarn install task and a compound watch task for extension workspace. |
| extension/.vscode/launch.json | Updates preLaunchTask to the new compound watch task. |
| .vscode/tasks.json | Adds a Yarn install task and compound watch task for repo workspace. |
| .vscode/launch.json | Updates preLaunchTask to the new compound watch task for repo workspace launches. |
Copilot's findings
- Files reviewed: 17/19 changed files
- Comments generated: 3
| const value = this._anyVisibleEditorIsAppHost(); | ||
| private _queueUpdate(): void { | ||
| const version = ++this._updateVersion; | ||
| this._updateTask = this._update(version); |
Comment on lines
+61
to
72
| private async _update(version: number): Promise<void> { | ||
| const value = await this._anyVisibleEditorIsAppHost(); | ||
| if (version !== this._updateVersion) { | ||
| return; | ||
| } | ||
|
|
||
| if (value === this._lastValue) { | ||
| return; | ||
| } | ||
| this._lastValue = value; | ||
| this._repository.setAppHostFileOpen(value); | ||
| } |
Comment on lines
131
to
144
| this._debounceTimer = setTimeout(() => { | ||
| this._debounceTimer = undefined; | ||
| for (const editor of vscode.window.visibleTextEditors) { | ||
| if (editor.document === document) { | ||
| this._applyDecorations(editor); | ||
| void this._applyDecorations(editor); | ||
| } | ||
| } | ||
| }, 250); | ||
| } | ||
|
|
||
| private _updateAllVisibleEditors(): void { | ||
| for (const editor of vscode.window.visibleTextEditors) { | ||
| this._applyDecorations(editor); | ||
| void this._applyDecorations(editor); | ||
| } |
Contributor
|
❓ CLI E2E Tests unknown — 95 passed, 0 failed, 6 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26425776700 |
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.
Description
This reapplies parser-backed AppHost resource parsing from #17361 so the VS Code extension no longer treats commented-out resource declarations or sample code inside strings as active AppHost resources. That restores the CodeLens and gutter behavior from the original PR while keeping the Yarn-only restore fixes now on
main.The C# parser uses Tree-sitter again, JavaScript and TypeScript parsing use syntax-tree traversal, and the AppHost file presence, CodeLens, gutter decoration, and parser tests are restored for active resources, comments, block comments, trailing comments, string literals, and file-based C# AppHosts. The extension remains Yarn-only:
package-lock.jsonstays deleted,.npmrconly configures the internal npm feed for Yarn v1, and the new tree-sitter lockfile entries resolve throughdotnet-public-npminstead of public npm registry URLs.Validation:
cd extension && yarn install --frozen-lockfile --non-interactive && yarn test./restore.sh && MSBUILDTERMINALLOGGER=false dotnet build extension/Extension.proj /t:ValidateYarnLockRegistries /v:minimalFixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?