commit
8d86d54c0d
@ -5,7 +5,7 @@ pub const BuildOption = struct {
|
||||
name: []const u8,
|
||||
value: ?[]const u8 = null,
|
||||
|
||||
/// Frees the strings assocated with this `BuildOption` and invalidates `self`.
|
||||
/// Frees the strings associated with this `BuildOption` and invalidates `self`.
|
||||
pub fn deinit(self: *BuildOption, allocator: std.mem.Allocator) void {
|
||||
allocator.free(self.name);
|
||||
if (self.value) |val| {
|
||||
|
@ -1034,11 +1034,11 @@ pub fn uriFromImportStr(self: *const DocumentStore, allocator: std.mem.Allocator
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
var seperator_index = handle.uri.len;
|
||||
while (seperator_index > 0) : (seperator_index -= 1) {
|
||||
if (std.fs.path.isSep(handle.uri[seperator_index - 1])) break;
|
||||
var separator_index = handle.uri.len;
|
||||
while (separator_index > 0) : (separator_index -= 1) {
|
||||
if (std.fs.path.isSep(handle.uri[separator_index - 1])) break;
|
||||
}
|
||||
const base = handle.uri[0 .. seperator_index - 1];
|
||||
const base = handle.uri[0 .. separator_index - 1];
|
||||
|
||||
return URI.pathRelative(allocator, base, import_str) catch |err| switch (err) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
|
@ -48,10 +48,10 @@ pub fn parse(allocator: std.mem.Allocator, include_carriage_return: bool, reader
|
||||
}
|
||||
|
||||
pub fn write(header: Header, include_carriage_return: bool, writer: anytype) @TypeOf(writer).Error!void {
|
||||
const seperator: []const u8 = if (include_carriage_return) "\r\n" else "\n";
|
||||
try writer.print("Content-Length: {}{s}", .{ header.content_length, seperator });
|
||||
const separator: []const u8 = if (include_carriage_return) "\r\n" else "\n";
|
||||
try writer.print("Content-Length: {}{s}", .{ header.content_length, separator });
|
||||
if (header.content_type) |content_type| {
|
||||
try writer.print("Content-Type: {s}{s}", .{ content_type, seperator });
|
||||
try writer.print("Content-Type: {s}{s}", .{ content_type, separator });
|
||||
}
|
||||
try writer.writeAll(seperator);
|
||||
try writer.writeAll(separator);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ offset_encoding: offsets.Encoding = .@"utf-16",
|
||||
status: enum {
|
||||
/// the server has not received a `initialize` request
|
||||
uninitialized,
|
||||
/// the server has recieved a `initialize` request and is awaiting the `initialized` notification
|
||||
/// the server has received a `initialize` request and is awaiting the `initialized` notification
|
||||
initializing,
|
||||
/// the server has been initialized and is ready to received requests
|
||||
initialized,
|
||||
@ -416,7 +416,7 @@ fn getAstCheckDiagnostics(
|
||||
if (term != .Exited) return;
|
||||
|
||||
var last_diagnostic: ?types.Diagnostic = null;
|
||||
// we dont store DiagnosticRelatedInformation in last_diagnostic instead
|
||||
// we don't store DiagnosticRelatedInformation in last_diagnostic instead
|
||||
// its stored in last_related_diagnostics because we need an ArrayList
|
||||
var last_related_diagnostics: std.ArrayListUnmanaged(types.DiagnosticRelatedInformation) = .{};
|
||||
|
||||
@ -1520,9 +1520,9 @@ pub fn completeFieldAccess(server: *Server, handle: *const DocumentStore.Handle,
|
||||
}
|
||||
|
||||
pub fn formatDetailledLabel(item: *types.CompletionItem, arena: std.mem.Allocator) error{OutOfMemory}!void {
|
||||
// NOTE: this is not ideal, we should build a detailled label like we do for label/detail
|
||||
// because this implementation is very loose, nothing is formated properly so we need to clean
|
||||
// things a little bit, wich is quite messy
|
||||
// NOTE: this is not ideal, we should build a detailed label like we do for label/detail
|
||||
// because this implementation is very loose, nothing is formatted properly so we need to clean
|
||||
// things a little bit, which is quite messy
|
||||
// but it works, it provide decent results
|
||||
|
||||
std.debug.assert(item.kind != null);
|
||||
@ -1553,7 +1553,7 @@ pub fn formatDetailledLabel(item: *types.CompletionItem, arena: std.mem.Allocato
|
||||
it = it[0..end];
|
||||
}
|
||||
|
||||
// loggerger.info("## label: {s} it: {s} kind: {} isValue: {}", .{item.label, it, item.kind, isValue});
|
||||
// log.info("## label: {s} it: {s} kind: {} isValue: {}", .{item.label, it, item.kind, isValue});
|
||||
|
||||
if (std.mem.startsWith(u8, it, "fn ") or std.mem.startsWith(u8, it, "@")) {
|
||||
var s: usize = std.mem.indexOf(u8, it, "(") orelse return;
|
||||
@ -1615,7 +1615,7 @@ pub fn formatDetailledLabel(item: *types.CompletionItem, arena: std.mem.Allocato
|
||||
log.warn("something wrong when trying to build label detail for a .Variable {s}", .{it});
|
||||
return;
|
||||
}
|
||||
// loggerger.info("s: {} -> {}", .{s, e});
|
||||
// log.info("s: {} -> {}", .{s, e});
|
||||
item.insertText = item.label;
|
||||
item.insertTextFormat = .PlainText;
|
||||
item.detail = item.label;
|
||||
@ -1638,7 +1638,7 @@ pub fn formatDetailledLabel(item: *types.CompletionItem, arena: std.mem.Allocato
|
||||
log.warn("something wrong when trying to build label detail for a .Variable {s}", .{it});
|
||||
return;
|
||||
}
|
||||
// loggerger.info("s: {} -> {}", .{s, e});
|
||||
// log.info("s: {} -> {}", .{s, e});
|
||||
item.insertText = item.label;
|
||||
item.insertTextFormat = .PlainText;
|
||||
item.detail = item.label;
|
||||
@ -1679,7 +1679,7 @@ pub fn formatDetailledLabel(item: *types.CompletionItem, arena: std.mem.Allocato
|
||||
.description = item.label, // right
|
||||
};
|
||||
} else {
|
||||
// TODO: if something is missing, it neecs to be implemented here
|
||||
// TODO: if something is missing, it needs to be implemented here
|
||||
}
|
||||
|
||||
// if (item.labelDetails != null)
|
||||
@ -1741,11 +1741,11 @@ pub fn completeFileSystemStringLiteral(
|
||||
const loc = pos_context.loc().?;
|
||||
var completing = handle.tree.source[loc.start + 1 .. loc.end - 1];
|
||||
|
||||
var seperator_index = completing.len;
|
||||
while (seperator_index > 0) : (seperator_index -= 1) {
|
||||
if (std.fs.path.isSep(completing[seperator_index - 1])) break;
|
||||
var separator_index = completing.len;
|
||||
while (separator_index > 0) : (separator_index -= 1) {
|
||||
if (std.fs.path.isSep(completing[separator_index - 1])) break;
|
||||
}
|
||||
completing = completing[0..seperator_index];
|
||||
completing = completing[0..separator_index];
|
||||
|
||||
var search_paths: std.ArrayListUnmanaged([]const u8) = .{};
|
||||
if (std.fs.path.isAbsolute(completing) and pos_context != .import_string_literal) {
|
||||
@ -1895,9 +1895,9 @@ fn initializeHandler(server: *Server, request: types.InitializeParams) Error!typ
|
||||
server.client_capabilities.supports_will_save_wait_until = synchronization.willSaveWaitUntil orelse false;
|
||||
}
|
||||
if (textDocument.codeAction) |codeaction| {
|
||||
if (codeaction.codeActionLiteralSupport) |literlSupport| {
|
||||
if (codeaction.codeActionLiteralSupport) |literalSupport| {
|
||||
if (!skip_set_fixall) {
|
||||
const fixall = std.mem.indexOfScalar(types.CodeActionKind, literlSupport.codeActionKind.valueSet, .@"source.fixAll") != null;
|
||||
const fixall = std.mem.indexOfScalar(types.CodeActionKind, literalSupport.codeActionKind.valueSet, .@"source.fixAll") != null;
|
||||
server.client_capabilities.supports_code_action_fixall = fixall;
|
||||
}
|
||||
}
|
||||
@ -2093,15 +2093,15 @@ fn requestConfiguration(server: *Server) Error!void {
|
||||
return;
|
||||
}
|
||||
|
||||
const configuration_items = comptime confi: {
|
||||
var comp_confi: [std.meta.fields(Config).len]types.ConfigurationItem = undefined;
|
||||
const configuration_items = comptime config: {
|
||||
var comp_config: [std.meta.fields(Config).len]types.ConfigurationItem = undefined;
|
||||
inline for (std.meta.fields(Config), 0..) |field, index| {
|
||||
comp_confi[index] = .{
|
||||
comp_config[index] = .{
|
||||
.section = "zls." ++ field.name,
|
||||
};
|
||||
}
|
||||
|
||||
break :confi comp_confi;
|
||||
break :config comp_config;
|
||||
};
|
||||
|
||||
server.sendRequest(
|
||||
@ -2829,9 +2829,9 @@ fn selectionRangeHandler(server: *Server, request: types.SelectionRangeParams) E
|
||||
const allocator = server.arena.allocator();
|
||||
const handle = server.document_store.getHandle(request.textDocument.uri) orelse return null;
|
||||
|
||||
// For each of the input positons, we need to compute the stack of AST
|
||||
// For each of the input positions, we need to compute the stack of AST
|
||||
// nodes/ranges which contain the position. At the moment, we do this in a
|
||||
// super inefficient way, by iterationg _all_ nodes, selecting the ones that
|
||||
// super inefficient way, by iterating _all_ nodes, selecting the ones that
|
||||
// contain position, and then sorting.
|
||||
//
|
||||
// A faster algorithm would be to walk the tree starting from the root,
|
||||
|
@ -91,7 +91,7 @@ pub const Enum = struct {
|
||||
fields: std.StringArrayHashMapUnmanaged(void),
|
||||
values: std.AutoArrayHashMapUnmanaged(Index, void),
|
||||
namespace: NamespaceIndex,
|
||||
tag_type_infered: bool,
|
||||
tag_type_inferred: bool,
|
||||
};
|
||||
|
||||
pub const Function = struct {
|
||||
|
@ -127,10 +127,10 @@ fn formatSnippetPlaceholder(
|
||||
_ = fmt;
|
||||
_ = options;
|
||||
|
||||
var splitit = std.mem.split(u8, data, "}");
|
||||
while (splitit.next()) |segment| {
|
||||
var split_it = std.mem.split(u8, data, "}");
|
||||
while (split_it.next()) |segment| {
|
||||
try writer.writeAll(segment);
|
||||
if (splitit.index) |index|
|
||||
if (split_it.index) |index|
|
||||
if (data[index - 1] == '}') {
|
||||
try writer.writeAll("\\}");
|
||||
};
|
||||
@ -1109,8 +1109,8 @@ fn resolveTypeOfNodeUncached(analyser: *Analyser, node_handle: NodeWithHandle) e
|
||||
const switch_case = tree.fullSwitchCase(case).?;
|
||||
var descriptor = std.ArrayListUnmanaged(u8){};
|
||||
|
||||
for (switch_case.ast.values, 0..) |vals, index| {
|
||||
try descriptor.appendSlice(analyser.arena, tree.getNodeSource(vals));
|
||||
for (switch_case.ast.values, 0..) |values, index| {
|
||||
try descriptor.appendSlice(analyser.arena, tree.getNodeSource(values));
|
||||
if (index != switch_case.ast.values.len - 1) try descriptor.appendSlice(analyser.arena, ", ");
|
||||
}
|
||||
|
||||
@ -1649,7 +1649,7 @@ pub fn isSymbolChar(char: u8) bool {
|
||||
|
||||
/// Given a byte index in a document (typically cursor offset), classify what kind of entity is at that index.
|
||||
///
|
||||
/// Classification is based on the lexical structure -- we fetch the line containin index, tokenize it,
|
||||
/// Classification is based on the lexical structure -- we fetch the line containing index, tokenize it,
|
||||
/// and look at the sequence of tokens just before the cursor. Due to the nice way zig is designed (only line
|
||||
/// comments, etc) lexing just a single line is always correct.
|
||||
pub fn getPositionContext(
|
||||
|
@ -426,7 +426,7 @@ fn getDiscardLoc(text: []const u8, loc: offsets.Loc) ?offsets.Loc {
|
||||
return null;
|
||||
};
|
||||
|
||||
// check if the identifier is preceed by a equal sign and then an underscore
|
||||
// check if the identifier is precede by a equal sign and then an underscore
|
||||
var i: usize = loc.start - 1;
|
||||
var found_equal_sign = false;
|
||||
const underscore_position = found: {
|
||||
|
@ -191,7 +191,7 @@ fn convertSymbolsInternal(
|
||||
symbol_buffer: *std.ArrayListUnmanaged(types.DocumentSymbol),
|
||||
mappings: *std.ArrayListUnmanaged(IndexToPositionEntry),
|
||||
) []types.DocumentSymbol {
|
||||
// aquire storage for exactly `from.len` symbols
|
||||
// acquire storage for exactly `from.len` symbols
|
||||
const prev_len = symbol_buffer.items.len;
|
||||
symbol_buffer.items.len += from.len;
|
||||
const to: []types.DocumentSymbol = symbol_buffer.items[prev_len..];
|
||||
|
@ -179,14 +179,14 @@ pub fn locToRange(text: []const u8, loc: Loc, encoding: Encoding) types.Range {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn rangeToSlice(text: []const u8, range: types.Range, encodig: Encoding) []const u8 {
|
||||
return locToSlice(text, rangeToLoc(text, range, encodig));
|
||||
pub fn rangeToSlice(text: []const u8, range: types.Range, encoding: Encoding) []const u8 {
|
||||
return locToSlice(text, rangeToLoc(text, range, encoding));
|
||||
}
|
||||
|
||||
pub fn rangeToLoc(text: []const u8, range: types.Range, encodig: Encoding) Loc {
|
||||
pub fn rangeToLoc(text: []const u8, range: types.Range, encoding: Encoding) Loc {
|
||||
return .{
|
||||
.start = positionToIndex(text, range.start, encodig),
|
||||
.end = positionToIndex(text, range.end, encodig),
|
||||
.start = positionToIndex(text, range.start, encoding),
|
||||
.end = positionToIndex(text, range.end, encoding),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ pub fn getSignatureInfo(analyser: *Analyser, alloc: std.mem.Allocator, handle: *
|
||||
const token_starts = tree.tokens.items(.start);
|
||||
|
||||
// Use the innermost scope to determine the earliest token we would need
|
||||
// to scan up to find a function or buitin call
|
||||
// to scan up to find a function or builtin call
|
||||
const first_token = tree.firstToken(innermost_block);
|
||||
// We start by finding the token that includes the current cursor position
|
||||
const last_token = blk: {
|
||||
|
Loading…
Reference in New Issue
Block a user