File tree Expand file tree Collapse file tree 5 files changed +15
-12
lines changed
Cabal-syntax/src/Distribution/Parsec
cabal-install/src/Distribution/Client
cabal-testsuite/PackageTests/ProjectImport/ParseWarningProvenance Expand file tree Collapse file tree 5 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,10 @@ import System.FilePath (normalise)
1616import Prelude ()
1717
1818-- | Parser error.
19- data PError = PError Position String
19+ data PError = PError { perrorPosition :: Position , perrorMessage :: String }
2020 deriving (Show , Generic )
2121
22+
2223data PErrorWithSource src = PErrorWithSource { perrorSource :: ! (PSource src ), perror :: ! PError }
2324 deriving (Show , Generic , Functor )
2425
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ instance Binary PWarnType
7373instance NFData PWarnType where rnf = genericRnf
7474
7575-- | Parser warning.
76- data PWarning = PWarning ! PWarnType ! Position String
76+ data PWarning = PWarning { pwarningType :: ! PWarnType , pwarningPosition :: ! Position , pwarningMessage :: ! String }
7777 deriving (Eq , Ord , Show , Generic )
7878
7979data PWarningWithSource src = PWarningWithSource { pwarningSource :: ! (PSource src ), pwarning :: ! PWarning }
Original file line number Diff line number Diff line change @@ -241,8 +241,8 @@ renderParseErrorGeneral header err_header provenance extra_info errors warnings
241241
242242 header' = if null header then " " else (" " <> header)
243243
244- renderedErrors = concatMap renderError errors
245- renderedWarnings = concatMap renderWarning warnings
244+ renderedErrors = concatMap renderError (sortBy (comparing perrorPosition) errors)
245+ renderedWarnings = concatMap renderWarning (sortBy (comparing pwarningPosition) warnings)
246246
247247 renderError :: PError -> [String ]
248248 renderError (PError pos msg)
Original file line number Diff line number Diff line change @@ -963,7 +963,9 @@ reportParseResultParsec verbosity fpath contents pr = do
963963 let (warnings, result) = runParseResult pr
964964 case result of
965965 Right x -> do
966- reportProjectParseWarnings verbosity fpath (map (showPWarningWithSource . fmap renderProjectFileSource) warnings)
966+ let sortKey p = (pwarningSource p, pwarningPosition (pwarning p))
967+ sortedWarnings = sortBy (comparing sortKey) warnings
968+ reportProjectParseWarnings verbosity fpath (map (showPWarningWithSource . fmap renderProjectFileSource) sortedWarnings)
967969 return x
968970 Left (_, errors) -> do
969971 dieWithException verbosity $ ProjectConfigParseFailure $ ProjectConfigParseError errors warnings
Original file line number Diff line number Diff line change 11# cabal v2-build
22Warnings found while parsing the project file, cabal.project:
3- - y.config:123:1: Invalid subsection "-"
4- - x.config:3:1: Invalid subsection "-"
5- - x.config:2:1: Invalid subsection "-"
6- - x.config:1:1: Invalid subsection "-"
7- - dir-y/a.config:123:1: Invalid subsection "-"
8- - dir-x/a.config:3:1: Invalid subsection "-"
9- - dir-x/a.config:2:1: Invalid subsection "-"
103 - dir-x/a.config:1:1: Invalid subsection "-"
4+ - dir-x/a.config:2:1: Invalid subsection "-"
5+ - dir-x/a.config:3:1: Invalid subsection "-"
6+ - dir-y/a.config:123:1: Invalid subsection "-"
7+ - x.config:1:1: Invalid subsection "-"
8+ - x.config:2:1: Invalid subsection "-"
9+ - x.config:3:1: Invalid subsection "-"
10+ - y.config:123:1: Invalid subsection "-"
You can’t perform that action at this time.
0 commit comments