summaryrefslogtreecommitdiff
path: root/script/vm/visible.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-10-25 03:11:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-10-25 03:11:49 +0800
commit28dc2d3adce8729c90cf8abdaf5eb46efd39f2f1 (patch)
tree46bf83aa9f001f006e3ee42872838bea5a9a0660 /script/vm/visible.lua
parent8f2dac8ba32271e45061128070063e0ddd0d73c4 (diff)
downloadlua-language-server-28dc2d3adce8729c90cf8abdaf5eb46efd39f2f1.zip
`---@private` and `---@protected`
#1316
Diffstat (limited to 'script/vm/visible.lua')
-rw-r--r--script/vm/visible.lua27
1 files changed, 25 insertions, 2 deletions
diff --git a/script/vm/visible.lua b/script/vm/visible.lua
index 362bc568..f0b30a22 100644
--- a/script/vm/visible.lua
+++ b/script/vm/visible.lua
@@ -4,11 +4,13 @@ local guide = require 'parser.guide'
local config = require 'config'
local glob = require 'glob'
+---@alias parser.visibleType 'public' | 'protected' | 'private'
+
---@class parser.object
----@field _visibleType? 'public' | 'protected' | 'private'
+---@field _visibleType? parser.visibleType
---@param source parser.object
----@return 'public' | 'protected' | 'private'
+---@return parser.visibleType
function vm.getVisibleType(source)
if source._visibleType then
return source._visibleType
@@ -19,6 +21,20 @@ function vm.getVisibleType(source)
return source.visible
end
end
+
+ if source.bindDocs then
+ for _, doc in ipairs(source.bindDocs) do
+ if doc.type == 'doc.private' then
+ source._visibleType = 'private'
+ return 'private'
+ end
+ if doc.type == 'doc.protected' then
+ source._visibleType = 'protected'
+ return 'protected'
+ end
+ end
+ end
+
local fieldName = guide.getKeyName(source)
local uri = guide.getUri(source)
@@ -44,6 +60,13 @@ function vm.getParentClass(source)
if source.type == 'doc.field' then
return vm.getGlobalNode(source.class)
end
+ if source.type == 'setfield'
+ or source.type == 'setindex'
+ or source.type == 'setmethod'
+ or source.type == 'tablefield'
+ or source.type == 'tableindex' then
+ return vm.getDefinedClass(guide.getUri(source), source.node)
+ end
return nil
end