LanguageClient: pass BaseTextEditor to outline generator

Change-Id: Id0e123f5614f3884bf3beaeafefd0ccbd1192d55
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-01-06 09:48:06 +01:00
parent 08e375d6f7
commit 48076ce617
3 changed files with 13 additions and 12 deletions

View File

@@ -274,15 +274,12 @@ private:
const DocumentUri m_uri; const DocumentUri m_uri;
}; };
Utils::TreeViewComboBox *LanguageClientOutlineWidgetFactory::createComboBox(Client *client, Utils::TreeViewComboBox *LanguageClientOutlineWidgetFactory::createComboBox(
Core::IEditor *editor) Client *client, TextEditor::BaseTextEditor *editor)
{ {
auto textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor); if (client && client->supportsDocumentSymbols(editor->textDocument()))
QTC_ASSERT(textEditor, return nullptr); return new OutlineComboBox(client, editor);
if (!client || !client->supportsDocumentSymbols(textEditor->textDocument())) return nullptr;
return nullptr;
return new OutlineComboBox(client, textEditor);
} }
OutlineComboBox::OutlineComboBox(Client *client, TextEditor::BaseTextEditor *editor) OutlineComboBox::OutlineComboBox(Client *client, TextEditor::BaseTextEditor *editor)

View File

@@ -27,7 +27,10 @@
#include <texteditor/ioutlinewidget.h> #include <texteditor/ioutlinewidget.h>
namespace TextEditor { class TextDocument; } namespace TextEditor {
class TextDocument;
class BaseTextEditor;
} // namespace TextEditor
namespace Utils { class TreeViewComboBox; } namespace Utils { class TreeViewComboBox; }
namespace LanguageClient { namespace LanguageClient {
@@ -39,7 +42,7 @@ class LanguageClientOutlineWidgetFactory : public TextEditor::IOutlineWidgetFact
public: public:
using IOutlineWidgetFactory::IOutlineWidgetFactory; using IOutlineWidgetFactory::IOutlineWidgetFactory;
static Utils::TreeViewComboBox *createComboBox(Client *client, Core::IEditor *editor); static Utils::TreeViewComboBox *createComboBox(Client *client, TextEditor::BaseTextEditor *editor);
// IOutlineWidgetFactory interface // IOutlineWidgetFactory interface
public: public:
bool supportsEditor(Core::IEditor *editor) const override; bool supportsEditor(Core::IEditor *editor) const override;

View File

@@ -288,10 +288,11 @@ void updateEditorToolBar(Core::IEditor *editor)
} }
if (!extras->m_client) { if (!extras->m_client) {
if (QWidget *comboBox = LanguageClientOutlineWidgetFactory::createComboBox(client, editor)) { QWidget *comboBox = LanguageClientOutlineWidgetFactory::createComboBox(client, textEditor);
if (comboBox) {
extras->m_client = client; extras->m_client = client;
extras->m_outlineAction = widget->insertExtraToolBarWidget(TextEditorWidget::Left, extras->m_outlineAction = widget->insertExtraToolBarWidget(TextEditorWidget::Left,
comboBox); comboBox);
} }
} }
} }