diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-30 16:57:20 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-30 16:57:20 +0800 |
commit | eca92d19c165c697d50ec83fbce5591a60c2124a (patch) | |
tree | c84edc1806496dddbb3d9b8dd46bd50977be853e /script-beta | |
parent | 7f963936a62ff7a138458c50736fcf106cc2fbe3 (diff) | |
download | lua-language-server-eca92d19c165c697d50ec83fbce5591a60c2124a.zip |
eachField 加入 library
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/core/hover/table.lua | 3 | ||||
-rw-r--r-- | script-beta/vm/eachField.lua | 24 | ||||
-rw-r--r-- | script-beta/vm/vm.lua | 3 |
3 files changed, 21 insertions, 9 deletions
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua index d1598f02..fb89c7f9 100644 --- a/script-beta/core/hover/table.lua +++ b/script-beta/core/hover/table.lua @@ -4,9 +4,6 @@ local util = require 'utility' local function getKey(src) local key = vm.getKeyName(src) if not key or #key <= 2 then - if src.library then - return src.name - end if not src.index then return '[any]' end diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua index f87815fa..fa995f07 100644 --- a/script-beta/vm/eachField.lua +++ b/script-beta/vm/eachField.lua @@ -1,19 +1,31 @@ -local vm = require 'vm.vm' -local guide = require 'parser.guide' +local vm = require 'vm.vm' +local guide = require 'parser.guide' +local library = require 'library' -local function eachFieldOfLibrary(source, lib, results) +local function eachFieldInTableLibrary(source, lib, results) if not lib or lib.type ~= 'table' or not lib.child then return end for _, value in pairs(lib.child) do - results[#results+1] =value + results[#results+1] = value + end +end + +local function eachFieldOfLibrary(results) + for _, lib in pairs(library.global) do + results[#results+1] = lib end end local function eachField(source) - local lib = vm.getLibrary(source) local results = guide.requestFields(source) - eachFieldOfLibrary(source, lib, results) + local lib = vm.getLibrary(source) + if lib then + eachFieldInTableLibrary(source, lib, results) + end + if source.special == '_G' then + eachFieldOfLibrary(results) + end return results end diff --git a/script-beta/vm/vm.lua b/script-beta/vm/vm.lua index 556de3df..5028a67c 100644 --- a/script-beta/vm/vm.lua +++ b/script-beta/vm/vm.lua @@ -126,6 +126,9 @@ function m.getKeyName(source) if not source then return nil end + if source.library then + return 's|' .. source.name + end if source.type == 'call' then local special = m.getSpecial(source.node) if special == 'rawset' |