🐛 fix(core): enable syntax diagnostics
This commit is contained in:
@@ -340,6 +340,48 @@ def assert_framing(server: Path) -> None:
|
||||
raise RuntimeError("continuous framing should reach shutdown")
|
||||
|
||||
|
||||
def assert_diagnostics(server: Path) -> None:
|
||||
client = LspClient(server)
|
||||
try:
|
||||
client.send({
|
||||
"jsonrpc": "2.0",
|
||||
"id": 41,
|
||||
"method": "initialize",
|
||||
"params": {},
|
||||
})
|
||||
if client.read().get("id") != 41:
|
||||
raise RuntimeError("missing initialize response")
|
||||
|
||||
uri = "file:///diagnostics.tsl"
|
||||
client.send({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "textDocument/didOpen",
|
||||
"params": {
|
||||
"textDocument": {
|
||||
"uri": uri,
|
||||
"languageId": "tsl",
|
||||
"version": 1,
|
||||
"text": "function broken(",
|
||||
},
|
||||
},
|
||||
})
|
||||
diagnostics = client.read(timeout=1)
|
||||
if diagnostics.get("method") != "textDocument/publishDiagnostics":
|
||||
raise RuntimeError("didOpen should publish diagnostics")
|
||||
params = diagnostics.get("params", {})
|
||||
if params.get("uri") != uri or not params.get("diagnostics"):
|
||||
raise RuntimeError("syntax diagnostics should identify the opened document")
|
||||
|
||||
client.send({"jsonrpc": "2.0", "id": 42, "method": "shutdown"})
|
||||
if client.read().get("id") != 42:
|
||||
raise RuntimeError("missing shutdown response")
|
||||
client.send({"jsonrpc": "2.0", "method": "exit"})
|
||||
if client.close_input() != 0:
|
||||
raise RuntimeError("diagnostics sequence should shut down cleanly")
|
||||
finally:
|
||||
client.kill()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--server", type=Path, required=True)
|
||||
@@ -349,6 +391,7 @@ def main() -> int:
|
||||
assert_json_rpc_errors(args.server)
|
||||
assert_cancellation_and_failures(args.server)
|
||||
assert_framing(args.server)
|
||||
assert_diagnostics(args.server)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user