summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/matcher/definition.lua48
-rw-r--r--server/src/matcher/vm.lua2
-rw-r--r--server/src/method/workspace/didChangeWatchedFiles.lua4
3 files changed, 31 insertions, 23 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua
index b325f46c..57c4be5d 100644
--- a/server/src/matcher/definition.lua
+++ b/server/src/matcher/definition.lua
@@ -5,36 +5,43 @@ local function parseResult(vm, result)
local tp = result.type
if tp == 'local' then
if result.value.uri ~= vm.uri then
- positions[#positions+1] = {
- result.value.source.start,
- result.value.source.finish,
- result.value.uri,
- }
- else
for _, info in ipairs(result) do
- if info.type == 'local' then
- positions[#positions+1] = {info.source.start, info.source.finish}
+ if info.type == 'set' then
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ info.source.uri,
+ }
end
end
+ else
+ for _, info in ipairs(result) do
+ if info.type == 'local' then
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ info.source.uri,
+ }
+ end
+ end
end
elseif tp == 'field' then
- if result.value.uri ~= vm.uri then
- positions[#positions+1] = {
- result.value.source.start,
- result.value.source.finish,
- result.value.uri,
- }
- else
- for _, info in ipairs(result) do
- if info.type == 'set' then
- positions[#positions+1] = {info.source.start, info.source.finish}
- end
+ for _, info in ipairs(result) do
+ if info.type == 'set' then
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ info.source.uri,
+ }
end
end
elseif tp == 'label' then
for _, info in ipairs(result) do
if info.type == 'set' then
- positions[#positions+1] = {info.source.start, info.source.finish}
+ positions[#positions+1] = {
+ info.source.start,
+ info.source.finish,
+ }
end
end
end
@@ -46,6 +53,7 @@ return function (vm, pos)
if not result then
return nil
end
+
local positions = parseResult(vm, result)
return positions
end
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index b7941b2c..b8b3a18b 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -107,6 +107,7 @@ function mt:addInfo(obj, type, source)
source = source or DefaultSource,
}
if source then
+ source.uri = self.uri
local other = self.results.sources[source]
if other then
if other.type == 'multi-source' then
@@ -578,7 +579,6 @@ function mt:createValue(tp, source, v)
type = tp,
source = source or DefaultSource,
value = v,
- uri = self.uri,
}
local lib = library.object[tp]
if lib then
diff --git a/server/src/method/workspace/didChangeWatchedFiles.lua b/server/src/method/workspace/didChangeWatchedFiles.lua
index df57baff..8f0feecd 100644
--- a/server/src/method/workspace/didChangeWatchedFiles.lua
+++ b/server/src/method/workspace/didChangeWatchedFiles.lua
@@ -17,11 +17,11 @@ return function (lsp, params)
-- 删除文件后,清除该文件的诊断
lsp:clearDiagnostics(change.uri)
end
- if lsp:isOpen(change.uri) then
+ if lsp:getVM(change.uri) then
needReset = true
end
end
- -- 发生任何文件变化后,重新计算当前的打开文件
+ -- 缓存过的文件发生变化后,重新计算
if needReset then
lsp.workspace:reset()
end