{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Language.LSP.Types.CodeAction where
import Data.Aeson.TH
import Data.Aeson.Types
import Data.Default
import Data.Text ( Text )
import Language.LSP.Types.Command
import Language.LSP.Types.Diagnostic
import Language.LSP.Types.Common
import Language.LSP.Types.Location
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils
import Language.LSP.Types.WorkspaceEdit
data CodeActionKind
=
CodeActionEmpty
|
CodeActionQuickFix
|
CodeActionRefactor
|
|
CodeActionRefactorInline
|
CodeActionRefactorRewrite
|
CodeActionSource
|
CodeActionSourceOrganizeImports
| CodeActionUnknown Text
deriving (ReadPrec [CodeActionKind]
ReadPrec CodeActionKind
Int -> ReadS CodeActionKind
ReadS [CodeActionKind]
(Int -> ReadS CodeActionKind)
-> ReadS [CodeActionKind]
-> ReadPrec CodeActionKind
-> ReadPrec [CodeActionKind]
-> Read CodeActionKind
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeActionKind]
$creadListPrec :: ReadPrec [CodeActionKind]
readPrec :: ReadPrec CodeActionKind
$creadPrec :: ReadPrec CodeActionKind
readList :: ReadS [CodeActionKind]
$creadList :: ReadS [CodeActionKind]
readsPrec :: Int -> ReadS CodeActionKind
$creadsPrec :: Int -> ReadS CodeActionKind
Read, Int -> CodeActionKind -> ShowS
[CodeActionKind] -> ShowS
CodeActionKind -> String
(Int -> CodeActionKind -> ShowS)
-> (CodeActionKind -> String)
-> ([CodeActionKind] -> ShowS)
-> Show CodeActionKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeActionKind] -> ShowS
$cshowList :: [CodeActionKind] -> ShowS
show :: CodeActionKind -> String
$cshow :: CodeActionKind -> String
showsPrec :: Int -> CodeActionKind -> ShowS
$cshowsPrec :: Int -> CodeActionKind -> ShowS
Show, CodeActionKind -> CodeActionKind -> Bool
(CodeActionKind -> CodeActionKind -> Bool)
-> (CodeActionKind -> CodeActionKind -> Bool) -> Eq CodeActionKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeActionKind -> CodeActionKind -> Bool
$c/= :: CodeActionKind -> CodeActionKind -> Bool
== :: CodeActionKind -> CodeActionKind -> Bool
$c== :: CodeActionKind -> CodeActionKind -> Bool
Eq)
instance ToJSON CodeActionKind where
toJSON :: CodeActionKind -> Value
toJSON CodeActionKind
CodeActionEmpty = Text -> Value
String Text
""
toJSON CodeActionKind
CodeActionQuickFix = Text -> Value
String Text
"quickfix"
toJSON CodeActionKind
CodeActionRefactor = Text -> Value
String Text
"refactor"
toJSON CodeActionKind
CodeActionRefactorExtract = Text -> Value
String Text
"refactor.extract"
toJSON CodeActionKind
CodeActionRefactorInline = Text -> Value
String Text
"refactor.inline"
toJSON CodeActionKind
CodeActionRefactorRewrite = Text -> Value
String Text
"refactor.rewrite"
toJSON CodeActionKind
CodeActionSource = Text -> Value
String Text
"source"
toJSON CodeActionKind
CodeActionSourceOrganizeImports = Text -> Value
String Text
"source.organizeImports"
toJSON (CodeActionUnknown Text
s) = Text -> Value
String Text
s
instance FromJSON CodeActionKind where
parseJSON :: Value -> Parser CodeActionKind
parseJSON (String Text
"") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionEmpty
parseJSON (String Text
"quickfix") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionQuickFix
parseJSON (String Text
"refactor") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionRefactor
parseJSON (String Text
"refactor.extract") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionRefactorExtract
parseJSON (String Text
"refactor.inline") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionRefactorInline
parseJSON (String Text
"refactor.rewrite") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionRefactorRewrite
parseJSON (String Text
"source") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionSource
parseJSON (String Text
"source.organizeImports") = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure CodeActionKind
CodeActionSourceOrganizeImports
parseJSON (String Text
s) = CodeActionKind -> Parser CodeActionKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> CodeActionKind
CodeActionUnknown Text
s)
parseJSON Value
_ = Parser CodeActionKind
forall a. Monoid a => a
mempty
data CodeActionKindClientCapabilities =
CodeActionKindClientCapabilities
{
CodeActionKindClientCapabilities -> List CodeActionKind
_valueSet :: List CodeActionKind
} deriving (Int -> CodeActionKindClientCapabilities -> ShowS
[CodeActionKindClientCapabilities] -> ShowS
CodeActionKindClientCapabilities -> String
(Int -> CodeActionKindClientCapabilities -> ShowS)
-> (CodeActionKindClientCapabilities -> String)
-> ([CodeActionKindClientCapabilities] -> ShowS)
-> Show CodeActionKindClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeActionKindClientCapabilities] -> ShowS
$cshowList :: [CodeActionKindClientCapabilities] -> ShowS
show :: CodeActionKindClientCapabilities -> String
$cshow :: CodeActionKindClientCapabilities -> String
showsPrec :: Int -> CodeActionKindClientCapabilities -> ShowS
$cshowsPrec :: Int -> CodeActionKindClientCapabilities -> ShowS
Show, ReadPrec [CodeActionKindClientCapabilities]
ReadPrec CodeActionKindClientCapabilities
Int -> ReadS CodeActionKindClientCapabilities
ReadS [CodeActionKindClientCapabilities]
(Int -> ReadS CodeActionKindClientCapabilities)
-> ReadS [CodeActionKindClientCapabilities]
-> ReadPrec CodeActionKindClientCapabilities
-> ReadPrec [CodeActionKindClientCapabilities]
-> Read CodeActionKindClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeActionKindClientCapabilities]
$creadListPrec :: ReadPrec [CodeActionKindClientCapabilities]
readPrec :: ReadPrec CodeActionKindClientCapabilities
$creadPrec :: ReadPrec CodeActionKindClientCapabilities
readList :: ReadS [CodeActionKindClientCapabilities]
$creadList :: ReadS [CodeActionKindClientCapabilities]
readsPrec :: Int -> ReadS CodeActionKindClientCapabilities
$creadsPrec :: Int -> ReadS CodeActionKindClientCapabilities
Read, CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool
(CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool)
-> (CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool)
-> Eq CodeActionKindClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool
$c/= :: CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool
== :: CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool
$c== :: CodeActionKindClientCapabilities
-> CodeActionKindClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''CodeActionKindClientCapabilities
instance Default CodeActionKindClientCapabilities where
def :: CodeActionKindClientCapabilities
def = List CodeActionKind -> CodeActionKindClientCapabilities
CodeActionKindClientCapabilities ([CodeActionKind] -> List CodeActionKind
forall a. [a] -> List a
List [CodeActionKind]
allKinds)
where allKinds :: [CodeActionKind]
allKinds = [ CodeActionKind
CodeActionQuickFix
, CodeActionKind
CodeActionRefactor
, CodeActionKind
CodeActionRefactorExtract
, CodeActionKind
CodeActionRefactorInline
, CodeActionKind
CodeActionRefactorRewrite
, CodeActionKind
CodeActionSource
, CodeActionKind
CodeActionSourceOrganizeImports
]
data CodeActionLiteralSupport =
CodeActionLiteralSupport
{ CodeActionLiteralSupport -> CodeActionKindClientCapabilities
_codeActionKind :: CodeActionKindClientCapabilities
} deriving (Int -> CodeActionLiteralSupport -> ShowS
[CodeActionLiteralSupport] -> ShowS
CodeActionLiteralSupport -> String
(Int -> CodeActionLiteralSupport -> ShowS)
-> (CodeActionLiteralSupport -> String)
-> ([CodeActionLiteralSupport] -> ShowS)
-> Show CodeActionLiteralSupport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeActionLiteralSupport] -> ShowS
$cshowList :: [CodeActionLiteralSupport] -> ShowS
show :: CodeActionLiteralSupport -> String
$cshow :: CodeActionLiteralSupport -> String
showsPrec :: Int -> CodeActionLiteralSupport -> ShowS
$cshowsPrec :: Int -> CodeActionLiteralSupport -> ShowS
Show, ReadPrec [CodeActionLiteralSupport]
ReadPrec CodeActionLiteralSupport
Int -> ReadS CodeActionLiteralSupport
ReadS [CodeActionLiteralSupport]
(Int -> ReadS CodeActionLiteralSupport)
-> ReadS [CodeActionLiteralSupport]
-> ReadPrec CodeActionLiteralSupport
-> ReadPrec [CodeActionLiteralSupport]
-> Read CodeActionLiteralSupport
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeActionLiteralSupport]
$creadListPrec :: ReadPrec [CodeActionLiteralSupport]
readPrec :: ReadPrec CodeActionLiteralSupport
$creadPrec :: ReadPrec CodeActionLiteralSupport
readList :: ReadS [CodeActionLiteralSupport]
$creadList :: ReadS [CodeActionLiteralSupport]
readsPrec :: Int -> ReadS CodeActionLiteralSupport
$creadsPrec :: Int -> ReadS CodeActionLiteralSupport
Read, CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool
(CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool)
-> (CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool)
-> Eq CodeActionLiteralSupport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool
$c/= :: CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool
== :: CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool
$c== :: CodeActionLiteralSupport -> CodeActionLiteralSupport -> Bool
Eq)
deriveJSON lspOptions ''CodeActionLiteralSupport
data CodeActionClientCapabilities = CodeActionClientCapabilities
{
CodeActionClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool,
CodeActionClientCapabilities -> Maybe CodeActionLiteralSupport
_codeActionLiteralSupport :: Maybe CodeActionLiteralSupport,
CodeActionClientCapabilities -> Maybe Bool
_isPreferredSupport :: Maybe Bool
}
deriving (Int -> CodeActionClientCapabilities -> ShowS
[CodeActionClientCapabilities] -> ShowS
CodeActionClientCapabilities -> String
(Int -> CodeActionClientCapabilities -> ShowS)
-> (CodeActionClientCapabilities -> String)
-> ([CodeActionClientCapabilities] -> ShowS)
-> Show CodeActionClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeActionClientCapabilities] -> ShowS
$cshowList :: [CodeActionClientCapabilities] -> ShowS
show :: CodeActionClientCapabilities -> String
$cshow :: CodeActionClientCapabilities -> String
showsPrec :: Int -> CodeActionClientCapabilities -> ShowS
$cshowsPrec :: Int -> CodeActionClientCapabilities -> ShowS
Show, ReadPrec [CodeActionClientCapabilities]
ReadPrec CodeActionClientCapabilities
Int -> ReadS CodeActionClientCapabilities
ReadS [CodeActionClientCapabilities]
(Int -> ReadS CodeActionClientCapabilities)
-> ReadS [CodeActionClientCapabilities]
-> ReadPrec CodeActionClientCapabilities
-> ReadPrec [CodeActionClientCapabilities]
-> Read CodeActionClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeActionClientCapabilities]
$creadListPrec :: ReadPrec [CodeActionClientCapabilities]
readPrec :: ReadPrec CodeActionClientCapabilities
$creadPrec :: ReadPrec CodeActionClientCapabilities
readList :: ReadS [CodeActionClientCapabilities]
$creadList :: ReadS [CodeActionClientCapabilities]
readsPrec :: Int -> ReadS CodeActionClientCapabilities
$creadsPrec :: Int -> ReadS CodeActionClientCapabilities
Read, CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool
(CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool)
-> (CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool)
-> Eq CodeActionClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool
$c/= :: CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool
== :: CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool
$c== :: CodeActionClientCapabilities
-> CodeActionClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''CodeActionClientCapabilities
makeExtendingDatatype "CodeActionOptions" [''WorkDoneProgressOptions]
[("_codeActionKinds", [t| Maybe (List CodeActionKind) |])]
deriveJSON lspOptions ''CodeActionOptions
makeExtendingDatatype "CodeActionRegistrationOptions"
[ ''TextDocumentRegistrationOptions
, ''CodeActionOptions
] []
deriveJSON lspOptions ''CodeActionRegistrationOptions
data CodeActionContext = CodeActionContext
{
CodeActionContext -> List Diagnostic
_diagnostics :: List Diagnostic
, CodeActionContext -> Maybe (List CodeActionKind)
_only :: Maybe (List CodeActionKind)
}
deriving (ReadPrec [CodeActionContext]
ReadPrec CodeActionContext
Int -> ReadS CodeActionContext
ReadS [CodeActionContext]
(Int -> ReadS CodeActionContext)
-> ReadS [CodeActionContext]
-> ReadPrec CodeActionContext
-> ReadPrec [CodeActionContext]
-> Read CodeActionContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeActionContext]
$creadListPrec :: ReadPrec [CodeActionContext]
readPrec :: ReadPrec CodeActionContext
$creadPrec :: ReadPrec CodeActionContext
readList :: ReadS [CodeActionContext]
$creadList :: ReadS [CodeActionContext]
readsPrec :: Int -> ReadS CodeActionContext
$creadsPrec :: Int -> ReadS CodeActionContext
Read, Int -> CodeActionContext -> ShowS
[CodeActionContext] -> ShowS
CodeActionContext -> String
(Int -> CodeActionContext -> ShowS)
-> (CodeActionContext -> String)
-> ([CodeActionContext] -> ShowS)
-> Show CodeActionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeActionContext] -> ShowS
$cshowList :: [CodeActionContext] -> ShowS
show :: CodeActionContext -> String
$cshow :: CodeActionContext -> String
showsPrec :: Int -> CodeActionContext -> ShowS
$cshowsPrec :: Int -> CodeActionContext -> ShowS
Show, CodeActionContext -> CodeActionContext -> Bool
(CodeActionContext -> CodeActionContext -> Bool)
-> (CodeActionContext -> CodeActionContext -> Bool)
-> Eq CodeActionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeActionContext -> CodeActionContext -> Bool
$c/= :: CodeActionContext -> CodeActionContext -> Bool
== :: CodeActionContext -> CodeActionContext -> Bool
$c== :: CodeActionContext -> CodeActionContext -> Bool
Eq)
deriveJSON lspOptions ''CodeActionContext
makeExtendingDatatype "CodeActionParams"
[ ''WorkDoneProgressParams
, ''PartialResultParams
]
[ ("_textDocument", [t|TextDocumentIdentifier|]),
("_range", [t|Range|]),
("_context", [t|CodeActionContext|])
]
deriveJSON lspOptions ''CodeActionParams
data CodeAction =
CodeAction
{
CodeAction -> Text
_title :: Text,
CodeAction -> Maybe CodeActionKind
_kind :: Maybe CodeActionKind,
CodeAction -> Maybe (List Diagnostic)
_diagnostics :: Maybe (List Diagnostic),
CodeAction -> Maybe Bool
_isPreferred :: Maybe Bool,
CodeAction -> Maybe WorkspaceEdit
_edit :: Maybe WorkspaceEdit,
CodeAction -> Maybe Command
_command :: Maybe Command
}
deriving (ReadPrec [CodeAction]
ReadPrec CodeAction
Int -> ReadS CodeAction
ReadS [CodeAction]
(Int -> ReadS CodeAction)
-> ReadS [CodeAction]
-> ReadPrec CodeAction
-> ReadPrec [CodeAction]
-> Read CodeAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeAction]
$creadListPrec :: ReadPrec [CodeAction]
readPrec :: ReadPrec CodeAction
$creadPrec :: ReadPrec CodeAction
readList :: ReadS [CodeAction]
$creadList :: ReadS [CodeAction]
readsPrec :: Int -> ReadS CodeAction
$creadsPrec :: Int -> ReadS CodeAction
Read, Int -> CodeAction -> ShowS
[CodeAction] -> ShowS
CodeAction -> String
(Int -> CodeAction -> ShowS)
-> (CodeAction -> String)
-> ([CodeAction] -> ShowS)
-> Show CodeAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeAction] -> ShowS
$cshowList :: [CodeAction] -> ShowS
show :: CodeAction -> String
$cshow :: CodeAction -> String
showsPrec :: Int -> CodeAction -> ShowS
$cshowsPrec :: Int -> CodeAction -> ShowS
Show, CodeAction -> CodeAction -> Bool
(CodeAction -> CodeAction -> Bool)
-> (CodeAction -> CodeAction -> Bool) -> Eq CodeAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeAction -> CodeAction -> Bool
$c/= :: CodeAction -> CodeAction -> Bool
== :: CodeAction -> CodeAction -> Bool
$c== :: CodeAction -> CodeAction -> Bool
Eq)
deriveJSON lspOptions ''CodeAction