Skip to content

Commit d2f5980

Browse files
committed
update semantic tokens
1 parent 85a9019 commit d2f5980

File tree

2 files changed

+106
-13
lines changed

2 files changed

+106
-13
lines changed

script/core/semantic-tokens.lua

Lines changed: 104 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,30 @@ local Care = util.switch()
459459
modifieres = define.TokenModifiers.modification,
460460
}
461461
end)
462+
: case 'doc.type.enum'
463+
: call(function (source, options, results)
464+
results[#results+1] = {
465+
start = source.start,
466+
finish = source.finish,
467+
type = define.TokenTypes.string,
468+
modifieres = define.TokenModifiers.static,
469+
}
470+
end)
471+
: case 'doc.resume'
472+
: call(function (source, options, results)
473+
results[#results+1] = {
474+
start = source.start,
475+
finish = source.finish,
476+
type = define.TokenTypes.string,
477+
modifieres = define.TokenModifiers.static,
478+
}
479+
local row = guide.rowColOf(source.start)
480+
results[#results+1] = {
481+
start = source.finish,
482+
finish = guide.positionOf(row, guide.getLineRange(options.state, row)),
483+
type = define.TokenTypes.comment,
484+
}
485+
end)
462486
: case 'doc.type.function'
463487
: call(function (source, options, results)
464488
results[#results+1] = {
@@ -475,6 +499,14 @@ local Care = util.switch()
475499
}
476500
end
477501
end)
502+
: case 'doc.type.table'
503+
: call(function (source, options, results)
504+
results[#results+1] = {
505+
start = source.start,
506+
finish = source.start + #'table',
507+
type = define.TokenTypes.type,
508+
}
509+
end)
478510
: case 'doc.type.arg.name'
479511
: call(function (source, options, results)
480512
results[#results+1] = {
@@ -484,6 +516,56 @@ local Care = util.switch()
484516
modifieres = define.TokenModifiers.declaration,
485517
}
486518
end)
519+
: case 'doc.version.unit'
520+
: call(function (source, options, results)
521+
results[#results+1] = {
522+
start = source.start,
523+
finish = source.finish,
524+
type = define.TokenTypes.enumMember,
525+
}
526+
end)
527+
: case 'doc.see.name'
528+
: call(function (source, options, results)
529+
results[#results+1] = {
530+
start = source.start,
531+
finish = source.finish,
532+
type = define.TokenTypes.class,
533+
}
534+
end)
535+
: case 'doc.see.field'
536+
: call(function (source, options, results)
537+
results[#results+1] = {
538+
start = source.start,
539+
finish = source.finish,
540+
type = define.TokenTypes.property,
541+
}
542+
end)
543+
: case 'doc.diagnostic'
544+
: call(function (source, options, results)
545+
results[#results+1] = {
546+
start = source.start,
547+
finish = source.start + #source.mode,
548+
type = define.TokenTypes.keyword,
549+
}
550+
end)
551+
: case 'doc.diagnostic.name'
552+
: call(function (source, options, results)
553+
results[#results+1] = {
554+
start = source.start,
555+
finish = source.finish,
556+
type = define.TokenTypes.event,
557+
modifieres = define.TokenModifiers.static,
558+
}
559+
end)
560+
: case 'doc.module'
561+
: call(function (source, options, results)
562+
results[#results+1] = {
563+
start = source.start,
564+
finish = source.finish,
565+
type = define.TokenTypes.string,
566+
modifieres = define.TokenModifiers.defaultLibrary,
567+
}
568+
end)
487569
: case 'doc.tailcomment'
488570
: call(function (source, options, results)
489571
results[#results+1] = {
@@ -652,19 +734,28 @@ return function (uri, start, finish)
652734
end)
653735

654736
for _, comm in ipairs(state.comms) do
655-
if comm.type == 'comment.short'
656-
and comm.text:sub(1, 2) == '-@' then
657-
results[#results+1] = {
658-
start = comm.start,
659-
finish = comm.start + 3,
660-
type = define.TokenTypes.comment,
661-
}
662-
results[#results+1] = {
663-
start = comm.start + 3,
664-
finish = comm.start + 2 + #comm.text:match '%S+',
665-
type = define.TokenTypes.comment,
666-
modifieres = define.TokenModifiers.documentation,
667-
}
737+
if comm.type == 'comment.short' then
738+
local head = comm.text:sub(1, 2)
739+
if head == '-@'
740+
or head == '-|' then
741+
results[#results+1] = {
742+
start = comm.start,
743+
finish = comm.start + 3,
744+
type = define.TokenTypes.comment,
745+
}
746+
results[#results+1] = {
747+
start = comm.start + 3,
748+
finish = comm.start + 2 + #comm.text:match '%S+',
749+
type = define.TokenTypes.comment,
750+
modifieres = define.TokenModifiers.documentation,
751+
}
752+
else
753+
results[#results+1] = {
754+
start = comm.start,
755+
finish = comm.finish,
756+
type = define.TokenTypes.comment,
757+
}
758+
end
668759
else
669760
results[#results+1] = {
670761
start = comm.start,

script/parser/guide.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ local childMap = {
145145
['doc.type.field'] = {'extends'},
146146
['doc.overload'] = {'overload', 'comment'},
147147
['doc.see'] = {'name', 'field'},
148+
['doc.version'] = {'#versions'},
149+
['doc.diagnostic'] = {'#names'},
148150
}
149151

150152
---@type table<string, fun(obj: parser.guide.object, list: parser.guide.object[])>

0 commit comments

Comments
 (0)