summaryrefslogtreecommitdiff
path: root/server-beta/src/files.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-10 21:44:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-10 21:44:05 +0800
commitcae5af4f384ce07da6dd5616c369d50356edee38 (patch)
treea276f8dd54d33581ce538b45c299bd9644ad9f74 /server-beta/src/files.lua
parent80f8f5bdda5a0401f28a83ea9dd649309ad16c55 (diff)
downloadlua-language-server-cae5af4f384ce07da6dd5616c369d50356edee38.zip
优化性能
Diffstat (limited to 'server-beta/src/files.lua')
-rw-r--r--server-beta/src/files.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/server-beta/src/files.lua b/server-beta/src/files.lua
index 8a362841..a9b833b2 100644
--- a/server-beta/src/files.lua
+++ b/server-beta/src/files.lua
@@ -213,6 +213,27 @@ function m.getGlobals(uri)
return file.globals
end
+--- 寻找全局变量
+function m.findGlobals(name)
+ local uris = {}
+ for uri, file in pairs(m.fileMap) do
+ if not file.globals then
+ local ast = m.getAst(uri)
+ if ast then
+ file.globals = {}
+ local globals = searcher.getGlobals(ast.ast)
+ for name in pairs(globals) do
+ file.globals[name] = true
+ end
+ end
+ end
+ if file.globals[name] then
+ uris[#uris+1] = file.uri
+ end
+ end
+ return uris
+end
+
--- 判断文件名相等
function m.eq(a, b)
if platform.OS == 'Windows' then