diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-30 14:59:38 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-30 14:59:38 +0800 |
commit | 30d1ac31b34ea50f3065e64a8483ad09a44b4c58 (patch) | |
tree | 35ab4559866b6d1f7a2ca1259f536e6ee8779842 /script-beta/vm/eachField.lua | |
parent | 5ad119e5848e3878ed37f58f71750bc4a17720a5 (diff) | |
download | lua-language-server-30d1ac31b34ea50f3065e64a8483ad09a44b4c58.zip |
library table 的hover
Diffstat (limited to 'script-beta/vm/eachField.lua')
-rw-r--r-- | script-beta/vm/eachField.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua new file mode 100644 index 00000000..670b0745 --- /dev/null +++ b/script-beta/vm/eachField.lua @@ -0,0 +1,20 @@ +local vm = require 'vm.vm' +local guide = require 'parser.guide' + +local function eachFieldOfLibrary(source, lib, callback) + if not lib or lib.type ~= 'table' or not lib.child then + return + end + for _, value in pairs(lib.child) do + callback(value) + end +end + +function vm.eachField(source, callback) + local lib = vm.getLibrary(source) + eachFieldOfLibrary(source, lib, callback) + local results = guide.requestFields(source) + for i = 1, #results do + callback(results[i]) + end +end |