Skip to content
Snippets Groups Projects
Commit 760aa0f8 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

CppTools: Get rid of SearchSymbols::setSeparateScope()


This will make it easier to use a single SearchSymbols instance and a
single run serving all locator filters.

Change-Id: Idb6a3693ad356227d46d0b28fb4c3a5db62b4ac4
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7e09b907
No related branches found
No related tags found
No related merge requests found
Showing with 163 additions and 93 deletions
...@@ -100,7 +100,6 @@ public: ...@@ -100,7 +100,6 @@ public:
SearchSymbols search; SearchSymbols search;
search.setSymbolsToSearchFor(m_parameters.types); search.setSymbolsToSearchFor(m_parameters.types);
search.setSeparateScope(true);
CPlusPlus::Snapshot::const_iterator it = m_snapshot.begin(); CPlusPlus::Snapshot::const_iterator it = m_snapshot.begin();
QString findString = (m_parameters.flags & Find::FindRegularExpression QString findString = (m_parameters.flags & Find::FindRegularExpression
...@@ -120,11 +119,14 @@ public: ...@@ -120,11 +119,14 @@ public:
foreach (const ModelItemInfo &info, modelInfos) { foreach (const ModelItemInfo &info, modelInfos) {
int index = matcher.indexIn(info.symbolName); int index = matcher.indexIn(info.symbolName);
if (index != -1) { if (index != -1) {
QStringList path = info.fullyQualifiedName.mid(0, QString text = info.typeNameRepresentation();
info.fullyQualifiedName.size() - 1); if (text.isEmpty())
text = info.symbolName;
Find::SearchResultItem item; Find::SearchResultItem item;
item.path = path; item.path = info.symbolScope.split(QLatin1String("::"),
item.text = info.symbolName; QString::SkipEmptyParts);
item.text = text;
item.textMarkPos = -1; item.textMarkPos = -1;
item.textMarkLength = 0; item.textMarkLength = 0;
item.icon = info.icon; item.icon = info.icon;
......
...@@ -41,9 +41,24 @@ CppClassesFilter::CppClassesFilter(CppModelManager *manager) ...@@ -41,9 +41,24 @@ CppClassesFilter::CppClassesFilter(CppModelManager *manager)
setDisplayName(tr("C++ Classes")); setDisplayName(tr("C++ Classes"));
search.setSymbolsToSearchFor(SymbolSearcher::Classes); search.setSymbolsToSearchFor(SymbolSearcher::Classes);
search.setSeparateScope(true);
} }
CppClassesFilter::~CppClassesFilter() CppClassesFilter::~CppClassesFilter()
{ {
} }
QString CppClassesFilter::stringToMatchUserInputAgainst(const ModelItemInfo &info)
{
return info.symbolName;
}
Locator::FilterEntry CppClassesFilter::filterEntryFromModelItemInfo(const ModelItemInfo &info)
{
const QVariant id = qVariantFromValue(info);
Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
filterEntry.extraInfo = info.symbolScope.isEmpty()
? info.shortNativeFilePath()
: info.symbolScope;
return filterEntry;
}
...@@ -42,6 +42,10 @@ class CPPTOOLS_EXPORT CppClassesFilter : public Internal::CppLocatorFilter ...@@ -42,6 +42,10 @@ class CPPTOOLS_EXPORT CppClassesFilter : public Internal::CppLocatorFilter
public: public:
CppClassesFilter(Internal::CppModelManager *manager); CppClassesFilter(Internal::CppModelManager *manager);
~CppClassesFilter(); ~CppClassesFilter();
private:
QString stringToMatchUserInputAgainst(const ModelItemInfo &info);
Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
}; };
} // namespace CppTools } // namespace CppTools
......
...@@ -49,8 +49,6 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager, Cor ...@@ -49,8 +49,6 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager, Cor
SymbolSearcher::Functions | SymbolSearcher::Functions |
SymbolSearcher::Classes); SymbolSearcher::Classes);
search.setSeparateScope(true);
connect(manager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), connect(manager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)),
this, SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr))); this, SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr)));
connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)), connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
...@@ -88,15 +86,18 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac ...@@ -88,15 +86,18 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
if (future.isCanceled()) if (future.isCanceled())
break; break;
if ((hasWildcard && regexp.exactMatch(info.symbolName)) QString matchString = info.typeNameRepresentation();
|| (!hasWildcard && matcher.indexIn(info.symbolName) != -1)) if (matchString.isEmpty())
matchString = info.symbolName;
if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1))
{ {
QString symbolName = info.symbolName;// + (info.type == ModelItemInfo::Declaration ? ";" : " {...}");
QVariant id = qVariantFromValue(info); QVariant id = qVariantFromValue(info);
Locator::FilterEntry filterEntry(this, symbolName, id, info.icon); Locator::FilterEntry filterEntry(this, matchString, id, info.icon);
filterEntry.extraInfo = info.symbolType; filterEntry.extraInfo = info.symbolScope;
if (info.symbolName.startsWith(entry, caseSensitivityForPrefix)) if (matchString.startsWith(entry, caseSensitivityForPrefix))
betterEntries.append(filterEntry); betterEntries.append(filterEntry);
else else
goodEntries.append(filterEntry); goodEntries.append(filterEntry);
......
...@@ -40,9 +40,25 @@ CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager) ...@@ -40,9 +40,25 @@ CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager)
setIncludedByDefault(false); setIncludedByDefault(false);
search.setSymbolsToSearchFor(SymbolSearcher::Functions); search.setSymbolsToSearchFor(SymbolSearcher::Functions);
search.setSeparateScope(true);
} }
CppFunctionsFilter::~CppFunctionsFilter() CppFunctionsFilter::~CppFunctionsFilter()
{ {
} }
QString CppFunctionsFilter::stringToMatchUserInputAgainst(const CppTools::ModelItemInfo &info)
{
return info.symbolName;
}
Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
{
const QVariant id = qVariantFromValue(info);
Locator::FilterEntry filterEntry(this, info.symbolName + info.symbolType, id, info.icon);
filterEntry.extraInfo = info.symbolScope.isEmpty()
? info.shortNativeFilePath()
: info.symbolScope;
return filterEntry;
}
...@@ -42,6 +42,10 @@ class CppFunctionsFilter : public CppLocatorFilter ...@@ -42,6 +42,10 @@ class CppFunctionsFilter : public CppLocatorFilter
public: public:
CppFunctionsFilter(CppModelManager *manager); CppFunctionsFilter(CppModelManager *manager);
~CppFunctionsFilter(); ~CppFunctionsFilter();
private:
QString stringToMatchUserInputAgainst(const ModelItemInfo &info);
Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
}; };
} // namespace Internal } // namespace Internal
......
...@@ -30,12 +30,9 @@ ...@@ -30,12 +30,9 @@
#include "cpplocatorfilter.h" #include "cpplocatorfilter.h"
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
#include <utils/fileutils.h>
#include <QStringMatcher> #include <QStringMatcher>
using namespace CppTools::Internal; using namespace CppTools::Internal;
using namespace Utils;
static const int MaxPendingDocuments = 10; static const int MaxPendingDocuments = 10;
...@@ -111,6 +108,23 @@ void CppLocatorFilter::onAboutToRemoveFiles(const QStringList &files) ...@@ -111,6 +108,23 @@ void CppLocatorFilter::onAboutToRemoveFiles(const QStringList &files)
m_searchList.remove(file); m_searchList.remove(file);
} }
QString CppLocatorFilter::stringToMatchUserInputAgainst(const CppTools::ModelItemInfo &info)
{
return info.scopedSymbolName();
}
Locator::FilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
{
const QVariant id = qVariantFromValue(info);
const QString name = info.symbolScope.isEmpty() ? info.symbolName : info.scopedSymbolName();
Locator::FilterEntry filterEntry(this, name, id, info.icon);
filterEntry.extraInfo = info.type == ModelItemInfo::Class || info.type == ModelItemInfo::Enum
? info.shortNativeFilePath()
: info.symbolType;
return filterEntry;
}
void CppLocatorFilter::refresh(QFutureInterface<void> &future) void CppLocatorFilter::refresh(QFutureInterface<void> &future)
{ {
Q_UNUSED(future) Q_UNUSED(future)
...@@ -146,19 +160,11 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato ...@@ -146,19 +160,11 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
const QList<ModelItemInfo> items = it.value(); const QList<ModelItemInfo> items = it.value();
foreach (const ModelItemInfo &info, items) { foreach (const ModelItemInfo &info, items) {
if ((hasWildcard && regexp.exactMatch(info.symbolName)) const QString matchString = stringToMatchUserInputAgainst(info);
|| (!hasWildcard && matcher.indexIn(info.symbolName) != -1)) { if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1)) {
QVariant id = qVariantFromValue(info); const Locator::FilterEntry filterEntry = filterEntryFromModelItemInfo(info);
Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon); if (matchString.startsWith(entry, caseSensitivityForPrefix))
if (!info.symbolType.isEmpty()) {
filterEntry.extraInfo = info.symbolType;
} else {
filterEntry.extraInfo = FileUtils::shortNativePath(
FileName::fromString(info.fileName));
}
if (info.symbolName.startsWith(entry, caseSensitivityForPrefix))
betterEntries.append(filterEntry); betterEntries.append(filterEntry);
else else
goodEntries.append(filterEntry); goodEntries.append(filterEntry);
......
...@@ -62,6 +62,10 @@ private slots: ...@@ -62,6 +62,10 @@ private slots:
void onDocumentUpdated(CPlusPlus::Document::Ptr updatedDoc); void onDocumentUpdated(CPlusPlus::Document::Ptr updatedDoc);
void onAboutToRemoveFiles(const QStringList &files); void onAboutToRemoveFiles(const QStringList &files);
private:
virtual QString stringToMatchUserInputAgainst(const ModelItemInfo &info);
virtual Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
private: private:
CppModelManager *m_manager; CppModelManager *m_manager;
......
...@@ -152,7 +152,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter() ...@@ -152,7 +152,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor(searchText)); ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor(searchText));
// ResultData::printFilterEntries(results); // ResultData::printFilterEntries(results);
QVERIFY(!results.isEmpty()); QVERIFY(!results.isEmpty());
QCOMPARE(expectedResults, results); QCOMPARE(results, expectedResults);
} }
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data() void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
......
...@@ -42,9 +42,8 @@ SearchSymbols::SymbolTypes SearchSymbols::AllTypes = ...@@ -42,9 +42,8 @@ SearchSymbols::SymbolTypes SearchSymbols::AllTypes =
| SymbolSearcher::Enums | SymbolSearcher::Enums
| SymbolSearcher::Declarations; | SymbolSearcher::Declarations;
SearchSymbols::SearchSymbols(): SearchSymbols::SearchSymbols() :
symbolsToSearchFor(SymbolSearcher::Classes | SymbolSearcher::Functions | SymbolSearcher::Enums), symbolsToSearchFor(SymbolSearcher::Classes | SymbolSearcher::Functions | SymbolSearcher::Enums)
separateScope(false)
{ {
} }
...@@ -53,11 +52,6 @@ void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types) ...@@ -53,11 +52,6 @@ void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types)
symbolsToSearchFor = types; symbolsToSearchFor = types;
} }
void SearchSymbols::setSeparateScope(bool separateScope)
{
this->separateScope = separateScope;
}
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, int sizeHint, const QString &scope) QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, int sizeHint, const QString &scope)
{ {
QString previousScope = switchScope(scope); QString previousScope = switchScope(scope);
...@@ -89,9 +83,7 @@ bool SearchSymbols::visit(Enum *symbol) ...@@ -89,9 +83,7 @@ bool SearchSymbols::visit(Enum *symbol)
QString name = symbolName(symbol); QString name = symbolName(symbol);
QString scopedName = scopedSymbolName(name); QString scopedName = scopedSymbolName(name);
QString previousScope = switchScope(scopedName); QString previousScope = switchScope(scopedName);
appendItem(separateScope ? name : scopedName, appendItem(name, QString(), previousScope, ModelItemInfo::Enum, symbol);
separateScope ? previousScope : QString(),
ModelItemInfo::Enum, symbol);
for (unsigned i = 0; i < symbol->memberCount(); ++i) { for (unsigned i = 0; i < symbol->memberCount(); ++i) {
accept(symbol->memberAt(i)); accept(symbol->memberAt(i));
} }
...@@ -116,12 +108,8 @@ bool SearchSymbols::visit(Function *symbol) ...@@ -116,12 +108,8 @@ bool SearchSymbols::visit(Function *symbol)
fullScope += QLatin1String("::"); fullScope += QLatin1String("::");
fullScope += extraScope; fullScope += extraScope;
QString name = symbolName(symbol); QString name = symbolName(symbol);
QString scopedName = scopedSymbolName(name); QString type = overview.prettyType(symbol->type());
QString type = overview.prettyType(symbol->type(), appendItem(name, type, fullScope, ModelItemInfo::Method, symbol);
separateScope ? symbol->unqualifiedName() : 0);
appendItem(separateScope ? type : scopedName,
separateScope ? fullScope : type,
ModelItemInfo::Method, symbol);
return false; return false;
} }
...@@ -152,11 +140,8 @@ bool SearchSymbols::visit(Declaration *symbol) ...@@ -152,11 +140,8 @@ bool SearchSymbols::visit(Declaration *symbol)
} }
QString name = symbolName(symbol); QString name = symbolName(symbol);
QString scopedName = scopedSymbolName(name); QString type = overview.prettyType(symbol->type());
QString type = overview.prettyType(symbol->type(), appendItem(name, type, _scope,
separateScope ? symbol->unqualifiedName() : 0);
appendItem(separateScope ? type : scopedName,
separateScope ? _scope : type,
symbol->type()->asFunctionType() ? ModelItemInfo::Method symbol->type()->asFunctionType() ? ModelItemInfo::Method
: ModelItemInfo::Declaration, : ModelItemInfo::Declaration,
symbol); symbol);
...@@ -169,9 +154,7 @@ bool SearchSymbols::visit(Class *symbol) ...@@ -169,9 +154,7 @@ bool SearchSymbols::visit(Class *symbol)
QString scopedName = scopedSymbolName(name); QString scopedName = scopedSymbolName(name);
QString previousScope = switchScope(scopedName); QString previousScope = switchScope(scopedName);
if (symbolsToSearchFor & SymbolSearcher::Classes) { if (symbolsToSearchFor & SymbolSearcher::Classes) {
appendItem(separateScope ? name : scopedName, appendItem(name, QString(), previousScope, ModelItemInfo::Class, symbol);
separateScope ? previousScope : QString(),
ModelItemInfo::Class, symbol);
} }
for (unsigned i = 0; i < symbol->memberCount(); ++i) { for (unsigned i = 0; i < symbol->memberCount(); ++i) {
accept(symbol->memberAt(i)); accept(symbol->memberAt(i));
...@@ -305,18 +288,13 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const ...@@ -305,18 +288,13 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
return symbolName; return symbolName;
} }
void SearchSymbols::appendItem(const QString &name, void SearchSymbols::appendItem(const QString &symbolName, const QString &symbolType,
const QString &info, const QString &symbolScope, ModelItemInfo::ItemType itemType,
ModelItemInfo::ItemType type,
Symbol *symbol) Symbol *symbol)
{ {
if (!symbol->name()) if (!symbol->name())
return; return;
QStringList fullyQualifiedName;
foreach (const Name *name, LookupContext::fullyQualifiedName(symbol))
fullyQualifiedName.append(findOrInsert(overview.prettyName(name)));
QString path = m_paths.value(symbol->fileId(), QString()); QString path = m_paths.value(symbol->fileId(), QString());
if (path.isEmpty()) { if (path.isEmpty()) {
path = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()); path = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
...@@ -324,8 +302,10 @@ void SearchSymbols::appendItem(const QString &name, ...@@ -324,8 +302,10 @@ void SearchSymbols::appendItem(const QString &name,
} }
const QIcon icon = icons.iconForSymbol(symbol); const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(findOrInsert(name), findOrInsert(info), type, items.append(ModelItemInfo(findOrInsert(symbolName),
fullyQualifiedName, findOrInsert(symbolType),
findOrInsert(symbolScope),
itemType,
path, path,
symbol->line(), symbol->line(),
symbol->column() - 1, // 1-based vs 0-based column symbol->column() - 1, // 1-based vs 0-based column
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <cplusplus/Icons.h> #include <cplusplus/Icons.h>
#include <cplusplus/Overview.h> #include <cplusplus/Overview.h>
#include <utils/fileutils.h>
#include <QIcon> #include <QIcon>
#include <QString> #include <QString>
#include <QSet> #include <QSet>
...@@ -58,15 +60,15 @@ struct CPPTOOLS_EXPORT ModelItemInfo ...@@ -58,15 +60,15 @@ struct CPPTOOLS_EXPORT ModelItemInfo
ModelItemInfo(const QString &symbolName, ModelItemInfo(const QString &symbolName,
const QString &symbolType, const QString &symbolType,
const QString &symbolScope,
ItemType type, ItemType type,
QStringList fullyQualifiedName,
const QString &fileName, const QString &fileName,
int line, int line,
int column, int column,
const QIcon &icon) const QIcon &icon)
: symbolName(symbolName), : symbolName(symbolName),
symbolType(symbolType), symbolType(symbolType),
fullyQualifiedName(fullyQualifiedName), symbolScope(symbolScope),
fileName(fileName), fileName(fileName),
icon(icon), icon(icon),
type(type), type(type),
...@@ -77,17 +79,42 @@ struct CPPTOOLS_EXPORT ModelItemInfo ...@@ -77,17 +79,42 @@ struct CPPTOOLS_EXPORT ModelItemInfo
ModelItemInfo(const ModelItemInfo &otherInfo) ModelItemInfo(const ModelItemInfo &otherInfo)
: symbolName(otherInfo.symbolName), : symbolName(otherInfo.symbolName),
symbolType(otherInfo.symbolType), symbolType(otherInfo.symbolType),
fullyQualifiedName(otherInfo.fullyQualifiedName), symbolScope(otherInfo.symbolScope),
fileName(otherInfo.fileName), fileName(otherInfo.fileName),
icon(otherInfo.icon), icon(otherInfo.icon),
type(otherInfo.type), type(otherInfo.type),
line(otherInfo.line), line(otherInfo.line),
column(otherInfo.column) column(otherInfo.column)
{ } { }
QString scopedSymbolName() const
{
return symbolScope.isEmpty()
? symbolName
: symbolScope + QLatin1String("::") + symbolName;
}
QString typeNameRepresentation() const
{
if (type == ModelItemInfo::Declaration) {
if (!symbolType.isEmpty()) {
const QString padding = symbolType.endsWith(QLatin1Char('*'))
? QString()
: QString(QLatin1Char(' '));
return symbolType + padding + symbolName;
}
} else if (type == ModelItemInfo::Method) {
return symbolName + symbolType;
}
return QString();
}
QString shortNativeFilePath() const
{ return Utils::FileUtils::shortNativePath(Utils::FileName::fromString(fileName)); }
QString symbolName; QString symbolName;
QString symbolType; QString symbolType;
QStringList fullyQualifiedName; QString symbolScope;
QString fileName; QString fileName;
QIcon icon; QIcon icon;
ItemType type; ItemType type;
...@@ -106,7 +133,6 @@ public: ...@@ -106,7 +133,6 @@ public:
SearchSymbols(); SearchSymbols();
void setSymbolsToSearchFor(SymbolTypes types); void setSymbolsToSearchFor(SymbolTypes types);
void setSeparateScope(bool separateScope);
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc, int sizeHint = 500) QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc, int sizeHint = 500)
{ return operator()(doc, sizeHint, QString()); } { return operator()(doc, sizeHint, QString()); }
...@@ -149,8 +175,9 @@ protected: ...@@ -149,8 +175,9 @@ protected:
QString scopedSymbolName(const QString &symbolName) const; QString scopedSymbolName(const QString &symbolName) const;
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const; QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
QString symbolName(const CPlusPlus::Symbol *symbol) const; QString symbolName(const CPlusPlus::Symbol *symbol) const;
void appendItem(const QString &name, void appendItem(const QString &symbolName,
const QString &info, const QString &symbolType,
const QString &symbolScope,
ModelItemInfo::ItemType type, ModelItemInfo::ItemType type,
CPlusPlus::Symbol *symbol); CPlusPlus::Symbol *symbol);
...@@ -166,7 +193,6 @@ private: ...@@ -166,7 +193,6 @@ private:
QList<ModelItemInfo> items; QList<ModelItemInfo> items;
SymbolTypes symbolsToSearchFor; SymbolTypes symbolsToSearchFor;
QHash<const CPlusPlus::StringLiteral *, QString> m_paths; QHash<const CPlusPlus::StringLiteral *, QString> m_paths;
bool separateScope;
}; };
} // namespace CppTools } // namespace CppTools
......
...@@ -143,6 +143,18 @@ inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size( ...@@ -143,6 +143,18 @@ inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size(
Q_DECLARE_METATYPE(ResultData) Q_DECLARE_METATYPE(ResultData)
Q_DECLARE_METATYPE(ResultDataList) Q_DECLARE_METATYPE(ResultDataList)
QT_BEGIN_NAMESPACE
namespace QTest {
template<> char *toString(const ResultData &data)
{
QByteArray ba = "\"" + data.m_symbolName.toUtf8() + "\", \"" + data.m_scope.toUtf8() + "\"";
return qstrdup(ba.data());
}
} // namespace QTest
QT_END_NAMESPACE
void CppToolsPlugin::test_builtinsymbolsearcher() void CppToolsPlugin::test_builtinsymbolsearcher()
{ {
QFETCH(QString, testFile); QFETCH(QString, testFile);
...@@ -182,8 +194,8 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data() ...@@ -182,8 +194,8 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("int myVariable"), _("")) << ResultData(_("int myVariable"), _(""))
<< ResultData(_("myFunction(bool, int)"), _("")) << ResultData(_("myFunction(bool, int)"), _(""))
<< ResultData(_("MyEnum"), _("")) << ResultData(_("MyEnum"), _(""))
<< ResultData(_("int V1"), _("")) << ResultData(_("int V1"), _("MyEnum"))
<< ResultData(_("int V2"), _("")) << ResultData(_("int V2"), _("MyEnum"))
<< ResultData(_("MyClass"), _("")) << ResultData(_("MyClass"), _(""))
<< ResultData(_("MyClass()"), _("MyClass")) << ResultData(_("MyClass()"), _("MyClass"))
<< ResultData(_("function1()"), _("MyClass")) << ResultData(_("function1()"), _("MyClass"))
...@@ -191,21 +203,21 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data() ...@@ -191,21 +203,21 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("int myVariable"), _("MyNamespace")) << ResultData(_("int myVariable"), _("MyNamespace"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace")) << ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("MyEnum"), _("MyNamespace")) << ResultData(_("MyEnum"), _("MyNamespace"))
<< ResultData(_("int V1"), _("MyNamespace")) << ResultData(_("int V1"), _("MyNamespace::MyEnum"))
<< ResultData(_("int V2"), _("MyNamespace")) << ResultData(_("int V2"), _("MyNamespace::MyEnum"))
<< ResultData(_("MyClass"), _("MyNamespace")) << ResultData(_("MyClass"), _("MyNamespace"))
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass")) << ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
<< ResultData(_("function1()"), _("MyNamespace::MyClass")) << ResultData(_("function1()"), _("MyNamespace::MyClass"))
<< ResultData(_("function2(bool, int)"), _("MyNamespace::MyClass")) << ResultData(_("function2(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("int myVariable"), _("")) << ResultData(_("int myVariable"), _("<anonymous namespace>"))
<< ResultData(_("myFunction(bool, int)"), _("")) << ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("MyEnum"), _("")) << ResultData(_("MyEnum"), _("<anonymous namespace>"))
<< ResultData(_("int V1"), _("")) << ResultData(_("int V1"), _("<anonymous namespace>::MyEnum"))
<< ResultData(_("int V2"), _("")) << ResultData(_("int V2"), _("<anonymous namespace>::MyEnum"))
<< ResultData(_("MyClass"), _("")) << ResultData(_("MyClass"), _("<anonymous namespace>"))
<< ResultData(_("MyClass()"), _("MyClass")) << ResultData(_("MyClass()"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("function1()"), _("MyClass")) << ResultData(_("function1()"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("function2(bool, int)"), _("MyClass")) << ResultData(_("function2(bool, int)"), _("<anonymous namespace>::MyClass"))
); );
// Check Classes // Check Classes
...@@ -220,7 +232,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data() ...@@ -220,7 +232,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< (ResultDataList() << (ResultDataList()
<< ResultData(_("MyClass"), _("")) << ResultData(_("MyClass"), _(""))
<< ResultData(_("MyClass"), _("MyNamespace")) << ResultData(_("MyClass"), _("MyNamespace"))
<< ResultData(_("MyClass"), _("")) << ResultData(_("MyClass"), _("<anonymous namespace>"))
); );
// Check Functions // Check Functions
...@@ -237,8 +249,8 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data() ...@@ -237,8 +249,8 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("function2(bool, int)"), _("MyClass")) << ResultData(_("function2(bool, int)"), _("MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace")) << ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("function2(bool, int)"), _("MyNamespace::MyClass")) << ResultData(_("function2(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("")) << ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("function2(bool, int)"), _("MyClass")) << ResultData(_("function2(bool, int)"), _("<anonymous namespace>::MyClass"))
); );
// Check Enums // Check Enums
...@@ -253,7 +265,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data() ...@@ -253,7 +265,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< (ResultDataList() << (ResultDataList()
<< ResultData(_("MyEnum"), _("")) << ResultData(_("MyEnum"), _(""))
<< ResultData(_("MyEnum"), _("MyNamespace")) << ResultData(_("MyEnum"), _("MyNamespace"))
<< ResultData(_("MyEnum"), _("")) << ResultData(_("MyEnum"), _("<anonymous namespace>"))
); );
// Check Declarations // Check Declarations
...@@ -268,6 +280,6 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data() ...@@ -268,6 +280,6 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< (ResultDataList() << (ResultDataList()
<< ResultData(_("int myVariable"), _("")) << ResultData(_("int myVariable"), _(""))
<< ResultData(_("int myVariable"), _("MyNamespace")) << ResultData(_("int myVariable"), _("MyNamespace"))
<< ResultData(_("int myVariable"), _("")) << ResultData(_("int myVariable"), _("<anonymous namespace>"))
); );
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment