Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow LSP test_file to autofill didOpen params from previous splits #5078

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

DavidLoftus
Copy link
Contributor

Currently file tests for LSP must provide carbon source code as an escaped string within notify params, i.e.

[[@LSP-NOTIFY:textDocument/didOpen:
  "textDocument": {
    "uri": "file:/class.carbon",
    "languageId": "carbon",
    "text": "class A {\n  fn F();\n  fn G() {}\n}\n"
  }
]]

This works fine for simple, single line files but gets annoying when working with more complicated files which are necessary when testing more complicated features e.g. goto-definition

--- class.carbon
class A {
  fn F();
  fn G() {}
}
--- STDIN
[[@LSP-NOTIFY:textDocument/didOpen:
  "textDocument": {
    "uri": "file:/class.carbon",
    "languageId": "carbon",
    "text": "AUTOFILL"
  }
]]

This PR extends file_test_base to be able to parse the notify/call params and inject files from the test_file's splits into the JSON input. I purposely avoid using the clangd types and manually parse the llvm::json::Value here to avoid introducing a depdendency on clangd to the generic file_test_base, but happy to change if we think that is fine. Also happy to accept other suggestions on alternative methods to achieve same result.

@github-actions github-actions bot requested a review from danakj March 6, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant