forked from qt-creator/qt-creator
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 <christian.stenger@digia.com>
This commit is contained in:
@@ -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,9 +1985,12 @@ 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;
|
||||||
|
QFutureInterface<Core::LocatorFilterEntry> dummyInterface;
|
||||||
|
if (CppClassesFilter *classesFilter
|
||||||
|
= ExtensionSystem::PluginManager::getObject<CppClassesFilter>()) {
|
||||||
|
const QList<Core::LocatorFilterEntry> matches
|
||||||
|
= classesFilter->matchesFor(dummyInterface, className);
|
||||||
foreach (const Core::LocatorFilterEntry &entry, matches) {
|
foreach (const Core::LocatorFilterEntry &entry, matches) {
|
||||||
IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>();
|
IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>();
|
||||||
if (info->symbolName() != className)
|
if (info->symbolName() != className)
|
||||||
@@ -2004,6 +2003,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
|
|||||||
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>".
|
||||||
if (className.size() > 2 && className.at(0) == QLatin1Char('Q') && className.at(1).isUpper()) {
|
if (className.size() > 2 && className.at(0) == QLatin1Char('Q') && className.at(1).isUpper()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user