Skip to content

Commit 682614e

Browse files
committed
check visible recursive
fix #2145
1 parent 2431b55 commit 682614e

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 3.6.24
44
* `FIX` shake of `codeLens`
5+
* `FIX` [#2145]
6+
7+
[#2145]: https://github.com/LuaLS/lua-language-server/issues/2145
58

69
## 3.6.23
710
`2023-7-7`

script/vm/visible.lua

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ local glob = require 'glob'
77
---@class parser.object
88
---@field package _visibleType? parser.visibleType
99

10-
---@param source parser.object
11-
---@return parser.visibleType
12-
function vm.getVisibleType(source)
10+
local function getVisibleType(source)
1311
if source._visibleType then
1412
return source._visibleType
1513
end
@@ -55,6 +53,23 @@ function vm.getVisibleType(source)
5553
return 'public'
5654
end
5755

56+
---@param source parser.object
57+
---@return parser.visibleType
58+
function vm.getVisibleType(source)
59+
if source._visibleType then
60+
return source._visibleType
61+
end
62+
for _, def in ipairs(vm.getDefs(source)) do
63+
local visible = getVisibleType(def)
64+
if visible ~= 'public' then
65+
source._visibleType = visible
66+
return visible
67+
end
68+
end
69+
source._visibleType = 'public'
70+
return 'public'
71+
end
72+
5873
---@param source parser.object
5974
---@return vm.global?
6075
function vm.getParentClass(source)

test/hover/init.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,6 +2381,25 @@ local obj: B {
23812381
}
23822382
]]
23832383

2384+
TEST [[
2385+
---@class A
2386+
local M = {}
2387+
2388+
---@private
2389+
M.x = 0
2390+
2391+
---@private
2392+
function M:init()
2393+
self.x = 1
2394+
end
2395+
2396+
---@type A
2397+
local <?a?>
2398+
]]
2399+
[[
2400+
local a: A
2401+
]]
2402+
23842403
TEST [[
23852404
---@class A
23862405
---@field x fun(): string

0 commit comments

Comments
 (0)