on master help sign in
Send absolute file names in annotations

This makes it much easier for clients of the IDE protocol to make use of namespace information.

commit2de8a47afa223ac831cce71f49917449270d8b33 authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateSun 17 May 2015, 18:53 (11 years ago) parentf350697
2 files changed+10−4
idris.cabal+1−1 src/Idris/Parser.hs+9−3
idris.cabal+1−1
@@ -869,7 +869,7 @@ Library
869869 , cheapskate < 0.2
870870 , containers >= 0.5 && < 0.6
871871 , deepseq < 1.5
872− , directory >= 1.2 && < 1.3
872+ , directory >= 1.2.2.0 && < 1.3
873873 , filepath < 1.5
874874 , fingertree >= 0.1 && < 0.2
875875 , haskeline >= 0.7 && < 0.8
src/Idris/Parser.hs+9−3
@@ -8,6 +8,8 @@ module Idris.Parser(module Idris.Parser,
88
99import Prelude hiding (pi)
1010
11+import qualified System.Directory as Dir (makeAbsolute)
12+
1113import Text.Trifecta.Delta
1214import Text.Trifecta hiding (span, stringLiteral, charLiteral, natural, symbol, char, string, whiteSpace, Err)
1315import Text.Parser.LookAhead
@@ -1244,7 +1246,8 @@ parseImports fname input
12441246 Failure err -> fail (show err)
12451247 Success (x, annots, i) ->
12461248 do putIState i
1247− sendHighlighting (addPath annots fname)
1249+ fname' <- runIO $ Dir.makeAbsolute fname
1250+ sendHighlighting $ addPath annots fname'
12481251 return x
12491252 where imports :: IdrisParser ((Maybe (Docstring ()), [String],
12501253 [ImportInfo],
@@ -1263,7 +1266,7 @@ parseImports fname input
12631266 addPath :: [(FC, OutputAnnotation)] -> FilePath -> [(FC, OutputAnnotation)]
12641267 addPath [] _ = []
12651268 addPath ((fc, AnnNamespace ns Nothing) : annots) path =
1266− (fc, AnnNamespace ns (Just path)) : addPath annots path
1269+ (fc, AnnNamespace ns (Just path)) : addPath annots path
12671270 addPath (annot:annots) path = annot : addPath annots path
12681271
12691272-- | There should be a better way of doing this...
@@ -1390,7 +1393,10 @@ loadSource lidr f toline
13901393 IDR fn -> Just fn
13911394 LIDR fn -> Just fn
13921395 _ -> Nothing
1393− sendHighlighting [(nfc, AnnNamespace ns srcFn)])
1396+ srcFnAbs <- case srcFn of
1397+ Just fn -> fmap Just (runIO $ Dir.makeAbsolute fn)
1398+ Nothing -> return Nothing
1399+ sendHighlighting [(nfc, AnnNamespace ns srcFnAbs)])
13941400 [(re, fn, ns, nfc) | ImportInfo re fn _ ns _ nfc <- imports]
13951401 reportParserWarnings
13961402