summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-16 10:33:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-16 10:33:38 +0800
commit6576326add050eb308249c69f9f5ee42d788d72f (patch)
tree173bdfbb65cb0dd69e25d88442146fb8e8bbcb97 /script-beta/core
parent87085809fa155c87b48d42d9304b75d97dd6c22d (diff)
downloadlua-language-server-6576326add050eb308249c69f9f5ee42d788d72f.zip
highlight 区分是否是全局变量
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/highlight.lua30
1 files changed, 22 insertions, 8 deletions
diff --git a/script-beta/core/highlight.lua b/script-beta/core/highlight.lua
index b404e419..d7671df2 100644
--- a/script-beta/core/highlight.lua
+++ b/script-beta/core/highlight.lua
@@ -11,6 +11,17 @@ local function eachRef(source, callback)
end
end
+local function eachField(source, callback)
+ local isGlobal = guide.isGlobal(source)
+ local results = guide.requestReference(source)
+ for i = 1, #results do
+ local res = results[i]
+ if isGlobal == guide.isGlobal(res) then
+ callback(res)
+ end
+ end
+end
+
local function eachLocal(source, callback)
callback(source)
if source.ref then
@@ -27,18 +38,21 @@ local function find(source, uri, callback)
or source.type == 'setlocal' then
eachLocal(source.node, callback)
elseif source.type == 'field'
- or source.type == 'method'
- or source.type == 'getindex'
+ or source.type == 'method' then
+ eachField(source.parent, callback)
+ elseif source.type == 'getindex'
or source.type == 'setindex'
- or source.type == 'tableindex'
- or source.type == 'goto'
- or source.type == 'label'
- or source.type == 'getglobal'
- or source.type == 'setglobal' then
+ or source.type == 'tableindex' then
+ eachField(source, callback)
+ elseif source.type == 'setglobal'
+ or source.type == 'getglobal' then
+ eachField(source, callback)
+ elseif source.type == 'goto'
+ or source.type == 'label' then
eachRef(source, callback)
elseif source.type == 'string'
and source.parent.index == source then
- eachRef(source.parent, callback)
+ eachField(source.parent, callback)
elseif source.type == 'string'
or source.type == 'boolean'
or source.type == 'number'