Skip to content

Ctrl+G D jumps to a C# symbol's definition, answered by its language server #454

Closed

Description

@a-team-app

Context

First slice of #63: a built-in language server client, proven on C# with csharp-ls. After this merges, a C# developer can jump from a call to its definition in another file in one key, and the status bar tells them whether the server is loading, ready, missing or stopped. This slice carries everything the first jump needs: starting and stopping the server, keeping it in step with open buffers, and the status bar state. See the pitch for the mockups.

Acceptance criteria

With csharp-ls installed (dotnet tool install -g csharp-ls) and a C# solution open:

  • Opening a .cs file shows C# ◌ loading in the status bar, beside where the language name is today, and it becomes C# ● ready once the server has loaded the solution.
  • With the caret on a call to a method declared in another file, Ctrl+G D opens that file and puts the caret on the method's name, revealed the way Go to line reveals a line.
  • Ctrl+G P then goes back to where Ctrl+G D was pressed, and Ctrl+G N forward again.
  • The same works for a type, a property and a local in the same file.
  • Ctrl+G D on a partial class lists its declarations in a picker (the Go to symbol picker's shape); Enter jumps to the one chosen.
  • Ctrl+G D still finds the right definition after unsaved edits that moved it.
  • Ctrl+G D with nothing to jump to (whitespace, a keyword) says so in the status bar and doesn't move.
  • Go to definition is in the Go menu after Go to symbol, showing Ctrl+G D, dimmed until the server is ready; it's in the F1 palette and on the mnemonic gd, and rebindable in Settings › Keyboard Shortcuts.
  • Without csharp-ls on PATH, opening a .cs file or pressing Ctrl+G D shows No C# language server. Install: dotnet tool install -g csharp-ls in the status bar. Nothing falls back to a text search.
  • If the server crashes, the status bar shows C# stopped and it isn't restarted in a loop.
  • Opening another folder or quitting leaves no csharp-ls process behind.
  • Files in languages without a server show just their language name, as today.
  • Works the same in the native (AOT) binary.

Tests

  • Message framing (Content-Length headers, split and joined reads), request/response matching, notifications and server-initiated requests the client must answer.
  • Buffer sync: open, edit, save and close produce the right notifications and versions.
  • Server lifecycle with a fake server process: start on first file, one per language and folder, shutdown on folder switch and quit, no restart loop after a crash.
  • Mapping a definition result (single location, several, none) to the jump, the picker or the status message.
  • The CI AOT job exercises the client (e.g. against a fake server) so trimming can't silently break it.

Out of scope

  • Find usages and the References tab (next task).
  • Settings › Language Servers, and servers for any language other than C# (later task). C# is hard-wired to csharp-ls for now.
  • Diagnostics, completion, hover, rename, formatting, server-backed Go to symbol.
  • Installing the server for the user.
  • StreamJsonRpc or any other RPC library: the pitch decided on a hand-rolled client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-team:devClaimed by the a-team Dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions