summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-09 22:26:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-09 22:26:38 +0800
commite3637203957ba1ed9b4949bb5e1550c5dea6955e (patch)
treef07216a5ac4ac335929bccd2403d1a9829fe128a /script-beta/core
parent7eccb5fd20db8f4d983a0426fe6f852559d22921 (diff)
downloadlua-language-server-e3637203957ba1ed9b4949bb5e1550c5dea6955e.zip
封装一下 guide.getUri
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/definition.lua7
-rw-r--r--script-beta/core/reference.lua7
-rw-r--r--script-beta/core/rename.lua4
3 files changed, 8 insertions, 10 deletions
diff --git a/script-beta/core/definition.lua b/script-beta/core/definition.lua
index ae6dce4a..8e76bfab 100644
--- a/script-beta/core/definition.lua
+++ b/script-beta/core/definition.lua
@@ -7,8 +7,8 @@ local findSource = require 'core.find-source'
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = guide.getRoot(a.target).uri
- local u2 = guide.getRoot(b.target).uri
+ local u1 = guide.getUri(a.target)
+ local u2 = guide.getUri(b.target)
if u1 == u2 then
return a.target.start < b.target.start
else
@@ -20,8 +20,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local root = guide.getRoot(res)
- local uri = root and root.uri
+ local uri = guide.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else
diff --git a/script-beta/core/reference.lua b/script-beta/core/reference.lua
index 025af99b..56580d0b 100644
--- a/script-beta/core/reference.lua
+++ b/script-beta/core/reference.lua
@@ -11,8 +11,8 @@ end
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = guide.getRoot(a.target).uri
- local u2 = guide.getRoot(b.target).uri
+ local u1 = guide.getUri(a.target)
+ local u2 = guide.getUri(b.target)
if u1 == u2 then
return a.target.start < b.target.start
else
@@ -24,8 +24,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local root = guide.getRoot(res)
- local uri = root and root.uri
+ local uri = guide.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else
diff --git a/script-beta/core/rename.lua b/script-beta/core/rename.lua
index 23929858..2de21bac 100644
--- a/script-beta/core/rename.lua
+++ b/script-beta/core/rename.lua
@@ -174,7 +174,7 @@ local function renameField(source, newname, callback)
end
callback(source, source.start, source.finish, newname)
elseif parent.type == 'setmethod' then
- local uri = guide.getRoot(source).uri
+ local uri = guide.getUri(source)
local text = files.getText(uri)
local func = parent.value
-- function mt:name () end --> mt['newname'] = function (self) end
@@ -377,7 +377,7 @@ function m.rename(uri, pos, newname)
start = start,
finish = finish,
text = text,
- uri = guide.getRoot(target).uri,
+ uri = guide.getUri(target),
}
end)