Skip to content

Commit bf65753

Browse files
committed
supports finding definition for class and alias
1 parent 02033e0 commit bf65753

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* `NEW` code lens. This feature is disabled by default.
55
* `NEW` settings:
66
* `Lua.codeLens.enable`: Enable code lens.
7+
* `CHG` supports finding definition for `@class` and `@alias`, since they may defined multi times.
78
* `FIX` [#831]
89
* `FIX` [#1729]
910
* `FIX` [#1737]

script/core/definition.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ return function (uri, offset)
205205
or src.type == 'doc.enum.name' then
206206
if source.type ~= 'doc.type.name'
207207
and source.type ~= 'doc.extends.name'
208-
and source.type ~= 'doc.see.name' then
208+
and source.type ~= 'doc.see.name'
209+
and source.type ~= 'doc.class.name'
210+
and source.type ~= 'doc.alias.name' then
209211
goto CONTINUE
210212
end
211213
end

script/vm/compiler.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,7 @@ local compilerSwitch = util.switch()
16261626
end
16271627
end)
16281628
: case 'doc.class.name'
1629+
: case 'doc.alias.name'
16291630
: call(function (source)
16301631
vm.setNode(source, vm.compileNode(source.parent))
16311632
end)

script/vm/ref.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ local function searchWord(source, pushResult, defMap, fileNotify)
8686
if not text then
8787
return
8888
end
89-
if not text:match(key) then
89+
if not text:find(key, 1, true) then
9090
return
9191
end
9292
local state = files.getState(uri)

test/definition/luadoc.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,3 +975,15 @@ print(x.<?a?>)
975975
]]
976976

977977
config.set(nil, 'Lua.type.castNumberToInteger', true)
978+
979+
TEST [[
980+
---@class <!A!>
981+
982+
---@class <!<?A?>!>
983+
]]
984+
985+
TEST [[
986+
---@alias <!A!> number
987+
988+
---@alias <!<?A?>!> number
989+
]]

0 commit comments

Comments
 (0)