Commit 0af0bd8e authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Show type icon for usings/typedefs

...in the completion widget.

Task-number: QTCREATORBUG-15078
Change-Id: I1309b628e1f060fa68bdcf13838037728207b035
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 69cf6b53
......@@ -177,6 +177,7 @@ static const char *completionKindToString(CodeCompletion::Kind kind)
case CodeCompletion::DestructorCompletionKind: return "Destructor";
case CodeCompletion::VariableCompletionKind: return "Variable";
case CodeCompletion::ClassCompletionKind: return "Class";
case CodeCompletion::TypeAliasCompletionKind: return "TypeAlias";
case CodeCompletion::TemplateClassCompletionKind: return "TemplateClass";
case CodeCompletion::EnumerationCompletionKind: return "Enumeration";
case CodeCompletion::EnumeratorCompletionKind: return "Enumerator";
......
......@@ -62,6 +62,7 @@ public:
DestructorCompletionKind,
VariableCompletionKind,
ClassCompletionKind,
TypeAliasCompletionKind,
TemplateClassCompletionKind,
EnumerationCompletionKind,
EnumeratorCompletionKind,
......
......@@ -118,6 +118,7 @@ QList<AssistProposalItem *> toAssistProposalItems(const CodeCompletions &complet
switch (ccr.completionKind()) {
case CodeCompletion::ClassCompletionKind:
case CodeCompletion::TemplateClassCompletionKind:
case CodeCompletion::TypeAliasCompletionKind:
item->setIcon(m_icons.iconForType(Icons::ClassIconType)); break;
case CodeCompletion::EnumerationCompletionKind: item->setIcon(m_icons.iconForType(Icons::EnumIconType)); break;
case CodeCompletion::EnumeratorCompletionKind: item->setIcon(m_icons.iconForType(Icons::EnumeratorIconType)); break;
......@@ -178,6 +179,7 @@ QList<AssistProposalItem *> toAssistProposalItems(const CodeCompletions &complet
break;
case CodeCompletion::Other:
item->setIcon(m_icons.iconForType(Icons::UnknownIconType));
break;
}
}
......
......@@ -126,6 +126,10 @@ void CodeCompletionsExtractor::extractCompletionKind()
case CXCursor_TemplateTypeParameter:
currentCodeCompletion_.setCompletionKind(CodeCompletion::ClassCompletionKind);
break;
case CXCursor_TypedefDecl:
case CXCursor_TypeAliasDecl:
currentCodeCompletion_.setCompletionKind(CodeCompletion::TypeAliasCompletionKind);
break;
case CXCursor_ClassTemplatePartialSpecialization:
case CXCursor_ClassTemplate:
case CXCursor_TemplateTemplateParameter:
......
......@@ -281,6 +281,28 @@ TEST_F(CodeCompletionsExtractor, Union)
CodeCompletion::Available));
}
TEST_F(CodeCompletionsExtractor, Typedef)
{
ClangCodeCompleteResults completeResults(getResults(classTranslationUnit, 20));
::CodeCompletionsExtractor extractor(completeResults.data());
ASSERT_THAT(extractor, HasCompletion(Utf8StringLiteral("TypeDef"),
CodeCompletion::TypeAliasCompletionKind,
CodeCompletion::Available));
}
TEST_F(CodeCompletionsExtractor, UsingAsTypeAlias)
{
ClangCodeCompleteResults completeResults(getResults(classTranslationUnit, 20));
::CodeCompletionsExtractor extractor(completeResults.data());
ASSERT_THAT(extractor, HasCompletion(Utf8StringLiteral("UsingClass"),
CodeCompletion::TypeAliasCompletionKind,
CodeCompletion::Available));
}
TEST_F(CodeCompletionsExtractor, TemplateTypeParameter)
{
ClangCodeCompleteResults completeResults(getResults(classTranslationUnit, 20));
......
......@@ -2,6 +2,7 @@ class Class {};
struct Struct{};
union Union{};
typedef Class TypeDef;
using UsingClass = Class;
template<class T> class TemplateClass{};
template<class T> class ClassTemplatePartialSpecialization;
template<class T> class ClassTemplatePartialSpecialization<T*>;
......@@ -13,7 +14,6 @@ template<class T> class ClassTemplatePartialSpecialization<T*>;
template<class TemplateTypeParameter, template<class> class TemplateTemplateParameter>
void function()
{
......
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