summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server-beta/src/core/definition.lua2
-rw-r--r--server-beta/src/parser/compile.lua2
-rw-r--r--server-beta/src/proto/provider.lua7
-rw-r--r--server-beta/src/searcher/eachRef.lua3
-rw-r--r--server-beta/test/crossfile/definition.lua19
-rw-r--r--server-beta/test/diagnostics/init.lua5
6 files changed, 32 insertions, 6 deletions
diff --git a/server-beta/src/core/definition.lua b/server-beta/src/core/definition.lua
index 1c2adf3e..9e69d27f 100644
--- a/server-beta/src/core/definition.lua
+++ b/server-beta/src/core/definition.lua
@@ -19,7 +19,7 @@ local function findDef(source, callback)
end
searcher.eachRef(source, function (info)
if info.mode == 'declare'
- or info.mode == 'set'
+ or info.mode == 'set'
or info.mode == 'return' then
local src = info.source
local root = guide.getRoot(src)
diff --git a/server-beta/src/parser/compile.lua b/server-beta/src/parser/compile.lua
index 9f92fb53..9db0c3e3 100644
--- a/server-beta/src/parser/compile.lua
+++ b/server-beta/src/parser/compile.lua
@@ -338,11 +338,11 @@ function Compile(obj, parent)
return
end
Compiled[obj] = true
+ obj.parent = parent
local f = vmMap[obj.type]
if not f then
return
end
- obj.parent = parent
f(obj)
end
diff --git a/server-beta/src/proto/provider.lua b/server-beta/src/proto/provider.lua
index 1799a284..9f3b5697 100644
--- a/server-beta/src/proto/provider.lua
+++ b/server-beta/src/proto/provider.lua
@@ -163,10 +163,11 @@ proto.on('textDocument/definition', function (params)
for i, info in ipairs(result) do
local targetUri = info.uri
local targetLines = files.getLines(targetUri)
+ local targetText = files.getText(targetUri)
response[i] = interface.locationLink(targetUri
- , interface.range(targetLines, text, info.target.start - 1, info.target.finish)
- , interface.range(targetLines, text, info.target.start - 1, info.target.finish)
- , interface.range(lines , text, info.source.start - 1, info.source.finish)
+ , interface.range(targetLines, targetText, info.target.start - 1, info.target.finish)
+ , interface.range(targetLines, targetText, info.target.start - 1, info.target.finish)
+ , interface.range(lines, text, info.source.start - 1, info.source.finish)
)
end
return response
diff --git a/server-beta/src/searcher/eachRef.lua b/server-beta/src/searcher/eachRef.lua
index 48c266bc..4cefa405 100644
--- a/server-beta/src/searcher/eachRef.lua
+++ b/server-beta/src/searcher/eachRef.lua
@@ -51,7 +51,7 @@ local function ofSpecialCall(call, func, index, callback)
local result = workspace.findUrisByRequirePath(literal, true)
local myUri = guide.getRoot(call).uri
for _, uri in ipairs(result) do
- if uri ~= myUri then
+ if not files.eq(uri, myUri) then
local ast = files.getAst(uri)
if ast then
searcher.eachRef(ast.ast, callback)
@@ -78,6 +78,7 @@ local function ofValue(value, callback)
source = value,
mode = 'value',
}
+ searcher.eachRef(value, callback)
end
local function ofSelf(loc, callback)
diff --git a/server-beta/test/crossfile/definition.lua b/server-beta/test/crossfile/definition.lua
index f218bf69..2f70e5e8 100644
--- a/server-beta/test/crossfile/definition.lua
+++ b/server-beta/test/crossfile/definition.lua
@@ -380,6 +380,25 @@ TEST {
}
}
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local <!x!>
+ return {
+ <!x!> = x,
+ }
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ print(t.<?x?>)
+ ]],
+ },
+}
+
--TEST {
-- {
-- path = 'a.lua',
diff --git a/server-beta/test/diagnostics/init.lua b/server-beta/test/diagnostics/init.lua
index 555bc0a8..bd922825 100644
--- a/server-beta/test/diagnostics/init.lua
+++ b/server-beta/test/diagnostics/init.lua
@@ -398,6 +398,11 @@ end
]]
TEST [[
+local <!t!> = {}
+t[1] = 1
+]]
+
+TEST [[
---@class <!Class!>
---@class <!Class!>
]]