forked from qt-creator/qt-creator
CMakeToolManager: Add static readFirstParagraphs()
Reuse it in CMakeEditor and CMakeFileCompletionAssistProvider.
Amends d04585b519
Change-Id: I8dbd59c815e017404ff215ca1ff68740d6653e91
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
committed by
Cristian Adam
parent
cbc6809b28
commit
4e90ca1b59
@@ -153,20 +153,6 @@ static QList<AssistProposalItemInterface *> generateList(const T &words, const Q
|
||||
});
|
||||
}
|
||||
|
||||
static QString readFirstParagraphs(const FilePath &helpFile)
|
||||
{
|
||||
static QMap<FilePath, QString> map;
|
||||
if (map.contains(helpFile))
|
||||
return map.value(helpFile);
|
||||
|
||||
auto content = helpFile.fileContents(1024).value_or(QByteArray());
|
||||
const QString firstParagraphs
|
||||
= QString("```\n%1\n```").arg(QString::fromUtf8(content.left(content.lastIndexOf("\n"))));
|
||||
|
||||
map[helpFile] = firstParagraphs;
|
||||
return firstParagraphs;
|
||||
}
|
||||
|
||||
static QList<AssistProposalItemInterface *> generateList(const QMap<QString, FilePath> &words,
|
||||
const QIcon &icon)
|
||||
{
|
||||
@@ -180,7 +166,7 @@ static QList<AssistProposalItemInterface *> generateList(const QMap<QString, Fil
|
||||
MarkDownAssitProposalItem *item = new MarkDownAssitProposalItem();
|
||||
item->setText(it.key());
|
||||
if (!it.value().isEmpty())
|
||||
item->setDetail(readFirstParagraphs(it.value()));
|
||||
item->setDetail(CMakeToolManager::readFirstParagraphs(it.value()));
|
||||
item->setIcon(icon);
|
||||
list << item;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user