Skip to content

Conversation

@5t3ph
Copy link
Contributor

@5t3ph 5t3ph commented Dec 16, 2025

Description

This is PR number 4 of 5

Review the extension's README for the install instructions, key features, and examples of how the extension works.

Motivation and context

This PR adds a VS Code extension that provides IntelliSense for token('…') usage, backed by @adobe/swc-tokens. It focuses on improving authoring ergonomics (autocomplete, quote handling, and diagnostics) while keeping the implementation predictable, testable, and aligned with existing token tooling.

The extension is implemented using a language-server-style split to keep token logic editor-agnostic and easy to evolve.

Why this approach

Language server–first design

Token parsing, completions, and diagnostics live in a pure server layer, separate from VS Code UI concerns.
This makes the logic:

  • Easier to test (no editor required)
  • Safer to refactor
  • Potentially reusable beyond VS Code
Pre-generated token data

The extension consumes a generated tokens.json rather than loading packages at runtime.

This keeps:

  • Editor behavior fast and synchronous
  • The extension offline-safe
  • Token data consistent with other internal tooling
Context-aware completions

Completions understand real CSS usage patterns, including:

  • Nested calc() and var() calls
  • Editing existing token() values
  • Missing or partial quotes

The goal is to avoid clobbering syntax while still being helpful during incremental edits.

Normalization over strictness

Common authoring mistakes (e.g. extra whitespace inside quotes) are automatically corrected where safe.
True errors (unknown tokens, missing quotes) still surface as diagnostics.

This keeps feedback useful without being noisy or blocking.

Testing strategy

Tests focus on realistic editor behavior:

  • Cursor-position–aware completions
  • Correct replacement ranges
  • Incremental typing and edits

This helps catch subtle regressions that wouldn’t show up in snapshot-style tests.

Out of scope / intentional constraints

  • No attempt to validate full CSS correctness
  • No runtime token resolution in the editor
  • No enforcement of token usage (assistive only)

These constraints keep the extension focused and predictable.

Screenshots

image image

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have added automated tests to cover my changes.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Automated tests cover all use cases and follow best practices for writing

Manual review test cases

The unit and integration tests should be fairly comprehensive, but I encourage you to install the extension and try it out!

5t3ph added 26 commits December 1, 2025 11:54
@5t3ph 5t3ph requested a review from a team as a code owner December 16, 2025 16:26
@5t3ph 5t3ph added Feature New feature or request CSS Processing 2nd gen These issues or PRs map to our 2nd generation work to modernizing infrastructure. labels Dec 16, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

⚠️ No Changeset found

Latest commit: 2639275

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@5t3ph 5t3ph changed the title Feature: token() VS Code Intellisense Extension (4/5) Feature: token() VS Code Intellisense Extension Dec 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

📚 Branch Preview Links

🔍 First Generation Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5943

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Comment on lines +58 to +59
"@adobe/postcss-token": "workspace:*",
"@adobe/swc-tokens": "workspace:*",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes versions workspace relative to assist in keeping changes in sync

TBD: an alternate method if we eventually decide to publish these packages for consumers

- **Resolved value** – A final primitive value
- **Custom property** – A CSS variable (`var(--swc-gray-500)`)

## Upon Token Data Update
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like the lightest-weight way to enable this across the affected packages, but we can evolve this process down the line if needed.

This should not need to be run often, as token values don't change frequently.

@@ -0,0 +1,201 @@
Apache License
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dupe required here to avoid a flag for deploying the extension

Copy link
Member

@cdransf cdransf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one minor comment. ✨

});

client.start();
// .then(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this block of comments? We can always restore from git history if needed.

Copy link
Contributor

@nikkimk nikkimk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had lots of fun playing with this locally. Instructions were clear. I had no issue using the extension. LGTM

Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installed the extension and it seems to work great! Looking forward to using it when writing CSS!

Base automatically changed from seckles/feature/component-styles to main January 16, 2026 16:08
@5t3ph 5t3ph enabled auto-merge (squash) January 16, 2026 16:26
@5t3ph 5t3ph merged commit e617033 into main Jan 16, 2026
21 checks passed
@5t3ph 5t3ph deleted the seckles/feature/swc-vscode-token branch January 16, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2nd gen These issues or PRs map to our 2nd generation work to modernizing infrastructure. CSS Processing Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants