@@ -14,6 +14,7 @@ module Development.IDE.Plugin.CodeAction
14
14
matchRegExMultipleImports
15
15
) where
16
16
17
+ import Debug.Trace
17
18
import Control.Applicative ((<|>) )
18
19
import Control.Applicative.Combinators.NonEmpty (sepBy1 )
19
20
import Control.Arrow (second ,
@@ -791,12 +792,12 @@ suggestAddTypeAnnotationToSatisfyConstraints sourceOpt Diagnostic{_range=_range,
791
792
-- In an equation for ‘f’:
792
793
-- f = seq "test" seq "test" (traceShow "test")
793
794
--
794
- | Just [ty, lit] <- matchRegexUnifySpaces _message (pat False False True False )
795
+ | Just [ty, lit] <- matchRegexUnifySpaces (trace ( " message: " <> show _message) _message) (pat False False True False )
795
796
<|> matchRegexUnifySpaces _message (pat False False False True )
796
797
<|> matchRegexUnifySpaces _message (pat False False False False )
797
798
798
- = codeEdit _range ty lit (makeAnnotatedLit ty lit)
799
- | Just source <- sourceOpt
799
+ = codeEdit _range (trace ( " ty " <> show ty <> " lit " <> show lit) ty) lit (makeAnnotatedLit ty lit)
800
+ | Just source <- trace ( " sourceOpt: " <> show sourceOpt) sourceOpt
800
801
, Just [ty, lit, srcspan] <- matchRegexUnifySpaces _message (pat True True False False )
801
802
, range <- case [ x | (x," " ) <- readSrcSpan (T. unpack srcspan)] of
802
803
[s] -> let x = realSrcSpanToRange s
@@ -808,6 +809,14 @@ suggestAddTypeAnnotationToSatisfyConstraints sourceOpt Diagnostic{_range=_range,
808
809
| otherwise = []
809
810
where
810
811
makeAnnotatedLit ty lit = " (" <> lit <> " :: " <> ty <> " )"
812
+ #if MIN_VERSION_ghc(9,8,0)
813
+ pat multiple _ _ _ = T. concat [ " .*Defaulting the type variable "
814
+ , " .*to type ‘([^ ]+)’ "
815
+ , " in the following constraint"
816
+ , if multiple then " s" else " "
817
+ , " .*arising from the literal ‘(.+)’"
818
+ ]
819
+ #else
811
820
#if MIN_VERSION_ghc(9,4,0)
812
821
pat multiple at inArg inExpr = T. concat [ " .*Defaulting the type variable "
813
822
, " .*to type ‘([^ ]+)’ "
@@ -829,6 +838,7 @@ suggestAddTypeAnnotationToSatisfyConstraints sourceOpt Diagnostic{_range=_range,
829
838
, if inExpr then " .+In the expression" else " "
830
839
, " .+In the expression"
831
840
]
841
+ #endif
832
842
#endif
833
843
codeEdit range ty lit replacement =
834
844
let title = " Add type annotation ‘" <> ty <> " ’ to ‘" <> lit <> " ’"
@@ -1992,3 +2002,20 @@ matchRegExMultipleImports message = do
1992
2002
_ -> Nothing
1993
2003
imps <- regExImports imports
1994
2004
return (binding, imps)
2005
+
2006
+ ---- Debugging
2007
+ -- pat multiple at inArg inExpr = T.concat [ ".*Defaulting the type variable "
2008
+ -- , ".*to type ‘([^ ]+)’ "
2009
+ -- , "in the following constraint"
2010
+ -- , if multiple then "s" else " "
2011
+ -- , ".*arising from the literal ‘(.+)’"
2012
+ -- , if inArg then ".+In the.+argument" else ""
2013
+ -- , if at then ".+at ([^ ]*)" else ""
2014
+ -- , if inExpr then ".+In the expression" else ""
2015
+ -- , ".+In the expression"
2016
+ -- ]
2017
+
2018
+
2019
+ -- Just [ty, lit] <- matchRegexUnifySpaces _message (pat False False True False)
2020
+ -- <|> matchRegexUnifySpaces _message (pat False False False True)
2021
+ -- <|> matchRegexUnifySpaces _message (pat False False False False)
0 commit comments