CMakePM: Revamp the CMake code completion

By using KSyntaxHighlighting's metadata from the cmake.xml file.

With this information the code completion has localized arguments for
functions.

Added support for Generator Expressions $< and function ${ completions.

The project functions/macros and options are also taken into
consideration.

The file completion is using FilePaths and should work remotely.

Change-Id: I79d1360c1249c65c9db65349f326be5d41f0f734
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2023-09-17 20:19:04 +02:00
parent 88ddecd281
commit bc1c24eb84
6 changed files with 449 additions and 30 deletions

View File

@@ -1250,6 +1250,9 @@ void CMakeBuildSystem::setupCMakeSymbolsHash()
{
m_cmakeSymbolsHash.clear();
m_projectKeywords.functions.clear();
m_projectKeywords.variables.clear();
for (const auto &cmakeFile : std::as_const(m_cmakeFiles)) {
for (const auto &func : cmakeFile.cmakeListFile.Functions) {
if (func.LowerCaseName() != "function" && func.LowerCaseName() != "macro"
@@ -1265,8 +1268,17 @@ void CMakeBuildSystem::setupCMakeSymbolsHash()
link.targetLine = arg.Line;
link.targetColumn = arg.Column - 1;
m_cmakeSymbolsHash.insert(QString::fromUtf8(arg.Value), link);
if (func.LowerCaseName() == "option")
m_projectKeywords.variables << QString::fromUtf8(arg.Value);
else
m_projectKeywords.functions << QString::fromUtf8(arg.Value);
}
}
// Code completion setup
if (CMakeTool *tool = CMakeKitAspect::cmakeTool(target()->kit()))
tool->keywords();
}
void CMakeBuildSystem::ensureBuildDirectory(const BuildDirParameters &parameters)