diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-29 19:49:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-29 19:49:44 +0800 |
commit | 5ad119e5848e3878ed37f58f71750bc4a17720a5 (patch) | |
tree | 3283a98acfe45dcedf5dd6e1720272d05b6a009c | |
parent | 35e15270a0b79e7162de78e328496e2274efedd2 (diff) | |
download | lua-language-server-5ad119e5848e3878ed37f58f71750bc4a17720a5.zip |
更新 hover
-rw-r--r-- | script-beta/parser/guide.lua | 2 | ||||
-rw-r--r-- | script-beta/vm/getClass.lua | 33 | ||||
-rw-r--r-- | script-beta/vm/getMeta.lua | 1 |
3 files changed, 8 insertions, 28 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 079c2aae..22e49c90 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -991,7 +991,7 @@ function m.searchFields(status, obj, key) local newStatus = m.status(status) local simple = m.getSimple(obj, 1) if not simple then - return nil + return {} end simple[#simple+1] = key and ('s|' .. key) or '*' m.searchSameFields(newStatus, simple, 'def') diff --git a/script-beta/vm/getClass.lua b/script-beta/vm/getClass.lua index 4d7ef69c..309a7693 100644 --- a/script-beta/vm/getClass.lua +++ b/script-beta/vm/getClass.lua @@ -1,10 +1,12 @@ -local vm = require 'vm.vm' +local vm = require 'vm.vm' +local guide = require 'parser.guide' local function getClass(source, classes, deep) if deep > 3 then return end - vm.eachField(source, function (src) + local value = guide.getObjectValue(source) or source + vm.eachField(value, function (src) local key = vm.getKeyName(src) if not key then return @@ -14,39 +16,18 @@ local function getClass(source, classes, deep) or lkey == 's|__name' or lkey == 's|name' or lkey == 's|class' then - if src.value and src.value.type == 'string' then - classes[#classes+1] = src.value[1] + local value = guide.getObjectValue(src) + if value and value.type == 'string' then + classes[#classes+1] = value[1] end end end) - if source.value then - vm.eachField(source.value, function (src) - local key = vm.getKeyName(src) - if not key then - return - end - local lkey = key:lower() - if lkey == 's|type' - or lkey == 's|__name' - or lkey == 's|name' - or lkey == 's|class' then - if src.value and src.value.type == 'string' then - classes[#classes+1] = src.value[1] - end - end - end) - end if #classes ~= 0 then return end vm.eachMeta(source, function (mt) getClass(mt, classes, deep + 1) end) - if source.value then - vm.eachMeta(source.value, function (mt) - getClass(mt, classes, deep + 1) - end) - end end function vm.getClass(source) diff --git a/script-beta/vm/getMeta.lua b/script-beta/vm/getMeta.lua index 49e9cf34..73d01aef 100644 --- a/script-beta/vm/getMeta.lua +++ b/script-beta/vm/getMeta.lua @@ -26,7 +26,6 @@ local function eachMetaOfRecv(source, callback) if special ~= 'setmetatable' then return end - vm.eachFieldInTable(call.args[1], callback) local mt = call.args[2] if mt then callback(mt) |