summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra/CheckM.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-12-06 15:43:34 +0000
committerhallgren <hallgren@chalmers.se>2013-12-06 15:43:34 +0000
commita98f4aa4be7b72a310a8b5826e3cc82c7edb8f40 (patch)
treea46830579656e347dc6dda7bdd0970e643f6387f /src/compiler/GF/Infra/CheckM.hs
parente2fe50e5859cb6ef359c1a08e3bceb3080cd2159 (diff)
Show relative file paths in error messages
This is to avoid one trivial reason for failures in the test suite.
Diffstat (limited to 'src/compiler/GF/Infra/CheckM.hs')
-rw-r--r--src/compiler/GF/Infra/CheckM.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/compiler/GF/Infra/CheckM.hs b/src/compiler/GF/Infra/CheckM.hs
index f1d4ebbde..045ba4852 100644
--- a/src/compiler/GF/Infra/CheckM.hs
+++ b/src/compiler/GF/Infra/CheckM.hs
@@ -15,17 +15,18 @@
module GF.Infra.CheckM
(Check, CheckResult, Message, runCheck,
checkError, checkCond, checkWarn, checkWarnings, checkAccumError,
- {-checkErr,-} checkIn, checkMap, checkMapRecover,
+ checkIn, checkInModule, checkMap, checkMapRecover,
parallelCheck, accumulateError, commitCheck,
) where
import GF.Data.Operations
--import GF.Infra.Ident
---import GF.Grammar.Grammar(Context)
---import GF.Grammar.Printer
+import GF.Grammar.Grammar(msrc) -- ,Context
+import GF.Grammar.Printer(ppLocation)
import qualified Data.Map as Map
import Text.PrettyPrint
+import System.FilePath(makeRelative)
import Control.Parallel.Strategies(parList,rseq,using)
import Control.Monad(liftM)
@@ -146,3 +147,10 @@ checkIn msg c = Check $ \{-ctxt-} msgs0 ->
augment' msgs0 msgs' = (msg $$ nest 3 (vcat (reverse msgs'))):msgs0
augment1 msg' = msg $$ nest 3 msg'
+
+-- | Augment error messages with a relative path to the source module and
+-- an contextual hint (which can be left 'empty')
+checkInModule cwd mi loc context =
+ checkIn (ppLocation relpath loc <> colon $$ nest 2 context)
+ where
+ relpath = makeRelative cwd (msrc mi)