From 21c7a9a060317a8bd0e3812c5f3dd5ae08888f3b Mon Sep 17 00:00:00 2001 From: uhbif19 Date: Mon, 16 May 2022 12:55:00 +0300 Subject: [PATCH] Fixes --- plugins/hls-stan-plugin/hls-stan-plugin.cabal | 8 +-- .../hls-stan-plugin/src/Ide/Plugin/Stan.hs | 53 ++++++++++--------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/plugins/hls-stan-plugin/hls-stan-plugin.cabal b/plugins/hls-stan-plugin/hls-stan-plugin.cabal index bf5da02787..624a506925 100644 --- a/plugins/hls-stan-plugin/hls-stan-plugin.cabal +++ b/plugins/hls-stan-plugin/hls-stan-plugin.cabal @@ -1,20 +1,20 @@ cabal-version: 2.4 name: hls-stan-plugin -version: 1.0.4.0 -synopsis: Hlint integration plugin with Haskell Language Server +version: 1.0.0.0 +synopsis: Stan integration plugin with Haskell Language Server description: Please see the README on GitHub at license: Apache-2.0 license-file: LICENSE author: The Haskell IDE Team -maintainer: atreyu.bbb@gmail.com +maintainer: uhbif19@gmail.com copyright: The Haskell IDE Team category: Development build-type: Simple extra-source-files: LICENSE - test/testdata/**/*.yaml + test/testdata/**/* flag pedantic description: Enable -Werror diff --git a/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs b/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs index 0b5eec0476..0282c15c90 100644 --- a/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs +++ b/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs @@ -9,7 +9,7 @@ import Data.Foldable (toList) import qualified Data.HashMap.Strict as HM import Data.Hashable (Hashable) import qualified Data.Map as Map -import Data.Maybe (fromJust) +import Data.Maybe (fromJust, mapMaybe) import qualified Data.Text as T import Data.Typeable (Typeable, cast) import Development.IDE (Action, FileDiagnostic, @@ -80,32 +80,33 @@ rules recorder = do void $ uses GetStanDiagnostics $ HM.keys files where analysisToDiagnostics :: NormalizedFilePath -> Analysis -> [FileDiagnostic] - analysisToDiagnostics file = map (observationToDianostic file) . toList . analysisObservations - observationToDianostic :: NormalizedFilePath -> Observation -> FileDiagnostic + analysisToDiagnostics file = mapMaybe (observationToDianostic file) . toList . analysisObservations + observationToDianostic :: NormalizedFilePath -> Observation -> Maybe FileDiagnostic observationToDianostic file (Observation {observationSrcSpan, observationInspectionId}) = - ( file, - ShowDiag, - LSP.Diagnostic - { _range = realSrcSpanToRange $ observationSrcSpan, - _severity = Just LSP.DsHint, - _code = Just (LSP.InR $ unId (inspectionId inspection)), - _source = Just "stan", - _message = message, - _relatedInformation = Nothing, - _tags = Nothing - } - ) - where - inspection = fromJust $ HM.lookup observationInspectionId inspectionsMap - -- Lookin similar to Stan CLI output - message :: T.Text - message = - T.unlines $ - [ " ✲ Name: " <> inspectionName inspection, - " ✲ Description: " <> inspectionDescription inspection, - "Possible solutions:" - ] - ++ map (" - " <>) (inspectionSolution inspection) + do + inspection <- HM.lookup observationInspectionId inspectionsMap + let + -- Looking similar to Stan CLI output + message :: T.Text + message = + T.unlines $ + [ " ✲ Name: " <> inspectionName inspection, + " ✲ Description: " <> inspectionDescription inspection, + "Possible solutions:" + ] + ++ map (" - " <>) (inspectionSolution inspection) + return ( file, + ShowDiag, + LSP.Diagnostic + { _range = realSrcSpanToRange $ observationSrcSpan, + _severity = Just LSP.DsHint, + _code = Just (LSP.InR $ unId (inspectionId inspection)), + _source = Just "stan", + _message = message, + _relatedInformation = Nothing, + _tags = Nothing + } + ) getHieFile :: NormalizedFilePath -> Action (Maybe HieFile) getHieFile nfp = runMaybeT $ do