Merge pull request #1233 from Techatrix/enum-completion

set Enum completion kind to .EnumMember
This commit is contained in:
Lee Cannon 2023-06-09 23:20:42 +01:00 committed by GitHub
commit 4d0e1afb72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -51,7 +51,7 @@ pub fn dotCompletions(
while (field_it.next()) |entry| {
try completions.append(arena, .{
.label = entry.key_ptr.*,
.kind = .Constant,
.kind = .EnumMember,
// include field.val?
});
}

View File

@ -2702,7 +2702,7 @@ fn makeInnerScope(context: ScopeContext, tree: Ast, node_idx: Ast.Node.Index) er
errdefer if (doc) |d| allocator.free(d);
var gop_res = try context.doc_scope.enum_completions.getOrPut(allocator, .{
.label = name,
.kind = .Enum,
.kind = .EnumMember,
.insertText = name,
.insertTextFormat = .PlainText,
.documentation = if (doc) |d| .{ .MarkupContent = types.MarkupContent{ .kind = .markdown, .value = d } } else null,

View File

@ -223,7 +223,7 @@ fn nodeToCompletion(
const field = tree.fullContainerField(node).?;
try list.append(allocator, .{
.label = handle.tree.tokenSlice(field.ast.main_token),
.kind = if (field.ast.tuple_like) .Enum else .Field,
.kind = if (field.ast.tuple_like) .EnumMember else .Field,
.documentation = doc,
.detail = Analyser.getContainerFieldSignature(handle.tree, field),
.insertText = tree.tokenSlice(field.ast.main_token),
@ -729,6 +729,7 @@ fn kindToSortScore(kind: types.CompletionItemKind) ?[]const u8 {
.Class,
.Interface,
.Struct,
.Enum,
// Union?
.TypeParameter,
=> "6_",
@ -757,7 +758,7 @@ pub fn addStructInitNodeFields(server: *Server, decl: Analyser.DeclWithHandle, c
const field = decl.handle.tree.fullContainerField(member) orelse continue;
try completions.append(server.arena.allocator(), .{
.label = decl.handle.tree.tokenSlice(field.ast.main_token),
.kind = if (field.ast.tuple_like) .Enum else .Field,
.kind = if (field.ast.tuple_like) .EnumMember else .Field,
.detail = Analyser.getContainerFieldSignature(decl.handle.tree, field),
.insertText = decl.handle.tree.tokenSlice(field.ast.main_token),
.insertTextFormat = .PlainText,
@ -770,7 +771,7 @@ pub fn addStructInitNodeFields(server: *Server, decl: Analyser.DeclWithHandle, c
const field = decl.handle.tree.fullContainerField(@intCast(u32, root_node)) orelse continue;
try completions.append(server.arena.allocator(), .{
.label = decl.handle.tree.tokenSlice(field.ast.main_token),
.kind = if (field.ast.tuple_like) .Enum else .Field,
.kind = if (field.ast.tuple_like) .EnumMember else .Field,
.detail = Analyser.getContainerFieldSignature(decl.handle.tree, field),
.insertText = decl.handle.tree.tokenSlice(field.ast.main_token),
.insertTextFormat = .PlainText,

View File

@ -297,8 +297,8 @@ test "completion - enum" {
\\};
\\const foo = E.<cursor>
, &.{
.{ .label = "alpha", .kind = .Enum },
.{ .label = "beta", .kind = .Enum },
.{ .label = "alpha", .kind = .EnumMember },
.{ .label = "beta", .kind = .EnumMember },
});
try testCompletion(
\\const E = enum {
@ -307,8 +307,8 @@ test "completion - enum" {
\\};
\\const foo: E = .<cursor>
, &.{
.{ .label = "alpha", .kind = .Enum },
.{ .label = "beta", .kind = .Enum },
.{ .label = "alpha", .kind = .EnumMember },
.{ .label = "beta", .kind = .EnumMember },
});
}