summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorkevinhwang91 <kevin.hwang@live.com>2022-04-02 22:47:16 +0800
committerkevinhwang91 <kevin.hwang@live.com>2022-04-02 22:58:03 +0800
commitb207c282d0cada8bcee641e68d65e8f6586c9381 (patch)
treeea0a408aa1a472d0a1f11420fe750ce8d2fb3a1c /script
parent499cd3acfe00bc38899d1bab2ed1b39dd11e14f6 (diff)
downloadlua-language-server-b207c282d0cada8bcee641e68d65e8f6586c9381.zip
fix(semantic-tokens): coreect token type priority
If metatable with `__call` method, adding `@class` and `@type fun()` together for a class make the token be regarded as function, we should make sure `@class` override `@type`.
Diffstat (limited to 'script')
-rw-r--r--script/core/semantic-tokens.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index ef426633..f16acafc 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -161,17 +161,7 @@ local Care = util.switch()
}
return
end
- -- 5. References to other functions
- if infer.hasType(loc, 'function') then
- results[#results+1] = {
- start = source.start,
- finish = source.finish,
- type = define.TokenTypes['function'],
- modifieres = source.type == 'setlocal' and define.TokenModifiers.declaration or nil,
- }
- return
- end
- -- 6. Class declaration
+ -- 5. Class declaration
-- only search this local
if loc.bindDocs then
for i, doc in ipairs(loc.bindDocs) do
@@ -189,7 +179,17 @@ local Care = util.switch()
end
end
end
- -- 6. const 变量 | Const variable
+ -- 6. References to other functions
+ if infer.hasType(loc, 'function') then
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes['function'],
+ modifieres = source.type == 'setlocal' and define.TokenModifiers.declaration or nil,
+ }
+ return
+ end
+ -- 7. const 变量 | Const variable
if loc.attrs then
for _, attr in ipairs(loc.attrs) do
local name = attr[1]