@@ -9,7 +9,7 @@ import Data.Foldable (toList)
99import qualified Data.HashMap.Strict as HM
1010import Data.Hashable (Hashable )
1111import qualified Data.Map as Map
12- import Data.Maybe (fromJust )
12+ import Data.Maybe (fromJust , mapMaybe )
1313import qualified Data.Text as T
1414import Data.Typeable (Typeable , cast )
1515import Development.IDE (Action , FileDiagnostic ,
@@ -80,32 +80,33 @@ rules recorder = do
8080 void $ uses GetStanDiagnostics $ HM. keys files
8181 where
8282 analysisToDiagnostics :: NormalizedFilePath -> Analysis -> [FileDiagnostic ]
83- analysisToDiagnostics file = map (observationToDianostic file) . toList . analysisObservations
84- observationToDianostic :: NormalizedFilePath -> Observation -> FileDiagnostic
83+ analysisToDiagnostics file = mapMaybe (observationToDianostic file) . toList . analysisObservations
84+ observationToDianostic :: NormalizedFilePath -> Observation -> Maybe FileDiagnostic
8585 observationToDianostic file (Observation {observationSrcSpan, observationInspectionId}) =
86- ( file,
87- ShowDiag ,
88- LSP. Diagnostic
89- { _range = realSrcSpanToRange $ observationSrcSpan,
90- _severity = Just LSP. DsHint ,
91- _code = Just (LSP. InR $ unId (inspectionId inspection)),
92- _source = Just " stan" ,
93- _message = message,
94- _relatedInformation = Nothing ,
95- _tags = Nothing
96- }
97- )
98- where
99- inspection = fromJust $ HM. lookup observationInspectionId inspectionsMap
100- -- Lookin similar to Stan CLI output
101- message :: T. Text
102- message =
103- T. unlines $
104- [ " ✲ Name: " <> inspectionName inspection,
105- " ✲ Description: " <> inspectionDescription inspection,
106- " Possible solutions:"
107- ]
108- ++ map (" - " <> ) (inspectionSolution inspection)
86+ do
87+ inspection <- HM. lookup observationInspectionId inspectionsMap
88+ let
89+ -- Looking similar to Stan CLI output
90+ message :: T. Text
91+ message =
92+ T. unlines $
93+ [ " ✲ Name: " <> inspectionName inspection,
94+ " ✲ Description: " <> inspectionDescription inspection,
95+ " Possible solutions:"
96+ ]
97+ ++ map (" - " <> ) (inspectionSolution inspection)
98+ return ( file,
99+ ShowDiag ,
100+ LSP. Diagnostic
101+ { _range = realSrcSpanToRange $ observationSrcSpan,
102+ _severity = Just LSP. DsHint ,
103+ _code = Just (LSP. InR $ unId (inspectionId inspection)),
104+ _source = Just " stan" ,
105+ _message = message,
106+ _relatedInformation = Nothing ,
107+ _tags = Nothing
108+ }
109+ )
109110
110111getHieFile :: NormalizedFilePath -> Action (Maybe HieFile )
111112getHieFile nfp = runMaybeT $ do
0 commit comments