2022-09-14 17:16:15 +03:00
|
|
|
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
|
2023-04-19 12:46:58 +03:00
|
|
|
import Juvix.Compiler.Internal.Translation.FromInternal.Analysis.TypeChecking.Data.Context qualified as Internal
|
2022-09-14 17:16:15 +03:00
|
|
|
|
2023-02-10 15:43:13 +03:00
|
|
|
runCommand :: Members '[Embed IO, App] r => HighlightOptions -> Sem r ()
|
2022-09-14 17:16:15 +03:00
|
|
|
runCommand HighlightOptions {..} = do
|
2023-04-19 12:46:58 +03:00
|
|
|
res <- fmap snd <$> runPipelineEither _highlightInputFile upToInternalTyped
|
2023-02-22 12:26:54 +03:00
|
|
|
inputFile <- someBaseToAbs' (_highlightInputFile ^. pathPath)
|
2022-09-14 17:16:15 +03:00
|
|
|
case res of
|
|
|
|
Left err -> do
|
2023-02-22 12:26:54 +03:00
|
|
|
let filterByFile = filter ((== inputFile) . (^. intervalFile))
|
2022-09-14 17:16:15 +03:00
|
|
|
genOpts <- askGenericOptions
|
2023-02-22 12:26:54 +03:00
|
|
|
sayRaw (Highlight.goErrors _highlightBackend (filterByFile . run . runReader genOpts $ errorIntervals err))
|
2022-09-14 17:16:15 +03:00
|
|
|
Right r -> do
|
2023-04-19 12:46:58 +03:00
|
|
|
let scoperResult = r ^. Internal.internalTypedResultScoped
|
|
|
|
tbl = scoperResult ^. Scoper.resultParserResult . Parser.resultTable
|
2022-09-14 17:16:15 +03:00
|
|
|
items = tbl ^. Parser.infoParsedItems
|
2023-04-19 12:46:58 +03:00
|
|
|
names = scoperResult ^. Scoper.resultScoperTable . Scoper.infoNames
|
2022-09-14 17:16:15 +03:00
|
|
|
hinput =
|
|
|
|
Highlight.filterInput
|
|
|
|
inputFile
|
|
|
|
Highlight.HighlightInput
|
|
|
|
{ _highlightNames = names,
|
2023-04-19 12:46:58 +03:00
|
|
|
_highlightParsed = items,
|
|
|
|
_highlightDoc = scoperResult ^. Scoper.resultScoperTable . Scoper.infoDoc,
|
|
|
|
_highlightTypes = r ^. Internal.resultIdenTypes
|
2022-09-14 17:16:15 +03:00
|
|
|
}
|
2023-04-19 12:46:58 +03:00
|
|
|
sayRaw (Highlight.highlight _highlightBackend hinput)
|