From 35aa1dab4dfd3c27f376291fe4784bc329aec6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 29 Jul 2021 20:36:13 +0800 Subject: improve --- script/core/noder.lua | 44 +++++++++++++++----------------------------- test.lua | 2 +- 2 files changed, 16 insertions(+), 30 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 _ = 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 diff --git a/test.lua b/test.lua index d9f8b957..b83f1056 100644 --- a/test.lua +++ b/test.lua @@ -91,7 +91,7 @@ local function main() --config.Lua.intelliSense.searchDepth = 5 --loadDocMetas() - --test 'full' + test 'full' require 'bee.platform'.OS = 'Windows' testAll() -- cgit v1.2.3