module Development.IDE.Plugin.Completions.Types (
module Development.IDE.Plugin.Completions.Types
) where
import Control.DeepSeq
import qualified Data.Map as Map
import qualified Data.Text as T
import Development.IDE.Spans.Common
import Language.Haskell.LSP.Types (CompletionItemKind)
data Backtick = Surrounded | LeftSide
deriving (Eq, Ord, Show)
data CompItem = CI
{ compKind :: CompletionItemKind
, insertText :: T.Text
, importedFrom :: T.Text
, typeText :: Maybe T.Text
, label :: T.Text
, isInfix :: Maybe Backtick
, docs :: SpanDoc
, isTypeCompl :: Bool
}
deriving (Eq, Show)
newtype QualCompls
= QualCompls { getQualCompls :: Map.Map T.Text [CompItem] }
deriving Show
instance Semigroup QualCompls where
(QualCompls a) <> (QualCompls b) = QualCompls $ Map.unionWith (++) a b
instance Monoid QualCompls where
mempty = QualCompls Map.empty
mappend = (Prelude.<>)
data CachedCompletions = CC
{ allModNamesAsNS :: [T.Text]
, unqualCompls :: [CompItem]
, qualCompls :: QualCompls
, importableModules :: [T.Text]
} deriving Show
instance NFData CachedCompletions where
rnf = rwhnf
instance Monoid CachedCompletions where
mempty = CC mempty mempty mempty mempty
instance Semigroup CachedCompletions where
CC a b c d <> CC a' b' c' d' =
CC (a<>a') (b<>b') (c<>c') (d<>d')