mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
LSP-306 [lsp] add some diagnostics
GitOrigin-RevId: d1aa5b3cd4a6ad5e8ae842cd3d83a35bb558c373
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8201c3a020
commit
d3951ff7c4
+16
-9
@@ -69,22 +69,29 @@ private suspend fun ByteReader.readFrame(): JsonElement? {
|
||||
val line = readUTF8Line()
|
||||
if (line.isNullOrEmpty()) break
|
||||
readSomething = true
|
||||
val (key, value) = line.split(':').map { it.trim() }
|
||||
if (key == "Content-Length") {
|
||||
contentLength = value.toInt()
|
||||
try {
|
||||
val (key, value) = line.split(':').map { it.trim() }
|
||||
if (key == "Content-Length") {
|
||||
contentLength = value.toInt()
|
||||
}
|
||||
} catch(x: Throwable) {
|
||||
throw IllegalStateException("could not read header: $line", x)
|
||||
}
|
||||
}
|
||||
if (!readSomething) return null
|
||||
if (contentLength == -1) throw IllegalStateException("Content-Length header not found")
|
||||
readByteArray(contentLength)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
when (e) {
|
||||
is IOException -> return null
|
||||
else -> throw e
|
||||
}
|
||||
catch (_: IOException) {
|
||||
return null
|
||||
}
|
||||
val jsonStr = buf.decodeToStringUtf8()
|
||||
return try {
|
||||
LSP.json.decodeFromString(JsonElement.serializer(), jsonStr)
|
||||
}
|
||||
catch (x: Throwable) {
|
||||
throw IllegalStateException("could not decode json: $jsonStr", x)
|
||||
}
|
||||
return LSP.json.decodeFromString(JsonElement.serializer(), buf.decodeToStringUtf8())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user