mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
handle lifecycle in test server correctly
This commit is contained in:
@@ -14,6 +14,7 @@ while True:
|
||||
sys.stdin.readline()
|
||||
message = json.loads(sys.stdin.read(length))
|
||||
|
||||
response = None
|
||||
if message["method"] == "build/initialize":
|
||||
response = {
|
||||
"jsonrpc": "2.0",
|
||||
@@ -29,18 +30,28 @@ while True:
|
||||
}
|
||||
}
|
||||
}
|
||||
# ignore notifications
|
||||
elif message["method"] == "build/initialized":
|
||||
continue
|
||||
elif message["method"] == "build/shutdown":
|
||||
response = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": message["id"],
|
||||
"result": None
|
||||
}
|
||||
elif message["method"] == "build/exit":
|
||||
break
|
||||
# ignore other notifications
|
||||
elif "id" in message:
|
||||
response = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": message["id"],
|
||||
"error": {
|
||||
"code": 123,
|
||||
"message": "unhandled method",
|
||||
"message": "unhandled method {}".format(message["method"]),
|
||||
}
|
||||
}
|
||||
|
||||
responseStr = json.dumps(response)
|
||||
sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(responseStr), responseStr))
|
||||
sys.stdout.flush()
|
||||
|
||||
if response:
|
||||
responseStr = json.dumps(response)
|
||||
sys.stdout.write("Content-Length: {}\r\n\r\n{}".format(len(responseStr), responseStr))
|
||||
sys.stdout.flush()
|
||||
|
||||
Reference in New Issue
Block a user