Commit 33650194 authored by Marco Bubke's avatar Marco Bubke
Browse files

Clang: Add tooltip for clang snippets



Change-Id: Ifccfd72c52910c6e1086d6c782552c60fbb89f5f
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 8d23d801
......@@ -100,14 +100,12 @@ QList<AssistProposalItem *> toAssistProposalItems(const CodeCompletions &complet
item = new ClangAssistProposalItem;
items.insert(name, item);
item->setText(name);
item->setDetail(ccr.hint().toString());
item->setOrder(ccr.priority());
const QString snippet = ccr.snippet().toString();
if (!snippet.isEmpty())
item->setData(snippet);
else
item->setData(qVariantFromValue(ccr));
if (ccr.completionKind() == CodeCompletion::KeywordCompletionKind)
item->setDetail(CompletionChunksToTextConverter::convertToToolTip(ccr.chunks()));
item->setData(QVariant::fromValue(ccr));
}
// FIXME: show the effective accessebility instead of availability
......
......@@ -114,6 +114,18 @@ QString CompletionChunksToTextConverter::convertToName(const QVector<ClangBackEn
return converter.text();
}
QString CompletionChunksToTextConverter::convertToToolTip(const QVector<ClangBackEnd::CodeCompletionChunk> &codeCompletionChunks)
{
CompletionChunksToTextConverter converter;
converter.setAddPlaceHolderText(true);
converter.setAddSpaces(true);
converter.setAddExtraVerticalSpaceBetweenBraces(true);
converter.parseChunks(codeCompletionChunks);
return converter.text();
}
void CompletionChunksToTextConverter::parse(const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
{
using ClangBackEnd::CodeCompletionChunk;
......
......@@ -59,7 +59,7 @@ public:
static QString convertToFunctionSignature(const QVector<ClangBackEnd::CodeCompletionChunk> &codeCompletionChunks);
static QString convertToName(const QVector<ClangBackEnd::CodeCompletionChunk> &codeCompletionChunks);
static QString convertToToolTip(const QVector<ClangBackEnd::CodeCompletionChunk> &codeCompletionChunks);
private:
void parse(const ClangBackEnd::CodeCompletionChunk & codeCompletionChunk);
void parseResultType(const Utf8String &text);
......
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