summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-10-30 16:38:24 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-10-30 16:38:24 +0800
commitb9c2e1475efca8ea4c0951c8d5ebf540d5a14415 (patch)
tree60e70e8530deb95d71def336745ad4358bca5b1e
parentf216f27c985625634d5ef337fc266c0f7682aa08 (diff)
downloadlua-language-server-b9c2e1475efca8ea4c0951c8d5ebf540d5a14415.zip
优化语义着色的性能
-rw-r--r--script-beta/core/semantic-tokens.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/script-beta/core/semantic-tokens.lua b/script-beta/core/semantic-tokens.lua
index fa037610..21a251be 100644
--- a/script-beta/core/semantic-tokens.lua
+++ b/script-beta/core/semantic-tokens.lua
@@ -67,11 +67,15 @@ Care['getlocal'] = function (source, results)
end
-- 3. 不是函数的局部变量
local hasFunc
- for _, def in ipairs(vm.getDefs(loc)) do
- if def.type == 'function'
- or (def.type == 'library' and def.value.type == 'function') then
- hasFunc = true
- break
+ local node = loc.node
+ if node then
+ for _, ref in ipairs(node.ref) do
+ local def = ref.value
+ if def.type == 'function'
+ or (def.type == 'library' and def.value.type == 'function') then
+ hasFunc = true
+ break
+ end
end
end
if hasFunc then