forked from qt-creator/qt-creator
ClangCodeModel: Move plugin class definition to .cpp
Change-Id: I437ca5df1981b11809cbf52efe7aa9aacc1159d7 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -12,7 +12,7 @@ add_qtc_plugin(ClangCodeModel
|
|||||||
SOURCES
|
SOURCES
|
||||||
clangactivationsequencecontextprocessor.cpp clangactivationsequencecontextprocessor.h
|
clangactivationsequencecontextprocessor.cpp clangactivationsequencecontextprocessor.h
|
||||||
clangactivationsequenceprocessor.cpp clangactivationsequenceprocessor.h
|
clangactivationsequenceprocessor.cpp clangactivationsequenceprocessor.h
|
||||||
clangcodemodelplugin.cpp clangcodemodelplugin.h
|
clangcodemodelplugin.cpp
|
||||||
clangcodemodeltr.h
|
clangcodemodeltr.h
|
||||||
clangcompletioncontextanalyzer.cpp clangcompletioncontextanalyzer.h
|
clangcompletioncontextanalyzer.cpp clangcompletioncontextanalyzer.h
|
||||||
clangconstants.h
|
clangconstants.h
|
||||||
@@ -35,7 +35,6 @@ add_qtc_plugin(ClangCodeModel
|
|||||||
clangtextmark.cpp clangtextmark.h
|
clangtextmark.cpp clangtextmark.h
|
||||||
clangutils.cpp clangutils.h
|
clangutils.cpp clangutils.h
|
||||||
tasktimers.cpp tasktimers.h
|
tasktimers.cpp tasktimers.h
|
||||||
EXPLICIT_MOC clangcodemodelplugin.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_plugin(ClangCodeModel
|
extend_qtc_plugin(ClangCodeModel
|
||||||
|
@@ -26,7 +26,6 @@ QtcPlugin {
|
|||||||
"clangactivationsequenceprocessor.cpp",
|
"clangactivationsequenceprocessor.cpp",
|
||||||
"clangactivationsequenceprocessor.h",
|
"clangactivationsequenceprocessor.h",
|
||||||
"clangcodemodelplugin.cpp",
|
"clangcodemodelplugin.cpp",
|
||||||
"clangcodemodelplugin.h",
|
|
||||||
"clangcodemodeltr.h",
|
"clangcodemodeltr.h",
|
||||||
"clangcompletioncontextanalyzer.cpp",
|
"clangcompletioncontextanalyzer.cpp",
|
||||||
"clangcompletioncontextanalyzer.h",
|
"clangcompletioncontextanalyzer.h",
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "clangcodemodelplugin.h"
|
|
||||||
|
|
||||||
#include "clangcodemodeltr.h"
|
#include "clangcodemodeltr.h"
|
||||||
#include "clangconstants.h"
|
#include "clangconstants.h"
|
||||||
#include "clangmodelmanagersupport.h"
|
#include "clangmodelmanagersupport.h"
|
||||||
@@ -23,6 +21,8 @@
|
|||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
#include <cppeditor/cppmodelmanager.h>
|
#include <cppeditor/cppmodelmanager.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectpanelfactory.h>
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
@@ -37,39 +37,34 @@
|
|||||||
|
|
||||||
#include <utils/async.h>
|
#include <utils/async.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
#include <utils/parameteraction.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ClangCodeModel::Internal {
|
namespace ClangCodeModel::Internal {
|
||||||
|
|
||||||
void ClangCodeModelPlugin::generateCompilationDB()
|
class ClangCodeModelPlugin final: public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
using namespace CppEditor;
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClangCodeModel.json")
|
||||||
|
|
||||||
Target *target = ProjectManager::startupTarget();
|
public:
|
||||||
if (!target)
|
~ClangCodeModelPlugin() final;
|
||||||
return;
|
void initialize() final;
|
||||||
|
|
||||||
const auto projectInfo = CppModelManager::projectInfo(target->project());
|
private:
|
||||||
if (!projectInfo)
|
void generateCompilationDB();
|
||||||
return;
|
void createCompilationDBAction();
|
||||||
FilePath baseDir = projectInfo->buildRoot();
|
|
||||||
if (baseDir == target->project()->projectDirectory())
|
|
||||||
baseDir = TemporaryDirectory::masterDirectoryFilePath();
|
|
||||||
|
|
||||||
QFuture<GenerateCompilationDbResult> task
|
Utils::ParameterAction *m_generateCompilationDBAction = nullptr;
|
||||||
= Utils::asyncRun(&Internal::generateCompilationDB, ProjectInfoList{projectInfo},
|
QFutureWatcher<GenerateCompilationDbResult> m_generatorWatcher;
|
||||||
baseDir, CompilationDbPurpose::Project,
|
};
|
||||||
warningsConfigForProject(target->project()),
|
|
||||||
globalClangOptions(),
|
|
||||||
FilePath());
|
|
||||||
ProgressManager::addTask(task, Tr::tr("Generating Compilation DB"), "generate compilation db");
|
|
||||||
m_generatorWatcher.setFuture(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClangCodeModelPlugin::~ClangCodeModelPlugin()
|
ClangCodeModelPlugin::~ClangCodeModelPlugin()
|
||||||
{
|
{
|
||||||
@@ -104,6 +99,31 @@ void ClangCodeModelPlugin::initialize()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClangCodeModelPlugin::generateCompilationDB()
|
||||||
|
{
|
||||||
|
using namespace CppEditor;
|
||||||
|
|
||||||
|
Target *target = ProjectManager::startupTarget();
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto projectInfo = CppModelManager::projectInfo(target->project());
|
||||||
|
if (!projectInfo)
|
||||||
|
return;
|
||||||
|
FilePath baseDir = projectInfo->buildRoot();
|
||||||
|
if (baseDir == target->project()->projectDirectory())
|
||||||
|
baseDir = TemporaryDirectory::masterDirectoryFilePath();
|
||||||
|
|
||||||
|
QFuture<GenerateCompilationDbResult> task
|
||||||
|
= Utils::asyncRun(&Internal::generateCompilationDB, ProjectInfoList{projectInfo},
|
||||||
|
baseDir, CompilationDbPurpose::Project,
|
||||||
|
warningsConfigForProject(target->project()),
|
||||||
|
globalClangOptions(),
|
||||||
|
FilePath());
|
||||||
|
ProgressManager::addTask(task, Tr::tr("Generating Compilation DB"), "generate compilation db");
|
||||||
|
m_generatorWatcher.setFuture(task);
|
||||||
|
}
|
||||||
|
|
||||||
void ClangCodeModelPlugin::createCompilationDBAction()
|
void ClangCodeModelPlugin::createCompilationDBAction()
|
||||||
{
|
{
|
||||||
// generate compile_commands.json
|
// generate compile_commands.json
|
||||||
@@ -179,3 +199,5 @@ void ClangCodeModelPlugin::createCompilationDBAction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ClangCodeModel::Internal
|
} // namespace ClangCodeModel::Internal
|
||||||
|
|
||||||
|
#include "clangcodemodelplugin.moc"
|
||||||
|
@@ -1,33 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "clangutils.h"
|
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
|
||||||
|
|
||||||
#include <utils/parameteraction.h>
|
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
|
||||||
|
|
||||||
namespace ClangCodeModel::Internal {
|
|
||||||
|
|
||||||
class ClangCodeModelPlugin final: public ExtensionSystem::IPlugin
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClangCodeModel.json")
|
|
||||||
|
|
||||||
public:
|
|
||||||
~ClangCodeModelPlugin() override;
|
|
||||||
void initialize() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void generateCompilationDB();
|
|
||||||
void createCompilationDBAction();
|
|
||||||
|
|
||||||
Utils::ParameterAction *m_generateCompilationDBAction = nullptr;
|
|
||||||
QFutureWatcher<GenerateCompilationDbResult> m_generatorWatcher;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // ClangCodeModel::Internal
|
|
Reference in New Issue
Block a user