summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2014-04-14 16:52:01 +0200
committerErik Verbruggen <erik.verbruggen@digia.com>2014-06-16 12:08:12 +0200
commit17febac88b8ecfde9a5502b27f72b58ab4277165 (patch)
treee71883b242d2ba6a22cef249cc4f53f6b6ea9879
parent4d812d86c6d35be3a459c476677df3f5c37c90a5 (diff)
downloadqt-creator-17febac88b8ecfde9a5502b27f72b58ab4277165.tar.gz
C++: Rename ModelItemInfo to IndexInfo.
And move it into its own header and source files. Change-Id: I37401badd819e028e1d767425759dc0ff27afe31 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
-rw-r--r--src/plugins/clangcodemodel/clangsymbolsearcher.cpp10
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp2
-rw-r--r--src/plugins/cpptools/builtinindexingsupport.cpp8
-rw-r--r--src/plugins/cpptools/cppclassesfilter.cpp6
-rw-r--r--src/plugins/cpptools/cppclassesfilter.h4
-rw-r--r--src/plugins/cpptools/cppcurrentdocumentfilter.cpp16
-rw-r--r--src/plugins/cpptools/cppcurrentdocumentfilter.h2
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.cpp6
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.h4
-rw-r--r--src/plugins/cpptools/cpplocatordata.cpp36
-rw-r--r--src/plugins/cpptools/cpplocatordata.h15
-rw-r--r--src/plugins/cpptools/cpplocatorfilter.cpp18
-rw-r--r--src/plugins/cpptools/cpplocatorfilter.h4
-rw-r--r--src/plugins/cpptools/cpptools.pro2
-rw-r--r--src/plugins/cpptools/cpptools.qbs1
-rw-r--r--src/plugins/cpptools/indexitem.cpp55
-rw-r--r--src/plugins/cpptools/indexitem.h160
-rw-r--r--src/plugins/cpptools/searchsymbols.cpp72
-rw-r--r--src/plugins/cpptools/searchsymbols.h137
-rw-r--r--src/plugins/cpptools/symbolsfindfilter.cpp4
20 files changed, 319 insertions, 243 deletions
diff --git a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
index a8512d53a8..990e3b22a7 100644
--- a/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
+++ b/src/plugins/clangcodemodel/clangsymbolsearcher.cpp
@@ -88,12 +88,12 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
}
++symbolNr;
- CppTools::ModelItemInfo info;
+ CppTools::IndexItem info;
switch (s.m_kind) {
case Symbol::Enum:
if (m_parameters.types & SymbolSearcher::Enums) {
- info.type = CppTools::ModelItemInfo::Enum;
+ info.type = CppTools::IndexItem::Enum;
info.symbolType = QLatin1String("enum");
break;
} else {
@@ -101,7 +101,7 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
}
case Symbol::Class:
if (m_parameters.types & SymbolSearcher::Classes) {
- info.type = CppTools::ModelItemInfo::Class;
+ info.type = CppTools::IndexItem::Class;
info.symbolType = QLatin1String("class");
break;
} else {
@@ -112,14 +112,14 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
case Symbol::Constructor:
case Symbol::Destructor:
if (m_parameters.types & SymbolSearcher::Functions) {
- info.type = CppTools::ModelItemInfo::Function;
+ info.type = CppTools::IndexItem::Function;
break;
} else {
continue;
}
case Symbol::Declaration:
if (m_parameters.types & SymbolSearcher::Declarations) {
- info.type = CppTools::ModelItemInfo::Declaration;
+ info.type = CppTools::IndexItem::Declaration;
break;
} else {
continue;
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index d519dda257..918d44889c 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -1920,7 +1920,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QList<Core::LocatorFilterEntry> matches = classesFilter->matchesFor(dummyInterface, className);
bool classExists = false;
foreach (const Core::LocatorFilterEntry &entry, matches) {
- ModelItemInfo::Ptr info = entry.internalData.value<ModelItemInfo::Ptr>();
+ IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>();
if (info->symbolName() != className)
continue;
classExists = true;
diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp
index 2977eb2ac7..ccad1e0e73 100644
--- a/src/plugins/cpptools/builtinindexingsupport.cpp
+++ b/src/plugins/cpptools/builtinindexingsupport.cpp
@@ -125,16 +125,16 @@ public:
break;
if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) {
QVector<Core::SearchResultItem> resultItems;
- search(it.value())->visitAllChildren([&](const ModelItemInfo::Ptr &info) {
+ search(it.value())->visitAllChildren([&](const IndexItem::Ptr &info) {
if (matcher.indexIn(info->symbolName()) != -1) {
QString text = info->symbolName();
QString scope = info->symbolScope();
- if (info->type() == ModelItemInfo::Function) {
+ if (info->type() == IndexItem::Function) {
QString name;
info->unqualifiedNameAndScope(info->symbolName(), &name, &scope);
text = name + info->symbolType();
- } else if (info->type() == ModelItemInfo::Declaration){
- text = ModelItemInfo::representDeclaration(info->symbolName(),
+ } else if (info->type() == IndexItem::Declaration){
+ text = IndexItem::representDeclaration(info->symbolName(),
info->symbolType());
}
diff --git a/src/plugins/cpptools/cppclassesfilter.cpp b/src/plugins/cpptools/cppclassesfilter.cpp
index 2f9eb3809c..5835b4346b 100644
--- a/src/plugins/cpptools/cppclassesfilter.cpp
+++ b/src/plugins/cpptools/cppclassesfilter.cpp
@@ -45,12 +45,12 @@ CppClassesFilter::~CppClassesFilter()
{
}
-QList<QList<ModelItemInfo::Ptr> > CppClassesFilter::itemsToMatchUserInputAgainst() const
+QList<QList<IndexItem::Ptr> > CppClassesFilter::itemsToMatchUserInputAgainst() const
{
- return QList<QList<CppTools::ModelItemInfo::Ptr> >() << m_data->classes();
+ return QList<QList<CppTools::IndexItem::Ptr> >() << m_data->classes();
}
-Core::LocatorFilterEntry CppClassesFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
+Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
{
const QVariant id = qVariantFromValue(info);
Core::LocatorFilterEntry filterEntry(this, info->symbolName(), id, info->icon());
diff --git a/src/plugins/cpptools/cppclassesfilter.h b/src/plugins/cpptools/cppclassesfilter.h
index 09c70bb0cb..446a90b7ca 100644
--- a/src/plugins/cpptools/cppclassesfilter.h
+++ b/src/plugins/cpptools/cppclassesfilter.h
@@ -45,8 +45,8 @@ public:
~CppClassesFilter();
private:
- QList<QList<CppTools::ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
- Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
+ QList<QList<CppTools::IndexItem::Ptr> > itemsToMatchUserInputAgainst() const;
+ Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
};
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
index 685950ed46..ef3242c15d 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
@@ -79,22 +79,22 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
Snapshot snapshot = m_modelManager->snapshot();
Document::Ptr thisDocument = snapshot.document(m_currentFileName);
if (thisDocument)
- search(thisDocument)->visitAllChildren([&](const ModelItemInfo::Ptr &info){
+ search(thisDocument)->visitAllChildren([&](const IndexItem::Ptr &info){
m_itemsOfCurrentDoc.append(info);
});
}
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
- foreach (ModelItemInfo::Ptr info, m_itemsOfCurrentDoc) {
+ foreach (IndexItem::Ptr info, m_itemsOfCurrentDoc) {
if (future.isCanceled())
break;
QString matchString = info->symbolName();
- if (info->type() == ModelItemInfo::Declaration)
- matchString = ModelItemInfo::representDeclaration(info->symbolName(),
- info->symbolType());
- else if (info->type() == ModelItemInfo::Function)
+ if (info->type() == IndexItem::Declaration)
+ matchString = IndexItem::representDeclaration(info->symbolName(),
+ info->symbolType());
+ else if (info->type() == IndexItem::Function)
matchString += info->symbolType();
if ((hasWildcard && regexp.exactMatch(matchString))
@@ -103,7 +103,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
QVariant id = qVariantFromValue(info);
QString name = matchString;
QString extraInfo = info->symbolScope();
- if (info->type() == ModelItemInfo::Function) {
+ if (info->type() == IndexItem::Function) {
if (info->unqualifiedNameAndScope(matchString, &name, &extraInfo))
name += info->symbolType();
}
@@ -125,7 +125,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection) const
{
- ModelItemInfo::Ptr info = qvariant_cast<CppTools::ModelItemInfo::Ptr>(selection.internalData);
+ IndexItem::Ptr info = qvariant_cast<CppTools::IndexItem::Ptr>(selection.internalData);
Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
}
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.h b/src/plugins/cpptools/cppcurrentdocumentfilter.h
index 0b24fe4ee4..06b9633d71 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.h
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.h
@@ -61,7 +61,7 @@ private slots:
private:
CppModelManager * m_modelManager;
QString m_currentFileName;
- QList<ModelItemInfo::Ptr> m_itemsOfCurrentDoc;
+ QList<IndexItem::Ptr> m_itemsOfCurrentDoc;
SearchSymbols search;
};
diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp
index 069829c353..ecdb8a971c 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.cpp
+++ b/src/plugins/cpptools/cppfunctionsfilter.cpp
@@ -45,12 +45,12 @@ CppFunctionsFilter::~CppFunctionsFilter()
{
}
-QList<QList<CppTools::ModelItemInfo::Ptr> > CppFunctionsFilter::itemsToMatchUserInputAgainst() const
+QList<QList<CppTools::IndexItem::Ptr> > CppFunctionsFilter::itemsToMatchUserInputAgainst() const
{
- return QList<QList<CppTools::ModelItemInfo::Ptr> >() << m_data->functions();
+ return QList<QList<CppTools::IndexItem::Ptr> >() << m_data->functions();
}
-Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
+Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
{
const QVariant id = qVariantFromValue(info);
diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h
index de30197792..ba0f9d49db 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.h
+++ b/src/plugins/cpptools/cppfunctionsfilter.h
@@ -45,8 +45,8 @@ public:
~CppFunctionsFilter();
private:
- QList<QList<ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
- Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
+ QList<QList<IndexItem::Ptr> > itemsToMatchUserInputAgainst() const;
+ Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
};
} // namespace Internal
diff --git a/src/plugins/cpptools/cpplocatordata.cpp b/src/plugins/cpptools/cpplocatordata.cpp
index 27fdb4703d..986834274d 100644
--- a/src/plugins/cpptools/cpplocatordata.cpp
+++ b/src/plugins/cpptools/cpplocatordata.cpp
@@ -53,22 +53,22 @@ CppLocatorData::CppLocatorData(CppModelManager *modelManager)
this, SLOT(onAboutToRemoveFiles(QStringList)));
}
-QList<ModelItemInfo::Ptr> CppLocatorData::enums()
+QList<IndexItem::Ptr> CppLocatorData::enums()
{
flushPendingDocument(true);
- return allModelItemInfos(m_allEnums);
+ return allIndexItems(m_allEnums);
}
-QList<ModelItemInfo::Ptr> CppLocatorData::classes()
+QList<IndexItem::Ptr> CppLocatorData::classes()
{
flushPendingDocument(true);
- return allModelItemInfos(m_allClasses);
+ return allIndexItems(m_allClasses);
}
-QList<ModelItemInfo::Ptr> CppLocatorData::functions()
+QList<IndexItem::Ptr> CppLocatorData::functions()
{
flushPendingDocument(true);
- return allModelItemInfos(m_allFunctions);
+ return allIndexItems(m_allFunctions);
}
void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document)
@@ -120,21 +120,19 @@ void CppLocatorData::flushPendingDocument(bool force)
foreach (CPlusPlus::Document::Ptr doc, m_pendingDocuments) {
const QString fileName = findOrInsertFilePath(doc->fileName());
- QList<ModelItemInfo::Ptr> resultsEnums;
- QList<ModelItemInfo::Ptr> resultsClasses;
- QList<ModelItemInfo::Ptr> resultsFunctions;
+ QList<IndexItem::Ptr> resultsEnums;
+ QList<IndexItem::Ptr> resultsClasses;
+ QList<IndexItem::Ptr> resultsFunctions;
- const int sizeHint = m_allEnums[fileName].size() + m_allClasses[fileName].size()
- + m_allFunctions[fileName].size() + 10;
- m_search(doc, sizeHint)->visitAllChildren([&](const ModelItemInfo::Ptr &info) {
+ m_search(doc)->visitAllChildren([&](const IndexItem::Ptr &info) {
switch (info->type()) {
- case ModelItemInfo::Enum:
+ case IndexItem::Enum:
resultsEnums.append(info);
break;
- case ModelItemInfo::Class:
+ case IndexItem::Class:
resultsClasses.append(info);
break;
- case ModelItemInfo::Function:
+ case IndexItem::Function:
resultsFunctions.append(info);
break;
default:
@@ -151,11 +149,11 @@ void CppLocatorData::flushPendingDocument(bool force)
m_pendingDocuments.reserve(MaxPendingDocuments);
}
-QList<ModelItemInfo::Ptr> CppLocatorData::allModelItemInfos(const QHash<QString,
- QList<ModelItemInfo::Ptr>> &items) const
+QList<IndexItem::Ptr> CppLocatorData::allIndexItems(
+ const QHash<QString, QList<IndexItem::Ptr>> &items) const
{
- QList<ModelItemInfo::Ptr> result;
- QHashIterator<QString, QList<ModelItemInfo::Ptr> > it(items);
+ QList<IndexItem::Ptr> result;
+ QHashIterator<QString, QList<IndexItem::Ptr> > it(items);
while (it.hasNext()) {
it.next();
result.append(it.value());
diff --git a/src/plugins/cpptools/cpplocatordata.h b/src/plugins/cpptools/cpplocatordata.h
index eb85e52df7..0feda706c4 100644
--- a/src/plugins/cpptools/cpplocatordata.h
+++ b/src/plugins/cpptools/cpplocatordata.h
@@ -49,9 +49,9 @@ class CppLocatorData : public QObject
public:
explicit CppLocatorData(CppModelManager *modelManager);
- QList<ModelItemInfo::Ptr> enums();
- QList<ModelItemInfo::Ptr> classes();
- QList<ModelItemInfo::Ptr> functions();
+ QList<IndexItem::Ptr> enums();
+ QList<IndexItem::Ptr> classes();
+ QList<IndexItem::Ptr> functions();
private slots:
void onDocumentUpdated(const CPlusPlus::Document::Ptr &document);
@@ -59,8 +59,7 @@ private slots:
private:
void flushPendingDocument(bool force);
- QList<ModelItemInfo::Ptr> allModelItemInfos(
- const QHash<QString, QList<ModelItemInfo::Ptr>> &items) const;
+ QList<IndexItem::Ptr> allIndexItems(const QHash<QString, QList<IndexItem::Ptr>> &items) const;
QString findOrInsertFilePath(const QString &path)
{ return m_strings.insert(path); }
@@ -71,9 +70,9 @@ private:
StringTable &m_strings; // Used to avoid QString duplication
SearchSymbols m_search;
- QHash<QString, QList<ModelItemInfo::Ptr> > m_allEnums;
- QHash<QString, QList<ModelItemInfo::Ptr> > m_allClasses;
- QHash<QString, QList<ModelItemInfo::Ptr> > m_allFunctions;
+ QHash<QString, QList<IndexItem::Ptr> > m_allEnums;
+ QHash<QString, QList<IndexItem::Ptr> > m_allClasses;
+ QHash<QString, QList<IndexItem::Ptr> > m_allFunctions;
mutable QMutex m_pendingDocumentsMutex;
QVector<CPlusPlus::Document::Ptr> m_pendingDocuments;
diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp
index c5d5af9e51..3c967c4d32 100644
--- a/src/plugins/cpptools/cpplocatorfilter.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter.cpp
@@ -48,11 +48,11 @@ CppLocatorFilter::~CppLocatorFilter()
{
}
-Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(ModelItemInfo::Ptr info)
+Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
{
const QVariant id = qVariantFromValue(info);
Core::LocatorFilterEntry filterEntry(this, info->scopedSymbolName(), id, info->icon());
- if (info->type() == ModelItemInfo::Class || info->type() == ModelItemInfo::Enum)
+ if (info->type() == IndexItem::Class || info->type() == IndexItem::Enum)
filterEntry.extraInfo = info->shortNativeFilePath();
else
filterEntry.extraInfo = info->symbolType();
@@ -65,9 +65,9 @@ void CppLocatorFilter::refresh(QFutureInterface<void> &future)
Q_UNUSED(future)
}
-QList<QList<CppTools::ModelItemInfo::Ptr> > CppLocatorFilter::itemsToMatchUserInputAgainst() const
+QList<QList<CppTools::IndexItem::Ptr> > CppLocatorFilter::itemsToMatchUserInputAgainst() const
{
- return QList<QList<CppTools::ModelItemInfo::Ptr> >()
+ return QList<QList<CppTools::IndexItem::Ptr> >()
<< m_data->classes()
<< m_data->functions()
<< m_data->enums();
@@ -94,16 +94,16 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
bool hasColonColon = entry.contains(QLatin1String("::"));
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
- const QList<QList<CppTools::ModelItemInfo::Ptr> > itemLists = itemsToMatchUserInputAgainst();
- foreach (const QList<CppTools::ModelItemInfo::Ptr> &items, itemLists) {
- foreach (ModelItemInfo::Ptr info, items) {
+ const QList<QList<CppTools::IndexItem::Ptr> > itemLists = itemsToMatchUserInputAgainst();
+ foreach (const QList<CppTools::IndexItem::Ptr> &items, itemLists) {
+ foreach (IndexItem::Ptr info, items) {
if (future.isCanceled())
break;
const QString matchString = hasColonColon ? info->scopedSymbolName()
: info->symbolName();
if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1)) {
- const Core::LocatorFilterEntry filterEntry = filterEntryFromModelItemInfo(info);
+ const Core::LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info);
if (matchString.startsWith(entry, caseSensitivityForPrefix))
betterEntries.append(filterEntry);
else
@@ -123,6 +123,6 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
void CppLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{
- ModelItemInfo::Ptr info = qvariant_cast<CppTools::ModelItemInfo::Ptr>(selection.internalData);
+ IndexItem::Ptr info = qvariant_cast<CppTools::IndexItem::Ptr>(selection.internalData);
Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
}
diff --git a/src/plugins/cpptools/cpplocatorfilter.h b/src/plugins/cpptools/cpplocatorfilter.h
index 527e3f050b..07d5ce5fb2 100644
--- a/src/plugins/cpptools/cpplocatorfilter.h
+++ b/src/plugins/cpptools/cpplocatorfilter.h
@@ -54,8 +54,8 @@ public:
void refresh(QFutureInterface<void> &future);
protected:
- virtual QList<QList<ModelItemInfo::Ptr> > itemsToMatchUserInputAgainst() const;
- virtual Core::LocatorFilterEntry filterEntryFromModelItemInfo(ModelItemInfo::Ptr info);
+ virtual QList<QList<IndexItem::Ptr> > itemsToMatchUserInputAgainst() const;
+ virtual Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
protected:
CppLocatorData *m_data;
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index 485c947a7f..e528f3e3d6 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -50,6 +50,7 @@ HEADERS += \
doxygengenerator.h \
functionutils.h \
includeutils.h \
+ indexitem.h \
insertionpointlocator.h \
searchsymbols.h \
stringtable.h \
@@ -103,6 +104,7 @@ SOURCES += \
doxygengenerator.cpp \
functionutils.cpp \
includeutils.cpp \
+ indexitem.cpp \
insertionpointlocator.cpp \
searchsymbols.cpp \
stringtable.cpp \
diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs
index f74a840566..53fc46f23c 100644
--- a/src/plugins/cpptools/cpptools.qbs
+++ b/src/plugins/cpptools/cpptools.qbs
@@ -71,6 +71,7 @@ QtcPlugin {
"doxygengenerator.cpp", "doxygengenerator.h",
"functionutils.cpp", "functionutils.h",
"includeutils.cpp", "includeutils.h",
+ "indexitem.cpp", "indexitem.h",
"insertionpointlocator.cpp", "insertionpointlocator.h",
"searchsymbols.cpp", "searchsymbols.h",
"stringtable.cpp", "stringtable.h",
diff --git a/src/plugins/cpptools/indexitem.cpp b/src/plugins/cpptools/indexitem.cpp
new file mode 100644
index 0000000000..66784975d0
--- /dev/null
+++ b/src/plugins/cpptools/indexitem.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** 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 "indexitem.h"
+
+#include <utils/fileutils.h>
+
+using namespace CppTools;
+
+QString IndexItem::shortNativeFilePath() const
+{
+ return Utils::FileUtils::shortNativePath(Utils::FileName::fromString(m_fileName));
+}
+
+void IndexItem::squeeze()
+{
+ m_children.squeeze();
+ for (int i = 0, ei = m_children.size(); i != ei; ++i)
+ m_children[i]->squeeze();
+}
+
+void IndexItem::visitAllChildren(std::function<void (const IndexItem::Ptr &)> f) const
+{
+ foreach (const IndexItem::Ptr &child, m_children) {
+ f(child);
+ if (!child->m_children.isEmpty())
+ child->visitAllChildren(f);
+ }
+}
diff --git a/src/plugins/cpptools/indexitem.h b/src/plugins/cpptools/indexitem.h
new file mode 100644
index 0000000000..2ebf070f4b
--- /dev/null
+++ b/src/plugins/cpptools/indexitem.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** 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 CPPTOOLS_INDEXITEM_H
+#define CPPTOOLS_INDEXITEM_H
+
+#include "cpptools_global.h"
+
+#include <utils/function.h>
+
+#include <QIcon>
+#include <QSharedPointer>
+#include <QMetaType>
+
+namespace CppTools {
+
+class CPPTOOLS_EXPORT IndexItem
+{
+ Q_DISABLE_COPY(IndexItem)
+
+public:
+ enum ItemType { Enum, Class, Function, Declaration };
+
+private:
+ IndexItem(const QString &symbolName,
+ const QString &symbolType,
+ const QString &symbolScope,
+ ItemType type,
+ const QString &fileName,
+ int line,
+ int column,
+ const QIcon &icon)
+ : m_symbolName(symbolName),
+ m_symbolType(symbolType),
+ m_symbolScope(symbolScope),
+ m_fileName(fileName),
+ m_icon(icon),
+ m_type(type),
+ m_line(line),
+ m_column(column)
+ {}
+
+ IndexItem(const QString &fileName, int sizeHint)
+ : m_fileName(fileName)
+ , m_type(Declaration)
+ , m_line(0)
+ , m_column(0)
+ { m_children.reserve(sizeHint); }
+
+public:
+ typedef QSharedPointer<IndexItem> Ptr;
+ static Ptr create(const QString &symbolName,
+ const QString &symbolType,
+ const QString &symbolScope,
+ ItemType type,
+ const QString &fileName,
+ int line,
+ int column,
+ const QIcon &icon)
+ {
+ return Ptr(new IndexItem(
+ symbolName, symbolType, symbolScope, type, fileName, line, column, icon));
+ }
+
+ static Ptr create(const QString &fileName, int sizeHint)
+ {
+ return Ptr(new IndexItem(fileName, sizeHint));
+ }
+
+ QString scopedSymbolName() const
+ {
+ return m_symbolScope.isEmpty()
+ ? m_symbolName
+ : m_symbolScope + QLatin1String("::") + m_symbolName;
+ }
+
+ bool unqualifiedNameAndScope(const QString &defaultName, QString *name, QString *scope) const
+ {
+ *name = defaultName;
+ *scope = m_symbolScope;
+ const QString qualifiedName = scopedSymbolName();
+ const int colonColonPosition = qualifiedName.lastIndexOf(QLatin1String("::"));
+ if (colonColonPosition != -1) {
+ *name = qualifiedName.mid(colonColonPosition + 2);
+ *scope = qualifiedName.left(colonColonPosition);
+ return true;
+ }
+ return false;
+ }
+
+ static QString representDeclaration(const QString &name, const QString &type)
+ {
+ if (type.isEmpty())
+ return QString();
+
+ const QString padding = type.endsWith(QLatin1Char('*'))
+ ? QString()
+ : QString(QLatin1Char(' '));
+ return type + padding + name;
+ }
+
+ QString shortNativeFilePath() const;
+
+ QString symbolName() const { return m_symbolName; }
+ QString symbolType() const { return m_symbolType; }
+ QString symbolScope() const { return m_symbolScope; }
+ QString fileName() const { return m_fileName; }
+ QIcon icon() const { return m_icon; }
+ ItemType type() const { return m_type; }
+ int line() const { return m_line; }
+ int column() const { return m_column; }
+
+ void addChild(IndexItem::Ptr childItem) { m_children.append(childItem); }
+ void squeeze();
+
+ void visitAllChildren(std::function<void (const IndexItem::Ptr &)> f) const;
+
+private:
+ QString m_symbolName; // as found in the code, therefore might be qualified
+ QString m_symbolType;
+ QString m_symbolScope;
+ QString m_fileName;
+ QIcon m_icon;
+ ItemType m_type;
+ int m_line;
+ int m_column;
+ QVector<IndexItem::Ptr> m_children;
+};
+
+} // CppTools namespace
+
+Q_DECLARE_METATYPE(CppTools::IndexItem::Ptr)
+
+#endif // CPPTOOLS_INDEXITEM_H
diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp
index 49bc13ce8d..0fe83a1a41 100644
--- a/src/plugins/cpptools/searchsymbols.cpp
+++ b/src/plugins/cpptools/searchsymbols.cpp
@@ -38,7 +38,7 @@
using namespace CPlusPlus;
using namespace CppTools;
-typedef Utils::ScopedSwap<ModelItemInfo::Ptr> ScopedModelItemInfoPtr;
+typedef Utils::ScopedSwap<IndexItem::Ptr> ScopedIndexItemPtr;
typedef Utils::ScopedSwap<QString> ScopedScope;
SearchSymbols::SymbolTypes SearchSymbols::AllTypes =
@@ -58,19 +58,19 @@ void SearchSymbols::setSymbolsToSearchFor(const SymbolTypes &types)
symbolsToSearchFor = types;
}
-ModelItemInfo::Ptr SearchSymbols::operator()(Document::Ptr doc, int sizeHint, const QString &scope)
+IndexItem::Ptr SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
{
- ModelItemInfo::Ptr root = ModelItemInfo::create(findOrInsert(doc->fileName()), sizeHint);
+ IndexItem::Ptr root = IndexItem::create(findOrInsert(doc->fileName()), 100);
{ // RAII scope
- ScopedModelItemInfoPtr parentRaii(_parent, root);
+ ScopedIndexItemPtr parentRaii(_parent, root);
QString newScope = scope;
ScopedScope scopeRaii(_scope, newScope);
- QTC_ASSERT(_parent, return ModelItemInfo::Ptr());
- QTC_ASSERT(root, return ModelItemInfo::Ptr());
+ QTC_ASSERT(_parent, return IndexItem::Ptr());
+ QTC_ASSERT(root, return IndexItem::Ptr());
QTC_ASSERT(_parent->fileName() == findOrInsert(doc->fileName()),
- return ModelItemInfo::Ptr());
+ return IndexItem::Ptr());
for (unsigned i = 0, ei = doc->globalSymbolCount(); i != ei; ++i)
accept(doc->globalSymbolAt(i));
@@ -89,11 +89,10 @@ bool SearchSymbols::visit(Enum *symbol)
return false;
QString name = overview.prettyName(symbol->name());
- ModelItemInfo::Ptr newParent =
- addChildItem(name, QString(), _scope, ModelItemInfo::Enum, symbol);
+ IndexItem::Ptr newParent = addChildItem(name, QString(), _scope, IndexItem::Enum, symbol);
if (!newParent)
newParent = _parent;
- ScopedModelItemInfoPtr parentRaii(_parent, newParent);
+ ScopedIndexItemPtr parentRaii(_parent, newParent);
QString newScope = scopedSymbolName(name, symbol);
ScopedScope scopeRaii(_scope, newScope);
@@ -110,7 +109,7 @@ bool SearchSymbols::visit(Function *symbol)
return false;
QString name = overview.prettyName(symbol->name());
QString type = overview.prettyType(symbol->type());
- addChildItem(name, type, _scope, ModelItemInfo::Function, symbol);
+ addChildItem(name, type, _scope, IndexItem::Function, symbol);
return false;
}
@@ -144,8 +143,8 @@ bool SearchSymbols::visit(Declaration *symbol)
QString name = overview.prettyName(symbol->name());
QString type = overview.prettyType(symbol->type());
addChildItem(name, type, _scope,
- symbol->type()->asFunctionType() ? ModelItemInfo::Function
- : ModelItemInfo::Declaration,
+ symbol->type()->asFunctionType() ? IndexItem::Function
+ : IndexItem::Declaration,
symbol);
}
@@ -156,12 +155,12 @@ bool SearchSymbols::visit(Class *symbol)
{
QString name = overview.prettyName(symbol->name());
- ModelItemInfo::Ptr newParent;
+ IndexItem::Ptr newParent;
if (symbolsToSearchFor & SymbolSearcher::Classes)
- newParent = addChildItem(name, QString(), _scope, ModelItemInfo::Class, symbol);
+ newParent = addChildItem(name, QString(), _scope, IndexItem::Class, symbol);
if (!newParent)
newParent = _parent;
- ScopedModelItemInfoPtr parentRaii(_parent, newParent);
+ ScopedIndexItemPtr parentRaii(_parent, newParent);
QString newScope = scopedSymbolName(name, symbol);
ScopedScope scopeRaii(_scope, newScope);
@@ -291,13 +290,12 @@ QString SearchSymbols::scopeName(const QString &name, const Symbol *symbol) cons
}
}
-ModelItemInfo::Ptr SearchSymbols::addChildItem(const QString &symbolName, const QString &symbolType,
- const QString &symbolScope,
- ModelItemInfo::ItemType itemType,
- Symbol *symbol)
+IndexItem::Ptr SearchSymbols::addChildItem(const QString &symbolName, const QString &symbolType,
+ const QString &symbolScope, IndexItem::ItemType itemType,
+ Symbol *symbol)
{
if (!symbol->name() || symbol->isGenerated())
- return ModelItemInfo::Ptr();
+ return IndexItem::Ptr();
QString path = m_paths.value(symbol->fileId(), QString());
if (path.isEmpty()) {
@@ -306,30 +304,14 @@ ModelItemInfo::Ptr SearchSymbols::addChildItem(const QString &symbolName, const
}
const QIcon icon = icons.iconForSymbol(symbol);
- ModelItemInfo::Ptr newItem = ModelItemInfo::create(findOrInsert(symbolName),
- findOrInsert(symbolType),
- findOrInsert(symbolScope),
- itemType,
- findOrInsert(path),
- symbol->line(),
- symbol->column() - 1, // 1-based vs 0-based column
- icon);
+ IndexItem::Ptr newItem = IndexItem::create(findOrInsert(symbolName),
+ findOrInsert(symbolType),
+ findOrInsert(symbolScope),
+ itemType,
+ findOrInsert(path),
+ symbol->line(),
+ symbol->column() - 1, // 1-based vs 0-based column
+ icon);
_parent->addChild(newItem);
return newItem;
}
-
-void ModelItemInfo::squeeze()
-{
- m_children.squeeze();
- for (int i = 0, ei = m_children.size(); i != ei; ++i)
- m_children[i]->squeeze();
-}
-
-void ModelItemInfo::visitAllChildren(std::function<void (const ModelItemInfo::Ptr &)> f) const
-{
- foreach (const ModelItemInfo::Ptr &child, m_children) {
- f(child);
- if (!child->m_children.isEmpty())
- child->visitAllChildren(f);
- }
-}
diff --git a/src/plugins/cpptools/searchsymbols.h b/src/plugins/cpptools/searchsymbols.h
index 3e05bb3ef0..c4306bfb96 100644
--- a/src/plugins/cpptools/searchsymbols.h
+++ b/src/plugins/cpptools/searchsymbols.h
@@ -32,137 +32,19 @@
#include "cpptools_global.h"
#include "cppindexingsupport.h"
+#include "indexitem.h"
#include "stringtable.h"
#include <cplusplus/CppDocument.h>
#include <cplusplus/Icons.h>
#include <cplusplus/Overview.h>
-#include <utils/fileutils.h>
-#include <utils/function.h>
-
-#include <QIcon>
#include <QString>
#include <QSet>
-#include <QSharedPointer>
#include <QHash>
namespace CppTools {
-class CPPTOOLS_EXPORT ModelItemInfo
-{
- Q_DISABLE_COPY(ModelItemInfo)
-
-public:
- enum ItemType { Enum, Class, Function, Declaration };
-
-private:
- ModelItemInfo(const QString &symbolName,
- const QString &symbolType,
- const QString &symbolScope,
- ItemType type,
- const QString &fileName,
- int line,
- int column,
- const QIcon &icon)
- : m_symbolName(symbolName),
- m_symbolType(symbolType),
- m_symbolScope(symbolScope),
- m_fileName(fileName),
- m_icon(icon),
- m_type(type),
- m_line(line),
- m_column(column)
- {}
-
- ModelItemInfo(const QString &fileName, int sizeHint)
- : m_fileName(fileName)
- , m_type(Declaration)
- , m_line(0)
- , m_column(0)
- { m_children.reserve(sizeHint); }
-
-public:
- typedef QSharedPointer<ModelItemInfo> Ptr;
- static Ptr create(const QString &symbolName,
- const QString &symbolType,
- const QString &symbolScope,
- ItemType type,
- const QString &fileName,
- int line,
- int column,
- const QIcon &icon)
- {
- return Ptr(new ModelItemInfo(
- symbolName, symbolType, symbolScope, type, fileName, line, column, icon));
- }
-
- static Ptr create(const QString &fileName, int sizeHint)
- {
- return Ptr(new ModelItemInfo(fileName, sizeHint));
- }
-
- QString scopedSymbolName() const
- {
- return m_symbolScope.isEmpty()
- ? m_symbolName
- : m_symbolScope + QLatin1String("::") + m_symbolName;
- }
-
- bool unqualifiedNameAndScope(const QString &defaultName, QString *name, QString *scope) const
- {
- *name = defaultName;
- *scope = m_symbolScope;
- const QString qualifiedName = scopedSymbolName();
- const int colonColonPosition = qualifiedName.lastIndexOf(QLatin1String("::"));
- if (colonColonPosition != -1) {
- *name = qualifiedName.mid(colonColonPosition + 2);
- *scope = qualifiedName.left(colonColonPosition);
- return true;
- }
- return false;
- }
-
- static QString representDeclaration(const QString &name, const QString &type)
- {
- if (type.isEmpty())
- return QString();
-
- const QString padding = type.endsWith(QLatin1Char('*'))
- ? QString()
- : QString(QLatin1Char(' '));
- return type + padding + name;
- }
-
- QString shortNativeFilePath() const
- { return Utils::FileUtils::shortNativePath(Utils::FileName::fromString(m_fileName)); }
-
- QString symbolName() const { return m_symbolName; }
- QString symbolType() const { return m_symbolType; }
- QString symbolScope() const { return m_symbolScope; }
- QString fileName() const { return m_fileName; }
- QIcon icon() const { return m_icon; }
- ItemType type() const { return m_type; }
- int line() const { return m_line; }
- int column() const { return m_column; }
-
- void addChild(ModelItemInfo::Ptr childItem) { m_children.append(childItem); }
- void squeeze();
-
- void visitAllChildren(std::function<void (const ModelItemInfo::Ptr &)> f) const;
-
-private:
- QString m_symbolName; // as found in the code, therefore might be qualified
- QString m_symbolType;
- QString m_symbolScope;
- QString m_fileName;
- QIcon m_icon;
- ItemType m_type;
- int m_line;
- int m_column;
- QVector<ModelItemInfo::Ptr> m_children;
-};
-
class SearchSymbols: protected CPlusPlus::SymbolVisitor
{
public:
@@ -174,10 +56,10 @@ public:
void setSymbolsToSearchFor(const SymbolTypes &types);
- ModelItemInfo::Ptr operator()(CPlusPlus::Document::Ptr doc, int sizeHint = 500)
- { return operator()(doc, sizeHint, QString()); }
+ IndexItem::Ptr operator()(CPlusPlus::Document::Ptr doc)
+ { return operator()(doc, QString()); }
- ModelItemInfo::Ptr operator()(CPlusPlus::Document::Ptr doc, int sizeHint, const QString &scope);
+ IndexItem::Ptr operator()(CPlusPlus::Document::Ptr doc, const QString &scope);
protected:
using SymbolVisitor::visit;
@@ -213,11 +95,9 @@ protected:
QString scopedSymbolName(const QString &symbolName, const CPlusPlus::Symbol *symbol) const;
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
QString scopeName(const QString &name, const CPlusPlus::Symbol *symbol) const;
- ModelItemInfo::Ptr addChildItem(const QString &symbolName,
- const QString &symbolType,
- const QString &symbolScope,
- ModelItemInfo::ItemType type,
- CPlusPlus::Symbol *symbol);
+ IndexItem::Ptr addChildItem(const QString &symbolName, const QString &symbolType,
+ const QString &symbolScope, IndexItem::ItemType type,
+ CPlusPlus::Symbol *symbol);
private:
QString findOrInsert(const QString &s)
@@ -225,7 +105,7 @@ private:
Internal::StringTable &strings; // Used to avoid QString duplication
- ModelItemInfo::Ptr _parent;
+ IndexItem::Ptr _parent;
QString _scope;
CPlusPlus::Overview overview;
CPlusPlus::Icons icons;
@@ -236,6 +116,5 @@ private:
} // namespace CppTools
Q_DECLARE_OPERATORS_FOR_FLAGS(CppTools::SearchSymbols::SymbolTypes)
-Q_DECLARE_METATYPE(CppTools::ModelItemInfo::Ptr)
#endif // SEARCHSYMBOLS_H
diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp
index 1b5ae8d76c..2b55a83e02 100644
--- a/src/plugins/cpptools/symbolsfindfilter.cpp
+++ b/src/plugins/cpptools/symbolsfindfilter.cpp
@@ -181,9 +181,9 @@ void SymbolsFindFilter::finish()
void SymbolsFindFilter::openEditor(const Core::SearchResultItem &item)
{
- if (!item.userData.canConvert<ModelItemInfo::Ptr>())
+ if (!item.userData.canConvert<IndexItem::Ptr>())
return;
- ModelItemInfo::Ptr info = item.userData.value<ModelItemInfo::Ptr>();
+ IndexItem::Ptr info = item.userData.value<IndexItem::Ptr>();
EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
}