summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-14 17:54:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-14 17:54:14 +0800
commit9ad3fdce5bd6c889f5734eddd04708595e1fa621 (patch)
tree028fe13842e0b7f40fd189f1109ef8ec1245812c /test
parent0d79784ccf47a03f9f35e1afbd579ecbab0acd5a (diff)
downloadlua-language-server-9ad3fdce5bd6c889f5734eddd04708595e1fa621.zip
`---@source`
Diffstat (limited to 'test')
-rw-r--r--test/tclient/init.lua1
-rw-r--r--test/tclient/tests/jump-source.lua76
2 files changed, 77 insertions, 0 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua
index 070cf337..80aae53a 100644
--- a/test/tclient/init.lua
+++ b/test/tclient/init.lua
@@ -8,4 +8,5 @@ require 'tclient.tests.resolve-completion'
require 'tclient.tests.performance-jass-common'
require 'tclient.tests.hover-pairs'
require 'tclient.tests.change-workspace-folder'
+require 'tclient.tests.jump-source'
require 'tclient.tests.build-meta'
diff --git a/test/tclient/tests/jump-source.lua b/test/tclient/tests/jump-source.lua
new file mode 100644
index 00000000..ff679826
--- /dev/null
+++ b/test/tclient/tests/jump-source.lua
@@ -0,0 +1,76 @@
+local lclient = require 'lclient'
+local util = require 'utility'
+local ws = require 'workspace'
+local files = require 'files'
+local furi = require 'file-uri'
+local fs = require 'bee.filesystem'
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+ client:initialize()
+
+ ws.awaitReady()
+
+ client:notify('textDocument/didOpen', {
+ textDocument = {
+ uri = furi.encode('1.lua'),
+ languageId = 'lua',
+ version = 0,
+ text = [[
+---@class AAA
+---@source file:///xxx.lua:50
+---@field x number
+local mt = {}
+
+---@source file:///yyy.lua:30
+function mt:ff() end
+]]
+ }
+ })
+
+ client:notify('textDocument/didOpen', {
+ textDocument = {
+ uri = furi.encode('main.lua'),
+ languageId = 'lua',
+ version = 0,
+ text = [[
+---@type AAA
+local a
+
+print(a.x)
+print(a.ff)
+]]
+ }
+ })
+
+ local locations = client:awaitRequest('textDocument/definition', {
+ textDocument = { uri = furi.encode('main.lua') },
+ position = { line = 3, character = 9 },
+ })
+
+ assert(util.equal(locations, {
+ {
+ uri = 'file:///xxx.lua',
+ range = {
+ start = { line = 49, character = 0 },
+ ['end'] = { line = 49, character = 0 },
+ }
+ }
+ }))
+
+ local locations = client:awaitRequest('textDocument/definition', {
+ textDocument = { uri = furi.encode('main.lua') },
+ position = { line = 4, character = 9 },
+ })
+
+ assert(util.equal(locations, {
+ {
+ uri = 'file:///yyy.lua',
+ range = {
+ start = { line = 29, character = 0 },
+ ['end'] = { line = 29, character = 0 },
+ }
+ }
+ }))
+end)