diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-05 16:13:42 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-05 16:13:42 +0800 |
commit | 5d4d2ccd06d56bb92219baf3825c5786efdf906c (patch) | |
tree | 790b601a7be4d13c0f2abcfc63547fa81f60b947 | |
parent | 4d91852b04e050ee958ee2b22a0219d48fcc7c20 (diff) | |
download | lua-language-server-5d4d2ccd06d56bb92219baf3825c5786efdf906c.zip |
放错文件了
-rw-r--r-- | server-beta/src/core/diagnostics/undefined-env-child.lua | 34 | ||||
-rw-r--r-- | server-beta/src/core/diagnostics/undefined-global.lua | 22 |
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 |