Workaround for #68: trim exactprinted text for unknown nodes

pull/75/head
Lennart Spitzner 2017-11-28 18:23:05 +01:00
parent 6a97379b33
commit 8a401d291e
2 changed files with 15 additions and 9 deletions

View File

@ -490,3 +490,6 @@ func
fmapuv :: U.Unbox a => (a -> b) -> U.Vector a -> V.Vector b
fmapuv f xs = G.generate (G.length xs) (f . (xs G.!))
#test parallellistcomp-workaround
cs0 = 0 : [ c / Interval n | c <- cs | n <- [1..] ]

View File

@ -82,6 +82,8 @@ import ApiAnnotation ( AnnKeywordId(..) )
import Data.Data
import Data.Generics.Schemes
import qualified Data.Char as Char
import DataTreePrint
import Data.HList.HList
@ -154,20 +156,21 @@ briDocByExactInlineOnly infoStr ast = do
let exactPrinted = Text.pack $ ExactPrint.exactPrint ast anns
fallbackMode <-
mAsk <&> _conf_errorHandling .> _econf_ExactPrintFallback .> confUnpack
let exactPrintNode = allocateNode $ BDFExternal
let exactPrintNode t = allocateNode $ BDFExternal
(ExactPrint.Types.mkAnnKey ast)
(foldedAnnKeys ast)
False
exactPrinted
let
errorAction = do
mTell $ [ErrorUnknownNode infoStr ast]
docLit $ Text.pack "{- BRITTANY ERROR UNHANDLED SYNTACTICAL CONSTRUCT -}"
t
let errorAction = do
mTell $ [ErrorUnknownNode infoStr ast]
docLit
$ Text.pack "{- BRITTANY ERROR UNHANDLED SYNTACTICAL CONSTRUCT -}"
case (fallbackMode, Text.lines exactPrinted) of
(ExactPrintFallbackModeNever, _ ) -> errorAction
(_ , [_]) -> exactPrintNode
(ExactPrintFallbackModeRisky, _ ) -> exactPrintNode
_ -> errorAction
(_ , [t]) -> exactPrintNode
(Text.dropWhile Char.isSpace . Text.dropWhileEnd Char.isSpace $ t)
(ExactPrintFallbackModeRisky, _) -> exactPrintNode exactPrinted
_ -> errorAction
rdrNameToText :: RdrName -> Text
-- rdrNameToText = Text.pack . show . flip runSDoc unsafeGlobalDynFlags . ppr