summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/definition.lua6
-rw-r--r--script/core/diagnostics/duplicate-doc-class.lua2
-rw-r--r--script/core/hover/label.lua3
-rw-r--r--script/core/reference.lua6
-rw-r--r--script/core/searcher.lua15
-rw-r--r--script/core/type-definition.lua6
6 files changed, 13 insertions, 25 deletions
diff --git a/script/core/definition.lua b/script/core/definition.lua
index b6b45871..fb74b73a 100644
--- a/script/core/definition.lua
+++ b/script/core/definition.lua
@@ -8,8 +8,8 @@ local guide = require 'parser.guide'
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = searcher.getUri(a.target)
- local u2 = searcher.getUri(b.target)
+ local u1 = guide.getUri(a.target)
+ local u2 = guide.getUri(b.target)
if u1 == u2 then
return a.target.start < b.target.start
else
@@ -21,7 +21,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local uri = searcher.getUri(res)
+ local uri = guide.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else
diff --git a/script/core/diagnostics/duplicate-doc-class.lua b/script/core/diagnostics/duplicate-doc-class.lua
index 20eedb5e..780d15b9 100644
--- a/script/core/diagnostics/duplicate-doc-class.lua
+++ b/script/core/diagnostics/duplicate-doc-class.lua
@@ -28,7 +28,7 @@ return function (uri, callback)
cache[name][#cache[name]+1] = {
start = otherDoc.start,
finish = otherDoc.finish,
- uri = searcher.getUri(otherDoc),
+ uri = guide.getUri(otherDoc),
}
end
end
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index 434eaff1..0d2bcf6f 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -9,6 +9,7 @@ local searcher = require 'core.searcher'
local lang = require 'language'
local config = require 'config'
local files = require 'files'
+local guide = require 'parser.guide'
local function asFunction(source, oop)
local name
@@ -164,7 +165,7 @@ local function asNumber(source)
if type(num) ~= 'number' then
return nil
end
- local uri = searcher.getUri(source)
+ local uri = guide.getUri(source)
local text = files.getText(uri)
if not text then
return nil
diff --git a/script/core/reference.lua b/script/core/reference.lua
index 109bf601..8f113a8d 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -7,8 +7,8 @@ local findSource = require 'core.find-source'
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = searcher.getUri(a.target)
- local u2 = searcher.getUri(b.target)
+ 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,7 +20,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local uri = searcher.getUri(res)
+ local uri = guide.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 9ac8f0a8..c6bf4f6d 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -71,6 +71,7 @@ local ignoredIDs = {
['dn:thread'] = true,
}
+---@class searcher
local m = {}
---@alias guide.searchmode '"ref"'|'"def"'|'"field"'|'"allref"'|'"alldef"'
@@ -200,20 +201,6 @@ local function pushResult(status, mode, source, force)
end
end
----获取uri
----@param obj parser.guide.object
----@return uri
-function m.getUri(obj)
- if obj.uri then
- return obj.uri
- end
- local root = getRoot(obj)
- if root then
- return root.uri
- end
- return ''
-end
-
---@param obj parser.guide.object
---@return parser.guide.object?
function m.getObjectValue(obj)
diff --git a/script/core/type-definition.lua b/script/core/type-definition.lua
index 4dd9ac32..6d45b601 100644
--- a/script/core/type-definition.lua
+++ b/script/core/type-definition.lua
@@ -9,8 +9,8 @@ local infer = require 'core.infer'
local function sortResults(results)
-- 先按照顺序排序
table.sort(results, function (a, b)
- local u1 = searcher.getUri(a.target)
- local u2 = searcher.getUri(b.target)
+ local u1 = guide.getUri(a.target)
+ local u2 = guide.getUri(b.target)
if u1 == u2 then
return a.target.start < b.target.start
else
@@ -22,7 +22,7 @@ local function sortResults(results)
for i = #results, 1, -1 do
local res = results[i].target
local f = res.finish
- local uri = searcher.getUri(res)
+ local uri = guide.getUri(res)
if lf and f > lf and uri == lu then
table.remove(results, i)
else