Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uhbif19 committed May 16, 2022
1 parent 990f0bb commit 21c7a9a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions plugins/hls-stan-plugin/hls-stan-plugin.cabal
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/haskell/haskell-language-server#readme>

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
Expand Down
53 changes: 27 additions & 26 deletions plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 21c7a9a

Please sign in to comment.