diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-31 20:17:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-31 20:17:15 +0800 |
commit | 3e516dd717440cad6fce8731a2b627abc6335bbb (patch) | |
tree | 39697f19197678af0a8ec6076faa80af01a911f3 /script/vm/local-id.lua | |
parent | 19e1709f0d53975fa0e752cb64c0c47e3c48bedf (diff) | |
download | lua-language-server-3e516dd717440cad6fce8731a2b627abc6335bbb.zip |
cleanup
Diffstat (limited to 'script/vm/local-id.lua')
-rw-r--r-- | script/vm/local-id.lua | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/script/vm/local-id.lua b/script/vm/local-id.lua index 3b266916..4c9da197 100644 --- a/script/vm/local-id.lua +++ b/script/vm/local-id.lua @@ -10,7 +10,7 @@ local m = {} m.ID_SPLITE = '\x1F' -local compileMap = util.switch() +local compileSwitch = util.switch() : case 'local' : call(function (source) source._localID = ('%d'):format(source.start) @@ -69,9 +69,8 @@ local compileMap = util.switch() m.compileLocalID(source.next) end end) - : getMap() -local leftMap = util.switch() +local leftSwitch = util.switch() : case 'field' : case 'method' : call(function (source) @@ -94,16 +93,11 @@ local leftMap = util.switch() : call(function (source) return source end) - : getMap() ---@param source parser.object ---@return parser.object? function m.getLocal(source) - local getLeft = leftMap[source.type] - if getLeft then - return getLeft(source) - end - return nil + return leftSwitch(source.type, source) end function m.compileLocalID(source) @@ -111,11 +105,10 @@ function m.compileLocalID(source) return end source._localID = false - local compiler = compileMap[source.type] - if not compiler then + if not compileSwitch:has(source.type) then return end - compiler(source) + compileSwitch(source.type, source) local root = guide.getRoot(source) if not root._localIDs then root._localIDs = util.multiTable(2) |