summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-10 10:19:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-10 10:19:42 +0800
commitd7ab66b25db024f2cb375192f36d3c72313e0e34 (patch)
treee63320e3c127fdd438b7c708989ed5f84771406d /script/vm
parentf616bd2baf6a03324d1d5d6df90607f770ea0a51 (diff)
downloadlua-language-server-d7ab66b25db024f2cb375192f36d3c72313e0e34.zip
cleanup
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/getDocs.lua28
-rw-r--r--script/vm/getGlobals.lua30
2 files changed, 43 insertions, 15 deletions
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index ba4fb560..8ee942d1 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -12,18 +12,32 @@ local noder = require 'core.noder'
---@param name? string
---@return parser.guide.object[]
function vm.getDocDefines(name)
- name = name or ''
local cache = vm.getCache 'getDocDefines'
if cache[name] then
return cache[name]
end
local results = {}
- local id = 'def:dn:' .. name
- for noders in collector.each(id) do
- for source in noder.eachSource(noders, id) do
- if source.type == 'doc.class.name'
- or source.type == 'doc.alias.name' then
- results[#results+1] = source
+ if name == '*' then
+ for noders in collector.each('def:dn:') do
+ for id in noder.eachID(noders) do
+ if id:sub(1, 3) == 'dn:'
+ and not id:find(noder.SPLIT_CHAR) then
+ for source in noder.eachSource(noders, id) do
+ if guide.isSet(source) then
+ results[#results+1] = source
+ end
+ end
+ end
+ end
+ end
+ else
+ local id = 'dn:' .. name
+ for noders in collector.each('def:' .. id) do
+ for source in noder.eachSource(noders, id) do
+ if source.type == 'doc.class.name'
+ or source.type == 'doc.alias.name' then
+ results[#results+1] = source
+ end
end
end
end
diff --git a/script/vm/getGlobals.lua b/script/vm/getGlobals.lua
index 5d64cef6..d794a394 100644
--- a/script/vm/getGlobals.lua
+++ b/script/vm/getGlobals.lua
@@ -1,4 +1,5 @@
local collector = require 'core.collector'
+local guide = require 'parser.guide'
---@diagnostic disable-next-line
---@class vm
local vm = require 'vm.vm'
@@ -21,19 +22,32 @@ function vm.getGlobalSets(name)
end
local results = {}
cache[name] = results
- local id
if name == '*' then
- id = 'def:g:'
+ for noders in collector.each('def:g:') do
+ for id in noder.eachID(noders) do
+ if id:sub(1, 2) == 'g:'
+ and not id:find(noder.SPLIT_CHAR) then
+ for source in noder.eachSource(noders, id) do
+ if guide.isSet(source) then
+ results[#results+1] = source
+ end
+ end
+ end
+ end
+ end
else
+ local id
if type(name) == 'string' then
- id = ('def:g:%s%s'):format(noder.STRING_CHAR, name)
+ id = ('g:%s%s'):format(noder.STRING_CHAR, name)
else
- id = ('def:g:%s'):format(noder.STRING_CHAR, name)
+ id = ('g:%s'):format(noder.STRING_CHAR, name)
end
- end
- for noders in collector.each(id) do
- for source in noder.eachSource(noders, id) do
- results[#results+1] = source
+ for noders in collector.each('def:' .. id) do
+ for source in noder.eachSource(noders, id) do
+ if guide.isSet(source) then
+ results[#results+1] = source
+ end
+ end
end
end
return results