summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/diagnostics/undefined-env-child.lua34
-rw-r--r--server-beta/src/core/diagnostics/undefined-global.lua22
2 files changed, 32 insertions, 24 deletions
diff --git a/server-beta/src/core/diagnostics/undefined-env-child.lua b/server-beta/src/core/diagnostics/undefined-env-child.lua
index b3d19c21..5815f9c3 100644
--- a/server-beta/src/core/diagnostics/undefined-env-child.lua
+++ b/server-beta/src/core/diagnostics/undefined-env-child.lua
@@ -1,3 +1,33 @@
-return function ()
-
+local files = require 'files'
+local guide = require 'parser.guide'
+local searcher = require 'searcher'
+local lang = require 'language'
+
+return function (uri, callback)
+ local ast = files.getAst(uri)
+ if not ast then
+ return
+ end
+ -- 再遍历一次 getglobal ,找出 _ENV 被重载的情况
+ guide.eachSourceType(ast.ast, 'getglobal', function (source)
+ -- 单独验证自己是否在重载过的 _ENV 中有定义
+ if source.node.tag == '_ENV' then
+ return
+ end
+ local setInENV
+ searcher.eachRef(source, function (info)
+ if info.mode == 'set' then
+ setInENV = true
+ end
+ end)
+ if setInENV then
+ return
+ end
+ local key = source[1]
+ callback {
+ start = source.start,
+ finish = source.finish,
+ message = lang.script('DIAG_UNDEF_ENV_CHILD', key),
+ }
+ end)
end
diff --git a/server-beta/src/core/diagnostics/undefined-global.lua b/server-beta/src/core/diagnostics/undefined-global.lua
index 71980c8b..6c9abaca 100644
--- a/server-beta/src/core/diagnostics/undefined-global.lua
+++ b/server-beta/src/core/diagnostics/undefined-global.lua
@@ -3,7 +3,6 @@ local searcher = require 'searcher'
local lang = require 'language'
local library = require 'library'
local config = require 'config'
-local guide = require 'parser.guide'
return function (uri, callback)
local ast = files.getAst(uri)
@@ -61,25 +60,4 @@ return function (uri, callback)
}
end
end)
- -- 再遍历一次 getglobal ,找出 _ENV 被重载的情况
- guide.eachSourceType(ast.ast, 'getglobal', function (source)
- if hasSet[source] == nil then
- -- 单独验证自己是否在重载过的 _ENV 中有定义
- local setInENV
- searcher.eachRef(source, function (info)
- if info.mode == 'set' then
- setInENV = true
- end
- end)
- if setInENV then
- return
- end
- local key = source[1]
- callback {
- start = source.start,
- finish = source.finish,
- message = lang.script('DIAG_UNDEF_ENV_CHILD', key),
- }
- end
- end)
end