lsp: Implement semantic tokens

This commit is contained in:
James Westman 2021-11-01 23:52:36 -05:00
parent 7a65956195
commit dfb09b9357
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
6 changed files with 65 additions and 5 deletions

View file

@ -22,7 +22,7 @@ import typing as T
from .ast_utils import *
from .errors import assert_true, AlreadyCaughtError, CompileError, CompilerBugError, MultipleErrors
from . import gir
from .lsp_utils import Completion, CompletionItemKind
from .lsp_utils import Completion, CompletionItemKind, SemanticToken, SemanticTokenType
from .tokenizer import Token
from .utils import lazy_prop
from .xml_emitter import XmlEmitter
@ -398,6 +398,12 @@ class IdentValue(Value):
return type.doc
def get_semantic_tokens(self) -> T.Iterator[SemanticToken]:
if isinstance(self.parent.value_type, gir.Enumeration):
token = self.group.tokens["value"]
yield SemanticToken(token.start, token.end, SemanticTokenType.EnumMember)
class BaseAttribute(AstNode):
""" A helper class for attribute syntax of the form `name: literal_value;`"""