1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Pull the context into the where clause.

This commit is contained in:
Rob Rix 2017-05-01 10:52:29 -04:00
parent e33da12d1b
commit c0dd99a5a4

View File

@ -93,12 +93,13 @@ data Error symbol = Error
showError :: Show symbol => Source.Source -> Error symbol -> ShowS
showError source Error{..}
= showSourcePos errorPos . showString ": error: " . showExpectation . showChar '\n'
. showString (toS (Source.sourceText (Source.actualLines source !! Info.line errorPos))) -- actualLines results include line endings, so no newline here
. showString context -- actualLines results include line endings, so no newline here
. showString (replicate (Info.column errorPos) ' ') . showChar '^' . showChar '\n'
where showExpectation = case (errorExpected, errorActual) of
([], Nothing) -> showString "no rule to match at end of input nodes"
(symbols, Nothing) -> showString "expected " . showSymbols symbols . showString " at end of input nodes"
(symbols, Just a) -> showString "expected " . showSymbols symbols . showString ", but got " . shows a
context = toS (Source.sourceText (Source.actualLines source !! Info.line errorPos))
showSymbols :: Show symbol => [symbol] -> ShowS
showSymbols [] = showString "end of input nodes"