Add didOpen handler (WIP)
This commit is contained in:
parent
81229426da
commit
d86d2af6d0
1 changed files with 29 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ static void _notify_handler(json_rpc_request_t *req, void *arg);
|
|||
static int _initialize(json_rpc_request_t *req, cJSON **resp, void *arg);
|
||||
static int _shutdown(json_rpc_request_t *req, cJSON **resp, void *arg);
|
||||
|
||||
static void _didopen_notf(json_rpc_request_t *req, void *arg);
|
||||
static void _exit_notf(json_rpc_request_t *req, void *arg);
|
||||
|
||||
int
|
||||
|
|
@ -79,7 +80,9 @@ _notify_handler(json_rpc_request_t *req, void *arg)
|
|||
|
||||
log_info("Handle notification \"%s\"\r\n", method);
|
||||
|
||||
if (!strcmp(method, "exit")) {
|
||||
if (!strcmp(method, "textDocument/didOpen")) {
|
||||
_didopen_notf(req, arg);
|
||||
} else if (!strcmp(method, "exit")) {
|
||||
_exit_notf(req, arg);
|
||||
} else {
|
||||
log_warn("Unrecognized notification method\r\n");
|
||||
|
|
@ -151,6 +154,31 @@ _shutdown(json_rpc_request_t *req, cJSON **resp, void *arg)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
_didopen_notf(json_rpc_request_t *req, void *arg) {
|
||||
cJSON *textdoc = cJSON_GetObjectItem(req->params, "textDocument");
|
||||
cJSON *val;
|
||||
|
||||
if ((textdoc == NULL) || (!cJSON_IsObject(textdoc))) {
|
||||
log_error("Invalid textDocument field\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
val = cJSON_GetObjectItem(textdoc, "uri");
|
||||
if (val && cJSON_IsString(val)) {
|
||||
log_info("textdoc uri: %s\r\n", val->valuestring);
|
||||
} else {
|
||||
log_warn("Invalid uri\r\n");
|
||||
}
|
||||
|
||||
val = cJSON_GetObjectItem(textdoc, "text");
|
||||
if (val && cJSON_IsString(val)) {
|
||||
log_info("textdoc text: \"%s\"\r\n", val->valuestring);
|
||||
} else {
|
||||
log_warn("Invalid text\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_exit_notf(json_rpc_request_t *req, void *arg)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue