diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-29 20:36:13 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-29 20:36:13 +0800 |
commit | 35aa1dab4dfd3c27f376291fe4784bc329aec6c3 (patch) | |
tree | e0460972b2e61f652e19d745e3039c85a900d33a /script/core/noder.lua | |
parent | e0cc99cf0c830ffb7da46cb0715e2112d8fd61b6 (diff) | |
download | lua-language-server-35aa1dab4dfd3c27f376291fe4784bc329aec6c3.zip |
improve
Diffstat (limited to 'script/core/noder.lua')
-rw-r--r-- | script/core/noder.lua | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua index b13c9763..ad593718 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -363,8 +363,6 @@ local function getNodeKey(source) return key, node end -local IDList = {} -local IDList2 = {} ---获取语法树单元的字符串ID ---@param source parser.guide.object ---@return string? id @@ -383,38 +381,26 @@ local function getID(source) tracy.ZoneBeginN 'getID' local _ <close> = tracy.ZoneEnd local current = source - local index = 0 - while true do - if current.type == 'paren' then - current = current.exp - if not current then - return nil - end - goto CONTINUE - end - local id, node = getNodeKey(current) - if not id then - break - end - index = index + 1 - IDList[index] = id - if not node then - break + while current.type == 'paren' do + current = current.exp + if not current then + source._id = false + return nil end - current = node - ::CONTINUE:: end - if index == 0 then + local id, node = getNodeKey(current) + if not id then source._id = false return nil end - for i = index + 1, #IDList2 do - IDList2[i] = nil - end - for i = 1, index do - IDList2[i] = IDList[index - i + 1] + if node then + local pid = getID(node) + if not pid then + source._id = false + return nil + end + id = pid .. SPLIT_CHAR .. id end - local id = tconcat(IDList2, SPLIT_CHAR) source._id = id return id end @@ -1427,6 +1413,6 @@ files.watch(function (ev, uri) end end) ---require 'tracy'.enable() +require 'tracy'.enable() return m |