diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-07-21 18:47:27 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-07-21 18:47:27 +0800 |
commit | 7a9f26241cec312c0c7930bcc71ca4f70a31facc (patch) | |
tree | 7ad18ad3744d96fc29157538dbe9fc26241e3f6c /script/service.lua | |
parent | 408991b4d15724906ec9dc8d62a9f1579effd384 (diff) | |
download | lua-language-server-7a9f26241cec312c0c7930bcc71ca4f70a31facc.zip |
将协议放到主线程解析
Diffstat (limited to 'script/service.lua')
-rw-r--r-- | script/service.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/script/service.lua b/script/service.lua index d0e34891..208a538f 100644 --- a/script/service.lua +++ b/script/service.lua @@ -23,6 +23,7 @@ local capability = require 'capability' local plugin = require 'plugin' local workspace = require 'workspace' local fn = require 'filename' +local json = require 'json' local ErrorCodes = { -- Defined by JSON RPC @@ -399,7 +400,9 @@ function mt:reCompile() self.chain = chainMgr() self.emmy = emmyMgr() self.globalValue = nil - self._compileTask:remove() + if self._compileTask then + self._compileTask:remove() + end self._needCompile = {} local n = 0 for uri in self._files:eachFile() do @@ -779,15 +782,20 @@ end function mt:_loadProto() while true do - local ok, proto = self._proto:pop() + local ok, protoStream = self._proto:pop() if not ok then - break + goto CONTINUE + end + local suc, proto = xpcall(json.decode, log.error, protoStream) + if not suc then + goto CONTINUE end if proto.method then self:_doProto(proto) else rpc:recieve(proto) end + ::CONTINUE:: end end |