diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-24 21:41:04 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-24 21:41:04 +0800 |
commit | c025849321b444b84eacd4e091cfa574ca6bc472 (patch) | |
tree | 64fc82e658edb6b1ab9e65b47ad1b877569d7d4f /server-beta/src/parser/guide.lua | |
parent | ff4f52962550da919b737f0f78bbaa4a507d6ba9 (diff) | |
download | lua-language-server-c025849321b444b84eacd4e091cfa574ca6bc472.zip |
更新 definition
Diffstat (limited to 'server-beta/src/parser/guide.lua')
-rw-r--r-- | server-beta/src/parser/guide.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/server-beta/src/parser/guide.lua b/server-beta/src/parser/guide.lua index d3ae7100..bd7f9150 100644 --- a/server-beta/src/parser/guide.lua +++ b/server-beta/src/parser/guide.lua @@ -1,6 +1,7 @@ local error = error local utf8Len = utf8.len local utf8Offset = utf8.offset +local type = type _ENV = nil @@ -195,6 +196,25 @@ function m.eachSource(root, offset, callback) end end +--- 遍历所有某种类型的source +function m.eachSourceOf(root, types, callback) + if type(types) == 'string' then + types = {[types] = true} + elseif type(types) == 'table' then + for i = 1, #types do + types[types[i]] = true + end + else + return + end + for i = 1, #root do + local source = root[i] + if types[source.type] then + callback(source) + end + end +end + --- 获取偏移对应的坐标(row从0开始,col为光标位置) ---@param lines table ---@return integer {name = 'row'} |