From 3fd972facc6dfb859d71899309723243b7b93880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 19 Nov 2018 17:48:40 +0800 Subject: =?UTF-8?q?=E5=87=8F=E5=B0=91=E6=97=A0=E7=94=A8=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lsp.lua | 3 --- src/method/textDocument/definition.lua | 6 ++++++ src/method/textDocument/didChange.lua | 1 - src/method/textDocument/didClose.lua | 1 - src/method/textDocument/didOpen.lua | 1 - 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lsp.lua b/src/lsp.lua index 563f7919..eeb4e560 100644 --- a/src/lsp.lua +++ b/src/lsp.lua @@ -59,10 +59,7 @@ function mt:_readAsContent(header) local id = res.id local method = res.method local params = res.params - log.debug(('执行任务[%s],ID[%s]'):format(method, id)) - local clock = os.clock() local response, err = self:_callback(method, params) - log.debug(('任务[%s]执行完毕,耗时[%.3f]秒,ID[%s]'):format(method, os.clock() - clock, id)) if response then self:_send { id = id, diff --git a/src/method/textDocument/definition.lua b/src/method/textDocument/definition.lua index 9601cc4a..9fcd7f18 100644 --- a/src/method/textDocument/definition.lua +++ b/src/method/textDocument/definition.lua @@ -7,6 +7,7 @@ return function (lsp, params) if not text then return nil, '找不到文件:' .. uri end + local start_clock = os.clock() -- lua是从1开始的,因此都要+1 local pos = parser.calcline.position_utf8(text, params.position.line + 1, params.position.character + 1) local suc, start, finish = matcher.definition(text, pos) @@ -30,5 +31,10 @@ return function (lsp, params) }, }, } + local passed_clock = os.clock() - start_clock + if passed_clock >= 0.01 then + log.warn(('[转到定义]耗时[%.3f]秒,文件大小[%s]字节'):format(passed_clock, #text)) + end + return response end diff --git a/src/method/textDocument/didChange.lua b/src/method/textDocument/didChange.lua index 09c62a6f..6856b729 100644 --- a/src/method/textDocument/didChange.lua +++ b/src/method/textDocument/didChange.lua @@ -1,7 +1,6 @@ return function (lsp, params) local doc = params.textDocument local change = params.contentChanges - log.debug('更新文件:', doc.uri) -- TODO 支持差量更新 lsp:saveText(doc.uri, doc.version, change[1].text) return true diff --git a/src/method/textDocument/didClose.lua b/src/method/textDocument/didClose.lua index 3dcbd7d7..d4edb624 100644 --- a/src/method/textDocument/didClose.lua +++ b/src/method/textDocument/didClose.lua @@ -1,6 +1,5 @@ return function (lsp, params) local doc = params.textDocument - log.debug('关闭文件:', doc.uri) lsp:removeText(doc.uri, doc.version) return true end diff --git a/src/method/textDocument/didOpen.lua b/src/method/textDocument/didOpen.lua index 8be4fa89..27fdda71 100644 --- a/src/method/textDocument/didOpen.lua +++ b/src/method/textDocument/didOpen.lua @@ -1,6 +1,5 @@ return function (lsp, params) local doc = params.textDocument - log.debug('打开文件:', doc.uri) lsp:saveText(doc.uri, doc.version, doc.text) return true end -- cgit v1.2.3