Skip to content

Commit c225412

Browse files
committed
Highlight the keywords all at once.
1 parent a72a341 commit c225412

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

semantic-analysis/src/Analysis/Analysis/Exception.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ exceptionsForLine l e = Set.filter (\ ex -> IntSet.member l (exceptionLines ex))
106106

107107
printExcSet :: Source.Source -> ExcSet -> IO ()
108108
printExcSet src e = for_ (zip [0..] (Source.lines src)) $ \ (i, line) -> do
109-
Text.putStr (pass (def (import' (raise (Text.dropWhileEnd (== '\n') (Source.toText line))))))
109+
Text.putStr (keywords (Text.dropWhileEnd (== '\n') (Source.toText line)))
110110
let es = exceptionsForLine i e
111111
fvs = freeVariablesForLine i e
112112
unless (null es && null fvs) $ do
@@ -117,10 +117,7 @@ printExcSet src e = for_ (zip [0..] (Source.lines src)) $ \ (i, line) -> do
117117
Text.putStrLn mempty
118118
where
119119
keyword k s = Text.intercalate (Text.pack "\ESC[34;1m" <> k <> reset) (Text.splitOn k s)
120-
raise = keyword (Text.pack "raise")
121-
import' = keyword (Text.pack "import")
122-
def = keyword (Text.pack "def")
123-
pass = keyword (Text.pack "pass")
120+
keywords = keyword (Text.pack "raise") . keyword (Text.pack "import") . keyword (Text.pack "def") . keyword (Text.pack "pass")
124121
union = Text.intercalate (Text.pack ", ")
125122
formatFreeVariables fvs = map (\ fv -> Text.pack "?" <> formatName (freeVariableName fv)) (Set.toList fvs)
126123
formatExceptions excs = map (Text.pack . show . formatName . exceptionName) (Set.toList excs)

0 commit comments

Comments
 (0)