From cae5af4f384ce07da6dd5616c369d50356edee38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 10 Nov 2019 21:44:05 +0800 Subject: =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/files.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'server-beta/src/files.lua') 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 -- cgit v1.2.3