Commit eefcd23c authored by Nikolai Kosjar's avatar Nikolai Kosjar

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: default avatarChristian Stenger <christian.stenger@digia.com>
parent 2db588f8
...@@ -1970,10 +1970,6 @@ QString unqualifiedNameForLocator(const Name *name) ...@@ -1970,10 +1970,6 @@ QString unqualifiedNameForLocator(const Name *name)
void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interface, void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interface,
QuickFixOperations &result) QuickFixOperations &result)
{ {
CppClassesFilter *classesFilter = ExtensionSystem::PluginManager::getObject<CppClassesFilter>();
if (!classesFilter)
return;
const NameAST *nameAst = nameUnderCursor(interface.path()); const NameAST *nameAst = nameUnderCursor(interface.path());
if (!nameAst) if (!nameAst)
return; return;
...@@ -1989,20 +1985,24 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa ...@@ -1989,20 +1985,24 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
const ProjectPart::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath); const ProjectPart::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
// Find an include file through the locator // Find an include file through the locator
QFutureInterface<Core::LocatorFilterEntry> dummyInterface;
QList<Core::LocatorFilterEntry> matches = classesFilter->matchesFor(dummyInterface, className);
bool classFoundInLocator = false; bool classFoundInLocator = false;
foreach (const Core::LocatorFilterEntry &entry, matches) { QFutureInterface<Core::LocatorFilterEntry> dummyInterface;
IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>(); if (CppClassesFilter *classesFilter
if (info->symbolName() != className) = ExtensionSystem::PluginManager::getObject<CppClassesFilter>()) {
continue; const QList<Core::LocatorFilterEntry> matches
classFoundInLocator = true; = classesFilter->matchesFor(dummyInterface, className);
foreach (const Core::LocatorFilterEntry &entry, matches) {
IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>();
if (info->symbolName() != className)
continue;
classFoundInLocator = true;
// Find the shortest way to include fileName given the includePaths // Find the shortest way to include fileName given the includePaths
const QString include = findShortestInclude(currentDocumentFilePath, info->fileName(), const QString include = findShortestInclude(currentDocumentFilePath, info->fileName(),
headerPaths); headerPaths);
if (!include.isEmpty()) if (!include.isEmpty())
result.append(new AddIncludeForUndefinedIdentifierOp(interface, 0, include)); result.append(new AddIncludeForUndefinedIdentifierOp(interface, 0, include));
}
} }
// If e.g. QString was found in "<qstring.h>" propose an extra prioritized entry "<QString>". // If e.g. QString was found in "<qstring.h>" propose an extra prioritized entry "<QString>".
......
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