on master help sign in
Highlight names in directives
e04ba85David Raymond Christiansen
src/Idris/AbsSyntaxTree.hs+2−2
@@ -678,8 +678,8 @@ data Directive = DLib Codegen String |
678 DDefault Bool |
678 DDefault Bool |
679 DLogging Integer |
679 DLogging Integer |
680 DDynamicLibs [String] |
680 DDynamicLibs [String] |
681− DNameHint Name [Name] |
681+ DNameHint Name FC [(Name, FC)] |
682− DErrorHandlers Name Name [Name] |
682+ DErrorHandlers Name FC Name FC [(Name, FC)] |
683 DLanguage LanguageExt |
683 DLanguage LanguageExt |
684 DUsed FC Name Name
684 DUsed FC Name Name
685
685
src/Idris/Directives.hs+19−9
@@ -4,6 +4,7 @@ module Idris.Directives(directiveAction) where
4import Idris.AbsSyntax
4import Idris.AbsSyntax
5import Idris.ASTUtils
5import Idris.ASTUtils
6import Idris.Imports
6import Idris.Imports
7+import Idris.Output (sendHighlighting)
7
8
8import Idris.Core.Evaluate
9import Idris.Core.Evaluate
9import Idris.Core.TT
10import Idris.Core.TT
@@ -43,15 +44,24 @@ directiveAction (DDynamicLibs libs) = do added <- addDyLib libs
43 Left lib -> addIBC (IBCDyLib (lib_name lib))
44 Left lib -> addIBC (IBCDyLib (lib_name lib))
44 Right msg -> fail $ msg
45 Right msg -> fail $ msg
45
46
46−directiveAction (DNameHint ty ns) = do ty' <- disambiguate ty
47+directiveAction (DNameHint ty tyFC ns) = do ty' <- disambiguate ty
47− mapM_ (addNameHint ty') ns
48+ mapM_ (addNameHint ty' . fst) ns
48− mapM_ (\n -> addIBC (IBCNameHint (ty', n))) ns
49+ mapM_ (\n -> addIBC (IBCNameHint (ty', fst n))) ns
49−
50+ sendHighlighting $
51+ [(tyFC, AnnName ty' Nothing Nothing Nothing)] ++
52+ map (\(n, fc) -> (fc, AnnBoundName n False)) ns
53+
50−directiveAction (DErrorHandlers fn arg ns) = do fn' <- disambiguate fn
54+directiveAction (DErrorHandlers fn nfc arg afc ns) =
55+ do fn' <- disambiguate fn
51− ns' <- mapM disambiguate ns
56+ ns' <- mapM (\(n, fc) -> do n' <- disambiguate n
57+ return (n', fc)) ns
52− addFunctionErrorHandlers fn' arg ns'
58+ addFunctionErrorHandlers fn' arg (map fst ns')
53− mapM_ (addIBC .
59+ mapM_ (addIBC .
54− IBCFunctionErrorHandler fn' arg) ns'
60+ IBCFunctionErrorHandler fn' arg . fst) ns'
61+ sendHighlighting $
62+ [(nfc, AnnName fn' Nothing Nothing Nothing),
63+ (afc, AnnBoundName arg False)] ++
64+ map (\(n, fc) -> (fc, AnnName n Nothing Nothing Nothing)) ns'
55
65
56directiveAction (DLanguage ext) = addLangExt ext
66directiveAction (DLanguage ext) = addLangExt ext
57
67
src/Idris/Parser.hs+7−7
@@ -1146,14 +1146,14 @@ directive syn = do try (lchar '%' *> reserved "lib")
1146 libs <- sepBy1 (fmap fst stringLiteral) (lchar ',')
1146 libs <- sepBy1 (fmap fst stringLiteral) (lchar ',')
1147 return [PDirective (DDynamicLibs libs)]
1147 return [PDirective (DDynamicLibs libs)]
1148 <|> do try (lchar '%' *> reserved "name")
1148 <|> do try (lchar '%' *> reserved "name")
1149− ty <- fst <$> fnName
1149+ (ty, tyFC) <- fnName
1150− ns <- sepBy1 (fst <$> name) (lchar ',')
1150+ ns <- sepBy1 name (lchar ',')
1151− return [PDirective (DNameHint ty ns)]
1151+ return [PDirective (DNameHint ty tyFC ns)]
1152 <|> do try (lchar '%' *> reserved "error_handlers")
1152 <|> do try (lchar '%' *> reserved "error_handlers")
1153− fn <- fst <$> fnName
1153+ (fn, nfc) <- fnName
1154− arg <- fst <$> fnName
1154+ (arg, afc) <- fnName
1155− ns <- sepBy1 (fst <$> name) (lchar ',')
1155+ ns <- sepBy1 name (lchar ',')
1156− return [PDirective (DErrorHandlers fn arg ns) ]
1156+ return [PDirective (DErrorHandlers fn nfc arg afc ns) ]
1157 <|> do try (lchar '%' *> reserved "language"); ext <- pLangExt;
1157 <|> do try (lchar '%' *> reserved "language"); ext <- pLangExt;
1158 return [PDirective (DLanguage ext)]
1158 return [PDirective (DLanguage ext)]
1159 <|> do fc <- getFC
1159 <|> do fc <- getFC