diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-06-24 10:38:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-06-24 10:38:35 +0800 |
commit | 8647f7987e30799f8a84b5ed3ae39484ca1c7135 (patch) | |
tree | b938fadac48fd9f3d7297dd01c574835484fb48d /server/src/files/file.lua | |
parent | 21b7cc4df0295df5915a7b4328c04f71e7cf25ca (diff) | |
download | lua-language-server-8647f7987e30799f8a84b5ed3ae39484ca1c7135.zip |
整理代码
Diffstat (limited to 'server/src/files/file.lua')
-rw-r--r-- | server/src/files/file.lua | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/server/src/files/file.lua b/server/src/files/file.lua index deaea8ba..61f62a00 100644 --- a/server/src/files/file.lua +++ b/server/src/files/file.lua @@ -3,11 +3,15 @@ local mt = {} mt.__index = mt mt.type = 'file' mt._uri = '' +mt._oldText = '' mt._text = '' mt._version = -1 +mt._vmCost = 0.0 +mt._lineCost = 0.0 ---@param buf string function mt:setText(buf) + self._oldText = self._text self._text = buf end @@ -16,6 +20,15 @@ function mt:getText() return self._text end +---@return string +function mt:getOldText() + return self._oldText +end + +function mt:clearOldText() + self._oldText = nil +end + ---@param version integer function mt:setVersion(version) self._version = version @@ -38,9 +51,23 @@ function mt:remove() end end +---@return boolean +function mt:isRemoved() + return self._removed == true +end + ---@param vm VM -function mt:saveVM(vm) +---@param version integer +---@param cost number +function mt:saveVM(vm, version, cost) + if self._vm then + self._vm:remove() + end self._vm = vm + if vm then + vm:setVersion(version) + end + self._vmCost = cost end ---@return VM @@ -48,6 +75,11 @@ function mt:getVM() return self._vm end +---@return number +function mt:getVMCost() + return self._vmCost +end + function mt:removeVM() if not self._vm then return @@ -56,17 +88,39 @@ function mt:removeVM() self._vm = nil end +---@param lines table +---@param cost number +function mt:saveLines(lines, cost) + self._lines = lines + self._lineCost = cost +end + +---@return table +function mt:getLines() + return self._lines +end + ---@return file function mt:getParent() return self._parent end ---@param uri uri +function mt:addChild(uri) + self._child[uri] = true +end + +---@param uri uri function mt:removeChild(uri) self._child[uri] = nil end ---@param uri uri +function mt:addParent(uri) + self._parent[uri] = true +end + +---@param uri uri function mt:removeParent(uri) self._parent[uri] = nil end @@ -79,6 +133,16 @@ function mt:eachParent() return pairs(self._parent) end +---@param err table +function mt:setAstErr(err) + self._astErr = err +end + +---@return table +function mt:getAstErr() + return self._astErr +end + ---@param uri string return function (uri) local self = setmetatable({ |