diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-17 03:28:39 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-17 03:28:39 +0800 |
commit | 3996e193acf42c0f42a3ed2ee65e5e674c9ddeb0 (patch) | |
tree | 9066b5036a0009565de426936d22694408da514d /script/vm/local-id.lua | |
parent | 8c5dacd639a13aa8b7d5b6c8125144a60002d7a0 (diff) | |
download | lua-language-server-3996e193acf42c0f42a3ed2ee65e5e674c9ddeb0.zip |
#980
Diffstat (limited to 'script/vm/local-id.lua')
-rw-r--r-- | script/vm/local-id.lua | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/script/vm/local-id.lua b/script/vm/local-id.lua index 728de301..1566e8f3 100644 --- a/script/vm/local-id.lua +++ b/script/vm/local-id.lua @@ -98,6 +98,7 @@ local leftSwitch = util.switch() return source.node end) : case 'local' + : case 'self' : call(function (source) return source end) @@ -108,6 +109,17 @@ function m.getLocal(source) return leftSwitch(source.type, source) end +---@param id string +---@param source parser.object +function m.insertLocalID(id, source) + local root = guide.getRoot(source) + if not root._localIDs then + root._localIDs = util.multiTable(2) + end + local sources = root._localIDs[id] + sources[#sources+1] = source +end + function m.compileLocalID(source) if not source then return @@ -117,15 +129,11 @@ function m.compileLocalID(source) return end compileSwitch(source.type, source) - if not source._localID then + local id = source._localID + if not id then return end - local root = guide.getRoot(source) - if not root._localIDs then - root._localIDs = util.multiTable(2) - end - local sources = root._localIDs[source._localID] - sources[#sources+1] = source + m.insertLocalID(id, source) end ---@param source parser.object |