summaryrefslogtreecommitdiff
path: root/script/files.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-30 19:54:44 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-30 19:54:44 +0800
commit1c6a36528c5b5094353ee02796069542e33a71c3 (patch)
tree32c785f84f4a8f32c30500b96d1474dca836fbb8 /script/files.lua
parent438056d664afab8a2a89f817892be690b557e052 (diff)
downloadlua-language-server-1c6a36528c5b5094353ee02796069542e33a71c3.zip
clean up code
Diffstat (limited to 'script/files.lua')
-rw-r--r--script/files.lua34
1 files changed, 33 insertions, 1 deletions
diff --git a/script/files.lua b/script/files.lua
index b3447cc4..17b0e290 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -21,6 +21,7 @@ m.fileMap = {}
m.dllMap = {}
m.watchList = {}
m.notifyCache = {}
+m.visible = {}
m.assocVersion = -1
m.assocMatcher = nil
m.globalVersion = 0
@@ -379,6 +380,38 @@ function m.getAst(uri)
return ast
end
+---设置文件的当前可见范围
+---@param uri uri
+---@param ranges range[]
+function m.setVisibles(uri, ranges)
+ uri = m.getUri(uri)
+ m.visible[uri] = ranges
+end
+
+---获取文件的当前可见范围
+---@param uri uri
+---@return table[]
+function m.getVisibles(uri)
+ uri = m.getUri(uri)
+ local file = m.fileMap[uri]
+ if not file then
+ return nil
+ end
+ local ranges = m.visible[uri]
+ if not ranges or #ranges == 0 then
+ return nil
+ end
+ local visibles = {}
+ for i, range in ipairs(ranges) do
+ local start, finish = m.unrange(uri, range)
+ visibles[i] = {
+ start = start,
+ finish = finish,
+ }
+ end
+ return visibles
+end
+
--- 获取文件行信息
---@param uri uri
---@return table lines
@@ -396,7 +429,6 @@ function m.getLines(uri)
return lines
end
-
function m.getOriginLines(uri)
uri = getUriKey(uri)
local file = m.fileMap[uri]