forked from qt-creator/qt-creator
CppTools: Fix qualified ids in the symbol searcher
The leaves in the treeview contained qualified ids. Change-Id: I290eaf9b1e666b6879d6d4b1f2483cfe7fb85362 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -119,13 +119,19 @@ 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) {
|
||||||
QString text = info.typeNameRepresentation();
|
QString text = info.symbolName;
|
||||||
if (text.isEmpty())
|
QString scope = info.symbolScope;
|
||||||
text = info.symbolName;
|
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;
|
Find::SearchResultItem item;
|
||||||
item.path = info.symbolScope.split(QLatin1String("::"),
|
item.path = scope.split(QLatin1String("::"), QString::SkipEmptyParts);
|
||||||
QString::SkipEmptyParts);
|
|
||||||
item.text = text;
|
item.text = text;
|
||||||
item.textMarkPos = -1;
|
item.textMarkPos = -1;
|
||||||
item.textMarkLength = 0;
|
item.textMarkLength = 0;
|
||||||
|
|||||||
@@ -86,9 +86,11 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
|
|||||||
if (future.isCanceled())
|
if (future.isCanceled())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
QString matchString = info.typeNameRepresentation();
|
QString matchString = info.symbolName;
|
||||||
if (matchString.isEmpty())
|
if (info.type == ModelItemInfo::Declaration)
|
||||||
matchString = info.symbolName;
|
matchString = ModelItemInfo::representDeclaration(info.symbolName, info.symbolType);
|
||||||
|
else if (info.type == ModelItemInfo::Method)
|
||||||
|
matchString += info.symbolType;
|
||||||
|
|
||||||
if ((hasWildcard && regexp.exactMatch(matchString))
|
if ((hasWildcard && regexp.exactMatch(matchString))
|
||||||
|| (!hasWildcard && matcher.indexIn(matchString) != -1))
|
|| (!hasWildcard && matcher.indexIn(matchString) != -1))
|
||||||
|
|||||||
@@ -64,4 +64,3 @@ Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppT
|
|||||||
|
|
||||||
return filterEntry;
|
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 (type.isEmpty())
|
||||||
if (!symbolType.isEmpty()) {
|
return QString();
|
||||||
const QString padding = symbolType.endsWith(QLatin1Char('*'))
|
|
||||||
? QString()
|
const QString padding = type.endsWith(QLatin1Char('*'))
|
||||||
: QString(QLatin1Char(' '));
|
? QString()
|
||||||
return symbolType + padding + symbolName;
|
: QString(QLatin1Char(' '));
|
||||||
}
|
return type + padding + name;
|
||||||
} else if (type == ModelItemInfo::Method) {
|
|
||||||
return symbolName + symbolType;
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString shortNativeFilePath() const
|
QString shortNativeFilePath() const
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ public:
|
|||||||
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
|
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
|
||||||
search.waitForFinished();
|
search.waitForFinished();
|
||||||
ResultDataList results = ResultData::fromSearchResultList(search.results());
|
ResultDataList results = ResultData::fromSearchResultList(search.results());
|
||||||
// ResultData::printFilterEntries(results);
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,8 +197,10 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
|||||||
<< ResultData(_("int V2"), _("MyEnum"))
|
<< ResultData(_("int V2"), _("MyEnum"))
|
||||||
<< ResultData(_("MyClass"), _(""))
|
<< ResultData(_("MyClass"), _(""))
|
||||||
<< ResultData(_("MyClass()"), _("MyClass"))
|
<< ResultData(_("MyClass()"), _("MyClass"))
|
||||||
<< ResultData(_("function1()"), _("MyClass"))
|
<< ResultData(_("functionDeclaredOnly()"), _("MyClass"))
|
||||||
<< ResultData(_("function2(bool, int)"), _("MyClass"))
|
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
|
||||||
|
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
|
||||||
|
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
|
||||||
<< ResultData(_("int myVariable"), _("MyNamespace"))
|
<< ResultData(_("int myVariable"), _("MyNamespace"))
|
||||||
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
|
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
|
||||||
<< ResultData(_("MyEnum"), _("MyNamespace"))
|
<< ResultData(_("MyEnum"), _("MyNamespace"))
|
||||||
@@ -207,8 +208,12 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
|||||||
<< ResultData(_("int V2"), _("MyNamespace::MyEnum"))
|
<< ResultData(_("int V2"), _("MyNamespace::MyEnum"))
|
||||||
<< ResultData(_("MyClass"), _("MyNamespace"))
|
<< ResultData(_("MyClass"), _("MyNamespace"))
|
||||||
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
|
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
|
||||||
<< ResultData(_("function1()"), _("MyNamespace::MyClass"))
|
<< ResultData(_("functionDeclaredOnly()"), _("MyNamespace::MyClass"))
|
||||||
<< ResultData(_("function2(bool, int)"), _("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(_("int myVariable"), _("<anonymous namespace>"))
|
||||||
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
|
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
|
||||||
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
|
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
|
||||||
@@ -216,8 +221,12 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
|||||||
<< ResultData(_("int V2"), _("<anonymous namespace>::MyEnum"))
|
<< ResultData(_("int V2"), _("<anonymous namespace>::MyEnum"))
|
||||||
<< ResultData(_("MyClass"), _("<anonymous namespace>"))
|
<< ResultData(_("MyClass"), _("<anonymous namespace>"))
|
||||||
<< ResultData(_("MyClass()"), _("<anonymous namespace>::MyClass"))
|
<< ResultData(_("MyClass()"), _("<anonymous namespace>::MyClass"))
|
||||||
<< ResultData(_("function1()"), _("<anonymous namespace>::MyClass"))
|
<< ResultData(_("functionDeclaredOnly()"), _("<anonymous namespace>::MyClass"))
|
||||||
<< ResultData(_("function2(bool, int)"), _("<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
|
// Check Classes
|
||||||
@@ -246,11 +255,15 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
|||||||
<< searchParameters
|
<< searchParameters
|
||||||
<< (ResultDataList()
|
<< (ResultDataList()
|
||||||
<< ResultData(_("myFunction(bool, int)"), _(""))
|
<< ResultData(_("myFunction(bool, int)"), _(""))
|
||||||
<< ResultData(_("function2(bool, int)"), _("MyClass"))
|
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
|
||||||
|
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
|
||||||
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
|
<< 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(_("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
|
// Check Enums
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
// Copyright header
|
// Copyright header
|
||||||
|
|
||||||
|
#define GENERATE_FUNC void myFunctionGenerated() {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Symbols in a global namespace
|
// Symbols in a global namespace
|
||||||
//
|
//
|
||||||
|
|
||||||
|
GENERATE_FUNC
|
||||||
|
|
||||||
int myVariable;
|
int myVariable;
|
||||||
|
|
||||||
int myFunction(bool yesno, int number) {}
|
int myFunction(bool yesno, int number) {}
|
||||||
@@ -14,10 +18,13 @@ class MyClass
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyClass() {}
|
MyClass() {}
|
||||||
int function1();
|
int functionDeclaredOnly();
|
||||||
int function2(bool yesno, int number) {}
|
int functionDefinedInClass(bool yesno, int number) {}
|
||||||
|
int functionDefinedOutSideClass(char c);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int MyClass::functionDefinedOutSideClass(char c) {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Symbols in a named namespace
|
// Symbols in a named namespace
|
||||||
//
|
//
|
||||||
@@ -34,12 +41,18 @@ class MyClass
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyClass() {}
|
MyClass() {}
|
||||||
int function1();
|
int functionDeclaredOnly();
|
||||||
int function2(bool yesno, int number) {}
|
int functionDefinedInClass(bool yesno, int number) {}
|
||||||
|
int functionDefinedOutSideClass(char c);
|
||||||
|
int functionDefinedOutSideClassAndNamespace(float x);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int MyClass::functionDefinedOutSideClass(char c) {}
|
||||||
|
|
||||||
} // namespace MyNamespace
|
} // namespace MyNamespace
|
||||||
|
|
||||||
|
int MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace(float x) {}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Symbols in an anonymous namespace
|
// Symbols in an anonymous namespace
|
||||||
//
|
//
|
||||||
@@ -56,8 +69,14 @@ class MyClass
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyClass() {}
|
MyClass() {}
|
||||||
int function1();
|
int functionDeclaredOnly();
|
||||||
int function2(bool yesno, int number) {}
|
int functionDefinedInClass(bool yesno, int number) {}
|
||||||
|
int functionDefinedOutSideClass(char c);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int MyClass::functionDefinedOutSideClass(char c) {}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
|
int main() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user