Skip to content

Add textDocument/references and textDocument/implementation to the LSP - #96

Open
trangius wants to merge 3 commits into
SogoCZE:mainfrom
trangius:add-references-and-implementation
Open

Add textDocument/references and textDocument/implementation to the LSP#96
trangius wants to merge 3 commits into
SogoCZE:mainfrom
trangius:add-references-and-implementation

Conversation

@trangius

Copy link
Copy Markdown
Contributor

Adds LSP support for "Find All References" and "Go to Implementation."

Tested manually in Zed via the seg4lt/zed-jai extension.

Example: a project where three programs share code:

  console/program.jai   does  #import,file "../repl.jai"
  2dgame/program.jai    does  #import,file "../repl.jai"
  3dgame/program.jai    does  #import,file "../repl.jai"

repl.jai then imports the engine module. So the path to engine/foo.jai depends on which program we reached it from:

  .../console/../engine/foo.jai
  .../2dgame/../engine/foo.jai
  .../3dgame/../engine/foo.jai

jails stored each as a separate entry in server.files.

When the editor opens that same file, its path is just:

  .../engine/foo.jai

That doesn't match any of the three above, so jails creates a fourth entry. That fourth entry isn't reachable from any program root in the load graph, so it has no siblings. Goto-definition, find references, and hover for anything outside the open file silently return nothing.

Fix: strip `..` and `.` segments from the path whenever we store or look up a file, so all four end up as the same key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant