summaryrefslogtreecommitdiff
path: root/script/parser
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-01-11 22:03:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-01-11 22:03:43 +0800
commit390474caca77ea5e745f3a3ae2ca7168e7165573 (patch)
tree97bdcf92bf6ec60d802f795f47e59bb8e33f3c61 /script/parser
parentd74c85c8517b9f3b7591cc337fa387f2805ebb40 (diff)
downloadlua-language-server-390474caca77ea5e745f3a3ae2ca7168e7165573.zip
stash
Diffstat (limited to 'script/parser')
-rw-r--r--script/parser/guide.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index b8290943..e3c466c0 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -99,6 +99,16 @@ local blockTypes = {
['main'] = true,
}
+local topBlockTypes = {
+ ['while'] = true,
+ ['function'] = true,
+ ['if'] = true,
+ ['ifblock'] = true,
+ ['elseblock'] = true,
+ ['elseifblock'] = true,
+ ['main'] = true,
+}
+
local breakBlockTypes = {
['while'] = true,
['in'] = true,
@@ -1250,13 +1260,10 @@ end
function m.getTopBlock(source)
for _ = 1, 1000 do
local block = source.parent
- if not m.isBlockType(block) then
+ if not block then
return nil
end
- if block.type ~= 'do'
- and block.type ~= 'in'
- and block.type ~= 'loop'
- and block.type ~= 'repeat' then
+ if topBlockTypes[block.type] then
return block
end
source = block