diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/await.lua | 4 | ||||
-rw-r--r-- | script-beta/core/hover/label.lua | 3 | ||||
-rw-r--r-- | script-beta/core/hover/name.lua | 7 | ||||
-rw-r--r-- | script-beta/vm/eachDef.lua | 18 | ||||
-rw-r--r-- | script-beta/vm/eachField.lua | 31 | ||||
-rw-r--r-- | script-beta/vm/eachRef.lua | 2 | ||||
-rw-r--r-- | script-beta/vm/getGlobals.lua | 3 | ||||
-rw-r--r-- | script-beta/vm/getLibrary.lua | 5 |
8 files changed, 50 insertions, 23 deletions
diff --git a/script-beta/await.lua b/script-beta/await.lua index 5a960e96..38fb6548 100644 --- a/script-beta/await.lua +++ b/script-beta/await.lua @@ -89,9 +89,7 @@ function m.step() waker() return true else - for i = 1, #m.delayQueue do - m.delayQueue[i] = nil - end + m.delayQueue = {} m.delayQueueIndex = 1 return false end diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index bcc65b8d..dd25d42e 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -27,6 +27,9 @@ local function asValue(source, title) cont = buildTable(source) type = nil end + if lib then + name = ('%s<%s>'):format(name, buildName(lib)) + end local pack = {} pack[#pack+1] = title pack[#pack+1] = name .. ':' diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua index 7b8cf449..917bf96d 100644 --- a/script-beta/core/hover/name.lua +++ b/script-beta/core/hover/name.lua @@ -29,9 +29,10 @@ end local function asLibrary(source, caller) local p - if caller.type == 'method' - or caller.type == 'getmethod' - or caller.type == 'setmethod' then + if caller + and (caller.type == 'method' + or caller.type == 'getmethod' + or caller.type == 'setmethod') then if source.parent then for _, parent in ipairs(source.parent) do if parent.type == 'object' then diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index 0274cbee..1b7ea621 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -25,7 +25,8 @@ function vm.eachDef(source, callback) if info.mode == 'declare' or info.mode == 'set' or info.mode == 'return' - or info.mode == 'value' then + or info.mode == 'value' + or info.mode == 'library' then results[#results+1] = info local src = info.source if info.mode == 'return' then @@ -38,11 +39,9 @@ function vm.eachDef(source, callback) for _, info in ipairs(results) do local src = info.source local destUri = guide.getRoot(src).uri - -- 如果是同一个文件,则检查位置关系后放行 - if sourceUri == destUri then - if checkPath(source, info) then - callback(info) - end + -- 如果是library,则直接放行 + if src.library then + callback(info) goto CONTINUE end -- 如果是global或field,则直接放行(因为无法确定顺序) @@ -55,6 +54,13 @@ function vm.eachDef(source, callback) callback(info) goto CONTINUE end + -- 如果是同一个文件,则检查位置关系后放行 + if sourceUri == destUri then + if checkPath(source, info) then + callback(info) + end + goto CONTINUE + end -- 如果不是同一个文件,则必须在该文件 return 后才放行 if valueUris[destUri] then callback(info) diff --git a/script-beta/vm/eachField.lua b/script-beta/vm/eachField.lua index 1d3d222d..a707407e 100644 --- a/script-beta/vm/eachField.lua +++ b/script-beta/vm/eachField.lua @@ -2,15 +2,28 @@ local guide = require 'parser.guide' local vm = require 'vm.vm' local function ofTabel(value, callback) - for _, field in ipairs(value) do - if field.type == 'tablefield' - or field.type == 'tableindex' then - callback { - source = field, - key = guide.getKeyName(field), - value = field.value, - mode = 'set', - } + if value.library then + if value.child then + for k, field in pairs(value.child) do + callback { + source = field, + key = 's|' .. k, + value = field, + mode = 'set', + } + end + end + else + for _, field in ipairs(value) do + if field.type == 'tablefield' + or field.type == 'tableindex' then + callback { + source = field, + key = guide.getKeyName(field), + value = field.value, + mode = 'set', + } + end end end end diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index d990ee1a..72d7c012 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -125,7 +125,7 @@ local function ofSpecialCall(call, func, index, callback) if lib then callback { source = lib, - mode = 'library', + mode = 'value', } end end diff --git a/script-beta/vm/getGlobals.lua b/script-beta/vm/getGlobals.lua index 699dd270..116bf8d5 100644 --- a/script-beta/vm/getGlobals.lua +++ b/script-beta/vm/getGlobals.lua @@ -3,6 +3,9 @@ local vm = require 'vm.vm' local function getGlobals(root) local env = guide.getENV(root) + if not env then + return nil + end local cache = {} local mark = {} vm.eachField(env, function (info) diff --git a/script-beta/vm/getLibrary.lua b/script-beta/vm/getLibrary.lua index 959b7084..d2f88116 100644 --- a/script-beta/vm/getLibrary.lua +++ b/script-beta/vm/getLibrary.lua @@ -3,6 +3,9 @@ local library = require 'library' local guide = require 'parser.guide' local function checkStdLibrary(source) + if source.library then + return source + end local globalName = vm.getGlobal(source) if not globalName then return nil @@ -73,7 +76,7 @@ local function getLibrary(source) return lib end return checkNode(source) or vm.eachRef(source, function (info) - return checkNode(info.source) + return checkStdLibrary(info.source) or checkNode(info.source) end) end |