Skip to content

Commit 9bcc9d5

Browse files
committed
cleanup
1 parent 2dab40c commit 9bcc9d5

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

script/vm/global.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ end
3434
---@param uri uri
3535
---@param source parser.object
3636
function mt:addGet(uri, source)
37+
if PREVIEW then
38+
return
39+
end
3740
local link = self.links[uri]
3841
if not link.gets then
3942
link.gets = {}

script/vm/ref.lua

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@ simpleSwitch = util.switch()
2626
end
2727
end
2828
end)
29-
: case 'doc.alias.name'
30-
: call(function (source, pushResult)
31-
local global = vm.getGlobal('type', source[1])
32-
if not global then
33-
return
34-
end
35-
for _, get in ipairs(global:getGets(guide.getUri(source))) do
36-
pushResult(get)
37-
end
38-
for _, set in ipairs(global:getSets(guide.getUri(source))) do
39-
pushResult(set)
40-
end
41-
end)
4229

4330
---@async
4431
local function searchInAllFiles(suri, searcher, notify)
@@ -229,18 +216,23 @@ function searchByParentNode(source, pushResult, defMap, fileNotify)
229216
nodeSwitch(source.type, source, pushResult, defMap, fileNotify)
230217
end
231218

232-
local function searchByNode(source, pushResult)
233-
local node = vm.compileNode(source)
219+
local function searchByGlobal(source, pushResult)
220+
if source.type == 'field'
221+
or source.type == 'method'
222+
or source.type == 'doc.class.name'
223+
or source.type == 'doc.alias.name' then
224+
source = source.parent
225+
end
226+
local node = vm.getGlobalNode(source)
234227
if not node then
235228
return
236229
end
237230
local uri = guide.getUri(source)
238-
for n in node:eachObject() do
239-
if n.type == 'global' then
240-
for _, get in ipairs(n:getGets(uri)) do
241-
pushResult(get)
242-
end
243-
end
231+
for _, set in ipairs(node:getSets(uri)) do
232+
pushResult(set)
233+
end
234+
for _, get in ipairs(node:getGets(uri)) do
235+
pushResult(get)
244236
end
245237
end
246238

@@ -292,7 +284,7 @@ function vm.getRefs(source, fileNotify)
292284

293285
searchBySimple(source, pushResult)
294286
searchByLocalID(source, pushResult)
295-
searchByNode(source, pushResult)
287+
searchByGlobal(source, pushResult)
296288
local defMap = searchByDef(source, pushResult)
297289
searchByParentNode(source, pushResult, defMap, fileNotify)
298290

test/crossfile/references.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,18 @@ TEST {
373373
]]
374374
},
375375
}
376+
377+
TEST {
378+
{
379+
path = 'a.lua',
380+
content = [[
381+
---@alias <~XX~> number
382+
]]
383+
},
384+
{
385+
path = 'b.lua',
386+
content = [[
387+
---@type <!XX!>
388+
]]
389+
}
390+
}

0 commit comments

Comments
 (0)