File tree Expand file tree Collapse file tree 3 files changed +43
-6
lines changed
Expand file tree Collapse file tree 3 files changed +43
-6
lines changed Original file line number Diff line number Diff line change @@ -402,7 +402,10 @@ local template = {
402402 [' Lua.doc.privateName' ] = Type .Array (Type .String ),
403403 [' Lua.doc.protectedName' ] = Type .Array (Type .String ),
404404 [' Lua.doc.packageName' ] = Type .Array (Type .String ),
405-
405+ [' Lua.doc.regengine' ] = Type .String >> ' glob' << {
406+ ' glob' ,
407+ ' lua' ,
408+ },
406409 -- VSCode
407410 [" Lua.addonManager.enable" ] = Type .Boolean >> true ,
408411 [' files.associations' ] = Type .Hash (Type .String , Type .String ),
Original file line number Diff line number Diff line change @@ -42,21 +42,33 @@ local function getVisibleType(source)
4242
4343 if type (fieldName ) == ' string' then
4444 local uri = guide .getUri (source )
45+ local regengine = config .get (uri , ' Lua.doc.regengine' )
46+ local function match (patterns )
47+ if regengine == " glob" then
48+ return glob .glob (patterns )(fieldName )
49+ else
50+ for i = 1 , # patterns do
51+ if string.find (fieldName , patterns [i ]) then
52+ return true
53+ end
54+ end
55+ end
56+ end
4557
4658 local privateNames = config .get (uri , ' Lua.doc.privateName' )
47- if # privateNames > 0 and glob . glob (privateNames )( fieldName ) then
59+ if # privateNames > 0 and match (privateNames ) then
4860 source ._visibleType = ' private'
4961 return ' private'
5062 end
51-
63+
5264 local protectedNames = config .get (uri , ' Lua.doc.protectedName' )
53- if # protectedNames > 0 and glob . glob (protectedNames )( fieldName ) then
65+ if # protectedNames > 0 and match (protectedNames ) then
5466 source ._visibleType = ' protected'
5567 return ' protected'
5668 end
57-
69+
5870 local packageNames = config .get (uri , ' Lua.doc.packageName' )
59- if # packageNames > 0 and glob . glob (packageNames )( fieldName ) then
71+ if # packageNames > 0 and match (packageNames ) then
6072 source ._visibleType = ' package'
6173 return ' package'
6274 end
Original file line number Diff line number Diff line change @@ -104,6 +104,28 @@ print(t2._id)
104104]]
105105config .set (nil , ' Lua.doc.protectedName' , nil )
106106
107+ config .set (nil , ' Lua.doc.regengine' , ' lua' )
108+ config .set (nil , ' Lua.doc.privateName' , { ' ^_[%w_]*%w$' })
109+ config .set (nil , ' Lua.doc.protectedName' , { ' ^_[%w_]*_$' })
110+ TEST [[
111+ ---@class A
112+ ---@field _id_ number
113+ ---@field _user number
114+
115+ ---@type A
116+ local t
117+ print(t.<!_id_!>)
118+ print(t.<!_user!>)
119+
120+ ---@class B: A
121+ local t2
122+ print(t2._id_)
123+ print(t2.<!_user!>)
124+ ]]
125+ config .set (nil , ' Lua.doc.privateName' , nil )
126+ config .set (nil , ' Lua.doc.protectedName' , nil )
127+ config .set (nil , ' Lua.doc.regengine' , nil )
128+
107129TEST [[
108130---@class A
109131---@field private x number
You can’t perform that action at this time.
0 commit comments