Skip to content

feat(cdk-explorer): add cdk/getConstructTree LSP route#1746

Merged
megha-narayanan merged 2 commits into
aws:mainfrom
megha-narayanan:feat/cdk-lsp-construct-tree
Jul 22, 2026
Merged

feat(cdk-explorer): add cdk/getConstructTree LSP route#1746
megha-narayanan merged 2 commits into
aws:mainfrom
megha-narayanan:feat/cdk-lsp-construct-tree

Conversation

@megha-narayanan

Copy link
Copy Markdown
Contributor

Exposes the source-decorated construct tree over the language server so a client can overlay source links onto its own tree without re-implementing resolution. The server already builds this tree for hover, definition, and CodeLens; this adds a cdk/getConstructTree request that serializes it.

Each entry is flattened and keyed by construct path (as in tree.json), carrying the resolved source location, the template file, and the character offset of the resource's block in that template.

  • No new resolution. The handler serializes the tree the server already caches (cachedIndex), so source locations and template files are exactly what hover and definition use. There is no second resolver to drift.
  • Flat entries, not a nested tree. The consumer keeps its own tree and only needs a path to location lookup, so the response is one entry per construct keyed by path.
  • templateOffset resolved per request. Each resource's block offset comes from cloud-assembly-api's template ranges, parsing each template at most once per request, so clients get a jump-to-resource position with no template-parsing dependency of their own.
  • no-assembly before synth. Until the app is synthesized there is no tree to serve, so the request returns a no-assembly status rather than erroring.

Fixes #

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Exposes the source-decorated construct tree (flattened, one entry per tree path) via a custom LSP request so a client can overlay source links and an open-template action without re-implementing source resolution.

The server already builds this tree for hover, definition, and CodeLens; onGetConstructTree serializes the cached tree in pre-order. Each entry carries sourceLocation, templateFile, and templateOffset (the resource block offset, resolved via cloud-assembly-api template ranges, each template parsed once). Returns no-assembly before synth.

Tests cover the flattened pre-order tree, templateOffset placement, and the no-assembly case.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.64%. Comparing base (58854ba) to head (efaf444).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1746      +/-   ##
==========================================
+ Coverage   89.59%   89.64%   +0.04%     
==========================================
  Files          78       78              
  Lines       11796    11847      +51     
  Branches     1657     1664       +7     
==========================================
+ Hits        10569    10620      +51     
  Misses       1198     1198              
  Partials       29       29              
Flag Coverage Δ
suite.unit 89.64% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@megha-narayanan megha-narayanan changed the title feat(lsp): add cdk/getConstructTree LSP route feat(cdk-explorer): add cdk/getConstructTree LSP route Jul 21, 2026
@megha-narayanan
megha-narayanan added this pull request to the merge queue Jul 22, 2026
@megha-narayanan
megha-narayanan removed this pull request from the merge queue due to a manual request Jul 22, 2026
@ShadowCat567

Copy link
Copy Markdown
Contributor

@mergify queue

@megha-narayanan
megha-narayanan added this pull request to the merge queue Jul 22, 2026
Merged via the queue into aws:main with commit 237e1b2 Jul 22, 2026
16 of 17 checks passed
@megha-narayanan
megha-narayanan deleted the feat/cdk-lsp-construct-tree branch July 22, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants