summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-06-02 15:59:52 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-06-02 15:59:52 +0800
commitf2e5c8f364d72331e6f1410ac084f73b50c51a8e (patch)
tree9a33b8c8cd127be4a268f12080157b124b95be03 /script
parentff4513f65d5c09fb84544263a6a90aa7b8197a4e (diff)
downloadlua-language-server-f2e5c8f364d72331e6f1410ac084f73b50c51a8e.zip
update
Diffstat (limited to 'script')
-rw-r--r--script/core/completion.lua6
-rw-r--r--script/core/diagnostics/undefined-field.lua2
-rw-r--r--script/core/hover/description.lua7
-rw-r--r--script/core/hover/label.lua29
-rw-r--r--script/vm/getMeta.lua53
-rw-r--r--script/vm/init.lua1
6 files changed, 18 insertions, 80 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 064dcc28..c9420d85 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1401,7 +1401,7 @@ local function checkTableLiteralFieldByCall(ast, text, offset, call, defs, index
if not param then
goto CONTINUE
end
- local defs = vm.getDefFields(param, 0)
+ local defs = vm.getDefs(param, '*')
for _, field in ipairs(defs) do
local name = guide.getKeyName(field)
if name and not mark[name] then
@@ -1728,14 +1728,14 @@ local function buildLuaDocOfFunction(func)
local returns = {}
if func.args then
for _, arg in ipairs(func.args) do
- args[#args+1] = vm.getInferType(arg)
+ args[#args+1] = infer.searchAndViewInfers(arg)
end
end
if func.returns then
for _, rtns in ipairs(func.returns) do
for n = 1, #rtns do
if not returns[n] then
- returns[n] = vm.getInferType(rtns[n])
+ returns[n] = infer.searchAndViewInfers(rtns[n])
end
end
end
diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua
index 7dd90840..6b2e718f 100644
--- a/script/core/diagnostics/undefined-field.lua
+++ b/script/core/diagnostics/undefined-field.lua
@@ -65,7 +65,7 @@ return function (uri, callback)
local empty = true
for _, docClass in ipairs(allDocClass) do
tracy.ZoneBeginN('undefined-field getDefFields')
- local refs = vm.getDefFields(docClass)
+ local refs = vm.getDefs(docClass, '*')
tracy.ZoneEnd()
for _, ref in ipairs(refs) do
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 327ddbe1..bcc3065a 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -225,13 +225,14 @@ local function getBindEnums(source, docGroup)
end
local function tryDocFieldUpComment(source)
- if source.type ~= 'doc.field' then
+ if source.type ~= 'doc.field.name' then
return
end
- if not source.bindGroup then
+ local docField = source.parent
+ if not docField.bindGroup then
return
end
- local comment = getBindComment(source, source.bindGroup, source)
+ local comment = getBindComment(docField, docField.bindGroup, docField)
return comment
end
diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua
index ce77dfe6..032f19c0 100644
--- a/script/core/hover/label.lua
+++ b/script/core/hover/label.lua
@@ -119,30 +119,21 @@ local function asField(source)
return asValue(source, 'field')
end
-local function asDocField(source)
- local name = source.field[1]
+local function asDocFieldName(source)
+ local name = source[1]
+ local docField = source.parent
local class
- for _, doc in ipairs(source.bindGroup) do
+ for _, doc in ipairs(docField.bindGroup) do
if doc.type == 'doc.class' then
class = doc
break
end
end
- local infers = {}
- for _, infer in ipairs(vm.getInfers(source.extends) or {}) do
- infers[#infers+1] = infer
- end
+ local view = infer.searchAndViewInfers(docField.extends)
if not class then
- return ('field ?.%s: %s'):format(
- name,
- searcher.viewInferType(infers)
- )
- end
- return ('field %s.%s: %s'):format(
- class.class[1],
- name,
- searcher.viewInferType(infers)
- )
+ return ('field ?.%s: %s'):format(name, view)
+ end
+ return ('field %s.%s: %s'):format(class.class[1], name, view)
end
local function asString(source)
@@ -211,7 +202,7 @@ return function (source, oop)
return asDocFunction(source)
elseif source.type == 'doc.type.name' then
return asDocTypeName(source)
- elseif source.type == 'doc.field' then
- return asDocField(source)
+ elseif source.type == 'doc.field.name' then
+ return asDocFieldName(source)
end
end
diff --git a/script/vm/getMeta.lua b/script/vm/getMeta.lua
deleted file mode 100644
index 44d1874a..00000000
--- a/script/vm/getMeta.lua
+++ /dev/null
@@ -1,53 +0,0 @@
----@type vm
-local vm = require 'vm.vm'
-
-local function eachMetaOfArg1(source, callback)
- local node, index = vm.getArgInfo(source)
- local special = vm.getSpecial(node)
- if special == 'setmetatable' and index == 1 then
- local mt = node.next.args[2]
- if mt then
- callback(mt)
- end
- end
-end
-
-local function eachMetaOfRecv(source, callback)
- if not source or source.type ~= 'select' then
- return
- end
- if source.index ~= 1 then
- return
- end
- local call = source.vararg
- if not call or call.type ~= 'call' then
- return
- end
- local special = vm.getSpecial(call.node)
- if special ~= 'setmetatable' then
- return
- end
- local mt = call.args[2]
- if mt then
- callback(mt)
- end
-end
-
-function vm.eachMetaValue(source, callback)
- vm.eachMeta(source, function (mt)
- for _, src in ipairs(vm.getDefFields(mt)) do
- if vm.getKeyName(src) == '__index' then
- if src.value then
- for _, valueSrc in ipairs(vm.getDefFields(src.value)) do
- callback(valueSrc)
- end
- end
- end
- end
- end)
-end
-
-function vm.eachMeta(source, callback)
- eachMetaOfArg1(source, callback)
- eachMetaOfRecv(source.value, callback)
-end
diff --git a/script/vm/init.lua b/script/vm/init.lua
index 6eb2941d..c38f01d5 100644
--- a/script/vm/init.lua
+++ b/script/vm/init.lua
@@ -2,7 +2,6 @@ local vm = require 'vm.vm'
require 'vm.getGlobals'
require 'vm.getDocs'
require 'vm.getLibrary'
-require 'vm.getMeta'
require 'vm.eachDef'
require 'vm.eachRef'
require 'vm.getLinks'