diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/global_protect.lua | 4 | ||||
-rw-r--r-- | server/src/log.lua | 2 | ||||
-rw-r--r-- | server/src/matcher/definition.lua | 2 | ||||
-rw-r--r-- | server/src/matcher/env.lua | 2 | ||||
-rw-r--r-- | server/src/method/textDocument/definition.lua | 2 | ||||
-rw-r--r-- | server/src/method/textDocument/implementation.lua | 4 | ||||
-rw-r--r-- | server/src/proto.lua | 6 | ||||
-rw-r--r-- | server/src/service.lua | 21 | ||||
-rw-r--r-- | server/src/utility/table.lua | 8 |
9 files changed, 25 insertions, 26 deletions
diff --git a/server/src/global_protect.lua b/server/src/global_protect.lua index 6c736ea6..27f84191 100644 --- a/server/src/global_protect.lua +++ b/server/src/global_protect.lua @@ -2,9 +2,9 @@ local mt = {} setmetatable(_G, mt) function mt:__index(k) - error(('读取不存在的全局变量[%s]'):format(k), 2) + error(('Read undefined global: [%s]'):format(k), 2) end function mt:__newindex(k, v) - error(('保存全局变量[%s] = [%s]'):format(k, v), 2) + error(('Save global: [%s] = [%s]'):format(k, v), 2) end diff --git a/server/src/log.lua b/server/src/log.lua index ec8b5423..3826e4f4 100644 --- a/server/src/log.lua +++ b/server/src/log.lua @@ -53,7 +53,7 @@ local function push_log(level, ...) log.file:write(buf) log.size = log.size + #buf if log.size > log.max_size then - log.file:write('[日志过大]') + log.file:write('[REACH MAX SIZE]') end return str end diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 794788e8..4dec7430 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -100,7 +100,7 @@ local function parseResult(result) end end else - error('unknow result.type:' .. result.type) + error('Unknow result type:' .. result.type) end return positions end diff --git a/server/src/matcher/env.lua b/server/src/matcher/env.lua index 13787fc0..ada26145 100644 --- a/server/src/matcher/env.lua +++ b/server/src/matcher/env.lua @@ -83,7 +83,7 @@ return function (root) o[key][k] = v end else - error(('[env.%s]是表,赋值也需要是表:[%s]'):format(key, value)) + error(('[env.%s] should be table, got [%s]'):format(key, value)) end else o[key] = value diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index 60130935..90c964f3 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -39,7 +39,7 @@ return function (lsp, params) local response = locations local passed_clock = os.clock() - start_clock if passed_clock >= 0.01 then - log.warn(('[转到定义]耗时[%.3f]秒,文件大小[%s]字节'):format(passed_clock, #lines.buf)) + log.warn(('[Goto Definition] takes [%.3f] sec, size [%s] bits.'):format(passed_clock, #lines.buf)) end return response diff --git a/server/src/method/textDocument/implementation.lua b/server/src/method/textDocument/implementation.lua index 6d3cd0ac..f035c749 100644 --- a/server/src/method/textDocument/implementation.lua +++ b/server/src/method/textDocument/implementation.lua @@ -5,7 +5,7 @@ return function (lsp, params) local uri = params.textDocument.uri local text = lsp:loadText(uri) if not text then - return nil, '找不到文件:' .. uri + return nil, 'Cannot find file: ' .. uri end local start_clock = os.clock() -- lua是从1开始的,因此都要+1 @@ -44,7 +44,7 @@ return function (lsp, params) local response = locations local passed_clock = os.clock() - start_clock if passed_clock >= 0.01 then - log.warn(('[转到实现]耗时[%.3f]秒,文件大小[%s]字节'):format(passed_clock, #text)) + log.warn(('[Goto Implementation] takes [%.3f] sec, size [%s] bits.'):format(passed_clock, #text)) end return response diff --git a/server/src/proto.lua b/server/src/proto.lua index 367abc02..a9635477 100644 --- a/server/src/proto.lua +++ b/server/src/proto.lua @@ -23,7 +23,7 @@ local function readProtoHeader() elseif header:sub(1, #'Content-Type') == 'Content-Type' then return nil else - log.error('错误的协议头:', header) + log.error('Proto header error:', header) return nil end end @@ -31,7 +31,7 @@ end local function readProtoContent(header) local len = tonumber(header:match('%d+')) if not len then - log.error('错误的协议头:', header) + log.error('Proto header error:', header) return nil end local buf = io.read(len+2) @@ -40,7 +40,7 @@ local function readProtoContent(header) end local suc, res = pcall(json.decode, buf) if not suc then - log.error('错误的协议:', buf) + log.error('Proto error:', buf) return nil end return res diff --git a/server/src/service.lua b/server/src/service.lua index a633f4a9..faec738a 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -37,13 +37,13 @@ function mt:_callMethod(name, params) if suc then return res, res2 else - return nil, '发生运行时错误:' .. res + return nil, 'Runtime error: ' .. res end end if optional then return false else - return nil, '没有注册方法:' .. name + return nil, 'Undefined method: ' .. name end end @@ -70,13 +70,13 @@ function mt:_doProto(proto) id = id, error = { code = ErrorCodes.UnknownErrorCode, - message = err or ('没有回应:' .. method), + message = err or ('Lack of response: ' .. method), }, } end end if response == nil then - log.error(err or ('没有回应:' .. method)) + log.error(err or ('Lack of response: ' .. method)) end end @@ -97,12 +97,12 @@ function mt:_buildTextCache() end local passed = os.clock() - clock log.debug(('\n\z - 语法树缓存完成\n\z - 耗时:[%.3f]秒\n\z - 数量:[%d]\n\z - 总大小:[%.3f]kb\n\z - 速度:[%.3f]kb/s\n\z - 内存:[%.3f]kb'):format( + Cache completion\n\z + Cost: [%.3f]秒\n\z + Num: [%d]\n\z + Size: [%.3f]kb\n\z + Speed:[%.3f]kb/s\n\z + Mem: [%.3f]kb'):format( passed, #list, size / 1000, @@ -168,7 +168,6 @@ end function mt:on_tick() local proto = thread.proto() if proto then - -- 协议内容读取成功后重置 self._idle_clock = os.clock() self:_doProto(proto) return diff --git a/server/src/utility/table.lua b/server/src/utility/table.lua index 37a74632..1c6b21d1 100644 --- a/server/src/utility/table.lua +++ b/server/src/utility/table.lua @@ -14,14 +14,14 @@ local KEY = {} function table.dump(tbl) if type(tbl) ~= 'table' then - error('必须是表') + error('Must be a table') end local table_mark = {} local lines = {} lines[#lines+1] = '{' local function unpack(tbl, tab) if table_mark[tbl] then - error('不能循环引用') + error('Cyclic references are not allowed.') end table_mark[tbl] = true local keys = {} @@ -35,7 +35,7 @@ function table.dump(tbl) elseif math_type(key) == 'integer' then KEY[key] = ('[%d]'):format(key) else - error('必须使用字符串或整数作为键') + error('Key must be `string` or `integer`') end keys[#keys+1] = key end @@ -52,7 +52,7 @@ function table.dump(tbl) elseif tp == 'string' or tp == 'number' or tp == 'boolean' then lines[#lines+1] = ('%s%s = %q,'):format(TAB[tab+1], KEY[key], value) else - error(('不支持的值类型[%s]'):format(tp)) + error(('Unsupport value type: [%s]'):format(tp)) end end end |