summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArcanox <arcanox@arcanox.me>2021-09-26 14:50:59 -0500
committerArcanox <arcanox@arcanox.me>2021-09-26 14:50:59 -0500
commita963b2958eed7388a72d3b14b563b602dd419914 (patch)
treec236bdb6b079bf6d4b2ef0d198f9225132ec22ad
parent17d2ae286db1b8c8484e5db5bc3c13a25b2426bb (diff)
downloadlua-language-server-a963b2958eed7388a72d3b14b563b602dd419914.zip
Fix a couple classification issues with table field access and simplify it in the process
-rw-r--r--script/core/semantic-tokens.lua62
1 files changed, 21 insertions, 41 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index 9f51c500..517eb25b 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -49,57 +49,37 @@ Care['getmethod'] = function (source, results)
end
end
Care['setmethod'] = Care['getmethod']
-Care['getfield'] = function (source, results)
- local field = source.field
- if not field then
- return
- end
- if isEnhanced and infer.hasType(field, 'function') then
- results[#results+1] = {
- start = field.start,
- finish = field.finish,
- type = define.TokenTypes['function'],
- }
- return
- end
- if source.dot and not (source.next and source.next.type ~= "call") then
- results[#results+1] = {
- start = field.start,
- finish = field.finish,
- type = define.TokenTypes.property,
- }
- return
+Care['field'] = function (source, results)
+ local modifiers = 0
+ if source.parent and source.parent.type == 'tablefield' then
+ modifiers = define.TokenModifiers.declaration
end
-end
-Care['setfield'] = Care['getfield']
-Care['tablefield'] = function (source, results)
- local field = source.field
- if not field then
- return
- end
- local value = source.value
- local isFunction = false
- if value then
- if isEnhanced then
- isFunction = value.type == 'function' or infer.hasType(value, 'function')
- else
- isFunction = value.type == 'function'
+ if source.parent then
+ local value = source.parent.value
+ if value and value.type == 'function' then
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.method,
+ modifieres = modifiers,
+ }
+ return
end
end
- if isFunction then
+ if isEnhanced and infer.hasType(source, 'function') then
results[#results+1] = {
- start = field.start,
- finish = field.finish,
+ start = source.start,
+ finish = source.finish,
type = define.TokenTypes.method,
- modifieres = define.TokenModifiers.declaration,
+ modifieres = modifiers,
}
return
end
results[#results+1] = {
- start = field.start,
- finish = field.finish,
+ start = source.start,
+ finish = source.finish,
type = define.TokenTypes.property,
- modifieres = define.TokenModifiers.declaration,
+ modifieres = modifiers,
}
end
Care['getlocal'] = function (source, results)