summaryrefslogtreecommitdiff
path: root/script-beta/vm/getGlobals.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-29 14:53:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-29 14:53:56 +0800
commit88ff3f4ae07311d4aed9c15df723c50da948f24f (patch)
treee5e16423a97496676a4b56fc157f21e9885cc306 /script-beta/vm/getGlobals.lua
parent049eaa1446d8b53cef14ec3a72f315f162ead2bc (diff)
downloadlua-language-server-88ff3f4ae07311d4aed9c15df723c50da948f24f.zip
暂存
Diffstat (limited to 'script-beta/vm/getGlobals.lua')
-rw-r--r--script-beta/vm/getGlobals.lua22
1 files changed, 21 insertions, 1 deletions
diff --git a/script-beta/vm/getGlobals.lua b/script-beta/vm/getGlobals.lua
index c5d6dc21..f5b22ff9 100644
--- a/script-beta/vm/getGlobals.lua
+++ b/script-beta/vm/getGlobals.lua
@@ -4,14 +4,34 @@ local files = require 'files'
local library = require 'library'
local util = require 'utility'
+local function searchG(ref, results)
+
+end
+
+local function searchEnvRef(ref, results)
+ if ref.type == 'setglobal'
+ or ref.type == 'getglobal' then
+ results[#results+1] = ref
+ searchG(ref, results)
+ elseif ref.type == 'getlocal' then
+ results[#results+1] = ref.next
+ searchG(ref.next, results)
+ end
+end
+
local function getGlobalsOfFile(uri)
local globals = {}
local ast = files.getAst(uri)
if not ast then
return globals
end
+ local results = {}
local env = guide.getENV(ast.ast)
- local results = guide.requestFields(env)
+ if env.ref then
+ for _, ref in ipairs(env.ref) do
+ searchEnvRef(ref, results)
+ end
+ end
for _, res in ipairs(results) do
local name = guide.getSimpleName(res)
if name then