Skip to content

Commit df58ac0

Browse files
committed
update
1 parent af4e309 commit df58ac0

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

script/vm/compiler.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function m.getClassFields(suri, node, key, pushResult)
150150
return
151151
end
152152
mark[name] = true
153-
for _, set in ipairs(class:getSets()) do
153+
for _, set in ipairs(class:getSets(suri)) do
154154
if set.type == 'doc.class' then
155155
-- check ---@field
156156
local hasFounded
@@ -1408,9 +1408,9 @@ local function compileByNode(source)
14081408
end
14091409

14101410
---@param source vm.node
1411-
local function compileByGlobal(source)
1411+
local function compileByGlobal(uri, source)
1412+
uri = uri or guide.getUri(source)
14121413
if source.type == 'global' then
1413-
local uri = guide.getUri(source)
14141414
nodeMgr.setNode(source, source)
14151415
if source.cate == 'variable' then
14161416
local hasMarkDoc
@@ -1453,7 +1453,7 @@ local function compileByGlobal(source)
14531453
return
14541454
end
14551455
if source._globalNode then
1456-
nodeMgr.setNode(source, m.compileNode(source._globalNode))
1456+
nodeMgr.setNode(source, m.compileNode(source._globalNode, uri))
14571457
return
14581458
end
14591459
end
@@ -1478,7 +1478,7 @@ end
14781478

14791479
---@param source parser.object
14801480
---@return vm.node
1481-
function m.compileNode(source)
1481+
function m.compileNode(source, uri)
14821482
if not source then
14831483
return false
14841484
end
@@ -1493,7 +1493,7 @@ function m.compileNode(source)
14931493
end
14941494

14951495
nodeMgr.nodeCache[source] = false
1496-
compileByGlobal(source)
1496+
compileByGlobal(uri, source)
14971497
compileByNode(source)
14981498

14991499
--localMgr.subscribeLocal(source, source._node)

script/vm/def.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ local function searchByNode(source, pushResult)
200200
if not node then
201201
return
202202
end
203+
local suri = guide.getUri(source)
203204
for n in nodeMgr.eachNode(node) do
204205
if n.type == 'global' then
205-
for _, set in ipairs(n:getSets()) do
206+
for _, set in ipairs(n:getSets(suri)) do
206207
pushResult(set)
207208
end
208209
else

script/vm/global-manager.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function m.getGlobalSets(suri, cate)
269269
local globals = m.getGlobals(cate)
270270
local result = {}
271271
for _, global in ipairs(globals) do
272-
local sets = global:getSets()
272+
local sets = global:getSets(suri)
273273
for _, set in ipairs(sets) do
274274
result[#result+1] = set
275275
end

script/vm/infer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function mt:_eraseAlias()
201201
local expandAlias = config.get(self.uri, 'Lua.hover.expandAlias')
202202
for n in nodeMgr.eachNode(self.node) do
203203
if n.type == 'global' and n.cate == 'type' then
204-
for _, set in ipairs(n:getSets()) do
204+
for _, set in ipairs(n:getSets(self.uri)) do
205205
if set.type == 'doc.alias' then
206206
if expandAlias then
207207
self.views[n.name] = nil

script/vm/ref.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ local function searchByNode(source, pushResult)
259259
if not node then
260260
return
261261
end
262+
local uri = guide.getUri(source)
262263
for n in nodeMgr.eachNode(node) do
263264
if n.type == 'global' then
264-
for _, get in ipairs(n:getGets()) do
265+
for _, get in ipairs(n:getGets(uri)) do
265266
pushResult(get)
266267
end
267268
end

test/tclient/tests/multi-workspace.lua

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ lclient():start(function (client)
8282
files.setText(rootUri .. '/ws1/unittest.lua', [[
8383
GLOBAL = 1
8484
---@class ZAAA
85-
---@type
85+
---@type Z
8686
]])
8787

8888
files.setText(rootUri .. '/ws2/unittest.lua', [[
8989
GLOBAL = 2
9090
---@class ZBBB
91-
---@type
91+
---@type Z
9292
]])
9393

9494
local defs1 = client:awaitRequest('textDocument/definition', {
@@ -112,4 +112,26 @@ GLOBAL = 2
112112
},
113113
})
114114
assert(#defs2 == 1)
115+
116+
local comps1 = client:awaitRequest('textDocument/completion', {
117+
textDocument = {
118+
uri = rootUri .. '/ws1/unittest.lua',
119+
},
120+
position = {
121+
line = 2,
122+
character = 10,
123+
},
124+
})
125+
assert(#comps1.items == 1)
126+
127+
local comps2 = client:awaitRequest('textDocument/completion', {
128+
textDocument = {
129+
uri = rootUri .. '/ws2/unittest.lua',
130+
},
131+
position = {
132+
line = 2,
133+
character = 10,
134+
},
135+
})
136+
assert(#comps2.items == 1)
115137
end)

0 commit comments

Comments
 (0)