@@ -30,7 +30,10 @@ data ErrorPosition = ErrorPosition
3030 , endColumn :: Int
3131 } deriving (Show, Eq, Ord)
3232
33−data ErrorSuggestion = ErrorSuggestion { replacement :: String } deriving (Show, Eq)
33+data ErrorSuggestion = ErrorSuggestion
34+ { replacement :: String
35+ , replaceRange :: Maybe ErrorPosition
36+ } deriving (Show, Eq)
3437
3538data JSONError = JSONError
3639 { position :: Maybe ErrorPosition
@@ -40,7 +43,7 @@ data JSONError = JSONError
4043 , filename :: Maybe String
4144 , moduleName :: Maybe String
4245 , suggestion :: Maybe ErrorSuggestion
43− } deriving (Show, Eq)
46+ } deriving (Show, Eq)
4447
4548data JSONResult = JSONResult
4649 { warnings :: [JSONError]
@@ -64,7 +67,7 @@ toJSONError verbose level e =
6467 (P.wikiUri e)
6568 (P.spanName <$> sspan)
6669 (P.runModuleName <$> P.errorModule e)
67− (toSuggestion <$> P.errorSuggestion (P.unwrapErrorMessage e))
70+ (toSuggestion e)
6871 where
6972 sspan :: Maybe P.SourceSpan
7073 sspan = P.errorSpan e
@@ -75,6 +78,11 @@ toJSONError verbose level e =
7578 (P.sourcePosColumn (P.spanStart ss))
7679 (P.sourcePosLine (P.spanEnd ss))
7780 (P.sourcePosColumn (P.spanEnd ss))
78− toSuggestion :: P.ErrorSuggestion -> ErrorSuggestion
79−-- TODO: Adding a newline because source spans chomp everything up to the next character
80− toSuggestion (P.ErrorSuggestion s) = ErrorSuggestion $ if null s then s else s ++ "\n"
81+ toSuggestion :: P.ErrorMessage -> Maybe ErrorSuggestion
82+ toSuggestion em =
83+ case P.errorSuggestion $ P.unwrapErrorMessage em of
84+ Nothing -> Nothing
85+ Just s -> Just $ ErrorSuggestion (suggestionText s) (toErrorPosition <$> P.suggestionSpan em)
86+
87+ -- TODO: Adding a newline because source spans chomp everything up to the next character
88+ suggestionText (P.ErrorSuggestion s) = if null s then s else s ++ "\n"