LSP: log non protocol lines instead of throwing an error

Some language server send non protocol conform lines over the same
transport layer as the protocol messages. Do not switch the client for
those servers into the error state, but print a warning message with the
content of these lines to a categorized log.

Change-Id: Ic6c62648f0237362136fd657fde71dd104bca9d1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2019-05-08 12:08:39 +02:00
parent e0a1b31e29
commit ea81b676c7
3 changed files with 15 additions and 15 deletions

View File

@@ -35,7 +35,6 @@
using namespace LanguageServerProtocol;
static Q_LOGGING_CATEGORY(LOGLSPCLIENTV, "qtc.languageclient.messages", QtWarningMsg);
static Q_LOGGING_CATEGORY(LOGLSPCLIENTPARSE, "qtc.languageclient.parse", QtWarningMsg);
namespace LanguageClient {
@@ -64,8 +63,8 @@ void BaseClientInterface::resetBuffer()
void BaseClientInterface::parseData(const QByteArray &data)
{
const qint64 preWritePosition = m_buffer.pos();
qCDebug(LOGLSPCLIENTPARSE) << "parse buffer pos: " << preWritePosition;
qCDebug(LOGLSPCLIENTPARSE) << " data: " << data;
qCDebug(parseLog) << "parse buffer pos: " << preWritePosition;
qCDebug(parseLog) << " data: " << data;
if (!m_buffer.atEnd())
m_buffer.seek(preWritePosition + m_buffer.bytesAvailable());
m_buffer.write(data);
@@ -73,9 +72,9 @@ void BaseClientInterface::parseData(const QByteArray &data)
while (!m_buffer.atEnd()) {
QString parseError;
BaseMessage::parse(&m_buffer, parseError, m_currentMessage);
qCDebug(LOGLSPCLIENTPARSE) << " complete: " << m_currentMessage.isComplete();
qCDebug(LOGLSPCLIENTPARSE) << " length: " << m_currentMessage.contentLength;
qCDebug(LOGLSPCLIENTPARSE) << " content: " << m_currentMessage.content;
qCDebug(parseLog) << " complete: " << m_currentMessage.isComplete();
qCDebug(parseLog) << " length: " << m_currentMessage.contentLength;
qCDebug(parseLog) << " content: " << m_currentMessage.content;
if (!parseError.isEmpty())
emit error(parseError);
if (!m_currentMessage.isComplete())