Fixed occasional crash on Sublime text, only get params when we use then
This commit is contained in:
parent
98ebac6d64
commit
04638a6d4d
@ -55,7 +55,7 @@ pub fn collectDocComments(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return try std.mem.join(allocator, if (format == .Markdown) "\\\n" else "\n", lines.items);
|
return try std.mem.join(allocator, if (format == .Markdown) " \n" else "\n", lines.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a function signature (keywords, name, return value)
|
/// Gets a function signature (keywords, name, return value)
|
||||||
|
12
src/main.zig
12
src/main.zig
@ -819,7 +819,6 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
|
|
||||||
std.debug.assert(root.Object.getValue("method") != null);
|
std.debug.assert(root.Object.getValue("method") != null);
|
||||||
const method = root.Object.getValue("method").?.String;
|
const method = root.Object.getValue("method").?.String;
|
||||||
const params = root.Object.getValue("params").?.Object;
|
|
||||||
|
|
||||||
const start_time = std.time.milliTimestamp();
|
const start_time = std.time.milliTimestamp();
|
||||||
defer {
|
defer {
|
||||||
@ -829,6 +828,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
|
|
||||||
// Core
|
// Core
|
||||||
if (std.mem.eql(u8, method, "initialize")) {
|
if (std.mem.eql(u8, method, "initialize")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const client_capabs = params.getValue("capabilities").?.Object;
|
const client_capabs = params.getValue("capabilities").?.Object;
|
||||||
if (client_capabs.getValue("textDocument")) |text_doc_capabs| {
|
if (client_capabs.getValue("textDocument")) |text_doc_capabs| {
|
||||||
if (text_doc_capabs.Object.getValue("semanticTokens")) |_| {
|
if (text_doc_capabs.Object.getValue("semanticTokens")) |_| {
|
||||||
@ -875,6 +875,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
}
|
}
|
||||||
// Workspace folder changes
|
// Workspace folder changes
|
||||||
else if (std.mem.eql(u8, method, "workspace/didChangeWorkspaceFolders")) {
|
else if (std.mem.eql(u8, method, "workspace/didChangeWorkspaceFolders")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const event = params.getValue("event").?.Object;
|
const event = params.getValue("event").?.Object;
|
||||||
const added = event.getValue("added").?.Array;
|
const added = event.getValue("added").?.Array;
|
||||||
const removed = event.getValue("removed").?.Array;
|
const removed = event.getValue("removed").?.Array;
|
||||||
@ -903,6 +904,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
}
|
}
|
||||||
// File changes
|
// File changes
|
||||||
else if (std.mem.eql(u8, method, "textDocument/didOpen")) {
|
else if (std.mem.eql(u8, method, "textDocument/didOpen")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const document = params.getValue("textDocument").?.Object;
|
const document = params.getValue("textDocument").?.Object;
|
||||||
const uri = document.getValue("uri").?.String;
|
const uri = document.getValue("uri").?.String;
|
||||||
const text = document.getValue("text").?.String;
|
const text = document.getValue("text").?.String;
|
||||||
@ -910,6 +912,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
const handle = try document_store.openDocument(uri, text);
|
const handle = try document_store.openDocument(uri, text);
|
||||||
try publishDiagnostics(handle.*, configFromUriOr(uri, config));
|
try publishDiagnostics(handle.*, configFromUriOr(uri, config));
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/didChange")) {
|
} else if (std.mem.eql(u8, method, "textDocument/didChange")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const text_document = params.getValue("textDocument").?.Object;
|
const text_document = params.getValue("textDocument").?.Object;
|
||||||
const uri = text_document.getValue("uri").?.String;
|
const uri = text_document.getValue("uri").?.String;
|
||||||
const content_changes = params.getValue("contentChanges").?.Array;
|
const content_changes = params.getValue("contentChanges").?.Array;
|
||||||
@ -923,6 +926,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
try document_store.applyChanges(handle, content_changes, local_config.zig_lib_path);
|
try document_store.applyChanges(handle, content_changes, local_config.zig_lib_path);
|
||||||
try publishDiagnostics(handle.*, local_config);
|
try publishDiagnostics(handle.*, local_config);
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/didSave")) {
|
} else if (std.mem.eql(u8, method, "textDocument/didSave")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const text_document = params.getValue("textDocument").?.Object;
|
const text_document = params.getValue("textDocument").?.Object;
|
||||||
const uri = text_document.getValue("uri").?.String;
|
const uri = text_document.getValue("uri").?.String;
|
||||||
const handle = document_store.getHandle(uri) orelse {
|
const handle = document_store.getHandle(uri) orelse {
|
||||||
@ -934,6 +938,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
} else if (std.mem.eql(u8, method, "textDocument/willSave")) {
|
} else if (std.mem.eql(u8, method, "textDocument/willSave")) {
|
||||||
// noop
|
// noop
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/didClose")) {
|
} else if (std.mem.eql(u8, method, "textDocument/didClose")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const document = params.getValue("textDocument").?.Object;
|
const document = params.getValue("textDocument").?.Object;
|
||||||
const uri = document.getValue("uri").?.String;
|
const uri = document.getValue("uri").?.String;
|
||||||
|
|
||||||
@ -941,11 +946,13 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
}
|
}
|
||||||
// Semantic highlighting
|
// Semantic highlighting
|
||||||
else if (std.mem.eql(u8, method, "textDocument/semanticTokens")) {
|
else if (std.mem.eql(u8, method, "textDocument/semanticTokens")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
// TODO Implement this (we dont get here from vscode atm even when we get the client capab.)
|
// TODO Implement this (we dont get here from vscode atm even when we get the client capab.)
|
||||||
return try respondGeneric(id, empty_array_response);
|
return try respondGeneric(id, empty_array_response);
|
||||||
}
|
}
|
||||||
// Autocomplete / Signatures
|
// Autocomplete / Signatures
|
||||||
else if (std.mem.eql(u8, method, "textDocument/completion")) {
|
else if (std.mem.eql(u8, method, "textDocument/completion")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const text_document = params.getValue("textDocument").?.Object;
|
const text_document = params.getValue("textDocument").?.Object;
|
||||||
const uri = text_document.getValue("uri").?.String;
|
const uri = text_document.getValue("uri").?.String;
|
||||||
const position = params.getValue("position").?.Object;
|
const position = params.getValue("position").?.Object;
|
||||||
@ -1010,6 +1017,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
std.mem.eql(u8, method, "textDocument/typeDefinition") or
|
std.mem.eql(u8, method, "textDocument/typeDefinition") or
|
||||||
std.mem.eql(u8, method, "textDocument/implementation"))
|
std.mem.eql(u8, method, "textDocument/implementation"))
|
||||||
{
|
{
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const document = params.getValue("textDocument").?.Object;
|
const document = params.getValue("textDocument").?.Object;
|
||||||
const uri = document.getValue("uri").?.String;
|
const uri = document.getValue("uri").?.String;
|
||||||
const position = params.getValue("position").?.Object;
|
const position = params.getValue("position").?.Object;
|
||||||
@ -1048,6 +1056,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
try respondGeneric(id, null_result_response);
|
try respondGeneric(id, null_result_response);
|
||||||
}
|
}
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/hover")) {
|
} else if (std.mem.eql(u8, method, "textDocument/hover")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const document = params.getValue("textDocument").?.Object;
|
const document = params.getValue("textDocument").?.Object;
|
||||||
const uri = document.getValue("uri").?.String;
|
const uri = document.getValue("uri").?.String;
|
||||||
const position = params.getValue("position").?.Object;
|
const position = params.getValue("position").?.Object;
|
||||||
@ -1085,6 +1094,7 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
try respondGeneric(id, null_result_response);
|
try respondGeneric(id, null_result_response);
|
||||||
}
|
}
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/documentSymbol")) {
|
} else if (std.mem.eql(u8, method, "textDocument/documentSymbol")) {
|
||||||
|
const params = root.Object.getValue("params").?.Object;
|
||||||
const document = params.getValue("textDocument").?.Object;
|
const document = params.getValue("textDocument").?.Object;
|
||||||
const uri = document.getValue("uri").?.String;
|
const uri = document.getValue("uri").?.String;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user