Yet better aliases, better label position context detection
This commit is contained in:
parent
02de547ce9
commit
f6e3109ff3
@ -235,15 +235,16 @@ fn resolveVarDeclAliasInternal(
|
|||||||
std.debug.assert(inner_node.node.id == .Root);
|
std.debug.assert(inner_node.node.id == .Root);
|
||||||
break :block inner_node;
|
break :block inner_node;
|
||||||
} else if (try resolveVarDeclAliasInternal(store, arena, .{ .node = infix_op.lhs, .handle = handle }, false)) |decl_handle| block: {
|
} else if (try resolveVarDeclAliasInternal(store, arena, .{ .node = infix_op.lhs, .handle = handle }, false)) |decl_handle| block: {
|
||||||
if (!isContainerDecl(decl_handle)) return null;
|
if (decl_handle.decl.* != .ast_node) return null;
|
||||||
break :block NodeWithHandle{
|
const resolved = (try resolveTypeOfNode(store, arena, .{ .node = decl_handle.decl.ast_node, .handle = decl_handle.handle })) orelse return null;
|
||||||
.node = decl_handle.decl.ast_node,
|
if (resolved.node.id != .ContainerDecl and resolved.node.id != .Root) return null;
|
||||||
.handle = decl_handle.handle,
|
break :block resolved;
|
||||||
};
|
|
||||||
} else return null;
|
} else return null;
|
||||||
|
|
||||||
if (try lookupSymbolContainer(store, arena, container_node, handle.tree.tokenSlice(infix_op.rhs.firstToken()), false)) |inner_decl| {
|
if (try lookupSymbolContainer(store, arena, container_node, handle.tree.tokenSlice(infix_op.rhs.firstToken()), false)) |inner_decl| {
|
||||||
if (!root and !isContainerDecl(inner_decl)) return null;
|
if (root) return inner_decl;
|
||||||
|
|
||||||
|
// if (!root and !isContainerDecl(inner_decl)) return null;
|
||||||
return inner_decl;
|
return inner_decl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -955,6 +956,7 @@ pub const PositionContext = union(enum) {
|
|||||||
var_access: SourceRange,
|
var_access: SourceRange,
|
||||||
global_error_set,
|
global_error_set,
|
||||||
enum_literal,
|
enum_literal,
|
||||||
|
pre_label,
|
||||||
label,
|
label,
|
||||||
other,
|
other,
|
||||||
empty,
|
empty,
|
||||||
@ -967,6 +969,7 @@ pub const PositionContext = union(enum) {
|
|||||||
.field_access => |r| r,
|
.field_access => |r| r,
|
||||||
.var_access => |r| r,
|
.var_access => |r| r,
|
||||||
.enum_literal => null,
|
.enum_literal => null,
|
||||||
|
.pre_label => null,
|
||||||
.label => null,
|
.label => null,
|
||||||
.other => null,
|
.other => null,
|
||||||
.empty => null,
|
.empty => null,
|
||||||
@ -1031,15 +1034,15 @@ pub fn documentPositionContext(allocator: *std.mem.Allocator, document: types.Te
|
|||||||
switch (tok.id) {
|
switch (tok.id) {
|
||||||
.StringLiteral, .MultilineStringLiteralLine => curr_ctx.ctx = .{ .string_literal = tok.loc },
|
.StringLiteral, .MultilineStringLiteralLine => curr_ctx.ctx = .{ .string_literal = tok.loc },
|
||||||
.Identifier => switch (curr_ctx.ctx) {
|
.Identifier => switch (curr_ctx.ctx) {
|
||||||
.empty => curr_ctx.ctx = .{ .var_access = tok.loc },
|
.empty, .pre_label => curr_ctx.ctx = .{ .var_access = tok.loc },
|
||||||
else => {},
|
else => {},
|
||||||
},
|
},
|
||||||
.Builtin => switch (curr_ctx.ctx) {
|
.Builtin => switch (curr_ctx.ctx) {
|
||||||
.empty => curr_ctx.ctx = .{ .builtin = tok.loc },
|
.empty, .pre_label => curr_ctx.ctx = .{ .builtin = tok.loc },
|
||||||
else => {},
|
else => {},
|
||||||
},
|
},
|
||||||
.Period, .PeriodAsterisk => switch (curr_ctx.ctx) {
|
.Period, .PeriodAsterisk => switch (curr_ctx.ctx) {
|
||||||
.empty => curr_ctx.ctx = .enum_literal,
|
.empty, .pre_label => curr_ctx.ctx = .enum_literal,
|
||||||
.enum_literal => curr_ctx.ctx = .empty,
|
.enum_literal => curr_ctx.ctx = .empty,
|
||||||
.field_access => {},
|
.field_access => {},
|
||||||
.other => {},
|
.other => {},
|
||||||
@ -1048,7 +1051,8 @@ pub fn documentPositionContext(allocator: *std.mem.Allocator, document: types.Te
|
|||||||
.field_access = tokenRangeAppend(curr_ctx.ctx.range().?, tok),
|
.field_access = tokenRangeAppend(curr_ctx.ctx.range().?, tok),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.Colon => curr_ctx.ctx = .label,
|
.Keyword_break, .Keyword_continue => curr_ctx.ctx = .pre_label,
|
||||||
|
.Colon => if (curr_ctx.ctx == .pre_label) { curr_ctx.ctx = .label; },
|
||||||
.QuestionMark => switch (curr_ctx.ctx) {
|
.QuestionMark => switch (curr_ctx.ctx) {
|
||||||
.field_access => {},
|
.field_access => {},
|
||||||
else => curr_ctx.ctx = .empty,
|
else => curr_ctx.ctx = .empty,
|
||||||
|
Loading…
Reference in New Issue
Block a user