diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-23 00:05:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-23 00:05:30 +0800 |
commit | 6da2b175e20ed3c03b0dfcfc9046de1e0e5d4444 (patch) | |
tree | fdc22d78150fd1c5edc46732c8b151ccfefb519f /script/src/files | |
parent | d0ff66c9abe9d6abbca12fd811e0c3cb69c1033a (diff) | |
download | lua-language-server-6da2b175e20ed3c03b0dfcfc9046de1e0e5d4444.zip |
正路目录
Diffstat (limited to 'script/src/files')
-rw-r--r-- | script/src/files/file.lua | 158 | ||||
-rw-r--r-- | script/src/files/files.lua | 115 | ||||
-rw-r--r-- | script/src/files/init.lua | 1 |
3 files changed, 0 insertions, 274 deletions
diff --git a/script/src/files/file.lua b/script/src/files/file.lua deleted file mode 100644 index 81aabba5..00000000 --- a/script/src/files/file.lua +++ /dev/null @@ -1,158 +0,0 @@ ----@class file -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 - ----@return string -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 -end - ----@return integer -function mt:getVersion() - return self._version -end - -function mt:remove() - if self._removed then - return - end - self._removed = true - self._text = nil - self._version = nil - if self._vm then - self._vm:remove() - end -end - ----@return boolean -function mt:isRemoved() - return self._removed == true -end - ----@param vm 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 -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 - end - self._vm:remove() - 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 - -function mt:getComments() - return self.comments -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 - -function mt:eachChild() - return pairs(self._child) -end - -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({ - _uri = uri, - _parent = {}, - _child = {}, - }, mt) - return self -end diff --git a/script/src/files/files.lua b/script/src/files/files.lua deleted file mode 100644 index 88ff7444..00000000 --- a/script/src/files/files.lua +++ /dev/null @@ -1,115 +0,0 @@ -local file = require 'files.file' - ----@class files -local mt = {} -mt.__index = mt -mt.type = 'files' -mt._fileCount = 0 ----@type table<uri, file> -mt._files = nil - ----@param uri uri ----@param text string -function mt:save(uri, text, version) - local f = self._files[uri] - if not f then - f = file(uri) - self._files[uri] = f - self._fileCount = self._fileCount + 1 - end - f:setText(text) - f:setVersion(version) -end - ----@param uri uri -function mt:remove(uri) - local f = self._files[uri] - if not f then - return - end - - f:remove() - self._files[uri] = nil - self._fileCount = self._fileCount - 1 -end - ----@param uri uri -function mt:open(uri, text) - self._open[uri] = text -end - ----@param uri uri -function mt:close(uri) - self._open[uri] = nil -end - ----@param uri uri ----@return boolean -function mt:isOpen(uri) - return self._open[uri] ~= nil -end - ----@param uri uri -function mt:setLibrary(uri) - self._library[uri] = true -end - ----@param uri uri ----@return uri -function mt:isLibrary(uri) - return self._library[uri] == true -end - ----@param uri uri -function mt:isDead(uri) - local f = self._files[uri] - if not f then - return true - end - if f:isRemoved() then - return true - end - return f:getVersion() == -1 -end - ----@param uri uri ----@return file -function mt:get(uri) - return self._files[uri] -end - -function mt:clear() - for _, f in pairs(self._files) do - f:remove() - end - self._files = {} - self._library = {} - self._fileCount = nil -end - -function mt:clearVM() - for _, f in pairs(self._files) do - f:removeVM() - end -end - -function mt:eachFile() - return pairs(self._files) -end - -function mt:eachOpened() - return pairs(self._open) -end - -function mt:count() - return self._fileCount -end - -return function () - local self = setmetatable({ - _files = {}, - _open = {}, - _library = {}, - }, mt) - return self -end diff --git a/script/src/files/init.lua b/script/src/files/init.lua deleted file mode 100644 index e090874d..00000000 --- a/script/src/files/init.lua +++ /dev/null @@ -1 +0,0 @@ -return require 'files.files' |