@@ -30,7 +30,10 @@ data ErrorPosition = ErrorPosition
30 , endColumn :: Int
30 , endColumn :: Int
31 } deriving (Show, Eq, Ord)
31 } deriving (Show, Eq, Ord)
33−data ErrorSuggestion = ErrorSuggestion { replacement :: String } deriving (Show, Eq)
33+data ErrorSuggestion = ErrorSuggestion
34+ { replacement :: String
35+ , replaceRange :: Maybe ErrorPosition
36+ } deriving (Show, Eq)
35data JSONError = JSONError
38data JSONError = JSONError
36 { position :: Maybe ErrorPosition
39 { position :: Maybe ErrorPosition
@@ -40,7 +43,7 @@ data JSONError = JSONError
40 , filename :: Maybe String
43 , filename :: Maybe String
41 , moduleName :: Maybe String
44 , moduleName :: Maybe String
42 , suggestion :: Maybe ErrorSuggestion
45 , suggestion :: Maybe ErrorSuggestion
43− } deriving (Show, Eq)
46+ } deriving (Show, Eq)
45data JSONResult = JSONResult
48data JSONResult = JSONResult
46 { warnings :: [JSONError]
49 { warnings :: [JSONError]
@@ -64,7 +67,7 @@ toJSONError verbose level e =
64 (P.wikiUri e)
67 (P.wikiUri e)
65 (P.spanName <$> sspan)
68 (P.spanName <$> sspan)
66 (P.runModuleName <$> P.errorModule e)
69 (P.runModuleName <$> P.errorModule e)
67− (toSuggestion <$> P.errorSuggestion (P.unwrapErrorMessage e))
70+ (toSuggestion e)
69 sspan :: Maybe P.SourceSpan
72 sspan :: Maybe P.SourceSpan
70 sspan = P.errorSpan e
73 sspan = P.errorSpan e
@@ -75,6 +78,11 @@ toJSONError verbose level e =
75 (P.sourcePosColumn (P.spanStart ss))
78 (P.sourcePosColumn (P.spanStart ss))
76 (P.sourcePosLine (P.spanEnd ss))
79 (P.sourcePosLine (P.spanEnd ss))
77 (P.sourcePosColumn (P.spanEnd ss))
80 (P.sourcePosColumn (P.spanEnd ss))
78− toSuggestion :: P.ErrorSuggestion -> ErrorSuggestion
81+ toSuggestion :: P.ErrorMessage -> Maybe ErrorSuggestion
83+ case P.errorSuggestion $ P.unwrapErrorMessage em of
85+ Just s -> Just $ ErrorSuggestion (suggestionText s) (toErrorPosition <$> P.suggestionSpan em)
79−-- TODO: Adding a newline because source spans chomp everything up to the next character
87+ -- 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"
88+ suggestionText (P.ErrorSuggestion s) = if null s then s else s ++ "\n"