forked from qt-creator/qt-creator
LanguageClient: add state changed signal to client
Change-Id: I13b69eb386b4e356f4f23c3b464f83a2a1d9ab14 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -299,6 +299,12 @@ public:
|
|||||||
|
|
||||||
bool reset();
|
bool reset();
|
||||||
|
|
||||||
|
void setState(Client::State state)
|
||||||
|
{
|
||||||
|
m_state = state;
|
||||||
|
emit q->stateChanged(state);
|
||||||
|
}
|
||||||
|
|
||||||
Client::State m_state = Client::Uninitialized;
|
Client::State m_state = Client::Uninitialized;
|
||||||
QHash<LanguageServerProtocol::MessageId,
|
QHash<LanguageServerProtocol::MessageId,
|
||||||
LanguageServerProtocol::ResponseHandler::Callback> m_responseHandlers;
|
LanguageServerProtocol::ResponseHandler::Callback> m_responseHandlers;
|
||||||
@@ -569,7 +575,7 @@ void Client::initialize()
|
|||||||
|
|
||||||
// directly send content now otherwise the state check of sendContent would fail
|
// directly send content now otherwise the state check of sendContent would fail
|
||||||
d->sendMessageNow(initRequest);
|
d->sendMessageNow(initRequest);
|
||||||
d->m_state = InitializeRequested;
|
d->setState(InitializeRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::shutdown()
|
void Client::shutdown()
|
||||||
@@ -581,7 +587,7 @@ void Client::shutdown()
|
|||||||
d->shutDownCallback(shutdownResponse);
|
d->shutDownCallback(shutdownResponse);
|
||||||
});
|
});
|
||||||
sendMessage(shutdown);
|
sendMessage(shutdown);
|
||||||
d->m_state = ShutdownRequested;
|
d->setState(ShutdownRequested);
|
||||||
d->m_shutdownTimer.start();
|
d->m_shutdownTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1526,7 +1532,7 @@ void Client::projectClosed(ProjectExplorer::Project *project)
|
|||||||
if (d->m_state == Initialized) {
|
if (d->m_state == Initialized) {
|
||||||
LanguageClientManager::shutdownClient(this);
|
LanguageClientManager::shutdownClient(this);
|
||||||
} else {
|
} else {
|
||||||
d->m_state = Shutdown; // otherwise the manager would try to restart this server
|
d->setState(Shutdown); // otherwise the manager would try to restart this server
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
d->m_project = nullptr;
|
d->m_project = nullptr;
|
||||||
@@ -1696,7 +1702,7 @@ bool ClientPrivate::reset()
|
|||||||
}
|
}
|
||||||
m_restartCountResetTimer.start();
|
m_restartCountResetTimer.start();
|
||||||
--m_restartsLeft;
|
--m_restartsLeft;
|
||||||
m_state = Client::Uninitialized;
|
setState(Client::Uninitialized);
|
||||||
m_responseHandlers.clear();
|
m_responseHandlers.clear();
|
||||||
m_clientInterface->resetBuffer();
|
m_clientInterface->resetBuffer();
|
||||||
updateOpenedEditorToolBars();
|
updateOpenedEditorToolBars();
|
||||||
@@ -1723,7 +1729,7 @@ bool ClientPrivate::reset()
|
|||||||
void Client::setError(const QString &message)
|
void Client::setError(const QString &message)
|
||||||
{
|
{
|
||||||
log(message);
|
log(message);
|
||||||
d->m_state = d->m_state < Initialized ? FailedToInitialize : Error;
|
d->setState(d->m_state < Initialized ? FailedToInitialize : Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressManager *Client::progressManager()
|
ProgressManager *Client::progressManager()
|
||||||
@@ -2152,7 +2158,7 @@ void ClientPrivate::initializeCallback(const InitializeRequest::Response &initRe
|
|||||||
QMessageBox::Retry | QMessageBox::Cancel,
|
QMessageBox::Retry | QMessageBox::Cancel,
|
||||||
QMessageBox::Retry);
|
QMessageBox::Retry);
|
||||||
if (result == QMessageBox::Retry) {
|
if (result == QMessageBox::Retry) {
|
||||||
m_state = Client::Uninitialized;
|
setState(Client::Uninitialized);
|
||||||
q->initialize();
|
q->initialize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2204,7 +2210,7 @@ void ClientPrivate::initializeCallback(const InitializeRequest::Response &initRe
|
|||||||
m_tokenSupport.setLegend(tokenProvider.legend());
|
m_tokenSupport.setLegend(tokenProvider.legend());
|
||||||
|
|
||||||
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " initialized";
|
||||||
m_state = Client::Initialized;
|
setState(Client::Initialized);
|
||||||
q->sendMessage(InitializeNotification(InitializedParams()));
|
q->sendMessage(InitializeNotification(InitializedParams()));
|
||||||
|
|
||||||
q->updateConfiguration(m_configuration);
|
q->updateConfiguration(m_configuration);
|
||||||
@@ -2227,7 +2233,7 @@ void ClientPrivate::shutDownCallback(const ShutdownRequest::Response &shutdownRe
|
|||||||
// directly send content now otherwise the state check of sendContent would fail
|
// directly send content now otherwise the state check of sendContent would fail
|
||||||
sendMessageNow(ExitNotification());
|
sendMessageNow(ExitNotification());
|
||||||
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " shutdown";
|
qCDebug(LOGLSPCLIENT) << "language server " << m_displayName << " shutdown";
|
||||||
m_state = Client::Shutdown;
|
setState(Client::Shutdown);
|
||||||
m_shutdownTimer.start();
|
m_shutdownTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -215,6 +215,7 @@ signals:
|
|||||||
void documentUpdated(TextEditor::TextDocument *document);
|
void documentUpdated(TextEditor::TextDocument *document);
|
||||||
void workDone(const LanguageServerProtocol::ProgressToken &token);
|
void workDone(const LanguageServerProtocol::ProgressToken &token);
|
||||||
void shadowDocumentSwitched(const Utils::FilePath &filePath);
|
void shadowDocumentSwitched(const Utils::FilePath &filePath);
|
||||||
|
void stateChanged(State state);
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user