diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-10 16:10:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-10 16:10:56 +0800 |
commit | e81e3400f29bf310e05afb9305a2cfa1c3271873 (patch) | |
tree | 263fd3cc9c000e04045b293db2256ab7213a57c1 /script/vm | |
parent | f335c413a409c1f03e379d7d5e1d5b377d378a0f (diff) | |
download | lua-language-server-e81e3400f29bf310e05afb9305a2cfa1c3271873.zip |
update
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/eachDef.lua | 10 | ||||
-rw-r--r-- | script/vm/getDef.lua | 29 | ||||
-rw-r--r-- | script/vm/getRef.lua (renamed from script/vm/eachRef.lua) | 0 | ||||
-rw-r--r-- | script/vm/init.lua | 4 |
4 files changed, 31 insertions, 12 deletions
diff --git a/script/vm/eachDef.lua b/script/vm/eachDef.lua deleted file mode 100644 index 3f7e1db9..00000000 --- a/script/vm/eachDef.lua +++ /dev/null @@ -1,10 +0,0 @@ ----@class vm -local vm = require 'vm.vm' - -function vm.getDefs(source, field) - return searcher.requestDefinition(source, field) -end - -function vm.getAllDefs(source, field) - return searcher.requestAllDefinition(source, field) -end diff --git a/script/vm/getDef.lua b/script/vm/getDef.lua new file mode 100644 index 00000000..11a64421 --- /dev/null +++ b/script/vm/getDef.lua @@ -0,0 +1,29 @@ +local util = require 'utility' + +---@class vm +local vm = require 'vm.vm' + +local simpleMap = util.switch() + : case 'local' + : call(function (source, results) + results[#results+1] = source + end) + : case 'getlocal' + : case 'setlocal' + : call(function (source, results) + results[#results+1] = source.node + end) + : getMap() + +function vm.getDefs(source, field) + local results = {} + local simple = simpleMap[source.type] + if simple then + simple(source, results) + end + return results +end + +function vm.getAllDefs(source, field) + return vm.getDefs(source, field) +end diff --git a/script/vm/eachRef.lua b/script/vm/getRef.lua index ded95b61..ded95b61 100644 --- a/script/vm/eachRef.lua +++ b/script/vm/getRef.lua diff --git a/script/vm/init.lua b/script/vm/init.lua index c3ccabc1..3a42fb9c 100644 --- a/script/vm/init.lua +++ b/script/vm/init.lua @@ -3,7 +3,7 @@ require 'vm.compiler' require 'vm.getGlobals' require 'vm.getDocs' require 'vm.getLibrary' -require 'vm.eachDef' -require 'vm.eachRef' +require 'vm.getDef' +require 'vm.getRef' require 'vm.getLinks' return vm |