Commit 1b0fe932 authored by Shashwat Dixit's avatar Shashwat Dixit Committed by Aaron Puchert

Fix CodeCompletion of Strongly Typed Enum

Summary: BUG: 375635

Reviewers: nalvarez, #kdevelop, kfunk, mwolff

Reviewed By: #kdevelop, mwolff

Subscribers: mwolff, kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D10738
parent 012325e3
......@@ -1035,7 +1035,7 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(boo
switch (kind) {
case CXCompletionChunk_TypedText:
typed = string;
replacement = string;
replacement += string;
break;
case CXCompletionChunk_ResultType:
resultType = string;
......@@ -1062,6 +1062,9 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(boo
if (isOverloadCandidate) {
typed += string;
}
else if (result.CursorKind == CXCursor_EnumConstantDecl) {
replacement += string;
}
break;
case CXCompletionChunk_CurrentParameter:
argumentRange.start = arguments.size();
......
......@@ -1354,6 +1354,12 @@ void TestCodeCompletion::testCompleteFunction_data()
<< CompletionItems({2, 0}, {"foo", "main"})
<< "main"
<< "int foo();\nint main() {\nmain();\n}";
QTest::newRow("bug375635")
<< "enum class Color {\nBlue, Green, Red, Yellow\n};\nvoid foo() {\nColor x;\nswitch (x) {\ncase : break;}\n}"
<< CompletionItems({6, 5}, {"Blue", "Green", "Red", "Yellow"})
<< "Yellow"
<< "enum class Color {\nBlue, Green, Red, Yellow\n};\nvoid foo() {\nColor x;\nswitch (x) {\ncase Color::Yellow: break;}\n}";
}
void TestCodeCompletion::testIgnoreGccBuiltins()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment