{-# 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.String
import Data.Text ( Text )
import qualified Data.Text as T
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]
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
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
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)
fromHierarchicalString :: Text -> CodeActionKind
fromHierarchicalString :: Text -> CodeActionKind
fromHierarchicalString Text
t = case Text
t of
Text
"" -> CodeActionKind
CodeActionEmpty
Text
"quickfix" -> CodeActionKind
CodeActionQuickFix
Text
"refactor" -> CodeActionKind
CodeActionRefactor
Text
"refactor.extract" -> CodeActionKind
CodeActionRefactorExtract
Text
"refactor.inline" -> CodeActionKind
CodeActionRefactorInline
Text
"refactor.rewrite" -> CodeActionKind
CodeActionRefactorRewrite
Text
"source" -> CodeActionKind
CodeActionSource
Text
"source.organizeImports" -> CodeActionKind
CodeActionSourceOrganizeImports
Text
s -> Text -> CodeActionKind
CodeActionUnknown Text
s
toHierarchicalString :: CodeActionKind -> Text
toHierarchicalString :: CodeActionKind -> Text
toHierarchicalString CodeActionKind
k = case CodeActionKind
k of
CodeActionKind
CodeActionEmpty -> Text
""
CodeActionKind
CodeActionQuickFix -> Text
"quickfix"
CodeActionKind
CodeActionRefactor -> Text
"refactor"
CodeActionKind
CodeActionRefactorExtract -> Text
"refactor.extract"
CodeActionKind
CodeActionRefactorInline -> Text
"refactor.inline"
CodeActionKind
CodeActionRefactorRewrite -> Text
"refactor.rewrite"
CodeActionKind
CodeActionSource -> Text
"source"
CodeActionKind
CodeActionSourceOrganizeImports -> Text
"source.organizeImports"
(CodeActionUnknown Text
s) -> Text
s
instance IsString CodeActionKind where
fromString :: String -> CodeActionKind
fromString = Text -> CodeActionKind
fromHierarchicalString forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
instance ToJSON CodeActionKind where
toJSON :: CodeActionKind -> Value
toJSON = Text -> Value
String forall b c a. (b -> c) -> (a -> b) -> a -> c
. CodeActionKind -> Text
toHierarchicalString
instance FromJSON CodeActionKind where
parseJSON :: Value -> Parser CodeActionKind
parseJSON (String Text
s) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Text -> CodeActionKind
fromHierarchicalString Text
s
parseJSON Value
_ = forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"CodeActionKind"
codeActionKindSubsumes :: CodeActionKind -> CodeActionKind -> Bool
codeActionKindSubsumes :: CodeActionKind -> CodeActionKind -> Bool
codeActionKindSubsumes CodeActionKind
parent CodeActionKind
child = CodeActionKind -> Text
toHierarchicalString CodeActionKind
parent Text -> Text -> Bool
`T.isPrefixOf` CodeActionKind -> Text
toHierarchicalString CodeActionKind
child
specCodeActionKinds :: [CodeActionKind]
specCodeActionKinds :: [CodeActionKind]
specCodeActionKinds = [
CodeActionKind
CodeActionQuickFix
, CodeActionKind
CodeActionRefactor
, CodeActionKind
CodeActionRefactorExtract
, CodeActionKind
CodeActionRefactorInline
, CodeActionKind
CodeActionRefactorRewrite
, CodeActionKind
CodeActionSource
, CodeActionKind
CodeActionSourceOrganizeImports
]
data CodeActionKindClientCapabilities =
CodeActionKindClientCapabilities
{
CodeActionKindClientCapabilities -> List CodeActionKind
_valueSet :: List CodeActionKind
} deriving (Int -> CodeActionKindClientCapabilities -> ShowS
[CodeActionKindClientCapabilities] -> ShowS
CodeActionKindClientCapabilities -> String
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]
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
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 (forall a. [a] -> List a
List [CodeActionKind]
specCodeActionKinds)
data CodeActionLiteralSupport =
CodeActionLiteralSupport
{ CodeActionLiteralSupport -> CodeActionKindClientCapabilities
_codeActionKind :: CodeActionKindClientCapabilities
} deriving (Int -> CodeActionLiteralSupport -> ShowS
[CodeActionLiteralSupport] -> ShowS
CodeActionLiteralSupport -> String
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]
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
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 CodeActionResolveClientCapabilities =
CodeActionResolveClientCapabilities
{ CodeActionResolveClientCapabilities -> List Text
_properties :: List Text
} deriving (Int -> CodeActionResolveClientCapabilities -> ShowS
[CodeActionResolveClientCapabilities] -> ShowS
CodeActionResolveClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeActionResolveClientCapabilities] -> ShowS
$cshowList :: [CodeActionResolveClientCapabilities] -> ShowS
show :: CodeActionResolveClientCapabilities -> String
$cshow :: CodeActionResolveClientCapabilities -> String
showsPrec :: Int -> CodeActionResolveClientCapabilities -> ShowS
$cshowsPrec :: Int -> CodeActionResolveClientCapabilities -> ShowS
Show, ReadPrec [CodeActionResolveClientCapabilities]
ReadPrec CodeActionResolveClientCapabilities
Int -> ReadS CodeActionResolveClientCapabilities
ReadS [CodeActionResolveClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeActionResolveClientCapabilities]
$creadListPrec :: ReadPrec [CodeActionResolveClientCapabilities]
readPrec :: ReadPrec CodeActionResolveClientCapabilities
$creadPrec :: ReadPrec CodeActionResolveClientCapabilities
readList :: ReadS [CodeActionResolveClientCapabilities]
$creadList :: ReadS [CodeActionResolveClientCapabilities]
readsPrec :: Int -> ReadS CodeActionResolveClientCapabilities
$creadsPrec :: Int -> ReadS CodeActionResolveClientCapabilities
Read, CodeActionResolveClientCapabilities
-> CodeActionResolveClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeActionResolveClientCapabilities
-> CodeActionResolveClientCapabilities -> Bool
$c/= :: CodeActionResolveClientCapabilities
-> CodeActionResolveClientCapabilities -> Bool
== :: CodeActionResolveClientCapabilities
-> CodeActionResolveClientCapabilities -> Bool
$c== :: CodeActionResolveClientCapabilities
-> CodeActionResolveClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''CodeActionResolveClientCapabilities
data CodeActionClientCapabilities = CodeActionClientCapabilities
{
CodeActionClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool,
CodeActionClientCapabilities -> Maybe CodeActionLiteralSupport
_codeActionLiteralSupport :: Maybe CodeActionLiteralSupport,
CodeActionClientCapabilities -> Maybe Bool
_isPreferredSupport :: Maybe Bool,
CodeActionClientCapabilities -> Maybe Bool
_disabledSupport :: Maybe Bool,
CodeActionClientCapabilities -> Maybe Bool
_dataSupport :: Maybe Bool,
CodeActionClientCapabilities
-> Maybe CodeActionResolveClientCapabilities
_resolveSupport :: Maybe CodeActionResolveClientCapabilities,
CodeActionClientCapabilities -> Maybe Bool
_honorsChangeAnnotations :: Maybe Bool
}
deriving (Int -> CodeActionClientCapabilities -> ShowS
[CodeActionClientCapabilities] -> ShowS
CodeActionClientCapabilities -> String
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]
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
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) |]), ("_resolveProvider", [t| Maybe Bool |]) ]
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]
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
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
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
newtype Reason = Reason {Reason -> Text
_reason :: Text}
deriving (ReadPrec [Reason]
ReadPrec Reason
Int -> ReadS Reason
ReadS [Reason]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Reason]
$creadListPrec :: ReadPrec [Reason]
readPrec :: ReadPrec Reason
$creadPrec :: ReadPrec Reason
readList :: ReadS [Reason]
$creadList :: ReadS [Reason]
readsPrec :: Int -> ReadS Reason
$creadsPrec :: Int -> ReadS Reason
Read, Int -> Reason -> ShowS
[Reason] -> ShowS
Reason -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Reason] -> ShowS
$cshowList :: [Reason] -> ShowS
show :: Reason -> String
$cshow :: Reason -> String
showsPrec :: Int -> Reason -> ShowS
$cshowsPrec :: Int -> Reason -> ShowS
Show, Reason -> Reason -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Reason -> Reason -> Bool
$c/= :: Reason -> Reason -> Bool
== :: Reason -> Reason -> Bool
$c== :: Reason -> Reason -> Bool
Eq)
deriveJSON lspOptions ''Reason
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 Reason
_disabled :: Maybe Reason,
CodeAction -> Maybe WorkspaceEdit
_edit :: Maybe WorkspaceEdit,
CodeAction -> Maybe Command
_command :: Maybe Command,
CodeAction -> Maybe Value
_xdata :: Maybe Value
}
deriving (ReadPrec [CodeAction]
ReadPrec CodeAction
Int -> ReadS CodeAction
ReadS [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
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
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