Commit f6d67beb authored by Marco Bubke's avatar Marco Bubke

Clang: Decrease the priority of operators

Change-Id: Ib04d2a14989fd221ab6d8f36c92d3520261b99ee
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 5df80855
......@@ -109,6 +109,7 @@ void CodeCompletionsExtractor::extractCompletionKind()
extractMethodCompletionKind();
break;
case CXCursor_FunctionDecl:
case CXCursor_ConversionFunction:
currentCodeCompletion_.setCompletionKind(CodeCompletion::FunctionCompletionKind);
break;
case CXCursor_VariableRef:
......@@ -259,6 +260,7 @@ void CodeCompletionsExtractor::adaptPriority()
decreasePriorityForNonAvailableCompletions();
decreasePriorityForQObjectInternals();
decreasePriorityForSignals();
decreasePriorityForOperators();
}
void CodeCompletionsExtractor::decreasePriorityForNonAvailableCompletions()
......@@ -295,6 +297,23 @@ void CodeCompletionsExtractor::decreasePriorityForQObjectInternals()
currentCodeCompletion_.setPriority(priority);
}
bool isOperator(CXCursorKind cxCursorKind, const Utf8String &name)
{
return cxCursorKind == CXCursor_ConversionFunction
|| (cxCursorKind == CXCursor_CXXMethod
&& name.startsWith(Utf8StringLiteral("operator")));
}
void CodeCompletionsExtractor::decreasePriorityForOperators()
{
quint32 priority = currentCodeCompletion_.priority();
if (isOperator(currentCxCodeCompleteResult.CursorKind, currentCodeCompletion().text()))
priority *= 100;
currentCodeCompletion_.setPriority(priority);
}
bool CodeCompletionsExtractor::hasText(const Utf8String &text, CXCompletionString cxCompletionString) const
{
const uint completionChunkCount = clang_getNumCompletionChunks(cxCompletionString);
......
......@@ -72,6 +72,7 @@ private:
void decreasePriorityForDestructors();
void decreasePriorityForSignals();
void decreasePriorityForQObjectInternals();
void decreasePriorityForOperators();
bool hasText(const Utf8String &text, CXCompletionString cxCompletionString) const;
......
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