summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-29 20:36:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-29 20:36:13 +0800
commit35aa1dab4dfd3c27f376291fe4784bc329aec6c3 (patch)
treee0460972b2e61f652e19d745e3039c85a900d33a
parente0cc99cf0c830ffb7da46cb0715e2112d8fd61b6 (diff)
downloadlua-language-server-35aa1dab4dfd3c27f376291fe4784bc329aec6c3.zip
improve
-rw-r--r--script/core/noder.lua44
-rw-r--r--test.lua2
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 _ <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
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()