From eefcd23cee45d0c555e7db4988b58210e17c4c80 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Tue, 7 Oct 2014 15:29:10 +0200 Subject: [PATCH] CppEditor: Offer refactoring action without CppClassesFilter ...in AddIncludeForUndefinedIdentifier. Even without this locator filter we can offer an refactoring action. See findIncludeForQtClass(). Change-Id: Ic616b82b0af9d59984da882e08f6ede714e85a86 Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppquickfixes.cpp | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 829045f83a..f492362871 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -1970,10 +1970,6 @@ QString unqualifiedNameForLocator(const Name *name) void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interface, QuickFixOperations &result) { - CppClassesFilter *classesFilter = ExtensionSystem::PluginManager::getObject(); - if (!classesFilter) - return; - const NameAST *nameAst = nameUnderCursor(interface.path()); if (!nameAst) return; @@ -1989,20 +1985,24 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa const ProjectPart::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath); // Find an include file through the locator - QFutureInterface dummyInterface; - QList matches = classesFilter->matchesFor(dummyInterface, className); bool classFoundInLocator = false; - foreach (const Core::LocatorFilterEntry &entry, matches) { - IndexItem::Ptr info = entry.internalData.value(); - if (info->symbolName() != className) - continue; - classFoundInLocator = true; + QFutureInterface dummyInterface; + if (CppClassesFilter *classesFilter + = ExtensionSystem::PluginManager::getObject()) { + const QList matches + = classesFilter->matchesFor(dummyInterface, className); + foreach (const Core::LocatorFilterEntry &entry, matches) { + IndexItem::Ptr info = entry.internalData.value(); + if (info->symbolName() != className) + continue; + classFoundInLocator = true; - // Find the shortest way to include fileName given the includePaths - const QString include = findShortestInclude(currentDocumentFilePath, info->fileName(), - headerPaths); - if (!include.isEmpty()) - result.append(new AddIncludeForUndefinedIdentifierOp(interface, 0, include)); + // Find the shortest way to include fileName given the includePaths + const QString include = findShortestInclude(currentDocumentFilePath, info->fileName(), + headerPaths); + if (!include.isEmpty()) + result.append(new AddIncludeForUndefinedIdentifierOp(interface, 0, include)); + } } // If e.g. QString was found in "" propose an extra prioritized entry "". -- GitLab