{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RecordWildCards #-}
module Ide.Plugin.Class.ExactPrint where
import Control.Monad.Trans.Maybe
import qualified Data.Text as T
import Development.IDE.GHC.Compat
import Ide.Plugin.Class.Types
import Ide.Plugin.Class.Utils
import Language.Haskell.GHC.ExactPrint
import Language.Haskell.GHC.ExactPrint.Parsers
import Data.Either.Extra (eitherToMaybe)
import Data.Functor.Identity (Identity)
import GHC.Parser.Annotation
import Language.LSP.Protocol.Types (Range)
makeEditText :: Monad m => ParsedModule -> DynFlags -> AddMinimalMethodsParams -> MaybeT m (T.Text, T.Text)
makeEditText :: forall (m :: * -> *).
Monad m =>
ParsedModule
-> DynFlags -> AddMinimalMethodsParams -> MaybeT m (Text, Text)
makeEditText ParsedModule
pm DynFlags
df AddMinimalMethodsParams{Bool
[(Text, Text)]
Range
VersionedTextDocumentIdentifier
verTxtDocId :: VersionedTextDocumentIdentifier
range :: Range
methodGroup :: [(Text, Text)]
withSig :: Bool
verTxtDocId :: AddMinimalMethodsParams -> VersionedTextDocumentIdentifier
range :: AddMinimalMethodsParams -> Range
methodGroup :: AddMinimalMethodsParams -> [(Text, Text)]
withSig :: AddMinimalMethodsParams -> Bool
..} = do
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
mDecls <- m (Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))])
-> MaybeT
m
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))])
-> MaybeT
m
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))])
-> (Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> m (Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]))
-> Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> MaybeT
m
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> m (Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> MaybeT
m
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))])
-> Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> MaybeT
m
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
forall a b. (a -> b) -> a -> b
$ ((Text, Text)
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)))
-> [(Text, Text)]
-> Maybe
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (DynFlags -> (Text, Text) -> Maybe (LHsDecl GhcPs, LHsDecl GhcPs)
makeMethodDecl DynFlags
df) [(Text, Text)]
methodGroup
let ps :: ParsedSource
ps = ParsedSource -> ParsedSource
forall ast. ExactPrint ast => ast -> ast
makeDeltaAst (ParsedSource -> ParsedSource) -> ParsedSource -> ParsedSource
forall a b. (a -> b) -> a -> b
$ ParsedModule -> ParsedSource
pm_parsed_source ParsedModule
pm
old :: Text
old = String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ ParsedSource -> String
forall ast. ExactPrint ast => ast -> String
exactPrint ParsedSource
ps
(ParsedSource
ps', Int
_, [String]
_) = Transform ParsedSource -> (ParsedSource, Int, [String])
forall a. Transform a -> (a, Int, [String])
runTransform (ParsedSource
-> [(LHsDecl GhcPs, LHsDecl GhcPs)]
-> Range
-> Bool
-> Transform ParsedSource
addMethodDecls ParsedSource
ps [(LHsDecl GhcPs, LHsDecl GhcPs)]
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
mDecls Range
range Bool
withSig)
new :: Text
new = String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ ParsedSource -> String
forall ast. ExactPrint ast => ast -> String
exactPrint ParsedSource
ps'
(Text, Text) -> MaybeT m (Text, Text)
forall a. a -> MaybeT m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text
old, Text
new)
makeMethodDecl :: DynFlags -> (T.Text, T.Text) -> Maybe (LHsDecl GhcPs, LHsDecl GhcPs)
makeMethodDecl :: DynFlags -> (Text, Text) -> Maybe (LHsDecl GhcPs, LHsDecl GhcPs)
makeMethodDecl DynFlags
df (Text
mName, Text
sig) = do
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
name <- Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall a b. Either a b -> Maybe b
eitherToMaybe (Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)))
-> Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall a b. (a -> b) -> a -> b
$ Parser (LHsDecl GhcPs)
parseDecl DynFlags
df (Text -> String
T.unpack Text
mName) (String
-> Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)))
-> (Text -> String)
-> Text
-> Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack (Text
-> Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)))
-> Text
-> Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall a b. (a -> b) -> a -> b
$ Text -> Text
toMethodName Text
mName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" = _"
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
sig' <- Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall a b. Either a b -> Maybe b
eitherToMaybe (Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)))
-> Either
ErrorMessages
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall a b. (a -> b) -> a -> b
$ Parser (LHsDecl GhcPs)
parseDecl DynFlags
df (Text -> String
T.unpack Text
sig) (String -> ParseResult (LHsDecl GhcPs))
-> String -> ParseResult (LHsDecl GhcPs)
forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
sig
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> Maybe
(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
name, GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
sig')
#if MIN_VERSION_ghc(9,5,0)
addMethodDecls :: ParsedSource -> [(LHsDecl GhcPs, LHsDecl GhcPs)] -> Range -> Bool -> TransformT Identity (Located (HsModule GhcPs))
#else
addMethodDecls :: ParsedSource -> [(LHsDecl GhcPs, LHsDecl GhcPs)] -> Range -> Bool -> TransformT Identity (Located HsModule)
#endif
addMethodDecls :: ParsedSource
-> [(LHsDecl GhcPs, LHsDecl GhcPs)]
-> Range
-> Bool
-> Transform ParsedSource
addMethodDecls ParsedSource
ps [(LHsDecl GhcPs, LHsDecl GhcPs)]
mDecls Range
range Bool
withSig
| Bool
withSig = [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> Transform ParsedSource
go (((GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)])
-> [(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
decl, GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
sig) -> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
sig, GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
decl]) [(LHsDecl GhcPs, LHsDecl GhcPs)]
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
mDecls)
| Bool
otherwise = [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> Transform ParsedSource
go (((GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> [(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
forall a b. (a -> b) -> [a] -> [b]
map (GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
forall a b. (a, b) -> a
fst [(LHsDecl GhcPs, LHsDecl GhcPs)]
[(GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs),
GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))]
mDecls)
where
go :: [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> Transform ParsedSource
go [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
inserting = do
[GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
allDecls <- ParsedSource -> TransformT Identity [LHsDecl GhcPs]
forall t (m :: * -> *).
(HasDecls t, Monad m) =>
t -> TransformT m [LHsDecl GhcPs]
forall (m :: * -> *).
Monad m =>
ParsedSource -> TransformT m [LHsDecl GhcPs]
hsDecls ParsedSource
ps
case (GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> Bool)
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> ([GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)],
[GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)])
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Range -> SrcSpan -> Bool
inRange Range
range (SrcSpan -> Bool)
-> (GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> SrcSpan)
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc) [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
allDecls of
([GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
before, L SrcSpanAnn' (EpAnn AnnListItem)
l HsDecl GhcPs
inst : [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
after) -> ParsedSource -> [LHsDecl GhcPs] -> Transform ParsedSource
forall t (m :: * -> *).
(HasDecls t, Monad m) =>
t -> [LHsDecl GhcPs] -> TransformT m t
forall (m :: * -> *).
Monad m =>
ParsedSource -> [LHsDecl GhcPs] -> TransformT m ParsedSource
replaceDecls ParsedSource
ps ([GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
before [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
forall a. [a] -> [a] -> [a]
++ SrcSpanAnn' (EpAnn AnnListItem)
-> HsDecl GhcPs
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
forall l e. l -> e -> GenLocated l e
L SrcSpanAnn' (EpAnn AnnListItem)
l (HsDecl GhcPs -> HsDecl GhcPs
forall {p} {b}.
(XCClsInstDecl p ~ (EpAnn [AddEpAnn], b)) =>
HsDecl p -> HsDecl p
addWhere HsDecl GhcPs
inst)GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
forall a. a -> [a] -> [a]
:((GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs))
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
forall a b. (a -> b) -> [a] -> [b]
map GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
-> GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)
forall {ann} {e}.
Monoid ann =>
GenLocated (SrcSpanAnn' (EpAnn ann)) e
-> GenLocated (SrcSpanAnn' (EpAnn ann)) e
newLine [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
inserting [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
-> [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
forall a. [a] -> [a] -> [a]
++ [GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
after))
([GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
before, []) -> ParsedSource -> [LHsDecl GhcPs] -> Transform ParsedSource
forall t (m :: * -> *).
(HasDecls t, Monad m) =>
t -> [LHsDecl GhcPs] -> TransformT m t
forall (m :: * -> *).
Monad m =>
ParsedSource -> [LHsDecl GhcPs] -> TransformT m ParsedSource
replaceDecls ParsedSource
ps [LHsDecl GhcPs]
[GenLocated (SrcSpanAnn' (EpAnn AnnListItem)) (HsDecl GhcPs)]
before
addWhere :: HsDecl p -> HsDecl p
addWhere instd :: HsDecl p
instd@(InstD XInstD p
xInstD (ClsInstD XClsInstD p
ext decl :: ClsInstDecl p
decl@ClsInstDecl{[LSig p]
[LDataFamInstDecl p]
[LTyFamInstDecl p]
Maybe (XRec p OverlapMode)
XCClsInstDecl p
LHsSigType p
LHsBinds p
cid_ext :: XCClsInstDecl p
cid_poly_ty :: LHsSigType p
cid_binds :: LHsBinds p
cid_sigs :: [LSig p]
cid_tyfam_insts :: [LTyFamInstDecl p]
cid_datafam_insts :: [LDataFamInstDecl p]
cid_overlap_mode :: Maybe (XRec p OverlapMode)
cid_ext :: forall pass. ClsInstDecl pass -> XCClsInstDecl pass
cid_poly_ty :: forall pass. ClsInstDecl pass -> LHsSigType pass
cid_binds :: forall pass. ClsInstDecl pass -> LHsBinds pass
cid_sigs :: forall pass. ClsInstDecl pass -> [LSig pass]
cid_tyfam_insts :: forall pass. ClsInstDecl pass -> [LTyFamInstDecl pass]
cid_datafam_insts :: forall pass. ClsInstDecl pass -> [LDataFamInstDecl pass]
cid_overlap_mode :: forall pass. ClsInstDecl pass -> Maybe (XRec pass OverlapMode)
..})) =
case XCClsInstDecl p
cid_ext of
(EpAnn Anchor
entry [AddEpAnn]
anns EpAnnComments
comments, b
key) ->
XInstD p -> InstDecl p -> HsDecl p
forall p. XInstD p -> InstDecl p -> HsDecl p
InstD XInstD p
xInstD (XClsInstD p -> ClsInstDecl p -> InstDecl p
forall pass. XClsInstD pass -> ClsInstDecl pass -> InstDecl pass
ClsInstD XClsInstD p
ext ClsInstDecl p
decl {
cid_ext = (EpAnn
entry
(AddEpAnn AnnWhere (EpaDelta (SameLine 1) []) : anns)
comments
, key)
})
XCClsInstDecl p
_ -> HsDecl p
instd
addWhere HsDecl p
decl = HsDecl p
decl
newLine :: GenLocated (SrcSpanAnn' (EpAnn ann)) e
-> GenLocated (SrcSpanAnn' (EpAnn ann)) e
newLine (L SrcSpanAnn' (EpAnn ann)
l e
e) =
let dp :: DeltaPos
dp = Int -> Int -> DeltaPos
deltaPos Int
1 Int
defaultIndent
in SrcSpanAnn' (EpAnn ann)
-> e -> GenLocated (SrcSpanAnn' (EpAnn ann)) e
forall l e. l -> e -> GenLocated l e
L (SrcSpan -> DeltaPos -> SrcSpanAnn' (EpAnn ann)
forall ann.
Monoid ann =>
SrcSpan -> DeltaPos -> SrcSpanAnn' (EpAnn ann)
noAnnSrcSpanDP (SrcSpanAnn' (EpAnn ann) -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
getLoc SrcSpanAnn' (EpAnn ann)
l) DeltaPos
dp SrcSpanAnn' (EpAnn ann)
-> SrcSpanAnn' (EpAnn ann) -> SrcSpanAnn' (EpAnn ann)
forall a. Semigroup a => a -> a -> a
<> SrcSpanAnn' (EpAnn ann)
l) e
e