undo DocumentStore constness changes
This commit is contained in:
parent
06ba47d460
commit
25ce5dd8aa
@ -181,7 +181,7 @@ pub fn getFunctionSnippet(allocator: std.mem.Allocator, tree: Ast, func: Ast.ful
|
||||
return buffer.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub fn hasSelfParam(arena: *std.heap.ArenaAllocator, document_store: *const DocumentStore, handle: *const DocumentStore.Handle, func: Ast.full.FnProto) !bool {
|
||||
pub fn hasSelfParam(arena: *std.heap.ArenaAllocator, document_store: *DocumentStore, handle: *const 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,7 +314,7 @@ fn getDeclName(tree: Ast, node: Ast.Node.Index) ?[]const u8 {
|
||||
};
|
||||
}
|
||||
|
||||
fn resolveVarDeclAliasInternal(store: *const 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;
|
||||
@ -367,7 +367,7 @@ fn resolveVarDeclAliasInternal(store: *const DocumentStore, arena: *std.heap.Are
|
||||
/// const decl = @import("decl-file.zig").decl;
|
||||
/// const other = decl.middle.other;
|
||||
///```
|
||||
pub fn resolveVarDeclAlias(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, decl_handle: NodeWithHandle) !?DeclWithHandle {
|
||||
pub fn resolveVarDeclAlias(store: *DocumentStore, arena: *std.heap.ArenaAllocator, decl_handle: NodeWithHandle) !?DeclWithHandle {
|
||||
const decl = decl_handle.node;
|
||||
const handle = decl_handle.handle;
|
||||
const tree = handle.tree;
|
||||
@ -431,7 +431,7 @@ fn findReturnStatement(tree: Ast, fn_decl: Ast.full.FnProto, body: Ast.Node.Inde
|
||||
return findReturnStatementInternal(tree, fn_decl, body, &already_found);
|
||||
}
|
||||
|
||||
pub fn resolveReturnType(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, fn_decl: Ast.full.FnProto, handle: *const 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: *const 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
|
||||
@ -468,7 +468,7 @@ pub fn resolveReturnType(store: *const DocumentStore, arena: *std.heap.ArenaAllo
|
||||
}
|
||||
|
||||
/// Resolves the child type of an optional type
|
||||
fn resolveUnwrapOptionalType(store: *const 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,
|
||||
@ -484,7 +484,7 @@ fn resolveUnwrapOptionalType(store: *const DocumentStore, arena: *std.heap.Arena
|
||||
return null;
|
||||
}
|
||||
|
||||
fn resolveUnwrapErrorType(store: *const 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{
|
||||
@ -505,7 +505,7 @@ fn resolveUnwrapErrorType(store: *const DocumentStore, arena: *std.heap.ArenaAll
|
||||
}
|
||||
|
||||
/// Resolves the child type of a deref type
|
||||
fn resolveDerefType(store: *const 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{
|
||||
@ -538,7 +538,7 @@ fn resolveDerefType(store: *const DocumentStore, arena: *std.heap.ArenaAllocator
|
||||
}
|
||||
|
||||
/// Resolves slicing and array access
|
||||
fn resolveBracketAccessType(store: *const 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,
|
||||
@ -575,7 +575,7 @@ fn resolveBracketAccessType(store: *const DocumentStore, arena: *std.heap.ArenaA
|
||||
}
|
||||
|
||||
/// Called to remove one level of pointerness before a field access
|
||||
pub fn resolveFieldAccessLhsType(store: *const 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;
|
||||
}
|
||||
|
||||
@ -614,7 +614,7 @@ pub fn isTypeIdent(text: []const u8) bool {
|
||||
}
|
||||
|
||||
/// Resolves the type of a node
|
||||
pub fn resolveTypeOfNodeInternal(store: *const 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| {
|
||||
@ -1080,7 +1080,7 @@ pub const TypeWithHandle = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub fn resolveTypeOfNode(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, node_handle: NodeWithHandle) error{OutOfMemory}!?TypeWithHandle {
|
||||
pub fn resolveTypeOfNode(store: *DocumentStore, arena: *std.heap.ArenaAllocator, node_handle: NodeWithHandle) error{OutOfMemory}!?TypeWithHandle {
|
||||
var bound_type_params = BoundTypeParams{};
|
||||
return resolveTypeOfNodeInternal(store, arena, node_handle, &bound_type_params);
|
||||
}
|
||||
@ -1153,7 +1153,7 @@ pub const FieldAccessReturn = struct {
|
||||
unwrapped: ?TypeWithHandle = null,
|
||||
};
|
||||
|
||||
pub fn getFieldAccessType(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, source_index: usize, tokenizer: *std.zig.Tokenizer) !?FieldAccessReturn {
|
||||
pub fn getFieldAccessType(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, source_index: usize, tokenizer: *std.zig.Tokenizer) !?FieldAccessReturn {
|
||||
var current_type = TypeWithHandle.typeVal(.{
|
||||
.node = undefined,
|
||||
.handle = handle,
|
||||
@ -1887,7 +1887,7 @@ pub const DeclWithHandle = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn resolveType(self: DeclWithHandle, store: *const DocumentStore, arena: *std.heap.ArenaAllocator, bound_type_params: *BoundTypeParams) !?TypeWithHandle {
|
||||
pub fn resolveType(self: DeclWithHandle, store: *DocumentStore, arena: *std.heap.ArenaAllocator, bound_type_params: *BoundTypeParams) !?TypeWithHandle {
|
||||
const tree = self.handle.tree;
|
||||
const node_tags = tree.nodes.items(.tag);
|
||||
const main_tokens = tree.nodes.items(.main_token);
|
||||
@ -1997,7 +1997,7 @@ fn findContainerScope(container_handle: NodeWithHandle) ?*Scope {
|
||||
} else null;
|
||||
}
|
||||
|
||||
fn iterateSymbolsContainerInternal(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, container_handle: NodeWithHandle, orig_handle: *const DocumentStore.Handle, comptime callback: anytype, context: anytype, instance_access: bool, use_trail: *std.ArrayList(Ast.Node.Index)) error{OutOfMemory}!void {
|
||||
fn iterateSymbolsContainerInternal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, container_handle: NodeWithHandle, orig_handle: *const DocumentStore.Handle, comptime callback: anytype, context: anytype, instance_access: bool, use_trail: *std.ArrayList(Ast.Node.Index)) error{OutOfMemory}!void {
|
||||
const container = container_handle.node;
|
||||
const handle = container_handle.handle;
|
||||
|
||||
@ -2064,7 +2064,7 @@ fn iterateSymbolsContainerInternal(store: *const DocumentStore, arena: *std.heap
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iterateSymbolsContainer(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, container_handle: NodeWithHandle, orig_handle: *const 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: *const DocumentStore.Handle, comptime callback: anytype, context: anytype, instance_access: bool) error{OutOfMemory}!void {
|
||||
var use_trail = std.ArrayList(Ast.Node.Index).init(arena.allocator());
|
||||
return try iterateSymbolsContainerInternal(store, arena, container_handle, orig_handle, callback, context, instance_access, &use_trail);
|
||||
}
|
||||
@ -2085,7 +2085,7 @@ pub fn iterateLabels(handle: *const DocumentStore.Handle, source_index: usize, c
|
||||
}
|
||||
}
|
||||
|
||||
fn iterateSymbolsGlobalInternal(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype, use_trail: *std.ArrayList(Ast.Node.Index)) error{OutOfMemory}!void {
|
||||
fn iterateSymbolsGlobalInternal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype, use_trail: *std.ArrayList(Ast.Node.Index)) error{OutOfMemory}!void {
|
||||
for (handle.document_scope.scopes.items) |scope| {
|
||||
if (source_index >= scope.loc.start and source_index <= scope.loc.end) {
|
||||
var decl_it = scope.decls.iterator();
|
||||
@ -2126,7 +2126,7 @@ fn iterateSymbolsGlobalInternal(store: *const DocumentStore, arena: *std.heap.Ar
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iterateSymbolsGlobal(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype) error{OutOfMemory}!void {
|
||||
pub fn iterateSymbolsGlobal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, source_index: usize, comptime callback: anytype, context: anytype) error{OutOfMemory}!void {
|
||||
var use_trail = std.ArrayList(Ast.Node.Index).init(arena.allocator());
|
||||
return try iterateSymbolsGlobalInternal(store, arena, handle, source_index, callback, context, &use_trail);
|
||||
}
|
||||
@ -2167,7 +2167,7 @@ pub fn innermostContainer(handle: *const DocumentStore.Handle, source_index: usi
|
||||
return TypeWithHandle.typeVal(.{ .node = current, .handle = handle });
|
||||
}
|
||||
|
||||
fn resolveUse(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, uses: []const Ast.Node.Index, symbol: []const u8, handle: *const DocumentStore.Handle) error{OutOfMemory}!?DeclWithHandle {
|
||||
fn resolveUse(store: *DocumentStore, arena: *std.heap.ArenaAllocator, uses: []const Ast.Node.Index, symbol: []const u8, handle: *const 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)
|
||||
@ -2218,7 +2218,7 @@ pub fn lookupLabel(handle: *const DocumentStore.Handle, symbol: []const u8, sour
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn lookupSymbolGlobal(store: *const DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, symbol: []const u8, source_index: usize) error{OutOfMemory}!?DeclWithHandle {
|
||||
pub fn lookupSymbolGlobal(store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, symbol: []const u8, source_index: usize) error{OutOfMemory}!?DeclWithHandle {
|
||||
const innermost_scope_idx = innermostBlockScopeIndex(handle.*, source_index);
|
||||
|
||||
var curr = innermost_scope_idx;
|
||||
@ -2246,7 +2246,7 @@ pub fn lookupSymbolGlobal(store: *const DocumentStore, arena: *std.heap.ArenaAll
|
||||
}
|
||||
|
||||
pub fn lookupSymbolContainer(
|
||||
store: *const DocumentStore,
|
||||
store: *DocumentStore,
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
container_handle: NodeWithHandle,
|
||||
symbol: []const u8,
|
||||
|
@ -11,7 +11,7 @@ const offsets = @import("offsets.zig");
|
||||
|
||||
pub const Builder = struct {
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
document_store: *const DocumentStore,
|
||||
document_store: *DocumentStore,
|
||||
handle: *const DocumentStore.Handle,
|
||||
offset_encoding: offsets.Encoding,
|
||||
|
||||
|
@ -81,7 +81,7 @@ const Builder = struct {
|
||||
/// `call` is the function call
|
||||
/// `decl_handle` should be a function protototype
|
||||
/// writes parameter hints into `builder.hints`
|
||||
fn writeCallHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *const DocumentStore, call: Ast.full.Call, decl_handle: analysis.DeclWithHandle) !void {
|
||||
fn writeCallHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *DocumentStore, call: Ast.full.Call, decl_handle: analysis.DeclWithHandle) !void {
|
||||
const handle = builder.handle;
|
||||
const tree = handle.tree;
|
||||
|
||||
@ -181,7 +181,7 @@ fn writeBuiltinHint(builder: *Builder, parameters: []const Ast.Node.Index, argum
|
||||
}
|
||||
|
||||
/// takes a Ast.full.Call (a function call), analysis its function expression, finds its declaration and writes parameter hints into `builder.hints`
|
||||
fn writeCallNodeHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *const DocumentStore, call: Ast.full.Call) !void {
|
||||
fn writeCallNodeHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *DocumentStore, call: Ast.full.Call) !void {
|
||||
if (call.ast.params.len == 0) return;
|
||||
if (builder.config.inlay_hints_exclude_single_argument and call.ast.params.len == 1) return;
|
||||
|
||||
@ -257,7 +257,7 @@ fn callWriteNodeInlayHint(allocator: std.mem.Allocator, args: anytype) error{Out
|
||||
|
||||
/// iterates over the ast and writes parameter hints into `builder.hints` for every function call and builtin call
|
||||
/// nodes outside the given range are excluded
|
||||
fn writeNodeInlayHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *const DocumentStore, maybe_node: ?Ast.Node.Index, range: types.Range) error{OutOfMemory}!void {
|
||||
fn writeNodeInlayHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *DocumentStore, maybe_node: ?Ast.Node.Index, range: types.Range) error{OutOfMemory}!void {
|
||||
const node = maybe_node orelse return;
|
||||
|
||||
const handle = builder.handle;
|
||||
@ -690,7 +690,7 @@ fn writeNodeInlayHint(builder: *Builder, arena: *std.heap.ArenaAllocator, store:
|
||||
pub fn writeRangeInlayHint(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
config: Config,
|
||||
store: *const DocumentStore,
|
||||
store: *DocumentStore,
|
||||
handle: *const DocumentStore.Handle,
|
||||
range: types.Range,
|
||||
hover_kind: types.MarkupContent.Kind,
|
||||
|
@ -56,11 +56,11 @@ pub fn labelReferences(
|
||||
const Builder = struct {
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
locations: std.ArrayListUnmanaged(types.Location),
|
||||
store: *const DocumentStore,
|
||||
store: *DocumentStore,
|
||||
decl: analysis.DeclWithHandle,
|
||||
encoding: offsets.Encoding,
|
||||
|
||||
pub fn init(arena: *std.heap.ArenaAllocator, store: *const DocumentStore, decl: analysis.DeclWithHandle, encoding: offsets.Encoding) Builder {
|
||||
pub fn init(arena: *std.heap.ArenaAllocator, store: *DocumentStore, decl: analysis.DeclWithHandle, encoding: offsets.Encoding) Builder {
|
||||
return Builder{
|
||||
.arena = arena,
|
||||
.locations = .{},
|
||||
@ -457,7 +457,7 @@ fn symbolReferencesInternal(
|
||||
|
||||
pub fn symbolReferences(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *const DocumentStore,
|
||||
store: *DocumentStore,
|
||||
decl_handle: analysis.DeclWithHandle,
|
||||
encoding: offsets.Encoding,
|
||||
include_decl: bool,
|
||||
|
@ -52,14 +52,14 @@ pub const TokenModifiers = packed struct {
|
||||
|
||||
const Builder = struct {
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *const DocumentStore,
|
||||
store: *DocumentStore,
|
||||
handle: *const DocumentStore.Handle,
|
||||
previous_position: usize = 0,
|
||||
previous_token: ?Ast.TokenIndex = null,
|
||||
arr: std.ArrayListUnmanaged(u32),
|
||||
encoding: offsets.Encoding,
|
||||
|
||||
fn init(arena: *std.heap.ArenaAllocator, store: *const DocumentStore, handle: *const DocumentStore.Handle, encoding: offsets.Encoding) Builder {
|
||||
fn init(arena: *std.heap.ArenaAllocator, store: *DocumentStore, handle: *const DocumentStore.Handle, encoding: offsets.Encoding) Builder {
|
||||
return Builder{
|
||||
.arena = arena,
|
||||
.store = store,
|
||||
@ -1025,7 +1025,7 @@ fn writeContainerField(builder: *Builder, node: Ast.Node.Index, field_token_type
|
||||
// TODO Range version, edit version.
|
||||
pub fn writeAllSemanticTokens(
|
||||
arena: *std.heap.ArenaAllocator,
|
||||
store: *const DocumentStore,
|
||||
store: *DocumentStore,
|
||||
handle: *const DocumentStore.Handle,
|
||||
encoding: offsets.Encoding,
|
||||
) ![]u32 {
|
||||
|
@ -8,7 +8,7 @@ const Token = std.zig.Token;
|
||||
const identifierFromPosition = @import("Server.zig").identifierFromPosition;
|
||||
const ast = @import("ast.zig");
|
||||
|
||||
fn fnProtoToSignatureInfo(document_store: *const DocumentStore, arena: *std.heap.ArenaAllocator, commas: u32, skip_self_param: bool, handle: *const DocumentStore.Handle, fn_node: Ast.Node.Index, proto: Ast.full.FnProto) !types.SignatureInformation {
|
||||
fn fnProtoToSignatureInfo(document_store: *DocumentStore, arena: *std.heap.ArenaAllocator, commas: u32, skip_self_param: bool, handle: *const DocumentStore.Handle, fn_node: Ast.Node.Index, proto: Ast.full.FnProto) !types.SignatureInformation {
|
||||
const ParameterInformation = types.SignatureInformation.ParameterInformation;
|
||||
|
||||
const tree = handle.tree;
|
||||
@ -67,7 +67,7 @@ fn fnProtoToSignatureInfo(document_store: *const DocumentStore, arena: *std.heap
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getSignatureInfo(document_store: *const DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, absolute_index: usize, comptime data: type) !?types.SignatureInformation {
|
||||
pub fn getSignatureInfo(document_store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *const DocumentStore.Handle, absolute_index: usize, comptime data: type) !?types.SignatureInformation {
|
||||
const innermost_block = analysis.innermostBlockScope(handle.*, absolute_index);
|
||||
const tree = handle.tree;
|
||||
const token_tags = tree.tokens.items(.tag);
|
||||
|
Loading…
Reference in New Issue
Block a user