forked from qt-creator/qt-creator
ILocatorFilter: Simplify Sync's onSetup in matchers
Remove no longer necessary bool return value from onSetup
functions and from refresh recipe functions,
see df5e3c587a
.
By default, when no return bool is specified inside a function
passed to Sync element, it's assumed that the return value is true.
Eliminate passing "=" captures in 2 lambdas.
Change-Id: I5005821444a386f70c0f05322812f98d3fd49926
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -31,10 +31,7 @@ LocatorMatcherTasks BookmarkFilter::matchers()
|
||||
|
||||
TreeStorage<LocatorStorage> storage;
|
||||
|
||||
const auto onSetup = [=] {
|
||||
storage->reportOutput(match(storage->input()));
|
||||
return true;
|
||||
};
|
||||
const auto onSetup = [=] { storage->reportOutput(match(storage->input())); };
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,6 @@ static LocatorMatcherTasks cmakeMatchers(const CMakeTargetLocatorFilter::BuildAc
|
||||
}
|
||||
}
|
||||
storage->reportOutput(entries);
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
@@ -89,7 +89,6 @@ LocatorMatcherTasks CommandLocator::matchers()
|
||||
}
|
||||
}
|
||||
storage->reportOutput(betterEntries + goodEntries);
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
@@ -71,7 +71,6 @@ LocatorMatcherTasks ExecuteFilter::matchers()
|
||||
}
|
||||
}
|
||||
storage->reportOutput(entries + others);
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
@@ -79,7 +79,6 @@ LocatorMatcherTasks ExternalToolsFilter::matchers()
|
||||
|
||||
storage->reportOutput(bestEntries + betterEntries + goodEntries
|
||||
+ LocatorFilterEntries{configEntry});
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
@@ -33,9 +33,9 @@ LocatorMatcherTasks LocatorFiltersFilter::matchers()
|
||||
|
||||
TreeStorage<LocatorStorage> storage;
|
||||
|
||||
const auto onSetup = [=] {
|
||||
const auto onSetup = [storage, icon = m_icon] {
|
||||
if (!storage->input().isEmpty())
|
||||
return true;
|
||||
return;
|
||||
|
||||
QMap<QString, ILocatorFilter *> uniqueFilters;
|
||||
const QList<ILocatorFilter *> allFilters = Locator::filters();
|
||||
@@ -53,7 +53,7 @@ LocatorMatcherTasks LocatorFiltersFilter::matchers()
|
||||
entry.acceptor = [shortcutString] {
|
||||
return AcceptResult{shortcutString + ' ', int(shortcutString.size() + 1)};
|
||||
};
|
||||
entry.displayIcon = m_icon;
|
||||
entry.displayIcon = icon;
|
||||
entry.extraInfo = filter->displayName();
|
||||
entry.toolTip = filter->description();
|
||||
QString keyboardShortcut;
|
||||
@@ -64,7 +64,6 @@ LocatorMatcherTasks LocatorFiltersFilter::matchers()
|
||||
}
|
||||
}
|
||||
storage->reportOutput(entries);
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ OpenDocumentsFilter::OpenDocumentsFilter()
|
||||
setPriority(High);
|
||||
setDefaultIncludedByDefault(true);
|
||||
// TODO: Remove the refresh recipe
|
||||
setRefreshRecipe(Tasking::Sync([this] { refreshInternally(); return true; }));
|
||||
setRefreshRecipe(Tasking::Sync([this] { refreshInternally(); }));
|
||||
|
||||
connect(DocumentModel::model(), &QAbstractItemModel::dataChanged,
|
||||
this, &OpenDocumentsFilter::slotDataChanged);
|
||||
|
@@ -187,9 +187,7 @@ LocatorMatcherTasks UrlLocatorFilter::matchers()
|
||||
entries.append(entry);
|
||||
}
|
||||
storage->reportOutput(entries);
|
||||
return true;
|
||||
};
|
||||
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ CppIncludesFilter::CppIncludesFilter()
|
||||
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||
setDefaultShortcutString("ai");
|
||||
setDefaultIncludedByDefault(true);
|
||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); return true; }));
|
||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); }));
|
||||
setPriority(ILocatorFilter::Low);
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::fileListChanged,
|
||||
|
@@ -30,7 +30,7 @@ HelpIndexFilter::HelpIndexFilter()
|
||||
setDescription(Tr::tr("Locates help topics, for example in the Qt documentation."));
|
||||
setDefaultIncludedByDefault(false);
|
||||
setDefaultShortcutString("?");
|
||||
setRefreshRecipe(Utils::Tasking::Sync([this] { invalidateCache(); return true; }));
|
||||
setRefreshRecipe(Utils::Tasking::Sync([this] { invalidateCache(); }));
|
||||
|
||||
m_icon = Utils::Icons::BOOKMARK.icon();
|
||||
connect(Core::HelpManager::Signals::instance(), &Core::HelpManager::Signals::setupFinished,
|
||||
|
@@ -70,9 +70,7 @@ LocatorMatcherTasks MacroLocatorFilter::matchers()
|
||||
}
|
||||
}
|
||||
storage->reportOutput(betterEntries + goodEntries);
|
||||
return true;
|
||||
};
|
||||
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ AllProjectsFilter::AllProjectsFilter()
|
||||
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||
setDefaultShortcutString("a");
|
||||
setDefaultIncludedByDefault(true);
|
||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); return true; }));
|
||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); }));
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::fileListChanged,
|
||||
this, &AllProjectsFilter::invalidateCache);
|
||||
|
@@ -25,7 +25,7 @@ CurrentProjectFilter::CurrentProjectFilter()
|
||||
"\"+<number>\" or \":<number>\" to jump to the column number as well."));
|
||||
setDefaultShortcutString("p");
|
||||
setDefaultIncludedByDefault(false);
|
||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); return true; }));
|
||||
setRefreshRecipe(Tasking::Sync([this] { invalidateCache(); }));
|
||||
|
||||
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
||||
this, &CurrentProjectFilter::currentProjectChanged);
|
||||
|
@@ -4421,7 +4421,7 @@ static LocatorMatcherTasks runConfigurationMatchers(
|
||||
const QString input = storage->input();
|
||||
const Target *target = ProjectManager::startupTarget();
|
||||
if (!target)
|
||||
return true;
|
||||
return;
|
||||
|
||||
LocatorFilterEntries entries;
|
||||
for (auto rc : target->runConfigurations()) {
|
||||
@@ -4439,7 +4439,6 @@ static LocatorMatcherTasks runConfigurationMatchers(
|
||||
}
|
||||
}
|
||||
storage->reportOutput(entries);
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ LocatorMatcherTasks LineNumberFilter::matchers()
|
||||
|
||||
TreeStorage<LocatorStorage> storage;
|
||||
|
||||
const auto onSetup = [=] {
|
||||
const auto onSetup = [storage] {
|
||||
const QStringList lineAndColumn = storage->input().split(':');
|
||||
int sectionCount = lineAndColumn.size();
|
||||
int line = 0;
|
||||
@@ -42,7 +42,7 @@ LocatorMatcherTasks LineNumberFilter::matchers()
|
||||
if (ok && sectionCount > 1)
|
||||
column = lineAndColumn.at(1).toInt(&ok);
|
||||
if (!ok)
|
||||
return true;
|
||||
return;
|
||||
if (EditorManager::currentEditor() && (line > 0 || column > 0)) {
|
||||
QString text;
|
||||
if (line > 0 && column > 0)
|
||||
@@ -64,7 +64,6 @@ LocatorMatcherTasks LineNumberFilter::matchers()
|
||||
};
|
||||
storage->reportOutput({entry});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
Reference in New Issue
Block a user