Skip to content

Commit 21c7a9a

Browse files
committed
Fixes
1 parent 990f0bb commit 21c7a9a

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

plugins/hls-stan-plugin/hls-stan-plugin.cabal

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
cabal-version: 2.4
22
name: hls-stan-plugin
3-
version: 1.0.4.0
4-
synopsis: Hlint integration plugin with Haskell Language Server
3+
version: 1.0.0.0
4+
synopsis: Stan integration plugin with Haskell Language Server
55
description:
66
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
77

88
license: Apache-2.0
99
license-file: LICENSE
1010
author: The Haskell IDE Team
11-
maintainer: atreyu.bbb@gmail.com
11+
maintainer: uhbif19@gmail.com
1212
copyright: The Haskell IDE Team
1313
category: Development
1414
build-type: Simple
1515
extra-source-files:
1616
LICENSE
17-
test/testdata/**/*.yaml
17+
test/testdata/**/*
1818

1919
flag pedantic
2020
description: Enable -Werror

plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs

+27-26
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Data.Foldable (toList)
99
import qualified Data.HashMap.Strict as HM
1010
import Data.Hashable (Hashable)
1111
import qualified Data.Map as Map
12-
import Data.Maybe (fromJust)
12+
import Data.Maybe (fromJust, mapMaybe)
1313
import qualified Data.Text as T
1414
import Data.Typeable (Typeable, cast)
1515
import 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

110111
getHieFile :: NormalizedFilePath -> Action (Maybe HieFile)
111112
getHieFile nfp = runMaybeT $ do

0 commit comments

Comments
 (0)