forked from qt-creator/qt-creator
Locator: Enable to show C++ type aliases
These were not showing up in any global symbol list so far. Fixes: QTCREATORBUG-5800 Change-Id: I8e5c3b9b26f09d8cbcd31431e28c103da05d9bf8 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -47,7 +47,8 @@ public:
|
||||
Classes = 0x1,
|
||||
Functions = 0x2,
|
||||
Enums = 0x4,
|
||||
Declarations = 0x8
|
||||
Declarations = 0x8,
|
||||
TypeAliases = 0x16,
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(SymbolTypes, SymbolType)
|
||||
|
@@ -35,7 +35,8 @@ CppLocatorData::CppLocatorData()
|
||||
{
|
||||
m_search.setSymbolsToSearchFor(SymbolSearcher::Enums |
|
||||
SymbolSearcher::Classes |
|
||||
SymbolSearcher::Functions);
|
||||
SymbolSearcher::Functions |
|
||||
SymbolSearcher::TypeAliases);
|
||||
m_pendingDocuments.reserve(MaxPendingDocuments);
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ const char INCLUDES_FILTER_ID[] = "All Included C/C++ Files";
|
||||
const char INCLUDES_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "All Included C/C++ Files");
|
||||
|
||||
const char LOCATOR_FILTER_ID[] = "Classes and Methods";
|
||||
const char LOCATOR_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "C++ Classes, Enums and Functions");
|
||||
const char LOCATOR_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "C++ Classes, Enums, Functions and Type Aliases");
|
||||
|
||||
const char SYMBOLS_FIND_FILTER_ID[] = "Symbols";
|
||||
const char SYMBOLS_FIND_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "C++ Symbols");
|
||||
|
@@ -121,8 +121,10 @@ bool SearchSymbols::visit(Namespace *symbol)
|
||||
bool SearchSymbols::visit(Declaration *symbol)
|
||||
{
|
||||
if (!(symbolsToSearchFor & SymbolSearcher::Declarations)) {
|
||||
// if we're searching for functions, still allow signal declarations to show up.
|
||||
if (symbolsToSearchFor & SymbolSearcher::Functions) {
|
||||
if ((symbolsToSearchFor & SymbolSearcher::TypeAliases) && symbol->type().isTypedef()) {
|
||||
// Continue.
|
||||
} else if (symbolsToSearchFor & SymbolSearcher::Functions) {
|
||||
// if we're searching for functions, still allow signal declarations to show up.
|
||||
Function *funTy = symbol->type()->asFunctionType();
|
||||
if (!funTy) {
|
||||
if (!symbol->type()->asObjCMethodType())
|
||||
|
@@ -197,6 +197,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
||||
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
|
||||
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
|
||||
_("MyNamespace::MyClass"))
|
||||
<< ResultData(_("MyNamespace::MyClass MY_CLASS"), _(""))
|
||||
<< ResultData(_("int myVariable"), _("<anonymous namespace>"))
|
||||
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
|
||||
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
|
||||
@@ -211,6 +212,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
||||
_("<anonymous namespace>::MyClass"))
|
||||
<< ResultData(_("functionDefinedOutSideClass(char)"),
|
||||
_("<anonymous namespace>::MyClass"))
|
||||
<< ResultData(_("MyClass MY_OTHER_CLASS"), _(""))
|
||||
<< ResultData(_("main()"), _(""))
|
||||
|
||||
);
|
||||
|
@@ -52,6 +52,7 @@ int MyClass::functionDefinedOutSideClass(char c) {}
|
||||
} // namespace MyNamespace
|
||||
|
||||
int MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace(float x) {}
|
||||
using MY_CLASS = MyNamespace::MyClass;
|
||||
|
||||
//
|
||||
// Symbols in an anonymous namespace
|
||||
@@ -78,5 +79,6 @@ int MyClass::functionDefinedOutSideClass(char c) {}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
typedef MyClass MY_OTHER_CLASS;
|
||||
|
||||
int main() {}
|
||||
|
Reference in New Issue
Block a user