forked from qt-creator/qt-creator
Core: De-virtualize IContext::contextHelp()
Adapt the using code. Change-Id: I2f46de253d5f00c4bd74b2adea163b7c23145393 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -48,7 +48,6 @@ class CMakeEditor final : public BaseTextEditor
|
||||
{
|
||||
public:
|
||||
CMakeEditor();
|
||||
void contextHelp(const HelpCallback &callback) const final;
|
||||
|
||||
private:
|
||||
CMakeKeywords m_keywords;
|
||||
@@ -58,43 +57,42 @@ CMakeEditor::CMakeEditor()
|
||||
{
|
||||
if (auto tool = CMakeToolManager::defaultProjectOrDefaultCMakeTool())
|
||||
m_keywords = tool->keywords();
|
||||
}
|
||||
|
||||
void CMakeEditor::contextHelp(const HelpCallback &callback) const
|
||||
{
|
||||
auto helpPrefix = [this](const QString &word) {
|
||||
if (m_keywords.includeStandardModules.contains(word))
|
||||
return "module/";
|
||||
if (m_keywords.functions.contains(word))
|
||||
return "command/";
|
||||
if (m_keywords.variables.contains(word))
|
||||
return "variable/";
|
||||
if (m_keywords.directoryProperties.contains(word))
|
||||
return "prop_dir/";
|
||||
if (m_keywords.targetProperties.contains(word))
|
||||
return "prop_tgt/";
|
||||
if (m_keywords.sourceProperties.contains(word))
|
||||
return "prop_sf/";
|
||||
if (m_keywords.testProperties.contains(word))
|
||||
return "prop_test/";
|
||||
if (m_keywords.properties.contains(word))
|
||||
return "prop_gbl/";
|
||||
if (m_keywords.policies.contains(word))
|
||||
return "policy/";
|
||||
if (m_keywords.environmentVariables.contains(word))
|
||||
return "envvar/";
|
||||
setContextHelpProvider([this](const HelpCallback &callback) {
|
||||
auto helpPrefix = [this](const QString &word) {
|
||||
if (m_keywords.includeStandardModules.contains(word))
|
||||
return "module/";
|
||||
if (m_keywords.functions.contains(word))
|
||||
return "command/";
|
||||
if (m_keywords.variables.contains(word))
|
||||
return "variable/";
|
||||
if (m_keywords.directoryProperties.contains(word))
|
||||
return "prop_dir/";
|
||||
if (m_keywords.targetProperties.contains(word))
|
||||
return "prop_tgt/";
|
||||
if (m_keywords.sourceProperties.contains(word))
|
||||
return "prop_sf/";
|
||||
if (m_keywords.testProperties.contains(word))
|
||||
return "prop_test/";
|
||||
if (m_keywords.properties.contains(word))
|
||||
return "prop_gbl/";
|
||||
if (m_keywords.policies.contains(word))
|
||||
return "policy/";
|
||||
if (m_keywords.environmentVariables.contains(word))
|
||||
return "envvar/";
|
||||
|
||||
return "unknown/";
|
||||
};
|
||||
return "unknown/";
|
||||
};
|
||||
|
||||
const QString word = Text::wordUnderCursor(editorWidget()->textCursor());
|
||||
const QString id = helpPrefix(word) + word;
|
||||
if (id.startsWith("unknown/")) {
|
||||
BaseTextEditor::contextHelp(callback);
|
||||
return;
|
||||
}
|
||||
const QString word = Text::wordUnderCursor(editorWidget()->textCursor());
|
||||
const QString id = helpPrefix(word) + word;
|
||||
if (id.startsWith("unknown/")) {
|
||||
BaseTextEditor::contextHelp(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callback({{id, word}, {}, {}, HelpItem::Unknown});
|
||||
callback({{id, word}, {}, {}, HelpItem::Unknown});
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user