Skip to content

feat: template ranges + two-way template/source navigation#1624

Open
megha-narayanan wants to merge 2 commits into
aws:feat/cdk-lspfrom
megha-narayanan:feat/explorer-range-mapping
Open

feat: template ranges + two-way template/source navigation#1624
megha-narayanan wants to merge 2 commits into
aws:feat/cdk-lspfrom
megha-narayanan:feat/explorer-range-mapping

Conversation

@megha-narayanan

Copy link
Copy Markdown
  • Computes character ranges for CloudFormation resource blocks in synthesized templates and uses them for navigation in both directions:
  • CodeLens "go to" now selects the whole resource block (was a zero-width cursor).
  • New go-to-definition from a synthesized template back to the construct's source.

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

Adds jsonc-parser@3.2.0 as a runtime dep, in preparation for computing
character ranges of template resource/property blocks (PR-A). Dedupes to
the jsonc-parser already resolved in the lockfile; no new version added.
…te ranges

Compute character-accurate ranges of CloudFormation resource blocks in
synthesized templates and use them for navigation in both directions.

cloud-assembly-api:
- resolveResourceRange(text, logicalId): the character range of a resource's
  value block, via jsonc-parser. A position-aware parse is used instead of a
  line scan because real templates contain literal braces and escaped quotes
  inside string values (for example Fn::Sub placeholders) that defeat naive
  brace matching.
- resolveLogicalIdAtOffset(text, offset): the inverse, mapping a position in a
  template back to the enclosing resource's logical id.

cdk-explorer LSP:
- resourceTarget now returns the real resource block range (previously a
  zero-width cursor at the logical-id key), so the CodeLens "go to" selects the
  whole block.
- onDefinition: go-to-definition from a synthesized template back to the
  construct's source, keyed by (templateFile, logicalId) since logical ids are
  only unique within a template.
- offset and position conversions extracted to lib/lsp/positions.ts.

The jsonc-parser runtime dependency is added in the preceding commit.
@github-actions github-actions Bot added the p2 label Jun 12, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team June 12, 2026 20:06
@megha-narayanan megha-narayanan marked this pull request as ready for review June 12, 2026 20:35
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.

1 participant