diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2014-09-05 11:22:02 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-10-06 15:55:57 +0200 |
commit | e29324118a95b3a48ccebff7bb0e1fd524f3e4dd (patch) | |
tree | abd35fce7fcf02f0c990bb2cb67d3c166292b8d9 | |
parent | 580b5d12398a9a3e67e63a3c27c70d48f4d1ed75 (diff) | |
download | qt-creator-e29324118a95b3a48ccebff7bb0e1fd524f3e4dd.tar.gz |
Clang: fix indexing to at least compile
Change-Id: Ife43b0850f61e17af5f2c2e4397c7db6bb12e598
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
-rw-r--r-- | src/plugins/clangcodemodel/clangcodemodel.pro | 2 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangcodemodel.qbs | 2 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangindexer.cpp | 33 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangindexer.h | 10 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangsymbolsearcher.cpp | 155 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangsymbolsearcher.h | 69 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/index.cpp | 5 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/indexer.cpp | 52 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/indexer.h | 2 |
9 files changed, 52 insertions, 278 deletions
diff --git a/src/plugins/clangcodemodel/clangcodemodel.pro b/src/plugins/clangcodemodel/clangcodemodel.pro index 494783d27f..0e90ca1921 100644 --- a/src/plugins/clangcodemodel/clangcodemodel.pro +++ b/src/plugins/clangcodemodel/clangcodemodel.pro @@ -75,14 +75,12 @@ SOURCES += clangutils.cpp \ contains(DEFINES, CLANG_INDEXING) { HEADERS += \ $$PWD/clangindexer.h \ - $$PWD/clangsymbolsearcher.h \ $$PWD/index.h \ $$PWD/indexer.h # $$PWD/dependencygraph.h \ SOURCES += \ $$PWD/clangindexer.cpp \ - $$PWD/clangsymbolsearcher.cpp \ $$PWD/index.cpp \ $$PWD/indexer.cpp # $$PWD/dependencygraph.cpp \ diff --git a/src/plugins/clangcodemodel/clangcodemodel.qbs b/src/plugins/clangcodemodel/clangcodemodel.qbs index 1da1f421d6..c0466e972b 100644 --- a/src/plugins/clangcodemodel/clangcodemodel.qbs +++ b/src/plugins/clangcodemodel/clangcodemodel.qbs @@ -105,8 +105,6 @@ QtcPlugin { files: [ "clangindexer.cpp", "clangindexer.h", - "clangsymbolsearcher.cpp", - "clangsymbolsearcher.h", "index.cpp", "index.h", "indexer.cpp", diff --git a/src/plugins/clangcodemodel/clangindexer.cpp b/src/plugins/clangcodemodel/clangindexer.cpp index f0e5f02286..0575fed58f 100644 --- a/src/plugins/clangcodemodel/clangindexer.cpp +++ b/src/plugins/clangcodemodel/clangindexer.cpp @@ -28,10 +28,8 @@ ****************************************************************************/ #include "clangindexer.h" -#include "clangsymbolsearcher.h" #include "clangutils.h" #include "indexer.h" -#include "liveunitsmanager.h" #include <coreplugin/icore.h> #include <coreplugin/progressmanager/progressmanager.h> @@ -52,14 +50,21 @@ ClangIndexingSupport::~ClangIndexingSupport() { } -QFuture<void> ClangIndexingSupport::refreshSourceFiles(const QStringList &sourceFiles) +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) { - return new ClangSymbolSearcher(m_indexer, parameters, fileNames); + Q_UNUSED(parameters); + Q_UNUSED(fileNames) +// return new ClangSymbolSearcher(m_indexer, parameters, fileNames); + return 0; } ClangIndexer::ClangIndexer() @@ -68,8 +73,8 @@ ClangIndexer::ClangIndexer() , m_isLoadingSession(false) , m_clangIndexer(new Indexer(this)) { - connect(m_clangIndexer, SIGNAL(indexingStarted(QFuture<void>)), - this, SLOT(onIndexingStarted(QFuture<void>))); + connect(m_clangIndexer, SIGNAL(indexingStarted(QFuture<void>, Internal::ProgressNotificationMode)), + this, SLOT(onIndexingStarted(QFuture<void>, Internal::ProgressNotificationMode))); QObject *session = ProjectExplorer::SessionManager::instance(); @@ -91,19 +96,18 @@ CppTools::CppIndexingSupport *ClangIndexer::indexingSupport() return m_indexingSupport.data(); } -QFuture<void> ClangIndexer::refreshSourceFiles(const QStringList &sourceFiles) +QFuture<void> ClangIndexer::refreshSourceFiles(const QSet<QString> &sourceFiles) { typedef CppTools::ProjectPart ProjectPart; - CppTools::CppModelManager *mmi = CppTools::CppModelManager::instance(); - LiveUnitsManager *lum = LiveUnitsManager::instance(); + CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); if (m_clangIndexer->isBusy()) m_clangIndexer->cancel(true); foreach (const QString &file, sourceFiles) { - if (lum->isTracking(file)) + if (m_clangIndexer->isTracking(file)) continue; // we get notified separately about open files. - const QList<ProjectPart::Ptr> &parts = mmi->projectPart(file); + const QList<ProjectPart::Ptr> &parts = modelManager->projectPart(file); if (!parts.isEmpty()) m_clangIndexer->addFile(file, parts.at(0)); else @@ -160,7 +164,8 @@ void ClangIndexer::indexNow(Unit::Ptr unit) void ClangIndexer::onIndexingStarted(QFuture<void> indexingFuture) { - Core::ICore::instance()->progressManager()->addTask(indexingFuture, - tr("C++ Indexing"), - QLatin1String("Key.Temp.Indexing")); + Core::ProgressManager::addTask(indexingFuture, QCoreApplication::translate( + "ClangCodeModel::Internal::ClangIndexer", + "Parsing C/C++/ObjC Files"), + "ClangCodeMode.Task.Indexing"); } diff --git a/src/plugins/clangcodemodel/clangindexer.h b/src/plugins/clangcodemodel/clangindexer.h index ec86f954ce..f9dd5f5576 100644 --- a/src/plugins/clangcodemodel/clangindexer.h +++ b/src/plugins/clangcodemodel/clangindexer.h @@ -42,6 +42,7 @@ class Indexer; namespace Internal { +typedef CppTools::CppModelManager::ProgressNotificationMode ProgressNotificationMode; class ClangIndexer; class ClangSymbolSearcher; @@ -51,8 +52,11 @@ public: ClangIndexingSupport(ClangIndexer *indexer); virtual ~ClangIndexingSupport(); - virtual QFuture<void> refreshSourceFiles(const QStringList &sourceFiles); - virtual CppTools::SymbolSearcher *createSymbolSearcher(CppTools::SymbolSearcher::Parameters parameters, QSet<QString> fileNames); + 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; @@ -68,7 +72,7 @@ public: CppTools::CppIndexingSupport *indexingSupport(); - QFuture<void> refreshSourceFiles(const QStringList &sourceFiles); + QFuture<void> refreshSourceFiles(const QSet<QString> &sourceFiles); void match(ClangSymbolSearcher *searcher) const; diff --git a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp deleted file mode 100644 index 990e3b22a7..0000000000 --- a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clangsymbolsearcher.h" -#include "symbol.h" - -#include <cpptools/searchsymbols.h> - -#include <cassert> - -using namespace ClangCodeModel; -using namespace ClangCodeModel::Internal; - -ClangSymbolSearcher::ClangSymbolSearcher(ClangIndexer *indexer, const Parameters ¶meters, QSet<QString> fileNames, QObject *parent) - : CppTools::SymbolSearcher(parent) - , m_indexer(indexer) - , m_parameters(parameters) - , m_fileNames(fileNames) - , m_future(0) -{ - assert(indexer); -} - -ClangSymbolSearcher::~ClangSymbolSearcher() -{ -} - -void ClangSymbolSearcher::runSearch(QFutureInterface<SearchResultItem> &future) -{ - m_future = &future; - m_indexer->match(this); - m_future = 0; -} - -void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols) -{ - QString findString = (m_parameters.flags & Find::FindRegularExpression - ? m_parameters.text : QRegExp::escape(m_parameters.text)); - if (m_parameters.flags & Find::FindWholeWords) - findString = QString::fromLatin1("\\b%1\\b").arg(findString); - QRegExp matcher(findString, (m_parameters.flags & Find::FindCaseSensitively - ? Qt::CaseSensitive : Qt::CaseInsensitive)); - - const int chunkSize = 10; - QVector<Core::SearchResultItem> resultItems; - resultItems.reserve(100); - - m_future->setProgressRange(0, allSymbols.size() % chunkSize); - m_future->setProgressValue(0); - - int symbolNr = 0; - foreach (const Symbol &s, allSymbols) { - if (symbolNr % chunkSize == 0) { - m_future->setProgressValue(symbolNr / chunkSize); - m_future->reportResults(resultItems); - resultItems.clear(); - - if (m_future->isPaused()) - m_future->waitForResume(); - if (m_future->isCanceled()) - return; - } - ++symbolNr; - - CppTools::IndexItem info; - - switch (s.m_kind) { - case Symbol::Enum: - if (m_parameters.types & SymbolSearcher::Enums) { - info.type = CppTools::IndexItem::Enum; - info.symbolType = QLatin1String("enum"); - break; - } else { - continue; - } - case Symbol::Class: - if (m_parameters.types & SymbolSearcher::Classes) { - info.type = CppTools::IndexItem::Class; - info.symbolType = QLatin1String("class"); - break; - } else { - continue; - } - case Symbol::Method: - case Symbol::Function: - case Symbol::Constructor: - case Symbol::Destructor: - if (m_parameters.types & SymbolSearcher::Functions) { - info.type = CppTools::IndexItem::Function; - break; - } else { - continue; - } - case Symbol::Declaration: - if (m_parameters.types & SymbolSearcher::Declarations) { - info.type = CppTools::IndexItem::Declaration; - break; - } else { - continue; - } - - default: continue; - } - - if (matcher.indexIn(s.m_name) == -1) - continue; - - info.symbolName = s.m_name; - info.fullyQualifiedName = s.m_qualification.split(QLatin1String("::")) << s.m_name; - info.fileName = s.m_location.fileName(); - info.icon = s.iconForSymbol(); - info.line = s.m_location.line(); - info.column = s.m_location.column() - 1; - - Core::SearchResultItem item; - item.path << s.m_qualification; - item.text = s.m_name; - item.icon = info.icon; - item.textMarkPos = -1; - item.textMarkLength = 0; - item.lineNumber = -1; - item.userData = qVariantFromValue(info); - - resultItems << item; - } - - if (!resultItems.isEmpty()) - m_future->reportResults(resultItems); -} diff --git a/src/plugins/clangcodemodel/clangsymbolsearcher.h b/src/plugins/clangcodemodel/clangsymbolsearcher.h deleted file mode 100644 index ff59e211c4..0000000000 --- a/src/plugins/clangcodemodel/clangsymbolsearcher.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLANGSYMBOLSEARCHER_H -#define CLANGSYMBOLSEARCHER_H - -#include "clangindexer.h" - -#include <cpptools/cppindexingsupport.h> - -#include <QLinkedList> - -namespace ClangCodeModel { - -class Symbol; - -namespace Internal { - -class ClangSymbolSearcher: public CppTools::SymbolSearcher -{ - Q_OBJECT - - typedef CppTools::SymbolSearcher::Parameters Parameters; - typedef Core::SearchResultItem SearchResultItem; - -public: - ClangSymbolSearcher(ClangIndexer *indexer, const Parameters ¶meters, QSet<QString> fileNames, QObject *parent = 0); - virtual ~ClangSymbolSearcher(); - virtual void runSearch(QFutureInterface<SearchResultItem> &future); - - void search(const QLinkedList<Symbol> &allSymbols); - -private: - ClangIndexer *m_indexer; - const Parameters m_parameters; - const QSet<QString> m_fileNames; - QFutureInterface<SearchResultItem> *m_future; -}; - -} // namespace Internal -} // namespace ClangCodeModel - -#endif // CLANGSYMBOLSEARCHER_H diff --git a/src/plugins/clangcodemodel/index.cpp b/src/plugins/clangcodemodel/index.cpp index cf85e6385b..f8fd868951 100644 --- a/src/plugins/clangcodemodel/index.cpp +++ b/src/plugins/clangcodemodel/index.cpp @@ -27,7 +27,6 @@ ** ****************************************************************************/ -#include "clangsymbolsearcher.h" #include "index.h" #include <QStringList> @@ -257,8 +256,8 @@ QList<Symbol> IndexPrivate::symbols(Symbol::Kind kind) const void IndexPrivate::match(ClangSymbolSearcher *searcher) const { QMutexLocker locker(&m_mutex); - - searcher->search(m_container); + Q_UNUSED(searcher); +// searcher->search(m_container); } QList<Symbol> IndexPrivate::symbolsFromIterators(const QList<SymbolIt> &symbolList) diff --git a/src/plugins/clangcodemodel/indexer.cpp b/src/plugins/clangcodemodel/indexer.cpp index ba140d1277..0982e7edb3 100644 --- a/src/plugins/clangcodemodel/indexer.cpp +++ b/src/plugins/clangcodemodel/indexer.cpp @@ -32,9 +32,7 @@ #include "index.h" #include "cxraii.h" #include "sourcelocation.h" -#include "liveunitsmanager.h" #include "utils_p.h" -#include "clangsymbolsearcher.h" #include "pchmanager.h" #include "raii/scopedclangoptions.h" @@ -61,19 +59,6 @@ #include <QDateTime> #include <QStringBuilder> -#include <cassert> - -//#define DEBUG -//#define DEBUG_DIAGNOSTICS - -#ifdef DEBUG - #define BEGIN_PROFILE_SCOPE(ID) { ScopepTimer t(ID); - #define END_PROFILE_SCOPE } -#else - #define BEGIN_PROFILE_SCOPE(ID) - #define END_PROFILE_SCOPE -#endif - using namespace Utils; using namespace ClangCodeModel; using namespace Internal; @@ -172,7 +157,7 @@ public: void computeDependencyGraph(); void analyzeRestoredSymbols(); - void runQuickIndexing(const Unit &unit, const ProjectPart::Ptr &part); + void runQuickIndexing(const Unit::Ptr &unit, const ProjectPart::Ptr &part); void run(); void run(const QStringList &fileNames); void runCore(const QHash<QString, FileData> &headers, @@ -389,7 +374,7 @@ protected: void addInclude(File *f) { - assert(f); +// assert(f); m_includes.insert(f->name(), f); } @@ -407,7 +392,7 @@ protected: void addSymbol(Symbol *symbol) { - assert(symbol); +// assert(symbol); m_symbols.append(symbol); } @@ -656,7 +641,7 @@ private: class QuickIndexer: public LibClangIndexer { public: - QuickIndexer(IndexerPrivate *indexer, const Unit &unit, const ProjectPart::Ptr &projectPart) + QuickIndexer(IndexerPrivate *indexer, const Unit::Ptr &unit, const ProjectPart::Ptr&projectPart) : LibClangIndexer(indexer) , m_unit(unit) , m_projectPart(projectPart) @@ -664,19 +649,19 @@ public: void run() { - if (isCanceled() || !m_unit.isLoaded()) { + if (isCanceled() || !m_unit->isLoaded()) { finish(); return; } - CXIndexAction idxAction = clang_IndexAction_create(m_unit.clangIndex()); + CXIndexAction idxAction = clang_IndexAction_create(m_unit->clangIndex()); const unsigned index_opts = CXIndexOpt_SuppressWarnings; // qDebug() << "Indexing TU" << m_unit.fileName() << "..."; /*int result =*/ clang_indexTranslationUnit(idxAction, this, &IndexCB, sizeof(IndexCB), index_opts, - m_unit.clangTranslationUnit()); + m_unit->clangTranslationUnit()); propagateResults(m_projectPart); @@ -685,7 +670,7 @@ public: } private: - Unit m_unit; + Unit::Ptr m_unit; ProjectPart::Ptr m_projectPart; }; @@ -839,23 +824,23 @@ void IndexerPrivate::reset() void IndexerPrivate::synchronize(const QVector<IndexingResult> &results) { - foreach (IndexingResult result, results) { + Q_UNUSED(results); +#if 0 + foreach (const IndexingResult &result, results) { QMutexLocker locker(&m_mutex); - result.m_unit.makeUnique(); - foreach (const Symbol &symbol, result.m_symbolsInfo) { addOrUpdateFileData(symbol.m_location.fileName(), result.m_projectPart, true); // Make the symbol available in the database. - m_index.insertSymbol(symbol, result.m_unit.timeStamp()); + m_index.insertSymbol(symbol, result.m_unit->timeStamp()); } // There might be files which were processed but did not "generate" any indexable symbol, // but we still need to make the index aware of them. - result.m_processedFiles.insert(result.m_unit.fileName()); + result.m_processedFiles.insert(result.m_unit->fileName()); foreach (const QString &fileName, result.m_processedFiles) { if (!m_index.containsFile(fileName)) m_index.insertFile(fileName, result.m_unit.timeStamp()); @@ -865,6 +850,7 @@ void IndexerPrivate::synchronize(const QVector<IndexingResult> &results) if (LiveUnitsManager::instance()->isTracking(result.m_unit.fileName())) LiveUnitsManager::instance()->updateUnit(result.m_unit.fileName(), result.m_unit); } +#endif } void IndexerPrivate::finished(LibClangIndexer *indexer) @@ -1089,11 +1075,11 @@ void IndexerPrivate::analyzeRestoredSymbols() } } -void IndexerPrivate::runQuickIndexing(const Unit &unit, const CppTools::ProjectPart::Ptr &part) +void IndexerPrivate::runQuickIndexing(const Unit::Ptr &unit, const CppTools::ProjectPart::Ptr &part) { QMutexLocker locker(&m_mutex); - addOrUpdateFileData(unit.fileName(), part, false); + addOrUpdateFileData(unit->fileName(), part, false); QuickIndexer indexer(this, unit, part); indexer.run(); @@ -1288,4 +1274,10 @@ void Indexer::runQuickIndexing(Unit::Ptr unit, const CppTools::ProjectPart::Ptr m_d->runQuickIndexing(unit, part); } +bool Indexer::isTracking(const QString &fileName) const +{ + return m_d->isTrackingFile(fileName, IndexerPrivate::ImplementationFile) + || m_d->isTrackingFile(fileName, IndexerPrivate::HeaderFile); +} + #include "indexer.moc" diff --git a/src/plugins/clangcodemodel/indexer.h b/src/plugins/clangcodemodel/indexer.h index d67523948b..ba918f5aad 100644 --- a/src/plugins/clangcodemodel/indexer.h +++ b/src/plugins/clangcodemodel/indexer.h @@ -87,6 +87,8 @@ public: void runQuickIndexing(Internal::Unit::Ptr unit, const ProjectPart::Ptr &part); + bool isTracking(const QString &fileName) const; + signals: void indexingStarted(QFuture<void> future); void indexingFinished(); |