Fix type application layouting (fixes #48)
- one-line externals are not detected as multiline in backend - layouting of EAsPat (when TypeApplications is disabled) - layouting of HsTyLit (TypeApplications with literals)pull/51/head
parent
fba8ad1a99
commit
ca13a1897f
|
@ -956,6 +956,7 @@ runBrittany tabSize text = do
|
||||||
foo = bar @Baz
|
foo = bar @Baz
|
||||||
|
|
||||||
#test comment-before-BDCols
|
#test comment-before-BDCols
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
|
layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
|
||||||
docAlt
|
docAlt
|
||||||
$ -- one-line solution
|
$ -- one-line solution
|
||||||
|
@ -972,7 +973,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
|
||||||
, [(guards, body, _bodyRaw)] <- [clauseDocs]
|
, [(guards, body, _bodyRaw)] <- [clauseDocs]
|
||||||
, let guardPart = singleLineGuardsDoc guards
|
, let guardPart = singleLineGuardsDoc guards
|
||||||
, wherePart <- case mWhereDocs of
|
, wherePart <- case mWhereDocs of
|
||||||
Nothing -> return @[] $ docEmpty
|
Nothing -> return @[] $ docEmpty
|
||||||
Just [w] -> return @[] $ docSeq
|
Just [w] -> return @[] $ docSeq
|
||||||
[ docSeparator
|
[ docSeparator
|
||||||
, appSep $ docLit $ Text.pack "where"
|
, appSep $ docLit $ Text.pack "where"
|
||||||
|
@ -1026,6 +1027,21 @@ foo n = case n of
|
||||||
bar n = case n of
|
bar n = case n of
|
||||||
(-2, -2) -> (-2, -2)
|
(-2, -2) -> (-2, -2)
|
||||||
|
|
||||||
|
#test issue 48 a
|
||||||
|
|
||||||
|
foo =
|
||||||
|
let a = b@1
|
||||||
|
cccc = ()
|
||||||
|
in foo
|
||||||
|
|
||||||
|
#test issue 48 b
|
||||||
|
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
foo =
|
||||||
|
let a = b @1
|
||||||
|
cccc = ()
|
||||||
|
in foo
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -312,6 +312,7 @@ briDocIsMultiLine briDoc = rec briDoc
|
||||||
BDForceMultiline _ -> True
|
BDForceMultiline _ -> True
|
||||||
BDForceSingleline bd -> rec bd
|
BDForceSingleline bd -> rec bd
|
||||||
BDForwardLineMode bd -> rec bd
|
BDForwardLineMode bd -> rec bd
|
||||||
|
BDExternal _ _ _ t | [_] <- Text.lines t -> False
|
||||||
BDExternal _ _ _ _ -> True
|
BDExternal _ _ _ _ -> True
|
||||||
BDAnnotationPrior _ bd -> rec bd
|
BDAnnotationPrior _ bd -> rec bd
|
||||||
BDAnnotationKW _ _ bd -> rec bd
|
BDAnnotationKW _ _ bd -> rec bd
|
||||||
|
|
|
@ -902,9 +902,11 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
|
||||||
briDocByExactInlineOnly "HsTickPragma{}" lexpr
|
briDocByExactInlineOnly "HsTickPragma{}" lexpr
|
||||||
EWildPat{} -> do
|
EWildPat{} -> do
|
||||||
docLit $ Text.pack "_"
|
docLit $ Text.pack "_"
|
||||||
EAsPat{} -> do
|
EAsPat asName asExpr -> do
|
||||||
-- TODO
|
docSeq
|
||||||
briDocByExactInlineOnly "EAsPat{}" lexpr
|
[ docLit $ (lrdrNameToText asName) <> Text.pack "@"
|
||||||
|
, layoutExpr asExpr
|
||||||
|
]
|
||||||
EViewPat{} -> do
|
EViewPat{} -> do
|
||||||
-- TODO
|
-- TODO
|
||||||
briDocByExactInlineOnly "EViewPat{}" lexpr
|
briDocByExactInlineOnly "EViewPat{}" lexpr
|
||||||
|
|
|
@ -19,6 +19,7 @@ import Language.Haskell.GHC.ExactPrint.Types ( mkAnnKey )
|
||||||
import HsSyn
|
import HsSyn
|
||||||
import Name
|
import Name
|
||||||
import Outputable ( ftext, showSDocUnsafe )
|
import Outputable ( ftext, showSDocUnsafe )
|
||||||
|
import BasicTypes
|
||||||
|
|
||||||
import DataTreePrint
|
import DataTreePrint
|
||||||
|
|
||||||
|
@ -599,8 +600,18 @@ layoutType ltype@(L _ typ) = docWrapNode ltype $ case typ of
|
||||||
]
|
]
|
||||||
HsExplicitTupleTy{} -> -- TODO
|
HsExplicitTupleTy{} -> -- TODO
|
||||||
briDocByExactInlineOnly "HsExplicitTupleTy{}" ltype
|
briDocByExactInlineOnly "HsExplicitTupleTy{}" ltype
|
||||||
HsTyLit{} -> -- TODO
|
HsTyLit lit -> case lit of
|
||||||
briDocByExactInlineOnly "HsTyLit{}" ltype
|
#if MIN_VERSION_ghc(8,2,0) /* ghc-8.2 */
|
||||||
|
HsNumTy (SourceText srctext) _ -> docLit $ Text.pack srctext
|
||||||
|
HsNumTy NoSourceText _ ->
|
||||||
|
error "overLitValBriDoc: literal with no SourceText"
|
||||||
|
HsStrTy (SourceText srctext) _ -> docLit $ Text.pack srctext
|
||||||
|
HsStrTy NoSourceText _ ->
|
||||||
|
error "overLitValBriDoc: literal with no SourceText"
|
||||||
|
#else /* ghc-8.0 */
|
||||||
|
HsNumTy srctext _ -> docLit $ Text.pack srctext
|
||||||
|
HsStrTy srctext _ -> docLit $ Text.pack srctext
|
||||||
|
#endif
|
||||||
HsCoreTy{} -> -- TODO
|
HsCoreTy{} -> -- TODO
|
||||||
briDocByExactInlineOnly "HsCoreTy{}" ltype
|
briDocByExactInlineOnly "HsCoreTy{}" ltype
|
||||||
HsWildCardTy _ ->
|
HsWildCardTy _ ->
|
||||||
|
|
Loading…
Reference in New Issue