on master help sign in
Trace loaded file spans for empty modules

Previously, the "reload IBC" step would obliterate the span, causing problems for IDE clients. Fixes #1959.

commit15a76fff19c6ac98a56a20df2dfa82f5b937bf2b authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateFri 27 Feb 2015, 12:30 (12 years ago) parentb32de5c
1 file changed+16
src/Idris/Parser.hs+16
src/Idris/Parser.hs+16
@@ -1311,8 +1311,24 @@ loadSource lidr f toline
13111311 mapM_ (addIBC . IBCImport) [(reexport, realName) | (reexport, realName, alias, fc) <- imports]
13121312 let syntax = defaultSyntax{ syn_namespace = reverse mname,
13131313 maxline = toline }
1314+ ist <- getIState
1315+ -- Save the span from parsing the module header, because
1316+ -- an empty program parse might obliterate it.
1317+ let oldSpan = idris_parsedSpan ist
13141318 ds' <- parseProg syntax f file pos
13151319
1320+ case (ds', oldSpan) of
1321+ ([], Just fc) ->
1322+ -- If no program elements were parsed, we dind't
1323+ -- get a loaded region in the IBC file. That
1324+ -- means we need to add it back.
1325+ do ist <- getIState
1326+ putIState ist { idris_parsedSpan = oldSpan
1327+ , ibc_write = IBCParsedRegion fc :
1328+ ibc_write ist
1329+ }
1330+ _ -> return ()
1331+
13161332 -- Parsing done, now process declarations
13171333
13181334 let ds = namespaces mname ds'