summaryrefslogtreecommitdiff
path: root/script/method/textDocument/semanticTokens.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/method/textDocument/semanticTokens.lua')
-rw-r--r--script/method/textDocument/semanticTokens.lua60
1 files changed, 36 insertions, 24 deletions
diff --git a/script/method/textDocument/semanticTokens.lua b/script/method/textDocument/semanticTokens.lua
index 6595459e..de50b43b 100644
--- a/script/method/textDocument/semanticTokens.lua
+++ b/script/method/textDocument/semanticTokens.lua
@@ -23,36 +23,48 @@ local constLib = {
['package.searchers'] = true
}
-local function buildLibToken(source, lib)
- local modifieres
- if constLib[lib.doc] then
- modifieres = TokenModifiers.readonly
- else
- modifieres = TokenModifiers.static
- end
- return {
- start = source.start,
- finish = source.finish,
- type = TokenTypes.namespace,
- modifieres = modifieres,
- }
-end
-
local Care = {
- ['name'] = function (source)
- local lib = findLib(source)
- if lib then
- return buildLibToken(source, lib)
- end
+ ['name'] = function (source, sources)
if source:get 'global' then
- return {
+ if findLib(source) then
+ if source[1] == '_G' then
+ return
+ end
+ sources[#sources+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = TokenTypes.namespace,
+ modifieres = TokenModifiers.static,
+ }
+ return
+ end
+ sources[#sources+1] = {
start = source.start,
finish = source.finish,
type = TokenTypes.namespace,
modifieres = TokenModifiers.deprecated,
}
- else
- return {
+ elseif source:get 'table index' then
+ sources[#sources+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = TokenTypes.property,
+ modifieres = TokenModifiers.declaration,
+ }
+ elseif source:bindLocal() then
+ if source:get 'arg' then
+ sources[#sources+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = TokenTypes.parameter,
+ modifieres = TokenModifiers.declaration,
+ }
+ end
+ if source[1] == '_ENV'
+ or source[1] == 'self' then
+ return
+ end
+ sources[#sources+1] = {
start = source.start,
finish = source.finish,
type = TokenTypes.variable,
@@ -92,7 +104,7 @@ local function resolveTokens(vm, lines)
local sources = {}
for _, source in ipairs(vm.sources) do
if Care[source.type] then
- sources[#sources+1] = Care[source.type](source)
+ Care[source.type](source, sources)
end
end