forked from qt-creator/qt-creator
LanguageClient: Show outline after server start
If the server was started by opening a document the outline factory and client was not properly initialized in the time the outline was requested. Update the outline after the client is fully initialized. Fixes: QTCREATORBUG-22695 Change-Id: I84dc56eead9774d80ed6baf7792daff930a7cb8e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/textmark.h>
|
||||
#include <texteditor/ioutlinewidget.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
@@ -1139,6 +1140,10 @@ void Client::intializeCallback(const InitializeRequest::Response &initResponse)
|
||||
if (auto textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor))
|
||||
textEditor->editorWidget()->addHoverHandler(&m_hoverHandler);
|
||||
}
|
||||
if (m_dynamicCapabilities.isRegistered(DocumentSymbolsRequest::methodName)
|
||||
.value_or(capabilities().documentSymbolProvider().value_or(false))) {
|
||||
TextEditor::IOutlineWidgetFactory::updateOutline();
|
||||
}
|
||||
emit initialized(m_serverCapabilities);
|
||||
}
|
||||
|
||||
|
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
virtual bool supportsEditor(Core::IEditor *editor) const = 0;
|
||||
virtual IOutlineWidget *createWidget(Core::IEditor *editor) = 0;
|
||||
|
||||
static void updateOutline();
|
||||
};
|
||||
|
||||
} // namespace TextEditor
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QLabel>
|
||||
@@ -40,6 +41,7 @@
|
||||
namespace TextEditor {
|
||||
|
||||
static QList<IOutlineWidgetFactory *> g_outlineWidgetFactories;
|
||||
static QPointer<Internal::OutlineFactory> g_outlineFactory;
|
||||
|
||||
IOutlineWidgetFactory::IOutlineWidgetFactory()
|
||||
{
|
||||
@@ -51,6 +53,12 @@ IOutlineWidgetFactory::~IOutlineWidgetFactory()
|
||||
g_outlineWidgetFactories.removeOne(this);
|
||||
}
|
||||
|
||||
void IOutlineWidgetFactory::updateOutline()
|
||||
{
|
||||
if (QTC_GUARD(!g_outlineFactory.isNull()))
|
||||
emit g_outlineFactory->updateOutline();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
|
||||
@@ -88,8 +96,10 @@ OutlineWidgetStack::OutlineWidgetStack(OutlineFactory *factory) :
|
||||
m_filterButton->setMenu(m_filterMenu);
|
||||
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
|
||||
this, &OutlineWidgetStack::updateEditor);
|
||||
connect(factory, &OutlineFactory::updateOutline,
|
||||
this, &OutlineWidgetStack::updateCurrentEditor);
|
||||
updateCurrentEditor(Core::EditorManager::currentEditor());
|
||||
updateCurrentEditor();
|
||||
}
|
||||
|
||||
OutlineWidgetStack::~OutlineWidgetStack() = default;
|
||||
@@ -159,7 +169,12 @@ void OutlineWidgetStack::updateFilterMenu()
|
||||
m_filterButton->setVisible(!m_filterMenu->actions().isEmpty());
|
||||
}
|
||||
|
||||
void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
|
||||
void OutlineWidgetStack::updateCurrentEditor()
|
||||
{
|
||||
updateEditor(Core::EditorManager::currentEditor());
|
||||
}
|
||||
|
||||
void OutlineWidgetStack::updateEditor(Core::IEditor *editor)
|
||||
{
|
||||
IOutlineWidget *newWidget = nullptr;
|
||||
|
||||
@@ -195,6 +210,8 @@ void OutlineWidgetStack::updateCurrentEditor(Core::IEditor *editor)
|
||||
|
||||
OutlineFactory::OutlineFactory()
|
||||
{
|
||||
QTC_CHECK(g_outlineFactory.isNull());
|
||||
g_outlineFactory = this;
|
||||
setDisplayName(tr("Outline"));
|
||||
setId("Outline");
|
||||
setPriority(600);
|
||||
|
@@ -55,7 +55,8 @@ private:
|
||||
QWidget *dummyWidget() const;
|
||||
void updateFilterMenu();
|
||||
void toggleCursorSynchronization();
|
||||
void updateCurrentEditor(Core::IEditor *editor);
|
||||
void updateEditor(Core::IEditor *editor);
|
||||
void updateCurrentEditor();
|
||||
|
||||
QStackedWidget *m_widgetStack;
|
||||
OutlineFactory *m_factory;
|
||||
@@ -76,6 +77,9 @@ public:
|
||||
Core::NavigationView createWidget() override;
|
||||
void saveSettings(QSettings *settings, int position, QWidget *widget) override;
|
||||
void restoreSettings(QSettings *settings, int position, QWidget *widget) override;
|
||||
|
||||
signals:
|
||||
void updateOutline();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user