Commit 920967d9 authored by Leandro Melo's avatar Leandro Melo
Browse files

Snippets: Make text snippets available to all groups.

And mark the completion item as a snippet.
parent 7eecf394
......@@ -34,29 +34,43 @@
using namespace TextEditor;
using namespace Internal;
SnippetProvider::SnippetProvider(Snippet::Group group, const QIcon &icon, int order) :
m_group(group), m_icon(icon), m_order(order)
{}
SnippetProvider::~SnippetProvider()
{}
namespace {
QList<CompletionItem> SnippetProvider::getSnippets(ICompletionCollector *collector) const
void appendSnippets(ICompletionCollector *collector,
QList<CompletionItem> *completionItems,
Snippet::Group group,
const QIcon &icon,
int order)
{
QList<CompletionItem> completionItems;
QSharedPointer<SnippetsCollection> collection =
SnippetsManager::instance()->snippetsCollection();
const int size = collection->totalActiveSnippets(m_group);
const int size = collection->totalActiveSnippets(group);
for (int i = 0; i < size; ++i) {
const Snippet &snippet = collection->snippet(i, m_group);
const Snippet &snippet = collection->snippet(i, group);
CompletionItem item(collector);
item.text = snippet.trigger() + QLatin1Char(' ') + snippet.complement();
item.data = snippet.content();
item.details = snippet.generateTip();
item.icon = m_icon;
item.order = m_order;
completionItems.append(item);
item.icon = icon;
item.order = order;
item.isSnippet = true;
completionItems->append(item);
}
}
} // anonymous
SnippetProvider::SnippetProvider(Snippet::Group group, const QIcon &icon, int order) :
m_group(group), m_icon(icon), m_order(order)
{}
SnippetProvider::~SnippetProvider()
{}
QList<CompletionItem> SnippetProvider::getSnippets(ICompletionCollector *collector) const
{
QList<CompletionItem> completionItems;
appendSnippets(collector, &completionItems, m_group, m_icon, m_order);
appendSnippets(collector, &completionItems, Snippet::PlainText, m_icon, m_order);
return completionItems;
}
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