@@ -15,7 +15,7 @@ import Idris.Primitives
15import Idris.Inliner
15import Idris.Inliner
16import Idris.PartialEval
16import Idris.PartialEval
17import Idris.DeepSeq
17import Idris.DeepSeq
18−import Idris.Output (iputStrLn, pshow, iWarn)
18+import Idris.Output (iputStrLn, pshow, iWarn, sendHighlighting)
19import IRTS.Lang
19import IRTS.Lang
21import Idris.Elab.Type
21import Idris.Elab.Type
@@ -51,7 +51,7 @@ import Data.List.Split (splitOn)
51import Util.Pretty(pretty, text)
51import Util.Pretty(pretty, text)
53elabData :: ElabInfo -> SyntaxInfo -> Docstring (Either Err PTerm)-> [(Name, Docstring (Either Err PTerm))] -> FC -> DataOpts -> PData -> Idris ()
53elabData :: ElabInfo -> SyntaxInfo -> Docstring (Either Err PTerm)-> [(Name, Docstring (Either Err PTerm))] -> FC -> DataOpts -> PData -> Idris ()
54−elabData info syn doc argDocs fc opts (PLaterdecl n t_in)
54+elabData info syn doc argDocs fc opts (PLaterdecl n nfc t_in)
55 = do let codata = Codata `elem` opts
55 = do let codata = Codata `elem` opts
56 iLOG (show (fc, doc))
56 iLOG (show (fc, doc))
57 checkUndefined fc n
57 checkUndefined fc n
@@ -59,8 +59,9 @@ elabData info syn doc argDocs fc opts (PLaterdecl n t_in)
60 addIBC (IBCDef n)
60 addIBC (IBCDef n)
61 updateContext (addTyDecl n (TCon 0 0) cty) -- temporary, to check cons
61 updateContext (addTyDecl n (TCon 0 0) cty) -- temporary, to check cons
62+ sendHighlighting [(nfc, AnnName n Nothing Nothing Nothing)]
63−elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
64+elabData info syn doc argDocs fc opts (PDatadecl n nfc t_in dcons)
64 = do let codata = Codata `elem` opts
65 = do let codata = Codata `elem` opts
65 iLOG (show fc)
66 iLOG (show fc)
66 undef <- isUndefined fc n
67 undef <- isUndefined fc n
@@ -116,6 +117,11 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
116 -- create a case function
117 -- create a case function
117 when (DefaultCaseFun `elem` opts) $
118 when (DefaultCaseFun `elem` opts) $
118 evalStateT (elabCaseFun False params n t dcons info) Map.empty
119 evalStateT (elabCaseFun False params n t dcons info) Map.empty
120+ -- Emit highlighting info
121+ sendHighlighting $ [(nfc, AnnName n Nothing Nothing Nothing)] ++
122+ map (\(_, _, n, nfc, _, _, _) ->
123+ (nfc, AnnName n Nothing Nothing Nothing))
120 setDetaggable :: Name -> Idris ()
126 setDetaggable :: Name -> Idris ()
121 setDetaggable n = do
127 setDetaggable n = do
@@ -194,7 +200,7 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
194 | otherwise = count n ts
200 | otherwise = count n ts
195 mParam args (_ : rest) = Nothing : mParam args rest
201 mParam args (_ : rest) = Nothing : mParam args rest
197− cname (_, _, n, _, _, _) = n
203+ cname (_, _, n, _, _, _, _) = n
199 -- Abuse of ElabInfo.
205 -- Abuse of ElabInfo.
200 -- TODO Contemplate whether the ElabInfo type needs modification.
206 -- TODO Contemplate whether the ElabInfo type needs modification.
@@ -212,9 +218,9 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
212elabCon :: ElabInfo -> SyntaxInfo -> Name -> Bool ->
218elabCon :: ElabInfo -> SyntaxInfo -> Name -> Bool ->
213 Type -> -- for unique kind checking
219 Type -> -- for unique kind checking
214 Type -> -- data type's kind
220 Type -> -- data type's kind
215− (Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, PTerm, FC, [Name]) ->
221+ (Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, FC, PTerm, FC, [Name]) ->
216 Idris (Name, Type)
222 Idris (Name, Type)
217−elabCon info syn tn codata expkind dkind (doc, argDocs, n, t_in, fc, forcenames)
223+elabCon info syn tn codata expkind dkind (doc, argDocs, n, nfc, t_in, fc, forcenames)
218 = do checkUndefined fc n
224 = do checkUndefined fc n
219 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ show t_in
225 logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ show t_in
220 (cty, ckind, t, inacc) <- buildType info syn fc [Constructor] n (if codata then mkLazy t_in else t_in)
226 (cty, ckind, t, inacc) <- buildType info syn fc [Constructor] n (if codata then mkLazy t_in else t_in)
@@ -302,17 +308,17 @@ type EliminatorState = StateT (Map.Map String Int) Idris
302-- FIXME: Many things have name starting with elim internally since this was the only purpose in the first edition of the function
308-- FIXME: Many things have name starting with elim internally since this was the only purpose in the first edition of the function
303-- rename to caseFun to match updated intend
309-- rename to caseFun to match updated intend
304elabCaseFun :: Bool -> [Int] -> Name -> PTerm ->
310elabCaseFun :: Bool -> [Int] -> Name -> PTerm ->
305− [(Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, PTerm, FC, [Name])] ->
311+ [(Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, FC, PTerm, FC, [Name])] ->
306 ElabInfo -> EliminatorState ()
312 ElabInfo -> EliminatorState ()
307elabCaseFun ind paramPos n ty cons info = do
313elabCaseFun ind paramPos n ty cons info = do
308 elimLog $ "Elaborating case function"
314 elimLog $ "Elaborating case function"
309− put (Map.fromList $ zip (concatMap (\(_, p, _, ty, _, _) -> (map show $ boundNamesIn ty) ++ map (show . fst) p) cons ++ (map show $ boundNamesIn ty)) (repeat 0))
315+ put (Map.fromList $ zip (concatMap (\(_, p, _, _, ty, _, _) -> (map show $ boundNamesIn ty) ++ map (show . fst) p) cons ++ (map show $ boundNamesIn ty)) (repeat 0))
310 let (cnstrs, _) = splitPi ty
316 let (cnstrs, _) = splitPi ty
311 let (splittedTy@(pms, idxs)) = splitPms cnstrs
317 let (splittedTy@(pms, idxs)) = splitPms cnstrs
312 generalParams <- namePis False pms
318 generalParams <- namePis False pms
313 motiveIdxs <- namePis False idxs
319 motiveIdxs <- namePis False idxs
314 let motive = mkMotive n paramPos generalParams motiveIdxs
320 let motive = mkMotive n paramPos generalParams motiveIdxs
315− consTerms <- mapM (\(c@(_, _, cnm, _, _, _)) -> do
321+ consTerms <- mapM (\(c@(_, _, cnm, _, _, _, _)) -> do
316 let casefunt = if ind then "elim_" else "case_"
322 let casefunt = if ind then "elim_" else "case_"
317 name <- freshName $ casefunt ++ simpleName cnm
323 name <- freshName $ casefunt ++ simpleName cnm
318 consTerm <- extractConsTerm c generalParams
324 consTerm <- extractConsTerm c generalParams
@@ -488,8 +494,8 @@ elabCaseFun ind paramPos n ty cons info = do
488 in return $ filter (\(n,_,_) -> not (n `elem` oldParams))implargs
494 in return $ filter (\(n,_,_) -> not (n `elem` oldParams))implargs
489 _ -> return implargs
495 _ -> return implargs
491− extractConsTerm :: (Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, PTerm, FC, [Name]) -> [(Name, Plicity, PTerm)] -> EliminatorState PTerm
497+ extractConsTerm :: (Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, FC, PTerm, FC, [Name]) -> [(Name, Plicity, PTerm)] -> EliminatorState PTerm
492− extractConsTerm (doc, argDocs, cnm, ty, fc, fs) generalParameters = do
498+ extractConsTerm (doc, argDocs, cnm, _, ty, fc, fs) generalParameters = do
493 let cons' = replaceParams paramPos generalParameters ty
499 let cons' = replaceParams paramPos generalParameters ty
494 let (args, resTy) = splitPi cons'
500 let (args, resTy) = splitPi cons'
495 implidxs <- implicitIndexes (doc, cnm, ty, fc, fs)
501 implidxs <- implicitIndexes (doc, cnm, ty, fc, fs)
@@ -524,8 +530,8 @@ elabCaseFun ind paramPos n ty cons info = do
524 convertImplPi (PImp {getTm = t, pname = n}) = Just (n, expl, t)
530 convertImplPi (PImp {getTm = t, pname = n}) = Just (n, expl, t)
525 convertImplPi _ = Nothing
531 convertImplPi _ = Nothing
527− generateEliminatorClauses :: (Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, PTerm, FC, [Name]) -> Name -> [PArg] -> [(Name, Plicity, PTerm)] -> EliminatorState PClause
533+ generateEliminatorClauses :: (Docstring (Either Err PTerm), [(Name, Docstring (Either Err PTerm))], Name, FC, PTerm, FC, [Name]) -> Name -> [PArg] -> [(Name, Plicity, PTerm)] -> EliminatorState PClause
528− generateEliminatorClauses (doc, _, cnm, ty, fc, fs) cnsElim generalArgs generalParameters = do
534+ generateEliminatorClauses (doc, _, cnm, _, ty, fc, fs) cnsElim generalArgs generalParameters = do
529 let cons' = replaceParams paramPos generalParameters ty
535 let cons' = replaceParams paramPos generalParameters ty
530 let (args, resTy) = splitPi cons'
536 let (args, resTy) = splitPi cons'
531 i <- State.lift getIState
537 i <- State.lift getIState