Ide.Plugin.SemanticTokens.Mappings

haskell-language-server-2.9.0.0: LSP server for GHC

Safe Haskell | None
Language | GHC2021

Ide.Plugin.SemanticTokens.Mappings

Contents

- 0. Mapping name to Hs semantic token type.
- 1. Mapping semantic token type to and from the LSP default token type.
- 2. Mapping from GHC type and tyThing to semantic token type.
- 3. Mapping from hieAst ContextInfo to haskell semantic token type.
- 4. Mapping from LSP tokens to SemanticTokenOriginal.

Description

This module provides mappings to convert token type information in the Haskell IDE plugin. It includes functions for:

1. Mapping semantic token type to and from the LSP default token type.
2. Mapping from GHC type and tyThing to semantic token type.
3. Mapping from hieAst identifier details to haskell semantic token type.
4. Mapping from LSP tokens to SemanticTokenOriginal.

Synopsis

- nameInfixOperator :: Name -> Maybe HsSemanticTokenType
- toLspTokenType :: SemanticTokensConfig -> HsSemanticTokenType -> SemanticTokenTypes
- lspTokenReverseMap :: SemanticTokensConfig -> Map SemanticTokenTypes HsSemanticTokenType
- lspTokenTypeHsTokenType :: SemanticTokensConfig -> SemanticTokenTypes -> Maybe HsSemanticTokenType
- tyThingSemantic :: TyThing -> Maybe HsSemanticTokenType
- tyThingSemantic' :: TyThing -> Maybe HsSemanticTokenType
- expandTypeSyn :: Type -> Type
- isFunType :: Type -> Bool
- hieKindFunMasksKind :: HieKind a -> HieFunMaskKind a
- recoverFunMaskArray :: Array TypeIndex HieTypeFlat -> Array TypeIndex Bool
- typeSemantic :: HieFunMaskKind hType -> hType -> Maybe HsSemanticTokenType
- infoTokenType :: ContextInfo -> Maybe HsSemanticTokenType
- recoverSemanticTokens :: SemanticTokensConfig -> VirtualFile -> SemanticTokens -> Either Text [SemanticTokenOriginal HsSemanticTokenType]
- lspTokenHsToken :: SemanticTokensConfig -> SemanticTokenOriginal SemanticTokenTypes -> SemanticTokenOriginal HsSemanticTokenType
- recoverLspSemanticTokens :: VirtualFile -> SemanticTokens -> Either Text [SemanticTokenOriginal SemanticTokenTypes]

# 0. Mapping name to Hs semantic token type.

nameInfixOperator :: Name -> Maybe HsSemanticTokenType #

# 1. Mapping semantic token type to and from the LSP default token type.

toLspTokenType :: SemanticTokensConfig -> HsSemanticTokenType -> SemanticTokenTypes #

map from haskell semantic token type to LSP default token type

lspTokenReverseMap :: SemanticTokensConfig -> Map SemanticTokenTypes HsSemanticTokenType #

lspTokenTypeHsTokenType :: SemanticTokensConfig -> SemanticTokenTypes -> Maybe HsSemanticTokenType #

# 2. Mapping from GHC type and tyThing to semantic token type.

tyThingSemantic :: TyThing -> Maybe HsSemanticTokenType #

tyThingSemantic

tyThingSemantic' :: TyThing -> Maybe HsSemanticTokenType #

expandTypeSyn :: Type -> Type #

isFunType :: Type -> Bool #

hieKindFunMasksKind :: HieKind a -> HieFunMaskKind a #

recoverFunMaskArray #

Arguments

:: Array TypeIndex HieTypeFlat | flat types
-> Array TypeIndex Bool | array of bool indicating whether the type is a function

typeSemantic :: HieFunMaskKind hType -> hType -> Maybe HsSemanticTokenType #

# 3. Mapping from hieAst ContextInfo to haskell semantic token type.

infoTokenType :: ContextInfo -> Maybe HsSemanticTokenType #

# 4. Mapping from LSP tokens to SemanticTokenOriginal.

recoverSemanticTokens :: SemanticTokensConfig -> VirtualFile -> SemanticTokens -> Either Text [SemanticTokenOriginal HsSemanticTokenType] #

recoverSemanticTokens for debug and test. this function is used to recover the original tokens(with token in haskell token type zoon) from the lsp semantic tokens(with token in lsp token type zoon) the `SemanticTokensConfig` used should be a map with bijection property

lspTokenHsToken :: SemanticTokensConfig -> SemanticTokenOriginal SemanticTokenTypes -> SemanticTokenOriginal HsSemanticTokenType #

lspTokenHsToken for debug and test. use the `SemanticTokensConfig` to convert lsp token type to haskell token type the `SemanticTokensConfig` used should be a map with bijection property

recoverLspSemanticTokens :: VirtualFile -> SemanticTokens -> Either Text [SemanticTokenOriginal SemanticTokenTypes] #

recoverLspSemanticTokens for debug and test. this function is used to recover the original tokens(with token in standard lsp token type zoon) from the lsp semantic tokens(with token in lsp token type zoon)