11{-# LANGUAGE CPP #-}
2+ {-# LANGUAGE DataKinds #-}
23{-# LANGUAGE PatternSynonyms #-}
34module Ide.Plugin.Stan (descriptor , Log ) where
45
@@ -11,6 +12,9 @@ import qualified Data.HashMap.Strict as HM
1112import Data.Maybe (mapMaybe )
1213import qualified Data.Text as T
1314import Development.IDE
15+ import Development.IDE.Core.InputPath
16+ (classifyProjectHaskellInputs ,
17+ unInputPath )
1418import Development.IDE.Core.Rules (getHieFile )
1519import qualified Development.IDE.Core.Shake as Shake
1620import Development.IDE.GHC.Compat (HieFile (.. ))
@@ -110,6 +114,7 @@ rules :: Recorder (WithPriority Log) -> PluginId -> Rules ()
110114rules recorder plId = do
111115 define (cmapWithPrio LogShake recorder) $
112116 \ GetStanDiagnostics file -> do
117+ let nfp = unInputPath file
113118 config <- getPluginConfigAction plId
114119 if plcGlobalOn config && plcDiagnosticsOn config then do
115120 maybeHie <- getHieFile file
@@ -144,7 +149,7 @@ rules recorder plId = do
144149
145150 -- Note that Stan works in terms of relative paths, but the HIE come in as absolute. Without
146151 -- making its path relative, the file name(s) won't line up with the associated Map keys.
147- relativeHsFilePath <- liftIO $ makeRelativeToCurrentDirectory $ fromNormalizedFilePath file
152+ relativeHsFilePath <- liftIO $ makeRelativeToCurrentDirectory $ fromNormalizedFilePath nfp
148153 let hieRelative = hie{hie_hs_file= relativeHsFilePath}
149154
150155 (checksMap, ignoredObservations) <- case configTrial of
@@ -161,12 +166,13 @@ rules recorder plId = do
161166 -- A Map from *relative* file paths (just one, in this case) to language extension info:
162167 cabalExtensionsMap <- liftIO $ createCabalExtensionsMap isLoud (stanArgsCabalFilePath stanArgs) [hieRelative]
163168 let analysis = runAnalysis cabalExtensionsMap checksMap ignoredObservations [hieRelative]
164- return (analysisToDiagnostics file analysis, Just () )
169+ return (analysisToDiagnostics nfp analysis, Just () )
165170 else return ([] , Nothing )
166171
167172 action $ do
168- files <- getFilesOfInterestUntracked
169- void $ uses GetStanDiagnostics $ HM. keys files
173+ filesOfInterest <- getFilesOfInterestUntracked
174+ let files = classifyProjectHaskellInputs $ HM. keys filesOfInterest
175+ void $ uses GetStanDiagnostics $ files
170176 where
171177 analysisToDiagnostics :: NormalizedFilePath -> Analysis -> [FileDiagnostic ]
172178 analysisToDiagnostics file = mapMaybe (observationToDianostic file) . toList . analysisObservations
0 commit comments