1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-14 08:27:03 +03:00
juvix/app/Commands/Dev/Highlight.hs
janmasrovira b2f926d50f
Ide improvements (#2009)
This pr includes the necessary machinery to have type and judoc
information for every identifier. This information is showed in
juvix-mode as a child-frame on the top right corner as showed in the
following screenshot.

![image](https://user-images.githubusercontent.com/5511599/232927816-dbf48ea9-e717-42f2-9c92-14a27a650c87.png)
2023-04-19 10:46:58 +01:00

35 lines
1.7 KiB
Haskell

module Commands.Dev.Highlight where
import Commands.Base
import Commands.Dev.Highlight.Options
import Juvix.Compiler.Concrete.Data.Highlight qualified as Highlight
import Juvix.Compiler.Concrete.Data.InfoTable qualified as Scoper
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping qualified as Scoper
import Juvix.Compiler.Concrete.Translation.FromSource qualified as Parser
import Juvix.Compiler.Internal.Translation.FromInternal.Analysis.TypeChecking.Data.Context qualified as Internal
runCommand :: Members '[Embed IO, App] r => HighlightOptions -> Sem r ()
runCommand HighlightOptions {..} = do
res <- fmap snd <$> runPipelineEither _highlightInputFile upToInternalTyped
inputFile <- someBaseToAbs' (_highlightInputFile ^. pathPath)
case res of
Left err -> do
let filterByFile = filter ((== inputFile) . (^. intervalFile))
genOpts <- askGenericOptions
sayRaw (Highlight.goErrors _highlightBackend (filterByFile . run . runReader genOpts $ errorIntervals err))
Right r -> do
let scoperResult = r ^. Internal.internalTypedResultScoped
tbl = scoperResult ^. Scoper.resultParserResult . Parser.resultTable
items = tbl ^. Parser.infoParsedItems
names = scoperResult ^. Scoper.resultScoperTable . Scoper.infoNames
hinput =
Highlight.filterInput
inputFile
Highlight.HighlightInput
{ _highlightNames = names,
_highlightParsed = items,
_highlightDoc = scoperResult ^. Scoper.resultScoperTable . Scoper.infoDoc,
_highlightTypes = r ^. Internal.resultIdenTypes
}
sayRaw (Highlight.highlight _highlightBackend hinput)