Skip to content

Commit 5dc2314

Browse files
committed
[clangd] Update the CompletionItemKind.
Summary: Fix some FIXMEs. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74609
1 parent 61dd060 commit 5dc2314

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

clang-tools-extra/clangd/CodeComplete.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind Kind) {
8787
return CompletionItemKind::Text;
8888
case SK::Enum:
8989
return CompletionItemKind::Enum;
90-
// FIXME(ioeric): use LSP struct instead of class when it is suppoted in the
91-
// protocol.
9290
case SK::Struct:
91+
return CompletionItemKind::Struct;
9392
case SK::Class:
9493
case SK::Protocol:
9594
case SK::Extension:
@@ -102,8 +101,6 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind Kind) {
102101
case SK::Using:
103102
return CompletionItemKind::Reference;
104103
case SK::Function:
105-
// FIXME(ioeric): this should probably be an operator. This should be fixed
106-
// when `Operator` is support type in the protocol.
107104
case SK::ConversionFunction:
108105
return CompletionItemKind::Function;
109106
case SK::Variable:
@@ -112,9 +109,8 @@ CompletionItemKind toCompletionItemKind(index::SymbolKind Kind) {
112109
return CompletionItemKind::Variable;
113110
case SK::Field:
114111
return CompletionItemKind::Field;
115-
// FIXME(ioeric): use LSP enum constant when it is supported in the protocol.
116112
case SK::EnumConstant:
117-
return CompletionItemKind::Value;
113+
return CompletionItemKind::EnumMember;
118114
case SK::InstanceMethod:
119115
case SK::ClassMethod:
120116
case SK::StaticMethod:

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ TEST(CompletionTest, Kinds) {
481481
AllOf(Has("function", CompletionItemKind::Function),
482482
Has("variable", CompletionItemKind::Variable),
483483
Has("int", CompletionItemKind::Keyword),
484-
Has("Struct", CompletionItemKind::Class),
484+
Has("Struct", CompletionItemKind::Struct),
485485
Has("MACRO", CompletionItemKind::Text),
486486
Has("indexFunction", CompletionItemKind::Function),
487487
Has("indexVariable", CompletionItemKind::Variable),
@@ -529,6 +529,17 @@ TEST(CompletionTest, Kinds) {
529529
AllOf(Named("complete_variable"), Kind(CompletionItemKind::Variable)),
530530
AllOf(Named("complete_static_member"),
531531
Kind(CompletionItemKind::Property))));
532+
533+
Results = completions(
534+
R"cpp(
535+
enum Color {
536+
Red
537+
};
538+
Color u = ^
539+
)cpp");
540+
EXPECT_THAT(Results.Completions,
541+
Contains(
542+
AllOf(Named("Red"), Kind(CompletionItemKind::EnumMember))));
532543
}
533544

534545
TEST(CompletionTest, NoDuplicates) {

0 commit comments

Comments
 (0)