Commit 190fb448 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Fix qualified ids in the symbol searcher

The leaves in the treeview contained qualified ids.

Change-Id: I290eaf9b1e666b6879d6d4b1f2483cfe7fb85362
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 75b0429e
......@@ -119,13 +119,19 @@ public:
foreach (const ModelItemInfo &info, modelInfos) {
int index = matcher.indexIn(info.symbolName);
if (index != -1) {
QString text = info.typeNameRepresentation();
if (text.isEmpty())
text = info.symbolName;
QString text = info.symbolName;
QString scope = info.symbolScope;
if (info.type == ModelItemInfo::Method) {
QString name;
info.unqualifiedNameAndScope(info.symbolName, &name, &scope);
text = name + info.symbolType;
} else if (info.type == ModelItemInfo::Declaration){
text = ModelItemInfo::representDeclaration(info.symbolName,
info.symbolType);
}
Find::SearchResultItem item;
item.path = info.symbolScope.split(QLatin1String("::"),
QString::SkipEmptyParts);
item.path = scope.split(QLatin1String("::"), QString::SkipEmptyParts);
item.text = text;
item.textMarkPos = -1;
item.textMarkLength = 0;
......
......@@ -86,9 +86,11 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
if (future.isCanceled())
break;
QString matchString = info.typeNameRepresentation();
if (matchString.isEmpty())
matchString = info.symbolName;
QString matchString = info.symbolName;
if (info.type == ModelItemInfo::Declaration)
matchString = ModelItemInfo::representDeclaration(info.symbolName, info.symbolType);
else if (info.type == ModelItemInfo::Method)
matchString += info.symbolType;
if ((hasWildcard && regexp.exactMatch(matchString))
|| (!hasWildcard && matcher.indexIn(matchString) != -1))
......
......@@ -64,4 +64,3 @@ Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppT
return filterEntry;
}
......@@ -106,19 +106,15 @@ struct CPPTOOLS_EXPORT ModelItemInfo
}
}
QString typeNameRepresentation() const
static QString representDeclaration(const QString &name, const QString &type)
{
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();
if (type.isEmpty())
return QString();
const QString padding = type.endsWith(QLatin1Char('*'))
? QString()
: QString(QLatin1Char(' '));
return type + padding + name;
}
QString shortNativeFilePath() const
......
......@@ -118,7 +118,6 @@ public:
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
search.waitForFinished();
ResultDataList results = ResultData::fromSearchResultList(search.results());
// ResultData::printFilterEntries(results);
return results;
}
......@@ -198,8 +197,10 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("int V2"), _("MyEnum"))
<< ResultData(_("MyClass"), _(""))
<< ResultData(_("MyClass()"), _("MyClass"))
<< ResultData(_("function1()"), _("MyClass"))
<< ResultData(_("function2(bool, int)"), _("MyClass"))
<< ResultData(_("functionDeclaredOnly()"), _("MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
<< ResultData(_("int myVariable"), _("MyNamespace"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("MyEnum"), _("MyNamespace"))
......@@ -207,8 +208,12 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("int V2"), _("MyNamespace::MyEnum"))
<< ResultData(_("MyClass"), _("MyNamespace"))
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
<< ResultData(_("function1()"), _("MyNamespace::MyClass"))
<< ResultData(_("function2(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDeclaredOnly()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("int myVariable"), _("<anonymous namespace>"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
......@@ -216,8 +221,12 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< ResultData(_("int V2"), _("<anonymous namespace>::MyEnum"))
<< ResultData(_("MyClass"), _("<anonymous namespace>"))
<< ResultData(_("MyClass()"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("function1()"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("function2(bool, int)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDeclaredOnly()"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("main()"), _(""))
);
// Check Classes
......@@ -246,11 +255,15 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
<< searchParameters
<< (ResultDataList()
<< ResultData(_("myFunction(bool, int)"), _(""))
<< ResultData(_("function2(bool, int)"), _("MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("function2(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("function2(bool, int)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
);
// Check Enums
......
// Copyright header
#define GENERATE_FUNC void myFunctionGenerated() {}
//
// Symbols in a global namespace
//
GENERATE_FUNC
int myVariable;
int myFunction(bool yesno, int number) {}
......@@ -14,10 +18,13 @@ class MyClass
{
public:
MyClass() {}
int function1();
int function2(bool yesno, int number) {}
int functionDeclaredOnly();
int functionDefinedInClass(bool yesno, int number) {}
int functionDefinedOutSideClass(char c);
};
int MyClass::functionDefinedOutSideClass(char c) {}
//
// Symbols in a named namespace
//
......@@ -34,12 +41,18 @@ class MyClass
{
public:
MyClass() {}
int function1();
int function2(bool yesno, int number) {}
int functionDeclaredOnly();
int functionDefinedInClass(bool yesno, int number) {}
int functionDefinedOutSideClass(char c);
int functionDefinedOutSideClassAndNamespace(float x);
};
int MyClass::functionDefinedOutSideClass(char c) {}
} // namespace MyNamespace
int MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace(float x) {}
//
// Symbols in an anonymous namespace
//
......@@ -56,8 +69,14 @@ class MyClass
{
public:
MyClass() {}
int function1();
int function2(bool yesno, int number) {}
int functionDeclaredOnly();
int functionDefinedInClass(bool yesno, int number) {}
int functionDefinedOutSideClass(char c);
};
int MyClass::functionDefinedOutSideClass(char c) {}
} // anonymous namespace
int main() {}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment