Skip to content

Commit e44142d

Browse files
committed
resolve LuaLS#632 ---@module 'moduleName'
1 parent f04887d commit e44142d

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

changelog.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
+ `Lua.completion.requireSeparator`
99
* `NEW` diagnostics:
1010
+ `different-requires`
11-
* `NEW` supports `---@CustomClass<string, number>`
11+
* `NEW` `---@CustomClass<string, number>`
1212
* `NEW` supports `$/cancelRequest`
13-
* `NEW` supports `EventEmitter`
13+
* `NEW` `EventEmitter`
1414
```lua
1515
--- @class Emit
1616
--- @field on fun(eventName: string, cb: function)
@@ -28,6 +28,11 @@
2828
-- should be s: string
2929
end)
3030
```
31+
* `NEW` `---@module 'moduleName'`
32+
```lua
33+
---@module 'mylib'
34+
local lib -- the same as `local lib = require 'mylib'`
35+
```
3136
* `CHG` hover: improve showing multi defines
3237
* `CHG` hover: improve showing multi comments at enums
3338
* `CHG` hover: shows method

script/core/noder.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,20 @@ compileNodeMap = util.switch()
10701070
end
10711071
end
10721072
end)
1073+
: case 'doc.module'
1074+
: call(function (noders, id, source)
1075+
if not source.module then
1076+
return
1077+
end
1078+
for _, src in ipairs(source.bindSources) do
1079+
if guide.isSet(src) then
1080+
local sourceID = getID(src)
1081+
if sourceID then
1082+
noders.require[sourceID] = source.module
1083+
end
1084+
end
1085+
end
1086+
end)
10731087
: case 'doc.param'
10741088
: call(function (noders, id, source)
10751089
pushForward(noders, id, getID(source.extends))

test/crossfile/definition.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ TEST {
128128
},
129129
}
130130

131+
TEST {
132+
{
133+
path = 'a.lua',
134+
content = 'local <!t!> = 1; return <!t!>',
135+
},
136+
{
137+
path = 'b.lua',
138+
content = [[
139+
---@module 'a'
140+
local <~t~>
141+
]],
142+
},
143+
}
144+
131145
--if require 'bee.platform'.OS == 'Windows' then
132146
--TEST {
133147
-- {

0 commit comments

Comments
 (0)