diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-10 22:20:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-10 22:20:17 +0800 |
commit | 4cc750f1c150930558bb721b5a73948b33549e42 (patch) | |
tree | c689710cd1faf57fcbdeba1bf3c668170fcc7a6d /server-beta/test/references/init.lua | |
parent | 5c3b733fd7ff097d576a618c78b48f75dcace49e (diff) | |
download | lua-language-server-4cc750f1c150930558bb721b5a73948b33549e42.zip |
查找引用
Diffstat (limited to 'server-beta/test/references/init.lua')
-rw-r--r-- | server-beta/test/references/init.lua | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/server-beta/test/references/init.lua b/server-beta/test/references/init.lua index 44cd5ab0..6f0f74fc 100644 --- a/server-beta/test/references/init.lua +++ b/server-beta/test/references/init.lua @@ -1,6 +1,5 @@ -local core = require 'core' -local parser = require 'parser' -local buildVM = require 'vm' +local core = require 'core.reference' +local files = require 'files' local function catch_target(script) local list = {} @@ -33,18 +32,20 @@ local function founded(targets, results) end function TEST(script) + files.removeAll() local target = catch_target(script) local start = script:find('<?', 1, true) local finish = script:find('?>', 1, true) local pos = (start + finish) // 2 + 1 local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') - local ast = parser:parse(new_script, 'lua', 'Lua 5.3') - assert(ast) - local vm = buildVM(ast) - assert(vm) + files.setText('', new_script) - local positions = core.definition(vm, pos, 'reference') - if positions then + local results = core('', pos) + if results then + local positions = {} + for i, result in ipairs(results) do + positions[i] = { result.target.start, result.target.finish } + end assert(founded(target, positions)) else assert(#target == 0) @@ -101,14 +102,14 @@ function table.<?dump?>() end ]] -TEST [[ ----@class <!Class!> ----@type <?Class?> ----@type <!Class!> -]] - -TEST [[ ----@class <?Class?> ----@type <!Class!> ----@type <!Class!> -]] +--TEST [[ +-----@class <!Class!> +-----@type <?Class?> +-----@type <!Class!> +--]] +-- +--TEST [[ +-----@class <?Class?> +-----@type <!Class!> +-----@type <!Class!> +--]] |