@@ -5,9 +5,8 @@ local guide = require 'parser.guide'
55local vm = require ' vm.vm'
66
77--- @class vm.infer
8+ --- @field node vm.node
89--- @field views table<string , boolean>
9- --- @field cachedView ? string
10- --- @field node ? vm.node
1110--- @field _drop table
1211local mt = {}
1312mt .__index = mt
@@ -137,7 +136,8 @@ local viewNodeSwitch;viewNodeSwitch = util.switch()
137136 local node = vm .compileNode (source )
138137 for c in node :eachObject () do
139138 if guide .isLiteral (c ) then
140- local view = vm .viewObject (c , uri )
139+ --- @cast c parser.object
140+ local view = vm .getInfer (c ):view (uri )
141141 if view then
142142 infer ._drop [view ] = true
143143 end
@@ -239,7 +239,7 @@ local viewNodeSwitch;viewNodeSwitch = util.switch()
239239--- @class vm.node
240240--- @field lastInfer ? vm.infer
241241
242- --- @param source vm.object | vm.node
242+ --- @param source vm.node. object | vm.node
243243--- @return vm.infer
244244function vm .getInfer (source )
245245 --- @type vm.node
289289
290290--- @param uri uri
291291function mt :_eraseAlias (uri )
292+ local count = 0
293+ for _ in pairs (self .views ) do
294+ count = count + 1
295+ end
296+ if count <= 1 then
297+ return
298+ end
292299 local expandAlias = config .get (uri , ' Lua.hover.expandAlias' )
293300 for n in self .node :eachObject () do
294301 if n .type == ' global' and n .cate == ' type' then
@@ -447,23 +454,6 @@ function mt:eachView(uri)
447454 return next , self .views
448455end
449456
450- --- @param other vm.infer
451- --- @return vm.infer
452- function mt :merge (other )
453- if self == vm .NULL then
454- return other
455- end
456- if other == vm .NULL then
457- return self
458- end
459-
460- local infer = setmetatable ({
461- node = vm .createNode (self .node , other .node ),
462- }, mt )
463-
464- return infer
465- end
466-
467457--- @return string ?
468458function mt :viewLiterals ()
469459 if not self .node then
@@ -539,7 +529,7 @@ function vm.viewKey(source, uri)
539529 if # source .types == 1 then
540530 return vm .viewKey (source .types [1 ], uri )
541531 else
542- local key = vm .viewObject (source , uri )
532+ local key = vm .getInfer (source ): view ( uri )
543533 return ' [' .. key .. ' ]'
544534 end
545535 end
0 commit comments