Commit daf93696 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Remove dead code

Change-Id: Ia36e96424580d9b34000cf4a9b38eab98f9c449c
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 6a1fc699
......@@ -5,7 +5,7 @@ LIBS += $$LLVM_LIBS
INCLUDEPATH += $$LLVM_INCLUDEPATH
DEFINES += CLANGCODEMODEL_LIBRARY
# The following defines are used to determine the clang include path for intrinsics
# The following defines are used to determine the clang include path for intrinsics.
DEFINES += CLANG_VERSION=\\\"$${LLVM_VERSION}\\\"
DEFINES += "\"CLANG_RESOURCE_DIR=\\\"$${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include\\\"\""
......@@ -33,26 +33,15 @@ SOURCES += \
clangmodelmanagersupport.cpp \
clangprojectsettings.cpp \
clangprojectsettingspropertiespage.cpp \
clangsymbol.cpp \
clangtextmark.cpp \
clangutils.cpp \
completionchunkstotextconverter.cpp \
cppcreatemarkers.cpp \
cxprettyprinter.cpp \
diagnostic.cpp \
fastindexer.cpp \
highlightingmarksreporter.cpp \
pchinfo.cpp \
pchmanager.cpp \
raii/scopedclangoptions.cpp \
semanticmarker.cpp \
sourcelocation.cpp \
sourcemarker.cpp \
unit.cpp \
unsavedfiledata.cpp \
utils.cpp \
utils_p.cpp
unsavedfiledata.cpp
HEADERS += \
activationsequencecontextprocessor.h \
......@@ -77,42 +66,16 @@ HEADERS += \
clangmodelmanagersupport.h \
clangprojectsettings.h \
clangprojectsettingspropertiespage.h \
clangsymbol.h \
clangtextmark.h \
clangutils.h \
completionchunkstotextconverter.h \
constants.h \
cppcreatemarkers.h \
cxprettyprinter.h \
cxraii.h \
diagnostic.h \
fastindexer.h \
highlightingmarksreporter.h \
pchinfo.h \
pchmanager.h \
raii/scopedclangoptions.h \
semanticmarker.h \
sourcelocation.h \
sourcemarker.h \
unit.h \
unsavedfiledata.h \
utils.h \
utils_p.h
contains(DEFINES, CLANG_INDEXING) {
HEADERS += \
clangindexer.h \
index.h \
indexer.h
# dependencygraph.h \
SOURCES += \
clangindexer.cpp \
index.cpp \
indexer.cpp
# dependencygraph.cpp \
}
unsavedfiledata.h
FORMS += clangprojectsettingspropertiespage.ui
......
......@@ -20,10 +20,6 @@ QtcPlugin {
"QmakeProjectManager",
]
property bool clangCompletion: true
property bool clangHighlighting: true
property bool clangIndexing: false
property string llvmConfig: Clang.llvmConfig(qbs, QtcFunctions, QtcProcessOutputReader)
property string llvmIncludeDir: Clang.includeDir(llvmConfig, QtcProcessOutputReader)
property string llvmLibDir: Clang.libDir(llvmConfig, QtcProcessOutputReader)
......@@ -39,149 +35,94 @@ QtcPlugin {
cpp.defines: {
var defines = base;
// The following defines are used to determine the clang include path for intrinsics.
defines.push('CLANG_VERSION="' + llvmVersion + '"');
defines.push('CLANG_RESOURCE_DIR="' + llvmLibDir + '/clang/' + llvmVersion + '/include"');
if (clangCompletion)
defines.push("CLANG_COMPLETION");
if (clangHighlighting)
defines.push("CLANG_HIGHLIGHTING");
if (clangIndexing)
defines.push("CLANG_INDEXING");
return defines;
}
Group {
name: "Completion support"
condition: product.clangCompletion
files: [
"activationsequencecontextprocessor.cpp",
"activationsequencecontextprocessor.h",
"activationsequenceprocessor.cpp",
"activationsequenceprocessor.h",
"clangassistproposal.cpp",
"clangassistproposal.h",
"clangassistproposalitem.cpp",
"clangassistproposalitem.h",
"clangassistproposalmodel.cpp",
"clangassistproposalmodel.h",
"clangcompletionassistinterface.cpp",
"clangcompletionassistinterface.h",
"clangcompletionassistprocessor.cpp",
"clangcompletionassistprocessor.h",
"clangcompletionassistprovider.cpp",
"clangcompletionassistprovider.h",
"clangfunctionhintmodel.cpp",
"clangfunctionhintmodel.h",
]
}
Group {
name: "Highlighting support"
condition: product.clangHighlighting
files: [
"cppcreatemarkers.cpp",
"cppcreatemarkers.h",
"highlightingmarksreporter.cpp",
"highlightingmarksreporter.h",
]
}
Group {
name: "Indexing support"
condition: product.clangIndexing
files: [
"clangindexer.cpp",
"clangindexer.h",
"index.cpp",
"index.h",
"indexer.cpp",
"indexer.h",
// "dependencygraph.h",
// "dependencygraph.cpp"
]
}
Group {
name: "Tests"
condition: project.testsEnabled
prefix: "test/"
files: [
"data/clangtestdata.qrc",
"clangcodecompletion_test.cpp",
"clangcodecompletion_test.h",
]
}
Group {
name: "Test resources"
prefix: "test/data/"
fileTags: "none"
files: [ "*" ]
excludeFiles: "clangtestdata.qrc"
}
files: [
"clang_global.h",
"activationsequencecontextprocessor.cpp",
"activationsequencecontextprocessor.h",
"activationsequenceprocessor.cpp",
"activationsequenceprocessor.h",
"clangassistproposal.cpp",
"clangassistproposal.h",
"clangassistproposalitem.cpp",
"clangassistproposalitem.h",
"clangassistproposalmodel.cpp",
"clangassistproposalmodel.h",
"clangbackendipcintegration.cpp",
"clangbackendipcintegration.h",
"clangcodemodelplugin.cpp",
"clangcodemodelplugin.h",
"clangcompletionassistinterface.cpp",
"clangcompletionassistinterface.h",
"clangcompletionassistprocessor.cpp",
"clangcompletionassistprocessor.h",
"clangcompletionassistprovider.cpp",
"clangcompletionassistprovider.h",
"clangcompletioncontextanalyzer.cpp",
"clangcompletioncontextanalyzer.h",
"clangeditordocumentparser.cpp",
"clangeditordocumentparser.h",
"clangeditordocumentprocessor.cpp",
"clangeditordocumentprocessor.h",
"clangdiagnosticfilter.cpp",
"clangdiagnosticfilter.h",
"clangdiagnosticmanager.cpp",
"clangdiagnosticmanager.h",
"clangeditordocumentparser.cpp",
"clangeditordocumentparser.h",
"clangeditordocumentprocessor.cpp",
"clangeditordocumentprocessor.h",
"clangfixitoperation.cpp",
"clangfixitoperation.h",
"clangfixitoperationsextractor.cpp",
"clangfixitoperationsextractor.h",
"clangfunctionhintmodel.cpp",
"clangfunctionhintmodel.h",
"clang_global.h",
"clangmodelmanagersupport.cpp",
"clangmodelmanagersupport.h",
"clangcodemodelplugin.cpp",
"clangcodemodelplugin.h",
"clangprojectsettings.cpp",
"clangprojectsettings.h",
"clangprojectsettingspropertiespage.cpp",
"clangprojectsettingspropertiespage.h",
"clangprojectsettingspropertiespage.ui",
"clangsymbol.cpp",
"clangsymbol.h",
"clangtextmark.cpp",
"clangtextmark.h",
"clangutils.cpp",
"clangutils.h",
"clangbackendipcintegration.cpp",
"clangbackendipcintegration.h",
"completionchunkstotextconverter.cpp",
"completionchunkstotextconverter.h",
"constants.h",
"cxprettyprinter.cpp",
"cxprettyprinter.h",
"cxraii.h",
"diagnostic.cpp",
"diagnostic.h",
"fastindexer.cpp",
"fastindexer.h",
"highlightingmarksreporter.cpp",
"highlightingmarksreporter.h",
"pchinfo.cpp",
"pchinfo.h",
"pchmanager.cpp",
"pchmanager.h",
"semanticmarker.cpp",
"semanticmarker.h",
"sourcelocation.cpp",
"sourcelocation.h",
"sourcemarker.cpp",
"sourcemarker.h",
"raii/scopedclangoptions.cpp",
"raii/scopedclangoptions.h",
"unit.cpp",
"unit.h",
"unsavedfiledata.cpp",
"unsavedfiledata.h",
"utils.cpp",
"utils.h",
"utils_p.cpp",
"utils_p.h",
"raii/scopedclangoptions.cpp",
"raii/scopedclangoptions.h",
]
Group {
name: "Tests"
condition: project.testsEnabled
prefix: "test/"
files: [
"data/clangtestdata.qrc",
"clangcodecompletion_test.cpp",
"clangcodecompletion_test.h",
]
}
Group {
name: "Test resources"
prefix: "test/data/"
fileTags: "none"
files: [ "*" ]
excludeFiles: "clangtestdata.qrc"
}
}
......@@ -33,7 +33,6 @@
#include "clangprojectsettingspropertiespage.h"
#include "constants.h"
#include "pchmanager.h"
#include "utils.h"
#ifdef WITH_TESTS
# include "test/clangcodecompletion_test.h"
......@@ -47,10 +46,14 @@
#include <texteditor/textmark.h>
#include <clang-c/Index.h>
namespace ClangCodeModel {
namespace Internal {
static void initializeTextMarks()
namespace {
void initializeTextMarks()
{
TextEditor::TextMark::setCategoryColor(Core::Id(Constants::CLANG_WARNING),
Utils::Theme::ClangCodeModel_Warning_TextMarkColor);
......@@ -58,6 +61,25 @@ static void initializeTextMarks()
Utils::Theme::ClangCodeModel_Error_TextMarkColor);
}
static bool clangInitialised = false;
static QMutex initialisationMutex;
void initializeClang()
{
if (clangInitialised)
return;
QMutexLocker locker(&initialisationMutex);
if (clangInitialised)
return;
clang_toggleCrashRecovery(1);
clang_enableStackTraces();
clangInitialised = true;
}
} // anonymous namespace
bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments)
......@@ -73,18 +95,12 @@ bool ClangCodeModelPlugin::initialize(const QStringList &arguments, QString *err
// Initialize Clang
ClangCodeModel::Internal::initializeClang();
// Set up Indexer
auto cppModelManager = CppTools::CppModelManager::instance();
#ifdef CLANG_INDEXING
m_indexer.reset(new ClangIndexer);
cppModelManager->setIndexingSupport(m_indexer->indexingSupport());
#endif // CLANG_INDEXING
// Set up PchManager
PchManager *pchManager = new PchManager(this);
ProjectExplorer::SessionManager *sessionManager = ProjectExplorer::SessionManager::instance();
connect(sessionManager, &ProjectExplorer::SessionManager::aboutToRemoveProject,
pchManager, &PchManager::onAboutToRemoveProject);
auto cppModelManager = CppTools::CppModelManager::instance();
connect(cppModelManager, &CppTools::CppModelManager::projectPartsUpdated,
pchManager, &PchManager::onProjectPartsUpdated);
......
......@@ -33,14 +33,8 @@
#include "clangmodelmanagersupport.h"
#ifdef CLANG_INDEXING
# include "clangindexer.h"
#endif // CLANG_INDEXING
#include <extensionsystem/iplugin.h>
#include <QScopedPointer>
namespace ClangCodeModel {
namespace Internal {
......@@ -55,9 +49,6 @@ public:
private:
ModelManagerSupportProviderClang m_modelManagerSupportProvider;
#ifdef CLANG_INDEXING
QScopedPointer<ClangIndexer> m_indexer;
#endif // CLANG_INDEXING
#ifdef WITH_TESTS
QList<QObject *> createTestObjects() const;
......
......@@ -94,7 +94,7 @@ IpcCommunicator &ClangCompletionAssistInterface::ipcCommunicator() const
return m_ipcCommunicator;
}
const UnsavedFiles &ClangCompletionAssistInterface::unsavedFiles() const
const Utils::UnsavedFiles &ClangCompletionAssistInterface::unsavedFiles() const
{
return m_unsavedFiles;
}
......
......@@ -33,7 +33,7 @@
#include "clangbackendipcintegration.h"
#include "pchinfo.h"
#include "utils.h"
#include "clangutils.h"
#include <cpptools/cppcompletionassistprovider.h>
......@@ -55,7 +55,7 @@ public:
const CPlusPlus::LanguageFeatures &features);
IpcCommunicator &ipcCommunicator() const;
const UnsavedFiles &unsavedFiles() const;
const Utils::UnsavedFiles &unsavedFiles() const;
bool objcEnabled() const;
const CppTools::ProjectPart::HeaderPaths &headerPaths() const;
CPlusPlus::LanguageFeatures languageFeatures() const;
......@@ -65,7 +65,7 @@ public:
private:
IpcCommunicator &m_ipcCommunicator;
UnsavedFiles m_unsavedFiles;
Utils::UnsavedFiles m_unsavedFiles;
QStringList m_options;
CppTools::ProjectPart::HeaderPaths m_headerPaths;
Internal::PchInfo::Ptr m_savedPchPointer;
......
......@@ -34,8 +34,6 @@
#include "clangfixitoperationsextractor.h"
#include "clangmodelmanagersupport.h"
#include "clangutils.h"
#include "cppcreatemarkers.h"
#include "diagnostic.h"
#include "highlightingmarksreporter.h"
#include "pchinfo.h"
......
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "clangindexer.h"
#include "clangutils.h"
#include "indexer.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <cpptools/cppmodelmanager.h>
#include <projectexplorer/session.h>
#include <QDir>
using namespace ClangCodeModel;
using namespace ClangCodeModel::Internal;
ClangIndexingSupport::ClangIndexingSupport(ClangIndexer *indexer)
: m_indexer(indexer)
{
}
ClangIndexingSupport::~ClangIndexingSupport()
{
}
QFuture<void> ClangIndexingSupport::refreshSourceFiles(
const QSet<QString> &sourceFiles,
CppTools::CppModelManager::ProgressNotificationMode mode)
{
Q_UNUSED(mode);
return m_indexer->refreshSourceFiles(sourceFiles);
}
CppTools::SymbolSearcher *ClangIndexingSupport::createSymbolSearcher(CppTools::SymbolSearcher::Parameters parameters, QSet<QString> fileNames)
{
Q_UNUSED(parameters);
Q_UNUSED(fileNames)
// return new ClangSymbolSearcher(m_indexer, parameters, fileNames);
return 0;
}
ClangIndexer::ClangIndexer()
: QObject(0)
, m_indexingSupport(new ClangIndexingSupport(this))
, m_isLoadingSession(false)
, m_clangIndexer(new Indexer(this))
{
connect(m_clangIndexer, SIGNAL(indexingStarted(QFuture<void>,Internal::ProgressNotificationMode)),
this, SLOT(onIndexingStarted(QFuture<void>,Internal::ProgressNotificationMode)));
QObject *session = ProjectExplorer::SessionManager::instance();
connect(session, SIGNAL(aboutToLoadSession(QString)),
this, SLOT(onAboutToLoadSession(QString)));
connect(session, SIGNAL(sessionLoaded(QString)),
this, SLOT(onSessionLoaded(QString)));
connect(session, SIGNAL(aboutToSaveSession()),
this, SLOT(onAboutToSaveSession()));
}
ClangIndexer::~ClangIndexer()
{
m_clangIndexer->cancel(true);
}
CppTools::CppIndexingSupport *ClangIndexer::indexingSupport()
{
return m_indexingSupport.data();
}
QFuture<void> ClangIndexer::refreshSourceFiles(const QSet<QString> &sourceFiles)
{
typedef CppTools::ProjectPart ProjectPart;
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
if (m_clangIndexer->isBusy())
m_clangIndexer->cancel(true);
foreach (const QString &file, sourceFiles) {
if (m_clangIndexer->isTracking(file))
continue; // we get notified separately about open files.
const QList<ProjectPart::Ptr> &parts = modelManager->projectPart(file);
if (!parts.isEmpty())
m_clangIndexer->addFile(file, parts.at(0));
else
m_clangIndexer->addFile(file, ProjectPart::Ptr());
}
if (!m_isLoadingSession)
m_clangIndexer->regenerate();
return QFuture<void>();
}
void ClangIndexer::match(ClangSymbolSearcher *searcher) const
{
m_clangIndexer->match(searcher);
}
void ClangIndexer::onAboutToLoadSession(const QString &sessionName)
{
m_isLoadingSession = true;
if (sessionName == QLatin1String("default"))
return;
QString path = Core::ICore::instance()->userResourcePath() + QLatin1String("/codemodel/");
if (QFile::exists(path) || QDir().mkpath(path))
m_clangIndexer->initialize(path + sessionName + QLatin1String(".qci"));
}
void ClangIndexer::onSessionLoaded(QString)
{
m_isLoadingSession = false;
m_clangIndexer->regenerate();
}
void ClangIndexer::onAboutToSaveSession()
{
m_clangIndexer->finalize();
}
void ClangIndexer::indexNow(Unit::Ptr unit)
{
typedef CppTools::ProjectPart ProjectPart;
QString file = unit->fileName();
CppTools::CppModelManager *mmi = CppTools::CppModelManager::instance();
const QList<ProjectPart::Ptr> &parts = mmi->projectPart(file);
ProjectPart::Ptr part;
if (!parts.isEmpty())
part = parts.at(0);
if (!m_isLoadingSession)
m_clangIndexer->runQuickIndexing(unit, part);
}
void ClangIndexer::onIndexingStarted(QFuture<void> indexingFuture)
{
Core::ProgressManager::addTask(indexingFuture, QCoreApplication::translate(
"ClangCodeModel::Internal::ClangIndexer",
"Parsing C/C++/ObjC Files"),
"ClangCodeMode.Task.Indexing");
}
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CLANGINDEXER_H
#define CLANGINDEXER_H
#include "fastindexer.h"
#include <cpptools/cppindexingsupport.h>
#include <QObject>
namespace ClangCodeModel {
class Indexer;
namespace Internal {
typedef CppTools::CppModelManager::ProgressNotificationMode ProgressNotificationMode;
class ClangIndexer;
class ClangSymbolSearcher;
class ClangIndexingSupport: public CppTools::CppIndexingSupport
{
public:
ClangIndexingSupport(ClangIndexer *indexer);
virtual ~ClangIndexingSupport();
virtual QFuture<void> refreshSourceFiles(
const QSet<QString> &sourceFiles,
ProgressNotificationMode mode);
virtual CppTools::SymbolSearcher *createSymbolSearcher(
CppTools::SymbolSearcher::Parameters parameters, QSet<QString> fileNames);
private:
ClangIndexer *m_indexer;
};
class ClangIndexer: public QObject, public FastIndexer
{
Q_OBJECT
public:
ClangIndexer();
~ClangIndexer();
CppTools::CppIndexingSupport *indexingSupport();
QFuture<void> refreshSourceFiles(const QSet<QString> &sourceFiles);
void match(ClangSymbolSearcher *searcher) const;
void indexNow(Unit::Ptr unit);
public slots:
void onAboutToLoadSession(const QString &sessionName);
void onSessionLoaded(QString);
void onAboutToSaveSession();
private slots:
void onIndexingStarted(QFuture<void> indexingFuture);
private:
QScopedPointer<ClangIndexingSupport> m_indexingSupport;
bool m_isLoadingSession;
Indexer *m_clangIndexer;
};
} // namespace Internal
} // namespace ClangCodeModel