summaryrefslogtreecommitdiff
path: root/script/core/semantic-tokens.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/core/semantic-tokens.lua')
-rw-r--r--script/core/semantic-tokens.lua59
1 files changed, 43 insertions, 16 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index 33449013..5833807b 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -32,7 +32,7 @@ local Care = util.switch()
end
options.libGlobals[name] = isLib
end
- local isFunc = vm.getInfer(source):hasFunction()
+ local isFunc = vm.getInfer(source):hasFunction(guide.getUri(source))
local type = isFunc and define.TokenTypes['function'] or define.TokenTypes.variable
local modifier = isLib and define.TokenModifiers.defaultLibrary or define.TokenModifiers.static
@@ -81,7 +81,7 @@ local Care = util.switch()
return
end
end
- if vm.getInfer(source):hasFunction() then
+ if vm.getInfer(source):hasFunction(guide.getUri(source)) then
results[#results+1] = {
start = source.start,
finish = source.finish,
@@ -134,19 +134,16 @@ local Care = util.switch()
return
end
local loc = source.node or source
+ local uri = guide.getUri(loc)
-- 1. 值为函数的局部变量 | Local variable whose value is a function
- if loc.ref then
- for _, ref in ipairs(loc.ref) do
- if ref.value and ref.value.type == 'function' then
- results[#results+1] = {
- start = source.start,
- finish = source.finish,
- type = define.TokenTypes['function'],
- modifieres = define.TokenModifiers.declaration,
- }
- return
- end
- end
+ if vm.getInfer(source):hasFunction(uri) then
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes['function'],
+ modifieres = define.TokenModifiers.declaration,
+ }
+ return
end
-- 3. 特殊变量 | Special variableif source[1] == '_ENV' then
if loc[1] == '_ENV' then
@@ -196,7 +193,7 @@ local Care = util.switch()
end
end
-- 6. References to other functions
- if vm.getInfer(loc):hasFunction() then
+ if vm.getInfer(loc):hasFunction(guide.getUri(source)) then
results[#results+1] = {
start = source.start,
finish = source.finish,
@@ -449,6 +446,7 @@ local Care = util.switch()
end
end)
: case 'doc.alias.name'
+ : case 'doc.enum.name'
: call(function (source, options, results)
if not options.annotation then
return
@@ -667,6 +665,14 @@ local Care = util.switch()
type = define.TokenTypes.keyword,
}
end)
+ : case 'doc.cast.block'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.keyword,
+ }
+ end)
: case 'doc.cast.name'
: call(function (source, options, results)
results[#results+1] = {
@@ -675,6 +681,23 @@ local Care = util.switch()
type = define.TokenTypes.variable,
}
end)
+ : case 'doc.type.code'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.string,
+ modifieres = define.TokenModifiers.abstract,
+ }
+ end)
+ : case 'doc.operator.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.operator,
+ }
+ end)
local function buildTokens(uri, results)
local tokens = {}
@@ -811,9 +834,13 @@ return function (uri, start, finish)
keyword = config.get(uri, 'Lua.semantic.keyword'),
}
+ local n = 0
guide.eachSourceBetween(state.ast, start, finish, function (source) ---@async
Care(source.type, source, options, results)
- await.delay()
+ n = n + 1
+ if n % 100 == 0 then
+ await.delay()
+ end
end)
for _, comm in ipairs(state.comms) do