Skip to content

Commit 5fb08df

Browse files
committed
don't show constructor in hover
1 parent 93dab3c commit 5fb08df

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

script/vm/compiler.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local vm = require 'vm.vm'
1111
---@field _node vm.node
1212
---@field cindex integer
1313
---@field func parser.object
14+
---@field hideView boolean
1415

1516
-- 该函数有副作用,会给source绑定node!
1617
---@param source parser.object
@@ -28,6 +29,12 @@ function vm.bindDocs(source)
2829
end
2930
if doc.type == 'doc.class' then
3031
vm.setNode(source, vm.compileNode(doc))
32+
for j = i + 1, #docs do
33+
local overload = docs[j]
34+
if overload.type == 'doc.overload' then
35+
overload.overload.hideView = true
36+
end
37+
end
3138
return true
3239
end
3340
if doc.type == 'doc.param' then

script/vm/infer.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,11 @@ function mt:_computeViews(uri)
386386
self.views = {}
387387

388388
for n in self.node:eachObject() do
389-
local view = viewNodeSwitch(n.type, n, self, uri)
390-
if view then
391-
self.views[view] = true
389+
if not n.hideView then
390+
local view = viewNodeSwitch(n.type, n, self, uri)
391+
if view then
392+
self.views[view] = true
393+
end
392394
end
393395
end
394396

test/hover/init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,3 +2466,12 @@ local t: {
24662466
[3]: table,
24672467
}
24682468
]]
2469+
2470+
TEST [[
2471+
---@class A
2472+
---@overload fun(x: number): boolean
2473+
local <?x?>
2474+
]]
2475+
[[
2476+
local x: A
2477+
]]

0 commit comments

Comments
 (0)