diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-10-27 21:04:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-10-27 21:04:17 +0800 |
commit | eb150a0c2392a5e69fe5d28a3b790fca6704a9a3 (patch) | |
tree | 0643b9c226f4578101d72b55a1ae475d840e9750 /script | |
parent | badf7b9db225c4277cc94e6735c2dade29624f52 (diff) | |
download | lua-language-server-eb150a0c2392a5e69fe5d28a3b790fca6704a9a3.zip |
improve private
can visible in method
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/visible.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/script/vm/visible.lua b/script/vm/visible.lua index 50c37bf0..72a1370c 100644 --- a/script/vm/visible.lua +++ b/script/vm/visible.lua @@ -105,6 +105,20 @@ function vm.getDefinedClass(suri, source) return nil end +---@param source parser.object +---@return vm.global? +local function getEnvClass(source) + local func = guide.getParentFunction(source) + if not func or func.type ~= 'function' then + return nil + end + local self = func.args and func.args[1] + if not self or self.type ~= 'self' then + return nil + end + return vm.getDefinedClass(guide.getUri(source), self) +end + ---@param parent parser.object ---@param field parser.object function vm.isVisible(parent, field) @@ -117,9 +131,14 @@ function vm.isVisible(parent, field) return true end local suri = guide.getUri(parent) + -- check <?obj?>.x local myClass = vm.getDefinedClass(suri, parent) if not myClass then - return false + -- check function <?mt?>:X() ... end + myClass = getEnvClass(parent) + if not myClass then + return false + end end if myClass == class then return true |