handleSemanticTokensFull handles textDocument/semanticTokens/full requests. It tokenizes the document and returns LSP-encoded semantic token data.
(params SemanticTokensParams)
| 1702 | // handleSemanticTokensFull handles textDocument/semanticTokens/full requests. |
| 1703 | // It tokenizes the document and returns LSP-encoded semantic token data. |
| 1704 | func (h *Handler) handleSemanticTokensFull(params SemanticTokensParams) (*SemanticTokens, error) { |
| 1705 | doc, ok := h.server.Documents().Get(params.TextDocument.URI) |
| 1706 | if !ok { |
| 1707 | return &SemanticTokens{Data: []uint32{}}, nil |
| 1708 | } |
| 1709 | |
| 1710 | tkz := tokenizer.GetTokenizer() |
| 1711 | defer tokenizer.PutTokenizer(tkz) |
| 1712 | tokens, err := tkz.Tokenize([]byte(doc.Content)) |
| 1713 | if err != nil { |
| 1714 | return &SemanticTokens{Data: []uint32{}}, nil |
| 1715 | } |
| 1716 | |
| 1717 | return &SemanticTokens{Data: encodeSemanticTokens(tokens)}, nil |
| 1718 | } |
| 1719 | |
| 1720 | // encodeSemanticTokens converts token positions to LSP semantic token encoding. |
| 1721 | // Each token is encoded as 5 uint32 values: |
no test coverage detected