Commit d83b9ab6 authored by Milian Wolff's avatar Milian Wolff

Group macros and built-in completion items behind declaration items.

parent 96750927
......@@ -165,7 +165,8 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(con
const CursorInRevision& position)
{
QList<CompletionTreeItemPointer> items;
items.reserve(m_results->NumResults);
QList<CompletionTreeItemPointer> macros;
QList<CompletionTreeItemPointer> builtin;
QSet<QualifiedIdentifier> handled;
......@@ -225,8 +226,29 @@ QList<CompletionTreeItemPointer> ClangCodeCompletionContext::completionItems(con
}
}
// TODO: grouping of macros and built-in stuff
items.append(CompletionTreeItemPointer(new SimpleItem(typed, resultType, text, CodeCompletionModel::GlobalScope)));
CompletionTreeItemPointer item(new SimpleItem(typed, resultType, text, CodeCompletionModel::GlobalScope));
if (result.CursorKind == CXCursor_MacroDefinition) {
// TODO: grouping of macros and built-in stuff
macros.append(item);
} else {
builtin.append(item);
}
}
if (!macros.isEmpty()) {
KDevelop::CompletionCustomGroupNode* node = new KDevelop::CompletionCustomGroupNode(i18n("Macros"), 900);
node->appendChildren(macros);
m_ungrouped << CompletionTreeElementPointer(node);
}
if (!builtin.isEmpty()) {
KDevelop::CompletionCustomGroupNode* node = new KDevelop::CompletionCustomGroupNode(i18n("Builtin"), 800);
node->appendChildren(builtin);
m_ungrouped << CompletionTreeElementPointer(node);
}
return items;
}
QList<CompletionTreeElementPointer> ClangCodeCompletionContext::ungroupedElements()
{
return m_ungrouped;
}
......@@ -45,8 +45,11 @@ public:
// not used, see above
return {};
}
QList<KDevelop::CompletionTreeElementPointer> ungroupedElements() override;
private:
std::unique_ptr<CXCodeCompleteResults, void(*)(CXCodeCompleteResults*)> m_results;
QList<KDevelop::CompletionTreeElementPointer> m_ungrouped;
};
#endif // CLANGCODECOMPLETIONCONTEXT_H
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