diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-01 16:39:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-01 16:39:52 +0800 |
commit | 36404de31bff1228ce1a785883918491db814676 (patch) | |
tree | 92f8f712dbe1c6a8336155ed8781bcf1c9c45d9d /server/src/vm/label.lua | |
parent | caed96510b21d6bdd9e1c4a175be7486c8c8ff5c (diff) | |
download | lua-language-server-36404de31bff1228ce1a785883918491db814676.zip |
支持标签
Diffstat (limited to 'server/src/vm/label.lua')
-rw-r--r-- | server/src/vm/label.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/server/src/vm/label.lua b/server/src/vm/label.lua index f8f8eb81..b82e98e8 100644 --- a/server/src/vm/label.lua +++ b/server/src/vm/label.lua @@ -1,3 +1,11 @@ +local function getDefaultSource() + return { + start = 0, + finish = 0, + uri = '', + } +end + local mt = {} mt.__index = mt mt.type = 'label' @@ -6,6 +14,26 @@ function mt:getName() return self.name end +function mt:addInfo(tp, source) + if source and not source.start then + error('Miss start: ' .. table.dump(source)) + end + self[#self+1] = { + type = tp, + source = source or getDefaultSource(), + } +end + +function mt:eachInfo(callback) + for _, info in ipairs(self) do + local res = callback(info) + if res ~= nil then + return res + end + end + return nil +end + return function (name, source) local self = setmetatable({ name = name, |