Skip to content

feat: go-to definition#9619

Merged
ematipico merged 1 commit into
feat/go-to-definitionfrom
feat/go-to-definition-part1
Mar 29, 2026
Merged

feat: go-to definition#9619
ematipico merged 1 commit into
feat/go-to-definitionfrom
feat/go-to-definition-part1

Conversation

@ematipico

@ematipico ematipico commented Mar 25, 2026

Copy link
Copy Markdown
Member

Summary

Part of #9618

This PR sets the foundations of go-to definition and implements part of the logic.

  • Added editor settings
  • Added conditional enabling via settings handle
  • Added dynamic registration of the capability
  • Features currently implemented
    • Simple JS binding detection and go-to in file and in another file
    • Simple class/className string detection of JSX attributes and HTML attributes, with go to the same file or another file

How it works

I added a new editor capability to the list. This new type now contains two functions, which are essentially two side of the same coin:

  • resolve_reference: essentially, when the cursor hovers over an entity, we resolve it against the CST of the document and its snippets. If we support it, we then return information such as the file path and the text range. Each language implements this function. Here, we also return a DefinitionReference that says: the reference is here (checked against the semantic model), the reference has been imported (via JS import for now, but it's been left generic), or the reference is a CSS string.
  • resolve_definition: It's the function that tries to find where the entity has been defined. It uses a mix of module graph and semantic model, depending on what we're looking for.

The module graph has been modified. We now store the content offset of the CSS snippets found in the HTML document. This information is needed so that, when we resolve the style definition, we can compute the correct offset.

Note

I used a coding agent to help me with tests, refactor of testing infra, updates things across tests. The majority of the architecture was designed by me.

Test Plan

Added plenty of tests.
Manually tested with Zed. It works like a charm for the things we're implementing.
Happy to share a recording if you want.

CI won't run, but I checked that just l and just f work. And all tests pass.

I refactored the tests of server.tests.ts because it was becoming a 2k lines of tests. I moved all the navigation tests into its own file, and added a new file to share the common utilities

Docs

@changeset-bot

changeset-bot Bot commented Mar 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cf03e1e

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

@ematipico ematipico requested review from a team March 25, 2026 11:39
@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter A-LSP Area: language server protocol L-JavaScript Language: JavaScript and super languages L-HTML Language: HTML and super languages labels Mar 25, 2026
@denbezrukov

Copy link
Copy Markdown
Contributor

WOW! It's so cool!

@ematipico ematipico merged commit 7e41ee9 into feat/go-to-definition Mar 29, 2026
5 checks passed
@ematipico ematipico deleted the feat/go-to-definition-part1 branch March 29, 2026 18:17
ematipico added a commit that referenced this pull request Apr 24, 2026
ematipico added a commit that referenced this pull request May 1, 2026
ematipico added a commit that referenced this pull request May 8, 2026
ematipico added a commit that referenced this pull request May 8, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Linter Area: linter A-LSP Area: language server protocol A-Project Area: project L-HTML Language: HTML and super languages L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants