use single line method signatures
This commit is contained in:
parent
f482950f5f
commit
ad8d75b613
197
src/analysis.zig
197
src/analysis.zig
@ -19,12 +19,7 @@ pub fn deinit() void {
|
||||
}
|
||||
|
||||
/// Gets a declaration's doc comments. Caller owns returned memory.
|
||||
pub fn getDocComments(
|
||||
allocator: *std.mem.Allocator,
|
||||
tree: Analysis.Tree,
|
||||
node: ast.Node.Index,
|
||||
format: types.MarkupContent.Kind,
|
||||
) !?[]const u8 {
|
||||
pub fn getDocComments(allocator: *std.mem.Allocator, tree: Analysis.Tree, node: ast.Node.Index, format: types.MarkupContent.Kind) !?[]const u8 {
|
||||
const base = tree.nodes.items(.main_token)[node];
|
||||
const base_kind = tree.nodes.items(.tag)[node];
|
||||
const tokens = tree.tokens.items(.tag);
|
||||
@ -72,13 +67,7 @@ pub fn getDocCommentTokenIndex(tokens: []std.zig.Token.Tag, base_token: ast.Toke
|
||||
} else idx + 1;
|
||||
}
|
||||
|
||||
pub fn collectDocComments(
|
||||
allocator: *std.mem.Allocator,
|
||||
tree: Analysis.Tree,
|
||||
doc_comments: ast.TokenIndex,
|
||||
format: types.MarkupContent.Kind,
|
||||
container_doc: bool,
|
||||
) ![]const u8 {
|
||||
pub fn collectDocComments(allocator: *std.mem.Allocator, tree: Analysis.Tree, doc_comments: ast.TokenIndex, format: types.MarkupContent.Kind, container_doc: bool) ![]const u8 {
|
||||
var lines = std.ArrayList([]const u8).init(allocator);
|
||||
defer lines.deinit();
|
||||
const tokens = tree.tokens.items(.tag);
|
||||
@ -106,12 +95,7 @@ pub fn getFunctionSignature(tree: Analysis.Tree, func: ast.full.FnProto) []const
|
||||
}
|
||||
|
||||
/// Creates snippet insert text for a function. Caller owns returned memory.
|
||||
pub fn getFunctionSnippet(
|
||||
allocator: *std.mem.Allocator,
|
||||
tree: Analysis.Tree,
|
||||
func: ast.full.FnProto,
|
||||
skip_self_param: bool,
|
||||
) ![]const u8 {
|
||||
pub fn getFunctionSnippet(allocator: *std.mem.Allocator, tree: Analysis.Tree, func: ast.full.FnProto, skip_self_param: bool) ![]const u8 {
|
||||
const name_index = func.name_token.?;
|
||||
|
||||
var buffer = std.ArrayList(u8).init(allocator);
|
||||
@ -172,12 +156,7 @@ pub fn getFunctionSnippet(
|
||||
return buffer.toOwnedSlice();
|
||||
}
|
||||
|
||||
pub fn hasSelfParam(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
document_store: *DocumentStore,
|
||||
handle: *DocumentStore.Handle,
|
||||
func: ast.full.FnProto,
|
||||
) !bool {
|
||||
pub fn hasSelfParam(arena: *std.heap.ArenaAllocator, document_store: *DocumentStore, handle: *DocumentStore.Handle, func: ast.full.FnProto) !bool {
|
||||
// Non-decl prototypes cannot have a self parameter.
|
||||
if (func.name_token == null) return false;
|
||||
if (func.ast.params.len == 0) return false;
|
||||
@ -314,12 +293,7 @@ fn isContainerDecl(decl_handle: DeclWithHandle) bool {
|
||||
};
|
||||
}
|
||||
|
||||
fn resolveVarDeclAliasInternal(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
node_handle: NodeWithHandle,
|
||||
root: bool,
|
||||
) error{OutOfMemory}!?DeclWithHandle {
|
||||
fn resolveVarDeclAliasInternal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, node_handle: NodeWithHandle, root: bool) error{OutOfMemory}!?DeclWithHandle {
|
||||
_ = root;
|
||||
const handle = node_handle.handle;
|
||||
const tree = handle.tree;
|
||||
@ -406,12 +380,7 @@ fn isBlock(tree: Analysis.Tree, node: ast.Node.Index) bool {
|
||||
};
|
||||
}
|
||||
|
||||
fn findReturnStatementInternal(
|
||||
tree: Analysis.Tree,
|
||||
fn_decl: ast.full.FnProto,
|
||||
body: ast.Node.Index,
|
||||
already_found: *bool,
|
||||
) ?ast.Node.Index {
|
||||
fn findReturnStatementInternal(tree: Analysis.Tree, fn_decl: ast.full.FnProto, body: ast.Node.Index, already_found: *bool) ?ast.Node.Index {
|
||||
var result: ?ast.Node.Index = null;
|
||||
|
||||
const node_tags = tree.nodes.items(.tag);
|
||||
@ -465,14 +434,7 @@ fn findReturnStatement(tree: Analysis.Tree, fn_decl: ast.full.FnProto, body: ast
|
||||
return findReturnStatementInternal(tree, fn_decl, body, &already_found);
|
||||
}
|
||||
|
||||
pub fn resolveReturnType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
fn_decl: ast.full.FnProto,
|
||||
handle: *DocumentStore.Handle,
|
||||
bound_type_params: *BoundTypeParams,
|
||||
fn_body: ?ast.Node.Index,
|
||||
) !?TypeWithHandle {
|
||||
pub fn resolveReturnType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, fn_decl: ast.full.FnProto, handle: *DocumentStore.Handle, bound_type_params: *BoundTypeParams, fn_body: ?ast.Node.Index) !?TypeWithHandle {
|
||||
const tree = handle.tree;
|
||||
if (isTypeFunction(tree, fn_decl) and fn_body != null) {
|
||||
// If this is a type function and it only contains a single return statement that returns
|
||||
@ -509,12 +471,7 @@ pub fn resolveReturnType(
|
||||
}
|
||||
|
||||
/// Resolves the child type of an optional type
|
||||
fn resolveUnwrapOptionalType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
opt: TypeWithHandle,
|
||||
bound_type_params: *BoundTypeParams,
|
||||
) !?TypeWithHandle {
|
||||
fn resolveUnwrapOptionalType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, opt: TypeWithHandle, bound_type_params: *BoundTypeParams) !?TypeWithHandle {
|
||||
const opt_node = switch (opt.type.data) {
|
||||
.other => |n| n,
|
||||
else => return null,
|
||||
@ -530,12 +487,7 @@ fn resolveUnwrapOptionalType(
|
||||
return null;
|
||||
}
|
||||
|
||||
fn resolveUnwrapErrorType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
rhs: TypeWithHandle,
|
||||
bound_type_params: *BoundTypeParams,
|
||||
) !?TypeWithHandle {
|
||||
fn resolveUnwrapErrorType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, rhs: TypeWithHandle, bound_type_params: *BoundTypeParams) !?TypeWithHandle {
|
||||
const rhs_node = switch (rhs.type.data) {
|
||||
.other => |n| n,
|
||||
.error_union => |n| return TypeWithHandle{
|
||||
@ -567,12 +519,7 @@ pub fn isPtrType(tree: Analysis.Tree, node: ast.Node.Index) bool {
|
||||
}
|
||||
|
||||
/// Resolves the child type of a deref type
|
||||
fn resolveDerefType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
deref: TypeWithHandle,
|
||||
bound_type_params: *BoundTypeParams,
|
||||
) !?TypeWithHandle {
|
||||
fn resolveDerefType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, deref: TypeWithHandle, bound_type_params: *BoundTypeParams) !?TypeWithHandle {
|
||||
const deref_node = switch (deref.type.data) {
|
||||
.other => |n| n,
|
||||
.pointer => |n| return TypeWithHandle{
|
||||
@ -605,13 +552,7 @@ fn resolveDerefType(
|
||||
}
|
||||
|
||||
/// Resolves slicing and array access
|
||||
fn resolveBracketAccessType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
lhs: TypeWithHandle,
|
||||
rhs: enum { Single, Range },
|
||||
bound_type_params: *BoundTypeParams,
|
||||
) !?TypeWithHandle {
|
||||
fn resolveBracketAccessType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, lhs: TypeWithHandle, rhs: enum { Single, Range }, bound_type_params: *BoundTypeParams) !?TypeWithHandle {
|
||||
const lhs_node = switch (lhs.type.data) {
|
||||
.other => |n| n,
|
||||
else => return null,
|
||||
@ -648,12 +589,7 @@ fn resolveBracketAccessType(
|
||||
}
|
||||
|
||||
/// Called to remove one level of pointerness before a field access
|
||||
pub fn resolveFieldAccessLhsType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
lhs: TypeWithHandle,
|
||||
bound_type_params: *BoundTypeParams,
|
||||
) !TypeWithHandle {
|
||||
pub fn resolveFieldAccessLhsType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, lhs: TypeWithHandle, bound_type_params: *BoundTypeParams) !TypeWithHandle {
|
||||
return (try resolveDerefType(store, arena, lhs, bound_type_params)) orelse lhs;
|
||||
}
|
||||
|
||||
@ -691,12 +627,7 @@ pub fn isTypeIdent(tree: Analysis.Tree, token_idx: ast.TokenIndex) bool {
|
||||
}
|
||||
|
||||
/// Resolves the type of a node
|
||||
pub fn resolveTypeOfNodeInternal(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
node_handle: NodeWithHandle,
|
||||
bound_type_params: *BoundTypeParams,
|
||||
) error{OutOfMemory}!?TypeWithHandle {
|
||||
pub fn resolveTypeOfNodeInternal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, node_handle: NodeWithHandle, bound_type_params: *BoundTypeParams) error{OutOfMemory}!?TypeWithHandle {
|
||||
// If we were asked to resolve this node before,
|
||||
// it is self-referential and we cannot resolve it.
|
||||
for (resolve_trail.items) |i| {
|
||||
@ -1201,13 +1132,7 @@ pub const FieldAccessReturn = struct {
|
||||
unwrapped: ?TypeWithHandle = null,
|
||||
};
|
||||
|
||||
pub fn getFieldAccessType(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
handle: *DocumentStore.Handle,
|
||||
source_index: usize,
|
||||
tokenizer: *std.zig.Tokenizer,
|
||||
) !?FieldAccessReturn {
|
||||
pub fn getFieldAccessType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *DocumentStore.Handle, source_index: usize, tokenizer: *std.zig.Tokenizer) !?FieldAccessReturn {
|
||||
var current_type = TypeWithHandle.typeVal(.{
|
||||
.node = undefined,
|
||||
.handle = handle,
|
||||
@ -1518,11 +1443,7 @@ fn tokenRangeAppend(prev: SourceRange, token: std.zig.Token) SourceRange {
|
||||
|
||||
const DocumentPosition = offsets.DocumentPosition;
|
||||
|
||||
pub fn documentPositionContext(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
document: types.TextDocument,
|
||||
doc_position: DocumentPosition,
|
||||
) !PositionContext {
|
||||
pub fn documentPositionContext(arena: *std.heap.ArenaAllocator, document: types.TextDocument, doc_position: DocumentPosition) !PositionContext {
|
||||
_ = document;
|
||||
|
||||
const line = doc_position.line;
|
||||
@ -1808,12 +1729,7 @@ const GetDocumentSymbolsContext = struct {
|
||||
encoding: offsets.Encoding,
|
||||
};
|
||||
|
||||
fn getDocumentSymbolsInternal(
|
||||
allocator: *std.mem.Allocator,
|
||||
tree: Analysis.Tree,
|
||||
node: ast.Node.Index,
|
||||
context: *GetDocumentSymbolsContext,
|
||||
) anyerror!void {
|
||||
fn getDocumentSymbolsInternal(allocator: *std.mem.Allocator, tree: Analysis.Tree, node: ast.Node.Index, context: *GetDocumentSymbolsContext) anyerror!void {
|
||||
const name = getDeclName(tree, node) orelse return;
|
||||
if (name.len == 0)
|
||||
return;
|
||||
@ -2072,16 +1988,7 @@ fn findContainerScope(container_handle: NodeWithHandle) ?*Scope {
|
||||
} else null;
|
||||
}
|
||||
|
||||
fn iterateSymbolsContainerInternal(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
container_handle: NodeWithHandle,
|
||||
orig_handle: *DocumentStore.Handle,
|
||||
comptime callback: anytype,
|
||||
context: anytype,
|
||||
instance_access: bool,
|
||||
use_trail: *std.ArrayList(*const ast.Node.Index),
|
||||
) error{OutOfMemory}!void {
|
||||
fn iterateSymbolsContainerInternal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, container_handle: NodeWithHandle, orig_handle: *DocumentStore.Handle, comptime callback: anytype, context: anytype, instance_access: bool, use_trail: *std.ArrayList(*const ast.Node.Index)) error{OutOfMemory}!void {
|
||||
const container = container_handle.node;
|
||||
const handle = container_handle.handle;
|
||||
|
||||
@ -2148,25 +2055,12 @@ fn iterateSymbolsContainerInternal(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iterateSymbolsContainer(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
container_handle: NodeWithHandle,
|
||||
orig_handle: *DocumentStore.Handle,
|
||||
comptime callback: anytype,
|
||||
context: anytype,
|
||||
instance_access: bool,
|
||||
) error{OutOfMemory}!void {
|
||||
pub fn iterateSymbolsContainer(store: *DocumentStore, arena: *std.heap.ArenaAllocator, container_handle: NodeWithHandle, orig_handle: *DocumentStore.Handle, comptime callback: anytype, context: anytype, instance_access: bool) error{OutOfMemory}!void {
|
||||
var use_trail = std.ArrayList(*const ast.Node.Index).init(&arena.allocator);
|
||||
return try iterateSymbolsContainerInternal(store, arena, container_handle, orig_handle, callback, context, instance_access, &use_trail);
|
||||
}
|
||||
|
||||
pub fn iterateLabels(
|
||||
handle: *DocumentStore.Handle,
|
||||
source_index: usize,
|
||||
comptime callback: anytype,
|
||||
context: anytype,
|
||||
) error{OutOfMemory}!void {
|
||||
pub fn iterateLabels(handle: *DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype) error{OutOfMemory}!void {
|
||||
for (handle.document_scope.scopes) |scope| {
|
||||
if (source_index >= scope.range.start and source_index < scope.range.end) {
|
||||
var decl_it = scope.decls.iterator();
|
||||
@ -2182,15 +2076,7 @@ pub fn iterateLabels(
|
||||
}
|
||||
}
|
||||
|
||||
fn iterateSymbolsGlobalInternal(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
handle: *DocumentStore.Handle,
|
||||
source_index: usize,
|
||||
comptime callback: anytype,
|
||||
context: anytype,
|
||||
use_trail: *std.ArrayList(*const ast.Node.Index),
|
||||
) error{OutOfMemory}!void {
|
||||
fn iterateSymbolsGlobalInternal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype, use_trail: *std.ArrayList(*const ast.Node.Index)) error{OutOfMemory}!void {
|
||||
for (handle.document_scope.scopes) |scope| {
|
||||
if (source_index >= scope.range.start and source_index <= scope.range.end) {
|
||||
var decl_it = scope.decls.iterator();
|
||||
@ -2231,14 +2117,7 @@ fn iterateSymbolsGlobalInternal(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iterateSymbolsGlobal(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
handle: *DocumentStore.Handle,
|
||||
source_index: usize,
|
||||
comptime callback: anytype,
|
||||
context: anytype,
|
||||
) error{OutOfMemory}!void {
|
||||
pub fn iterateSymbolsGlobal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype) error{OutOfMemory}!void {
|
||||
var use_trail = std.ArrayList(*const ast.Node.Index).init(&arena.allocator);
|
||||
return try iterateSymbolsGlobalInternal(store, arena, handle, source_index, callback, context, &use_trail);
|
||||
}
|
||||
@ -2279,13 +2158,7 @@ pub fn innermostContainer(handle: *DocumentStore.Handle, source_index: usize) Ty
|
||||
return TypeWithHandle.typeVal(.{ .node = current, .handle = handle });
|
||||
}
|
||||
|
||||
fn resolveUse(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
uses: []const *const ast.Node.Index,
|
||||
symbol: []const u8,
|
||||
handle: *DocumentStore.Handle,
|
||||
) error{OutOfMemory}!?DeclWithHandle {
|
||||
fn resolveUse(store: *DocumentStore, arena: *std.heap.ArenaAllocator, uses: []const *const ast.Node.Index, symbol: []const u8, handle: *DocumentStore.Handle) error{OutOfMemory}!?DeclWithHandle {
|
||||
// If we were asked to resolve this symbol before,
|
||||
// it is self-referential and we cannot resolve it.
|
||||
if (std.mem.indexOfScalar([*]const u8, using_trail.items, symbol.ptr) != null)
|
||||
@ -2319,11 +2192,7 @@ fn resolveUse(
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn lookupLabel(
|
||||
handle: *DocumentStore.Handle,
|
||||
symbol: []const u8,
|
||||
source_index: usize,
|
||||
) error{OutOfMemory}!?DeclWithHandle {
|
||||
pub fn lookupLabel(handle: *DocumentStore.Handle, symbol: []const u8, source_index: usize) error{OutOfMemory}!?DeclWithHandle {
|
||||
for (handle.document_scope.scopes) |scope| {
|
||||
if (source_index >= scope.range.start and source_index < scope.range.end) {
|
||||
if (scope.decls.getEntry(symbol)) |candidate| {
|
||||
@ -2342,13 +2211,7 @@ pub fn lookupLabel(
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn lookupSymbolGlobal(
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
handle: *DocumentStore.Handle,
|
||||
symbol: []const u8,
|
||||
source_index: usize,
|
||||
) error{OutOfMemory}!?DeclWithHandle {
|
||||
pub fn lookupSymbolGlobal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *DocumentStore.Handle, symbol: []const u8, source_index: usize) error{OutOfMemory}!?DeclWithHandle {
|
||||
const innermost_scope_idx = innermostBlockScopeIndex(handle.*, source_index);
|
||||
|
||||
var curr = innermost_scope_idx;
|
||||
@ -2555,11 +2418,7 @@ const ScopeContext = struct {
|
||||
tree: Analysis.Tree,
|
||||
};
|
||||
|
||||
fn makeInnerScope(
|
||||
allocator: *std.mem.Allocator,
|
||||
context: ScopeContext,
|
||||
node_idx: ast.Node.Index,
|
||||
) error{OutOfMemory}!void {
|
||||
fn makeInnerScope(allocator: *std.mem.Allocator, context: ScopeContext, node_idx: ast.Node.Index) error{OutOfMemory}!void {
|
||||
const scopes = context.scopes;
|
||||
const tree = context.tree;
|
||||
const tags = tree.nodes.items(.tag);
|
||||
@ -2675,11 +2534,7 @@ fn makeInnerScope(
|
||||
|
||||
// Whether we have already visited the root node.
|
||||
var had_root = true;
|
||||
fn makeScopeInternal(
|
||||
allocator: *std.mem.Allocator,
|
||||
context: ScopeContext,
|
||||
node_idx: ast.Node.Index,
|
||||
) error{OutOfMemory}!void {
|
||||
fn makeScopeInternal(allocator: *std.mem.Allocator, context: ScopeContext, node_idx: ast.Node.Index) error{OutOfMemory}!void {
|
||||
const scopes = context.scopes;
|
||||
const tree = context.tree;
|
||||
const tags = tree.nodes.items(.tag);
|
||||
|
@ -53,14 +53,7 @@ build_runner_path: []const u8,
|
||||
build_runner_cache_path: []const u8,
|
||||
std_uri: ?[]const u8,
|
||||
|
||||
pub fn init(
|
||||
self: *DocumentStore,
|
||||
allocator: *std.mem.Allocator,
|
||||
zig_exe_path: ?[]const u8,
|
||||
build_runner_path: []const u8,
|
||||
build_runner_cache_path: []const u8,
|
||||
zig_lib_path: ?[]const u8,
|
||||
) !void {
|
||||
pub fn init(self: *DocumentStore, allocator: *std.mem.Allocator, zig_exe_path: ?[]const u8, build_runner_path: []const u8, build_runner_cache_path: []const u8, zig_lib_path: ?[]const u8) !void {
|
||||
self.allocator = allocator;
|
||||
self.handles = std.StringHashMap(*Handle).init(allocator);
|
||||
self.zig_exe_path = zig_exe_path;
|
||||
@ -502,12 +495,7 @@ pub fn applySave(self: *DocumentStore, handle: *Handle) !void {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn applyChanges(
|
||||
self: *DocumentStore,
|
||||
handle: *Handle,
|
||||
content_changes: std.json.Array,
|
||||
offset_encoding: offsets.Encoding,
|
||||
) !void {
|
||||
pub fn applyChanges(self: *DocumentStore, handle: *Handle, content_changes: std.json.Array, offset_encoding: offsets.Encoding) !void {
|
||||
const document = &handle.document;
|
||||
|
||||
for (content_changes.items) |change| {
|
||||
@ -574,12 +562,7 @@ pub fn applyChanges(
|
||||
try self.refreshDocument(handle);
|
||||
}
|
||||
|
||||
pub fn uriFromImportStr(
|
||||
self: *DocumentStore,
|
||||
allocator: *std.mem.Allocator,
|
||||
handle: Handle,
|
||||
import_str: []const u8,
|
||||
) !?[]const u8 {
|
||||
pub fn uriFromImportStr(self: *DocumentStore, allocator: *std.mem.Allocator, handle: Handle, import_str: []const u8) !?[]const u8 {
|
||||
if (std.mem.eql(u8, import_str, "std")) {
|
||||
if (self.std_uri) |uri| return try std.mem.dupe(allocator, u8, uri) else {
|
||||
log.debug("Cannot resolve std library import, path is null.", .{});
|
||||
@ -742,12 +725,7 @@ pub fn deinit(self: *DocumentStore) void {
|
||||
self.build_files.deinit(self.allocator);
|
||||
}
|
||||
|
||||
fn tagStoreCompletionItems(
|
||||
self: DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
base: *DocumentStore.Handle,
|
||||
comptime name: []const u8,
|
||||
) ![]types.CompletionItem {
|
||||
fn tagStoreCompletionItems(self: DocumentStore, arena: *std.heap.ArenaAllocator, base: *DocumentStore.Handle, comptime name: []const u8) ![]types.CompletionItem {
|
||||
// TODO Better solution for deciding what tags to include
|
||||
var max_len: usize = @field(base.document_scope, name).count();
|
||||
for (base.imports_used.items) |uri| {
|
||||
@ -769,18 +747,10 @@ fn tagStoreCompletionItems(
|
||||
return result_set.entries.items(.key);
|
||||
}
|
||||
|
||||
pub fn errorCompletionItems(
|
||||
self: DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
base: *DocumentStore.Handle,
|
||||
) ![]types.CompletionItem {
|
||||
pub fn errorCompletionItems(self: DocumentStore, arena: *std.heap.ArenaAllocator, base: *DocumentStore.Handle) ![]types.CompletionItem {
|
||||
return try self.tagStoreCompletionItems(arena, base, "error_completions");
|
||||
}
|
||||
|
||||
pub fn enumCompletionItems(
|
||||
self: DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
base: *DocumentStore.Handle,
|
||||
) ![]types.CompletionItem {
|
||||
pub fn enumCompletionItems(self: DocumentStore, arena: *std.heap.ArenaAllocator, base: *DocumentStore.Handle) ![]types.CompletionItem {
|
||||
return try self.tagStoreCompletionItems(arena, base, "enum_completions");
|
||||
}
|
||||
|
126
src/main.zig
126
src/main.zig
@ -348,16 +348,7 @@ fn typeToCompletion(arena: *std.heap.ArenaAllocator, list: *std.ArrayList(types.
|
||||
}
|
||||
}
|
||||
|
||||
fn nodeToCompletion(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
list: *std.ArrayList(types.CompletionItem),
|
||||
node_handle: analysis.NodeWithHandle,
|
||||
unwrapped: ?analysis.TypeWithHandle,
|
||||
orig_handle: *DocumentStore.Handle,
|
||||
is_type_val: bool,
|
||||
parent_is_type_val: ?bool,
|
||||
config: Config,
|
||||
) error{OutOfMemory}!void {
|
||||
fn nodeToCompletion(arena: *std.heap.ArenaAllocator, list: *std.ArrayList(types.CompletionItem), node_handle: analysis.NodeWithHandle, unwrapped: ?analysis.TypeWithHandle, orig_handle: *DocumentStore.Handle, is_type_val: bool, parent_is_type_val: ?bool, config: Config) error{OutOfMemory}!void {
|
||||
const node = node_handle.node;
|
||||
const handle = node_handle.handle;
|
||||
const tree = handle.tree;
|
||||
@ -614,11 +605,7 @@ fn gotoDefinitionSymbol(id: types.RequestId, arena: *std.heap.ArenaAllocator, de
|
||||
});
|
||||
}
|
||||
|
||||
fn hoverSymbol(
|
||||
id: types.RequestId,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
decl_handle: analysis.DeclWithHandle,
|
||||
) (std.os.WriteError || error{OutOfMemory})!void {
|
||||
fn hoverSymbol(id: types.RequestId, arena: *std.heap.ArenaAllocator, decl_handle: analysis.DeclWithHandle) (std.os.WriteError || error{OutOfMemory})!void {
|
||||
const handle = decl_handle.handle;
|
||||
const tree = handle.tree;
|
||||
|
||||
@ -758,13 +745,7 @@ fn hoverDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, p
|
||||
return try hoverSymbol(id, arena, decl);
|
||||
}
|
||||
|
||||
fn getSymbolFieldAccess(
|
||||
handle: *DocumentStore.Handle,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
position: offsets.DocumentPosition,
|
||||
range: analysis.SourceRange,
|
||||
config: Config,
|
||||
) !?analysis.DeclWithHandle {
|
||||
fn getSymbolFieldAccess(handle: *DocumentStore.Handle, arena: *std.heap.ArenaAllocator, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config) !?analysis.DeclWithHandle {
|
||||
_ = config;
|
||||
|
||||
const name = identifierFromPosition(position.absolute_index, handle.*);
|
||||
@ -793,27 +774,12 @@ fn getSymbolFieldAccess(
|
||||
return null;
|
||||
}
|
||||
|
||||
fn gotoDefinitionFieldAccess(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
position: offsets.DocumentPosition,
|
||||
range: analysis.SourceRange,
|
||||
config: Config,
|
||||
resolve_alias: bool,
|
||||
) !void {
|
||||
fn gotoDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config, resolve_alias: bool) !void {
|
||||
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
|
||||
return try gotoDefinitionSymbol(id, arena, decl, resolve_alias);
|
||||
}
|
||||
|
||||
fn hoverDefinitionFieldAccess(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
position: offsets.DocumentPosition,
|
||||
range: analysis.SourceRange,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn hoverDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config) !void {
|
||||
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
|
||||
return try hoverSymbol(id, arena, decl);
|
||||
}
|
||||
@ -857,15 +823,7 @@ fn renameDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId,
|
||||
});
|
||||
}
|
||||
|
||||
fn renameDefinitionFieldAccess(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
position: offsets.DocumentPosition,
|
||||
range: analysis.SourceRange,
|
||||
new_name: []const u8,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn renameDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, new_name: []const u8, config: Config) !void {
|
||||
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
|
||||
|
||||
var workspace_edit = types.WorkspaceEdit{
|
||||
@ -891,14 +849,7 @@ fn renameDefinitionLabel(arena: *std.heap.ArenaAllocator, id: types.RequestId, h
|
||||
});
|
||||
}
|
||||
|
||||
fn referencesDefinitionGlobal(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
pos_index: usize,
|
||||
include_decl: bool,
|
||||
skip_std_references: bool,
|
||||
) !void {
|
||||
fn referencesDefinitionGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, pos_index: usize, include_decl: bool, skip_std_references: bool) !void {
|
||||
const decl = (try getSymbolGlobal(arena, pos_index, handle)) orelse return try respondGeneric(id, null_result_response);
|
||||
var locs = std.ArrayList(types.Location).init(&arena.allocator);
|
||||
try references.symbolReferences(
|
||||
@ -917,15 +868,7 @@ fn referencesDefinitionGlobal(
|
||||
});
|
||||
}
|
||||
|
||||
fn referencesDefinitionFieldAccess(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
position: offsets.DocumentPosition,
|
||||
range: analysis.SourceRange,
|
||||
include_decl: bool,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn referencesDefinitionFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, include_decl: bool, config: Config) !void {
|
||||
const decl = (try getSymbolFieldAccess(handle, arena, position, range, config)) orelse return try respondGeneric(id, null_result_response);
|
||||
var locs = std.ArrayList(types.Location).init(&arena.allocator);
|
||||
try references.symbolReferences(arena, &document_store, decl, offset_encoding, include_decl, &locs, std.ArrayList(types.Location).append, config.skip_std_references);
|
||||
@ -1109,13 +1052,7 @@ fn completeBuiltin(arena: *std.heap.ArenaAllocator, id: types.RequestId, config:
|
||||
});
|
||||
}
|
||||
|
||||
fn completeGlobal(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
pos_index: usize,
|
||||
handle: *DocumentStore.Handle,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn completeGlobal(arena: *std.heap.ArenaAllocator, id: types.RequestId, pos_index: usize, handle: *DocumentStore.Handle, config: Config) !void {
|
||||
var completions = std.ArrayList(types.CompletionItem).init(&arena.allocator);
|
||||
|
||||
const context = DeclToCompletionContext{
|
||||
@ -1138,14 +1075,7 @@ fn completeGlobal(
|
||||
});
|
||||
}
|
||||
|
||||
fn completeFieldAccess(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
position: offsets.DocumentPosition,
|
||||
range: analysis.SourceRange,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn completeFieldAccess(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, position: offsets.DocumentPosition, range: analysis.SourceRange, config: Config) !void {
|
||||
var completions = std.ArrayList(types.CompletionItem).init(&arena.allocator);
|
||||
|
||||
const line_mem_start = @ptrToInt(position.line.ptr) - @ptrToInt(handle.document.mem.ptr);
|
||||
@ -1170,12 +1100,7 @@ fn completeFieldAccess(
|
||||
});
|
||||
}
|
||||
|
||||
fn completeError(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn completeError(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, config: Config) !void {
|
||||
const completions = try document_store.errorCompletionItems(arena, handle);
|
||||
truncateCompletions(completions, config.max_detail_length);
|
||||
logger.debug("Completing error:", .{});
|
||||
@ -1191,12 +1116,7 @@ fn completeError(
|
||||
});
|
||||
}
|
||||
|
||||
fn completeDot(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
handle: *DocumentStore.Handle,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn completeDot(arena: *std.heap.ArenaAllocator, id: types.RequestId, handle: *DocumentStore.Handle, config: Config) !void {
|
||||
var completions = try document_store.enumCompletionItems(arena, handle);
|
||||
truncateCompletions(completions, config.max_detail_length);
|
||||
|
||||
@ -1432,12 +1352,7 @@ fn semanticTokensFullHandler(arena: *std.heap.ArenaAllocator, id: types.RequestI
|
||||
return try respondGeneric(id, no_semantic_tokens_response);
|
||||
}
|
||||
|
||||
fn completionHandler(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
req: requests.Completion,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn completionHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.Completion, config: Config) !void {
|
||||
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
|
||||
logger.warn("Trying to complete in non existent document {s}", .{req.params.textDocument.uri});
|
||||
return try respondGeneric(id, no_completions_response);
|
||||
@ -1460,12 +1375,7 @@ fn completionHandler(
|
||||
}
|
||||
}
|
||||
|
||||
fn signatureHelpHandler(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
req: requests.SignatureHelp,
|
||||
config: Config,
|
||||
) !void {
|
||||
fn signatureHelpHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.SignatureHelp, config: Config) !void {
|
||||
_ = config;
|
||||
|
||||
const getSignatureInfo = @import("signature_help.zig").getSignatureInfo;
|
||||
@ -1499,13 +1409,7 @@ fn signatureHelpHandler(
|
||||
return try respondGeneric(id, no_signatures_response);
|
||||
}
|
||||
|
||||
fn gotoHandler(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
id: types.RequestId,
|
||||
req: requests.GotoDefinition,
|
||||
config: Config,
|
||||
resolve_alias: bool,
|
||||
) !void {
|
||||
fn gotoHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: requests.GotoDefinition, config: Config, resolve_alias: bool) !void {
|
||||
const handle = document_store.getHandle(req.params.textDocument.uri) orelse {
|
||||
logger.warn("Trying to go to definition in non existent document {s}", .{req.params.textDocument.uri});
|
||||
return try respondGeneric(id, null_result_response);
|
||||
|
@ -9,13 +9,7 @@ usingnamespace @import("./ast.zig");
|
||||
|
||||
const ast = std.zig.Ast;
|
||||
|
||||
fn tokenReference(
|
||||
handle: *DocumentStore.Handle,
|
||||
tok: ast.TokenIndex,
|
||||
encoding: offsets.Encoding,
|
||||
context: anytype,
|
||||
comptime handler: anytype,
|
||||
) !void {
|
||||
fn tokenReference(handle: *DocumentStore.Handle, tok: ast.TokenIndex, encoding: offsets.Encoding, context: anytype, comptime handler: anytype) !void {
|
||||
const loc = offsets.tokenRelativeLocation(handle.tree, 0, handle.tree.tokens.items(.start)[tok], encoding) catch return;
|
||||
try handler(context, types.Location{
|
||||
.uri = handle.uri(),
|
||||
@ -32,14 +26,7 @@ fn tokenReference(
|
||||
});
|
||||
}
|
||||
|
||||
pub fn labelReferences(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
decl: analysis.DeclWithHandle,
|
||||
encoding: offsets.Encoding,
|
||||
include_decl: bool,
|
||||
context: anytype,
|
||||
comptime handler: anytype,
|
||||
) !void {
|
||||
pub fn labelReferences(arena: *std.heap.ArenaAllocator, decl: analysis.DeclWithHandle, encoding: offsets.Encoding, include_decl: bool, context: anytype, comptime handler: anytype) !void {
|
||||
_ = arena;
|
||||
|
||||
std.debug.assert(decl.decl.* == .label_decl);
|
||||
@ -70,15 +57,7 @@ pub fn labelReferences(
|
||||
}
|
||||
}
|
||||
|
||||
fn symbolReferencesInternal(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *DocumentStore,
|
||||
node_handle: analysis.NodeWithHandle,
|
||||
decl: analysis.DeclWithHandle,
|
||||
encoding: offsets.Encoding,
|
||||
context: anytype,
|
||||
comptime handler: anytype,
|
||||
) error{OutOfMemory}!void {
|
||||
fn symbolReferencesInternal(arena: *std.heap.ArenaAllocator, store: *DocumentStore, node_handle: analysis.NodeWithHandle, decl: analysis.DeclWithHandle, encoding: offsets.Encoding, context: anytype, comptime handler: anytype) error{OutOfMemory}!void {
|
||||
const node = node_handle.node;
|
||||
const handle = node_handle.handle;
|
||||
const tree = handle.tree;
|
||||
@ -515,16 +494,7 @@ fn symbolReferencesInternal(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn symbolReferences(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *DocumentStore,
|
||||
decl_handle: analysis.DeclWithHandle,
|
||||
encoding: offsets.Encoding,
|
||||
include_decl: bool,
|
||||
context: anytype,
|
||||
comptime handler: anytype,
|
||||
skip_std_references: bool,
|
||||
) !void {
|
||||
pub fn symbolReferences(arena: *std.heap.ArenaAllocator, store: *DocumentStore, decl_handle: analysis.DeclWithHandle, encoding: offsets.Encoding, include_decl: bool, context: anytype, comptime handler: anytype, skip_std_references: bool) !void {
|
||||
std.debug.assert(decl_handle.decl.* != .label_decl);
|
||||
const curr_handle = decl_handle.handle;
|
||||
if (include_decl) {
|
||||
|
@ -25,14 +25,7 @@ fn refHandler(context: RefHandlerContext, loc: types.Location) !void {
|
||||
try context.edits.put(loc.uri, text_edits.toOwnedSlice());
|
||||
}
|
||||
|
||||
pub fn renameSymbol(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *DocumentStore,
|
||||
decl_handle: analysis.DeclWithHandle,
|
||||
new_name: []const u8,
|
||||
edits: *std.StringHashMap([]types.TextEdit),
|
||||
encoding: offsets.Encoding,
|
||||
) !void {
|
||||
pub fn renameSymbol(arena: *std.heap.ArenaAllocator, store: *DocumentStore, decl_handle: analysis.DeclWithHandle, new_name: []const u8, edits: *std.StringHashMap([]types.TextEdit), encoding: offsets.Encoding) !void {
|
||||
std.debug.assert(decl_handle.decl.* != .label_decl);
|
||||
try references.symbolReferences(arena, store, decl_handle, encoding, true, RefHandlerContext{
|
||||
.edits = edits,
|
||||
@ -41,13 +34,7 @@ pub fn renameSymbol(
|
||||
}, refHandler, true);
|
||||
}
|
||||
|
||||
pub fn renameLabel(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
decl_handle: analysis.DeclWithHandle,
|
||||
new_name: []const u8,
|
||||
edits: *std.StringHashMap([]types.TextEdit),
|
||||
encoding: offsets.Encoding,
|
||||
) !void {
|
||||
pub fn renameLabel(arena: *std.heap.ArenaAllocator, decl_handle: analysis.DeclWithHandle, new_name: []const u8, edits: *std.StringHashMap([]types.TextEdit), encoding: offsets.Encoding) !void {
|
||||
std.debug.assert(decl_handle.decl.* == .label_decl);
|
||||
try references.labelReferences(arena, decl_handle, encoding, true, RefHandlerContext{
|
||||
.edits = edits,
|
||||
|
@ -177,20 +177,11 @@ const Builder = struct {
|
||||
}
|
||||
};
|
||||
|
||||
inline fn writeToken(
|
||||
builder: *Builder,
|
||||
token_idx: ?ast.TokenIndex,
|
||||
tok_type: TokenType,
|
||||
) !void {
|
||||
inline fn writeToken(builder: *Builder, token_idx: ?ast.TokenIndex, tok_type: TokenType) !void {
|
||||
return try writeTokenMod(builder, token_idx, tok_type, .{});
|
||||
}
|
||||
|
||||
inline fn writeTokenMod(
|
||||
builder: *Builder,
|
||||
token_idx: ?ast.TokenIndex,
|
||||
tok_type: TokenType,
|
||||
tok_mod: TokenModifiers,
|
||||
) !void {
|
||||
inline fn writeTokenMod(builder: *Builder, token_idx: ?ast.TokenIndex, tok_type: TokenType, tok_mod: TokenModifiers) !void {
|
||||
if (token_idx) |ti| {
|
||||
try builder.add(ti, tok_type, tok_mod);
|
||||
}
|
||||
@ -258,12 +249,7 @@ const WriteTokensError = error{
|
||||
MovedBackwards,
|
||||
};
|
||||
|
||||
fn writeNodeTokens(
|
||||
builder: *Builder,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *DocumentStore,
|
||||
maybe_node: ?ast.Node.Index,
|
||||
) WriteTokensError!void {
|
||||
fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *DocumentStore, maybe_node: ?ast.Node.Index) WriteTokensError!void {
|
||||
const node = maybe_node orelse return;
|
||||
|
||||
const handle = builder.handle;
|
||||
@ -995,14 +981,7 @@ fn writeNodeTokens(
|
||||
}
|
||||
}
|
||||
|
||||
fn writeContainerField(
|
||||
builder: *Builder,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *DocumentStore,
|
||||
node: ast.Node.Index,
|
||||
field_token_type: ?TokenType,
|
||||
child_frame: anytype,
|
||||
) !void {
|
||||
fn writeContainerField(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *DocumentStore, node: ast.Node.Index, field_token_type: ?TokenType, child_frame: anytype) !void {
|
||||
const tree = builder.handle.tree;
|
||||
const container_field = SemanticToken.containerField(tree, node).?;
|
||||
const base = tree.nodes.items(.main_token)[node];
|
||||
@ -1036,12 +1015,7 @@ fn writeContainerField(
|
||||
}
|
||||
|
||||
// TODO Range version, edit version.
|
||||
pub fn writeAllSemanticTokens(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *DocumentStore,
|
||||
handle: *DocumentStore.Handle,
|
||||
encoding: offsets.Encoding,
|
||||
) ![]u32 {
|
||||
pub fn writeAllSemanticTokens(arena: *std.heap.ArenaAllocator, store: *DocumentStore, handle: *DocumentStore.Handle, encoding: offsets.Encoding) ![]u32 {
|
||||
var builder = Builder.init(arena.child_allocator, handle, encoding);
|
||||
errdefer builder.arr.deinit();
|
||||
|
||||
|
@ -94,11 +94,7 @@ pub const DiagnosticSeverity = enum(i64) {
|
||||
Information = 3,
|
||||
Hint = 4,
|
||||
|
||||
pub fn jsonStringify(
|
||||
value: DiagnosticSeverity,
|
||||
options: json.StringifyOptions,
|
||||
out_stream: anytype,
|
||||
) !void {
|
||||
pub fn jsonStringify(value: DiagnosticSeverity, options: json.StringifyOptions, out_stream: anytype) !void {
|
||||
try json.stringify(@enumToInt(value), options, out_stream);
|
||||
}
|
||||
};
|
||||
@ -149,11 +145,7 @@ pub const TextDocument = struct {
|
||||
pub const WorkspaceEdit = struct {
|
||||
changes: ?std.StringHashMap([]TextEdit),
|
||||
|
||||
pub fn jsonStringify(
|
||||
self: WorkspaceEdit,
|
||||
options: std.json.StringifyOptions,
|
||||
writer: anytype,
|
||||
) @TypeOf(writer).Error!void {
|
||||
pub fn jsonStringify(self: WorkspaceEdit, options: std.json.StringifyOptions, writer: anytype) @TypeOf(writer).Error!void {
|
||||
try writer.writeByte('{');
|
||||
if (self.changes) |changes| {
|
||||
try writer.writeAll("\"changes\": {");
|
||||
@ -209,11 +201,7 @@ pub const InsertTextFormat = enum(i64) {
|
||||
PlainText = 1,
|
||||
Snippet = 2,
|
||||
|
||||
pub fn jsonStringify(
|
||||
value: InsertTextFormat,
|
||||
options: json.StringifyOptions,
|
||||
out_stream: anytype,
|
||||
) !void {
|
||||
pub fn jsonStringify(value: InsertTextFormat, options: json.StringifyOptions, out_stream: anytype) !void {
|
||||
try json.stringify(@enumToInt(value), options, out_stream);
|
||||
}
|
||||
};
|
||||
@ -246,11 +234,7 @@ pub const CompletionItem = struct {
|
||||
Operator = 24,
|
||||
TypeParameter = 25,
|
||||
|
||||
pub fn jsonStringify(
|
||||
value: Kind,
|
||||
options: json.StringifyOptions,
|
||||
out_stream: anytype,
|
||||
) !void {
|
||||
pub fn jsonStringify(value: Kind, options: json.StringifyOptions, out_stream: anytype) !void {
|
||||
try json.stringify(@enumToInt(value), options, out_stream);
|
||||
}
|
||||
};
|
||||
@ -294,11 +278,7 @@ pub const DocumentSymbol = struct {
|
||||
Operator = 25,
|
||||
TypeParameter = 26,
|
||||
|
||||
pub fn jsonStringify(
|
||||
value: Kind,
|
||||
options: json.StringifyOptions,
|
||||
out_stream: anytype,
|
||||
) !void {
|
||||
pub fn jsonStringify(value: Kind, options: json.StringifyOptions, out_stream: anytype) !void {
|
||||
try json.stringify(@enumToInt(value), options, out_stream);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user