forked from qt-creator/qt-creator
CMakePM: Allow code completion for CMake files without a project
By taking the default CMake tool in Qt Creator. Similar to the editor. Change-Id: Id1effa3c4f71dc59dcf940f0fc246aa87c9ba0f7 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmaketool.h"
|
||||
#include "cmaketoolmanager.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
@@ -197,12 +198,16 @@ IAssistProposal *CMakeFileCompletionAssist::performAsync()
|
||||
Project *project = nullptr;
|
||||
const FilePath &filePath = interface()->filePath();
|
||||
if (!filePath.isEmpty() && filePath.isFile()) {
|
||||
CMakeTool *cmake = nullptr;
|
||||
project = static_cast<CMakeProject *>(ProjectManager::projectForFile(filePath));
|
||||
if (project && project->activeTarget()) {
|
||||
CMakeTool *cmake = CMakeKitAspect::cmakeTool(project->activeTarget()->kit());
|
||||
if (cmake && cmake->isValid())
|
||||
keywords = cmake->keywords();
|
||||
}
|
||||
if (project && project->activeTarget())
|
||||
cmake = CMakeKitAspect::cmakeTool(project->activeTarget()->kit());
|
||||
|
||||
if (!cmake)
|
||||
cmake = CMakeToolManager::defaultCMakeTool();
|
||||
|
||||
if (cmake && cmake->isValid())
|
||||
keywords = cmake->keywords();
|
||||
}
|
||||
|
||||
QStringList buildTargets;
|
||||
|
||||
Reference in New Issue
Block a user