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:
Jarek Kobus
2023-09-27 13:01:18 +02:00
committed by Cristian Adam
parent cbc6809b28
commit 4e90ca1b59
4 changed files with 19 additions and 19 deletions

View File

@@ -167,6 +167,21 @@ void CMakeToolManager::updateDocumentation()
Core::HelpManager::registerDocumentation(docs);
}
QString CMakeToolManager::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;
}
QList<Id> CMakeToolManager::autoDetectCMakeForDevice(const FilePaths &searchPaths,
const QString &detectionSource,
QString *logMessage)