Hack away LayouterBasics (ouch)
parent
e46e459e87
commit
494a0ba09a
|
@ -34,21 +34,23 @@ import qualified Language.Haskell.GHC.ExactPrint as ExactPrint
|
||||||
-- import qualified Language.Haskell.GHC.ExactPrint.Annotate as ExactPrint.Annotate
|
-- import qualified Language.Haskell.GHC.ExactPrint.Annotate as ExactPrint.Annotate
|
||||||
import qualified Language.Haskell.GHC.ExactPrint.Types as ExactPrint.Types
|
import qualified Language.Haskell.GHC.ExactPrint.Types as ExactPrint.Types
|
||||||
import qualified Language.Haskell.GHC.ExactPrint.Types as ExactPrint
|
import qualified Language.Haskell.GHC.ExactPrint.Types as ExactPrint
|
||||||
import Language.Haskell.GHC.ExactPrint.Types (AnnKey, Annotation)
|
-- import Language.Haskell.GHC.ExactPrint.Types (AnnKey, Annotation)
|
||||||
import qualified Language.Haskell.GHC.ExactPrint.Utils as ExactPrint.Utils
|
import qualified Language.Haskell.GHC.ExactPrint.Utils as ExactPrint.Utils
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
processDefault
|
processDefault
|
||||||
:: ( ExactPrint.Annotate.Annotate ast
|
:: (
|
||||||
, MonadMultiWriter Text.Builder.Builder m
|
-- ExactPrint.Annotate.Annotate ast
|
||||||
, MonadMultiReader ExactPrint.Types.Anns m
|
ExactPrint.ExactPrint ast
|
||||||
|
, MonadMultiWriter Text.Builder.Builder m
|
||||||
|
-- , MonadMultiReader ExactPrint.Types.Anns m
|
||||||
)
|
)
|
||||||
=> Located ast
|
=> Located ast
|
||||||
-> m ()
|
-> m ()
|
||||||
processDefault x = do
|
processDefault x = do
|
||||||
anns <- mAsk
|
-- anns <- mAsk
|
||||||
let str = ExactPrint.exactPrint x anns
|
let str = ExactPrint.exactPrint x {-anns-}
|
||||||
-- this hack is here so our print-empty-module trick does not add
|
-- this hack is here so our print-empty-module trick does not add
|
||||||
-- a newline at the start if there actually is no module header / imports
|
-- a newline at the start if there actually is no module header / imports
|
||||||
-- / anything.
|
-- / anything.
|
||||||
|
@ -63,16 +65,18 @@ processDefault x = do
|
||||||
-- not handled by brittany yet). Useful when starting implementing new
|
-- not handled by brittany yet). Useful when starting implementing new
|
||||||
-- syntactic constructs when children are not handled yet.
|
-- syntactic constructs when children are not handled yet.
|
||||||
briDocByExact
|
briDocByExact
|
||||||
:: (ExactPrint.Annotate.Annotate ast)
|
::
|
||||||
|
-- (ExactPrint.Annotate.Annotate ast)
|
||||||
|
Data ast
|
||||||
=> Located ast
|
=> Located ast
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
briDocByExact ast = do
|
briDocByExact ast = do
|
||||||
anns <- mAsk
|
-- anns <- mAsk
|
||||||
traceIfDumpConf
|
traceIfDumpConf
|
||||||
"ast"
|
"ast"
|
||||||
_dconf_dump_ast_unknown
|
_dconf_dump_ast_unknown
|
||||||
(printTreeWithCustom 100 (customLayouterF anns) ast)
|
(printTreeWithCustom 100 (customLayouterF {-anns-}) ast)
|
||||||
docExt ast anns True
|
docExt ast {-anns-} True
|
||||||
|
|
||||||
-- | Use ExactPrint's output for this node.
|
-- | Use ExactPrint's output for this node.
|
||||||
-- Consider that for multi-line input, the indentation of the code produced
|
-- Consider that for multi-line input, the indentation of the code produced
|
||||||
|
@ -80,38 +84,44 @@ briDocByExact ast = do
|
||||||
-- of its surroundings as layouted by brittany. But there are safe uses of
|
-- of its surroundings as layouted by brittany. But there are safe uses of
|
||||||
-- this, e.g. for any top-level declarations.
|
-- this, e.g. for any top-level declarations.
|
||||||
briDocByExactNoComment
|
briDocByExactNoComment
|
||||||
:: (ExactPrint.Annotate.Annotate ast)
|
::
|
||||||
|
-- (ExactPrint.Annotate.Annotate ast)
|
||||||
|
Data ast
|
||||||
=> Located ast
|
=> Located ast
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
briDocByExactNoComment ast = do
|
briDocByExactNoComment ast = do
|
||||||
anns <- mAsk
|
-- anns <- mAsk
|
||||||
traceIfDumpConf
|
traceIfDumpConf
|
||||||
"ast"
|
"ast"
|
||||||
_dconf_dump_ast_unknown
|
_dconf_dump_ast_unknown
|
||||||
(printTreeWithCustom 100 (customLayouterF anns) ast)
|
(printTreeWithCustom 100 (customLayouterF {-anns-}) ast)
|
||||||
docExt ast anns False
|
docExt ast {-anns-} False
|
||||||
|
|
||||||
-- | Use ExactPrint's output for this node, presuming that this output does
|
-- | Use ExactPrint's output for this node, presuming that this output does
|
||||||
-- not contain any newlines. If this property is not met, the semantics
|
-- not contain any newlines. If this property is not met, the semantics
|
||||||
-- depend on the @econf_AllowRiskyExactPrintUse@ config flag.
|
-- depend on the @econf_AllowRiskyExactPrintUse@ config flag.
|
||||||
briDocByExactInlineOnly
|
briDocByExactInlineOnly
|
||||||
:: (ExactPrint.Annotate.Annotate ast)
|
::
|
||||||
|
-- (ExactPrint.Annotate.Annotate ast)
|
||||||
|
(Data ast, ExactPrint.ExactPrint ast)
|
||||||
=> String
|
=> String
|
||||||
-> Located ast
|
-> Located ast
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
briDocByExactInlineOnly infoStr ast = do
|
briDocByExactInlineOnly infoStr ast = do
|
||||||
anns <- mAsk
|
-- anns <- mAsk
|
||||||
traceIfDumpConf
|
traceIfDumpConf
|
||||||
"ast"
|
"ast"
|
||||||
_dconf_dump_ast_unknown
|
_dconf_dump_ast_unknown
|
||||||
(printTreeWithCustom 100 (customLayouterF anns) ast)
|
(printTreeWithCustom 100 (customLayouterF {-anns-}) ast)
|
||||||
let exactPrinted = Text.pack $ ExactPrint.exactPrint ast anns
|
let exactPrinted = Text.pack $ ExactPrint.exactPrint ast {-anns-}
|
||||||
fallbackMode <-
|
fallbackMode <-
|
||||||
mAsk <&> _conf_errorHandling .> _econf_ExactPrintFallback .> confUnpack
|
mAsk <&> _conf_errorHandling .> _econf_ExactPrintFallback .> confUnpack
|
||||||
let
|
let
|
||||||
exactPrintNode t = allocateNode $ BDFExternal
|
exactPrintNode t = allocateNode $ BDFExternal
|
||||||
(ExactPrint.Types.mkAnnKey ast)
|
-- ({-ExactPrint.Types.mkAnnKey-} undefined ast)
|
||||||
(foldedAnnKeys ast)
|
undefined
|
||||||
|
-- (foldedAnnKeys ast)
|
||||||
|
undefined
|
||||||
False
|
False
|
||||||
t
|
t
|
||||||
let
|
let
|
||||||
|
@ -138,37 +148,47 @@ lrdrNameToText :: GenLocated l RdrName -> Text
|
||||||
lrdrNameToText (L _ n) = rdrNameToText n
|
lrdrNameToText (L _ n) = rdrNameToText n
|
||||||
|
|
||||||
lrdrNameToTextAnnGen
|
lrdrNameToTextAnnGen
|
||||||
:: (MonadMultiReader Config m, MonadMultiReader (Map AnnKey Annotation) m)
|
:: (MonadMultiReader Config m
|
||||||
|
-- , MonadMultiReader (Map AnnKey Annotation) m
|
||||||
|
)
|
||||||
=> (Text -> Text)
|
=> (Text -> Text)
|
||||||
-> Located RdrName
|
-> Located RdrName
|
||||||
-> m Text
|
-> m Text
|
||||||
lrdrNameToTextAnnGen f ast@(L _ n) = do
|
lrdrNameToTextAnnGen f ast@(L _ n) = do
|
||||||
anns <- mAsk
|
-- anns <- mAsk
|
||||||
let t = f $ rdrNameToText n
|
let t = f $ rdrNameToText n
|
||||||
let
|
let
|
||||||
hasUni x (ExactPrint.Types.G y, _) = x == y
|
-- hasUni x (ExactPrint.Types.G y, _) = x == y
|
||||||
hasUni _ _ = False
|
hasUni _ _ = False
|
||||||
-- TODO: in general: we should _always_ process all annotaiton stuff here.
|
-- TODO: in general: we should _always_ process all annotaiton stuff here.
|
||||||
-- whatever we don't probably should have had some effect on the
|
-- whatever we don't probably should have had some effect on the
|
||||||
-- output. in such cases, resorting to byExact is probably the safe
|
-- output. in such cases, resorting to byExact is probably the safe
|
||||||
-- choice.
|
-- choice.
|
||||||
return $ case Map.lookup (ExactPrint.Types.mkAnnKey ast) anns of
|
return $ case {-Map.lookup ({-ExactPrint.Types.mkAnnKey-} undefined ast) anns-} undefined of
|
||||||
Nothing -> t
|
Nothing -> t
|
||||||
Just (ExactPrint.Types.Ann _ _ _ aks _ _) -> case n of
|
Just {-(ExactPrint.Types.Ann _ _ _ aks _ _)-} _ -> case n of
|
||||||
Exact{} | t == Text.pack "()" -> t
|
Exact{} | t == Text.pack "()" -> t
|
||||||
_ | any (hasUni AnnBackquote) aks -> Text.pack "`" <> t <> Text.pack "`"
|
_ | any (hasUni AnnBackquote) aks -> Text.pack "`" <> t <> Text.pack "`"
|
||||||
_ | any (hasUni AnnCommaTuple) aks -> t
|
_ | any (hasUni AnnCommaTuple) aks -> t
|
||||||
_ | any (hasUni AnnOpenP) aks -> Text.pack "(" <> t <> Text.pack ")"
|
_ | any (hasUni AnnOpenP) aks -> Text.pack "(" <> t <> Text.pack ")"
|
||||||
_ | otherwise -> t
|
_ | otherwise -> t
|
||||||
|
|
||||||
|
where
|
||||||
|
aks :: [a]
|
||||||
|
aks = undefined
|
||||||
|
|
||||||
lrdrNameToTextAnn
|
lrdrNameToTextAnn
|
||||||
:: (MonadMultiReader Config m, MonadMultiReader (Map AnnKey Annotation) m)
|
:: (MonadMultiReader Config m
|
||||||
|
-- , MonadMultiReader (Map AnnKey Annotation) m
|
||||||
|
)
|
||||||
=> Located RdrName
|
=> Located RdrName
|
||||||
-> m Text
|
-> m Text
|
||||||
lrdrNameToTextAnn = lrdrNameToTextAnnGen id
|
lrdrNameToTextAnn = lrdrNameToTextAnnGen id
|
||||||
|
|
||||||
lrdrNameToTextAnnTypeEqualityIsSpecial
|
lrdrNameToTextAnnTypeEqualityIsSpecial
|
||||||
:: (MonadMultiReader Config m, MonadMultiReader (Map AnnKey Annotation) m)
|
:: (MonadMultiReader Config m
|
||||||
|
-- , MonadMultiReader (Map AnnKey Annotation) m
|
||||||
|
)
|
||||||
=> Located RdrName
|
=> Located RdrName
|
||||||
-> m Text
|
-> m Text
|
||||||
lrdrNameToTextAnnTypeEqualityIsSpecial ast = do
|
lrdrNameToTextAnnTypeEqualityIsSpecial ast = do
|
||||||
|
@ -186,7 +206,7 @@ lrdrNameToTextAnnTypeEqualityIsSpecial ast = do
|
||||||
lrdrNameToTextAnnTypeEqualityIsSpecialAndRespectTick
|
lrdrNameToTextAnnTypeEqualityIsSpecialAndRespectTick
|
||||||
:: ( Data ast
|
:: ( Data ast
|
||||||
, MonadMultiReader Config m
|
, MonadMultiReader Config m
|
||||||
, MonadMultiReader (Map AnnKey Annotation) m
|
-- , MonadMultiReader (Map AnnKey Annotation) m
|
||||||
)
|
)
|
||||||
=> Located ast
|
=> Located ast
|
||||||
-> Located RdrName
|
-> Located RdrName
|
||||||
|
@ -205,28 +225,30 @@ askIndent = confUnpack . _lconfig_indentAmount . _conf_layout <$> mAsk
|
||||||
|
|
||||||
|
|
||||||
extractAllComments
|
extractAllComments
|
||||||
:: ExactPrint.Annotation -> [(ExactPrint.Comment, ExactPrint.DeltaPos)]
|
:: Annotation -> [(Comment, DeltaPos)]
|
||||||
extractAllComments ann =
|
extractAllComments ann =
|
||||||
ExactPrint.annPriorComments ann ++ extractRestComments ann
|
undefined
|
||||||
|
-- ExactPrint.annPriorComments ann ++ extractRestComments ann
|
||||||
|
|
||||||
extractRestComments
|
extractRestComments
|
||||||
:: ExactPrint.Annotation -> [(ExactPrint.Comment, ExactPrint.DeltaPos)]
|
:: Annotation -> [(Comment, DeltaPos)]
|
||||||
extractRestComments ann =
|
extractRestComments ann =
|
||||||
ExactPrint.annFollowingComments ann
|
undefined
|
||||||
++ (ExactPrint.annsDP ann >>= \case
|
-- ExactPrint.annFollowingComments ann
|
||||||
(ExactPrint.AnnComment com, dp) -> [(com, dp)]
|
-- ++ (ExactPrint.annsDP ann >>= \case
|
||||||
_ -> []
|
-- (ExactPrint.AnnComment com, dp) -> [(com, dp)]
|
||||||
)
|
-- _ -> []
|
||||||
|
-- )
|
||||||
|
|
||||||
filterAnns :: Data.Data.Data ast => ast -> ExactPrint.Anns -> ExactPrint.Anns
|
-- filterAnns :: Data.Data.Data ast => ast -> ExactPrint.Anns -> ExactPrint.Anns
|
||||||
filterAnns ast = Map.filterWithKey (\k _ -> k `Set.member` foldedAnnKeys ast)
|
-- filterAnns ast = Map.filterWithKey (\k _ -> k `Set.member` foldedAnnKeys ast)
|
||||||
|
|
||||||
-- | True if there are any comments that are
|
-- | True if there are any comments that are
|
||||||
-- a) connected to any node below (in AST sense) the given node AND
|
-- a) connected to any node below (in AST sense) the given node AND
|
||||||
-- b) after (in source code order) the node.
|
-- b) after (in source code order) the node.
|
||||||
hasAnyCommentsBelow :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
hasAnyCommentsBelow :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
||||||
hasAnyCommentsBelow ast@(L l _) =
|
hasAnyCommentsBelow ast@(L l _) =
|
||||||
List.any (\(c, _) -> ExactPrint.commentIdentifier c > ExactPrint.Utils.rs l)
|
List.any (\(c, _) -> {-ExactPrint.commentIdentifier-} undefined c > ExactPrint.Utils.rs l)
|
||||||
<$> astConnectedComments ast
|
<$> astConnectedComments ast
|
||||||
|
|
||||||
hasCommentsBetween
|
hasCommentsBetween
|
||||||
|
@ -236,18 +258,18 @@ hasCommentsBetween
|
||||||
-> AnnKeywordId
|
-> AnnKeywordId
|
||||||
-> ToBriDocM Bool
|
-> ToBriDocM Bool
|
||||||
hasCommentsBetween ast leftKey rightKey = do
|
hasCommentsBetween ast leftKey rightKey = do
|
||||||
mAnn <- astAnn ast
|
mAnn <- {-astAnn-} undefined ast
|
||||||
let
|
let
|
||||||
go1 [] = False
|
go1 [] = False
|
||||||
go1 ((ExactPrint.G kw, _dp) : rest) | kw == leftKey = go2 rest
|
-- go1 ((ExactPrint.G kw, _dp) : rest) | kw == leftKey = go2 rest
|
||||||
go1 (_ : rest) = go1 rest
|
go1 (_ : rest) = go1 rest
|
||||||
go2 [] = False
|
go2 [] = False
|
||||||
go2 ((ExactPrint.AnnComment _, _dp) : _rest) = True
|
-- go2 ((ExactPrint.AnnComment _, _dp) : _rest) = True
|
||||||
go2 ((ExactPrint.G kw, _dp) : _rest) | kw == rightKey = False
|
-- go2 ((ExactPrint.G kw, _dp) : _rest) | kw == rightKey = False
|
||||||
go2 (_ : rest) = go2 rest
|
go2 (_ : rest) = go2 rest
|
||||||
case mAnn of
|
case mAnn of
|
||||||
Nothing -> pure False
|
Nothing -> pure False
|
||||||
Just ann -> pure $ go1 $ ExactPrint.annsDP ann
|
Just ann -> pure $ go1 $ undefined ann
|
||||||
|
|
||||||
-- | True if there are any comments that are connected to any node below (in AST
|
-- | True if there are any comments that are connected to any node below (in AST
|
||||||
-- sense) the given node
|
-- sense) the given node
|
||||||
|
@ -258,7 +280,7 @@ hasAnyCommentsConnected ast = not . null <$> astConnectedComments ast
|
||||||
-- sense) the given node
|
-- sense) the given node
|
||||||
hasAnyRegularCommentsConnected :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
hasAnyRegularCommentsConnected :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
||||||
hasAnyRegularCommentsConnected ast =
|
hasAnyRegularCommentsConnected ast =
|
||||||
any isRegularComment <$> astConnectedComments ast
|
any {-isRegularComment-} undefined <$> astConnectedComments ast
|
||||||
|
|
||||||
-- | Regular comments are comments that are actually "source code comments",
|
-- | Regular comments are comments that are actually "source code comments",
|
||||||
-- i.e. things that start with "--" or "{-". In contrast to comment-annotations
|
-- i.e. things that start with "--" or "{-". In contrast to comment-annotations
|
||||||
|
@ -269,51 +291,66 @@ hasAnyRegularCommentsConnected ast =
|
||||||
-- I believe that most of the time we branch on the existence of comments, we
|
-- I believe that most of the time we branch on the existence of comments, we
|
||||||
-- only care about "regular" comments. We simply did not need the distinction
|
-- only care about "regular" comments. We simply did not need the distinction
|
||||||
-- because "irregular" comments are not that common outside of type/data decls.
|
-- because "irregular" comments are not that common outside of type/data decls.
|
||||||
isRegularComment :: (ExactPrint.Comment, ExactPrint.DeltaPos) -> Bool
|
-- isRegularComment :: (ExactPrint.Comment, ExactPrint.DeltaPos) -> Bool
|
||||||
isRegularComment = (== Nothing) . ExactPrint.Types.commentOrigin . fst
|
-- isRegularComment = (== Nothing) . ExactPrint.Types.commentOrigin . fst
|
||||||
|
|
||||||
|
type DeltaPos = ()
|
||||||
|
type Comment = ()
|
||||||
|
|
||||||
astConnectedComments
|
astConnectedComments
|
||||||
:: Data ast
|
:: Data ast
|
||||||
=> GHC.Located ast
|
=> GHC.Located ast
|
||||||
-> ToBriDocM [(ExactPrint.Types.Comment, ExactPrint.Types.DeltaPos)]
|
-> ToBriDocM [(Comment, DeltaPos)]
|
||||||
astConnectedComments ast = do
|
astConnectedComments ast = do
|
||||||
anns <- filterAnns ast <$> mAsk
|
undefined
|
||||||
pure $ extractAllComments =<< Map.elems anns
|
-- anns <- filterAnns ast <$> mAsk
|
||||||
|
-- pure $ extractAllComments =<< Map.elems anns
|
||||||
|
|
||||||
hasAnyCommentsPrior :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
hasAnyCommentsPrior :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
||||||
hasAnyCommentsPrior ast = astAnn ast <&> \case
|
hasAnyCommentsPrior ast = {-astAnn-} undefined ast <&> \case
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
Just (ExactPrint.Types.Ann _ priors _ _ _ _) -> not $ null priors
|
Just _ {-(ExactPrint.Types.Ann _ priors _ _ _ _)-} -> not $ null priors
|
||||||
|
where priors = [undefined]
|
||||||
|
|
||||||
hasAnyRegularCommentsRest :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
hasAnyRegularCommentsRest :: Data ast => GHC.Located ast -> ToBriDocM Bool
|
||||||
hasAnyRegularCommentsRest ast = astAnn ast <&> \case
|
hasAnyRegularCommentsRest ast = {-astAnn-} undefined ast <&> \case
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
Just ann -> any isRegularComment (extractRestComments ann)
|
Just ann -> undefined -- any isRegularComment (extractRestComments ann)
|
||||||
|
|
||||||
hasAnnKeywordComment
|
hasAnnKeywordComment
|
||||||
:: Data ast => GHC.Located ast -> AnnKeywordId -> ToBriDocM Bool
|
:: Data ast => GHC.Located ast -> AnnKeywordId -> ToBriDocM Bool
|
||||||
hasAnnKeywordComment ast annKeyword = astAnn ast <&> \case
|
hasAnnKeywordComment ast annKeyword = {-astAnn-} undefined ast <&> \case
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
Just ann -> any hasK (extractAllComments ann)
|
Just ann -> any hasK ({-extractAllComments-} thing ann)
|
||||||
where hasK = (== Just annKeyword) . ExactPrint.Types.commentOrigin . fst
|
where
|
||||||
|
hasK = (== Just annKeyword) . ExactPrint.Types.commentOrigin . fst
|
||||||
|
thing ann = [undefined]
|
||||||
|
|
||||||
hasAnnKeyword
|
hasAnnKeyword
|
||||||
:: (Data a, MonadMultiReader (Map AnnKey Annotation) m)
|
:: (Data a
|
||||||
|
-- , MonadMultiReader (Map AnnKey Annotation) m
|
||||||
|
, Functor m
|
||||||
|
)
|
||||||
=> Located a
|
=> Located a
|
||||||
-> AnnKeywordId
|
-> AnnKeywordId
|
||||||
-> m Bool
|
-> m Bool
|
||||||
hasAnnKeyword ast annKeyword = astAnn ast <&> \case
|
hasAnnKeyword ast annKeyword = {-astAnn-} astAnn' ast <&> \case
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
Just (ExactPrint.Types.Ann _ _ _ aks _ _) -> any hasK aks
|
Just {-(ExactPrint.Types.Ann _ _ _ aks _ _)-} undefined -> any hasK aks
|
||||||
where
|
where
|
||||||
hasK (ExactPrint.Types.G x, _) = x == annKeyword
|
-- hasK (ExactPrint.Types.G x, _) = x == annKeyword
|
||||||
hasK _ = False
|
hasK _ = False
|
||||||
|
aks = [undefined]
|
||||||
|
-- astAnn' :: Functor f => Located a -> f (Maybe b)
|
||||||
|
astAnn' = undefined
|
||||||
|
|
||||||
astAnn
|
type Annotation = ()
|
||||||
:: (Data ast, MonadMultiReader (Map AnnKey Annotation) m)
|
|
||||||
=> GHC.Located ast
|
-- astAnn
|
||||||
-> m (Maybe Annotation)
|
-- :: (Data ast, MonadMultiReader (Map AnnKey Annotation) m)
|
||||||
astAnn ast = Map.lookup (ExactPrint.Types.mkAnnKey ast) <$> mAsk
|
-- => GHC.Located ast
|
||||||
|
-- -> m (Maybe Annotation)
|
||||||
|
-- astAnn ast = {-Map.lookup ({-ExactPrint.Types.mkAnnKey-} undefined ast)-} undefined <$> mAsk
|
||||||
|
|
||||||
-- new BriDoc stuff
|
-- new BriDoc stuff
|
||||||
|
|
||||||
|
@ -338,7 +375,7 @@ allocNodeIndex = do
|
||||||
-- docExt :: (ExactPrint.Annotate.Annotate ast, MonadMultiState NodeAllocIndex m)
|
-- docExt :: (ExactPrint.Annotate.Annotate ast, MonadMultiState NodeAllocIndex m)
|
||||||
-- => Located ast -> ExactPrint.Types.Anns -> Bool -> m BriDocNumbered
|
-- => Located ast -> ExactPrint.Types.Anns -> Bool -> m BriDocNumbered
|
||||||
-- docExt x anns shouldAddComment = allocateNode $ BDFExternal
|
-- docExt x anns shouldAddComment = allocateNode $ BDFExternal
|
||||||
-- (ExactPrint.Types.mkAnnKey x)
|
-- ({-ExactPrint.Types.mkAnnKey-} undefined x)
|
||||||
-- (foldedAnnKeys x)
|
-- (foldedAnnKeys x)
|
||||||
-- shouldAddComment
|
-- shouldAddComment
|
||||||
-- (Text.pack $ ExactPrint.exactPrint x anns)
|
-- (Text.pack $ ExactPrint.exactPrint x anns)
|
||||||
|
@ -393,7 +430,7 @@ allocNodeIndex = do
|
||||||
-- -> m BriDocNumbered
|
-- -> m BriDocNumbered
|
||||||
-- docPostComment ast bdm = do
|
-- docPostComment ast bdm = do
|
||||||
-- bd <- bdm
|
-- bd <- bdm
|
||||||
-- allocateNode $ BDFAnnotationPost (ExactPrint.Types.mkAnnKey ast) bd
|
-- allocateNode $ BDFAnnotationPost ({-ExactPrint.Types.mkAnnKey-} undefined ast) bd
|
||||||
--
|
--
|
||||||
-- docWrapNode :: ( Data.Data.Data ast, MonadMultiState NodeAllocIndex m)
|
-- docWrapNode :: ( Data.Data.Data ast, MonadMultiState NodeAllocIndex m)
|
||||||
-- => Located ast
|
-- => Located ast
|
||||||
|
@ -405,9 +442,9 @@ allocNodeIndex = do
|
||||||
-- i2 <- allocNodeIndex
|
-- i2 <- allocNodeIndex
|
||||||
-- return
|
-- return
|
||||||
-- $ (,) i1
|
-- $ (,) i1
|
||||||
-- $ BDFAnnotationPrior (ExactPrint.Types.mkAnnKey ast)
|
-- $ BDFAnnotationPrior ({-ExactPrint.Types.mkAnnKey-} undefined ast)
|
||||||
-- $ (,) i2
|
-- $ (,) i2
|
||||||
-- $ BDFAnnotationPost (ExactPrint.Types.mkAnnKey ast)
|
-- $ BDFAnnotationPost ({-ExactPrint.Types.mkAnnKey-} undefined ast)
|
||||||
-- $ bd
|
-- $ bd
|
||||||
--
|
--
|
||||||
-- docPar :: MonadMultiState NodeAllocIndex m
|
-- docPar :: MonadMultiState NodeAllocIndex m
|
||||||
|
@ -438,16 +475,19 @@ docLitS :: String -> ToBriDocM BriDocNumbered
|
||||||
docLitS s = allocateNode $ BDFLit $ Text.pack s
|
docLitS s = allocateNode $ BDFLit $ Text.pack s
|
||||||
|
|
||||||
docExt
|
docExt
|
||||||
:: (ExactPrint.Annotate.Annotate ast)
|
::
|
||||||
=> Located ast
|
-- (ExactPrint.Annotate.Annotate ast)
|
||||||
-> ExactPrint.Types.Anns
|
Located ast
|
||||||
|
-- -> ExactPrint.Types.Anns
|
||||||
-> Bool
|
-> Bool
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
docExt x anns shouldAddComment = allocateNode $ BDFExternal
|
docExt x shouldAddComment = allocateNode $ BDFExternal
|
||||||
(ExactPrint.Types.mkAnnKey x)
|
-- ({-ExactPrint.Types.mkAnnKey-} undefined x)
|
||||||
(foldedAnnKeys x)
|
undefined
|
||||||
|
-- (foldedAnnKeys x)
|
||||||
|
undefined
|
||||||
shouldAddComment
|
shouldAddComment
|
||||||
(Text.pack $ ExactPrint.exactPrint x anns)
|
(Text.pack $ {-ExactPrint.exactPrint x anns-} undefined)
|
||||||
|
|
||||||
docAlt :: [ToBriDocM BriDocNumbered] -> ToBriDocM BriDocNumbered
|
docAlt :: [ToBriDocM BriDocNumbered] -> ToBriDocM BriDocNumbered
|
||||||
docAlt l = allocateNode . BDFAlt =<< sequence l
|
docAlt l = allocateNode . BDFAlt =<< sequence l
|
||||||
|
@ -585,7 +625,7 @@ docNodeAnnKW
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
docNodeAnnKW ast kw bdm =
|
docNodeAnnKW ast kw bdm =
|
||||||
docAnnotationKW (ExactPrint.Types.mkAnnKey ast) kw bdm
|
docAnnotationKW ({-{-ExactPrint.Types.mkAnnKey-} undefined-} undefined ast) kw bdm
|
||||||
|
|
||||||
docNodeMoveToKWDP
|
docNodeMoveToKWDP
|
||||||
:: Data.Data.Data ast
|
:: Data.Data.Data ast
|
||||||
|
@ -595,7 +635,7 @@ docNodeMoveToKWDP
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
docNodeMoveToKWDP ast kw shouldRestoreIndent bdm =
|
docNodeMoveToKWDP ast kw shouldRestoreIndent bdm =
|
||||||
docMoveToKWDP (ExactPrint.Types.mkAnnKey ast) kw shouldRestoreIndent bdm
|
docMoveToKWDP ({-{-ExactPrint.Types.mkAnnKey-} undefined-} undefined ast) kw shouldRestoreIndent bdm
|
||||||
|
|
||||||
class DocWrapable a where
|
class DocWrapable a where
|
||||||
docWrapNode :: ( Data.Data.Data ast)
|
docWrapNode :: ( Data.Data.Data ast)
|
||||||
|
@ -618,18 +658,18 @@ instance DocWrapable (ToBriDocM BriDocNumbered) where
|
||||||
i2 <- allocNodeIndex
|
i2 <- allocNodeIndex
|
||||||
return
|
return
|
||||||
$ (,) i1
|
$ (,) i1
|
||||||
$ BDFAnnotationPrior (ExactPrint.Types.mkAnnKey ast)
|
$ BDFAnnotationPrior ({-ExactPrint.Types.mkAnnKey-} undefined ast)
|
||||||
$ (,) i2
|
$ (,) i2
|
||||||
$ BDFAnnotationRest (ExactPrint.Types.mkAnnKey ast)
|
$ BDFAnnotationRest ({-ExactPrint.Types.mkAnnKey-} undefined ast)
|
||||||
$ bd
|
$ bd
|
||||||
docWrapNodePrior ast bdm = do
|
docWrapNodePrior ast bdm = do
|
||||||
bd <- bdm
|
bd <- bdm
|
||||||
i1 <- allocNodeIndex
|
i1 <- allocNodeIndex
|
||||||
return $ (,) i1 $ BDFAnnotationPrior (ExactPrint.Types.mkAnnKey ast) $ bd
|
return $ (,) i1 $ BDFAnnotationPrior ({-ExactPrint.Types.mkAnnKey-} undefined ast) $ bd
|
||||||
docWrapNodeRest ast bdm = do
|
docWrapNodeRest ast bdm = do
|
||||||
bd <- bdm
|
bd <- bdm
|
||||||
i2 <- allocNodeIndex
|
i2 <- allocNodeIndex
|
||||||
return $ (,) i2 $ BDFAnnotationRest (ExactPrint.Types.mkAnnKey ast) $ bd
|
return $ (,) i2 $ BDFAnnotationRest ({-ExactPrint.Types.mkAnnKey-} undefined ast) $ bd
|
||||||
|
|
||||||
instance DocWrapable (ToBriDocM a) => DocWrapable [ToBriDocM a] where
|
instance DocWrapable (ToBriDocM a) => DocWrapable [ToBriDocM a] where
|
||||||
docWrapNode ast bdms = case bdms of
|
docWrapNode ast bdms = case bdms of
|
||||||
|
|
Loading…
Reference in New Issue