Skip to content

Commit e6a8520

Browse files
committed
Use correct extension/file mappings even in the case of a config fiasco
The Stan plugin will still operate as expected even if we can't load a config -- it will simply default to showing all inspections.
1 parent c0dac2e commit e6a8520

File tree

1 file changed

+9
-9
lines changed
  • plugins/hls-stan-plugin/src/Ide/Plugin

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,20 @@ rules recorder plId = do
169169
relativeHsFilePath <- liftIO $ makeRelativeToCurrentDirectory $ fromNormalizedFilePath file
170170
let hieRelative = hie{hie_hs_file=relativeHsFilePath}
171171

172-
(cabalExtensionsMap, checksMap, confIgnored) <- case configTrial of
172+
(checksMap, ignoredObservations) <- case configTrial of
173173
FiascoL es -> do
174174
logWith recorder Development.IDE.Warning (LogWarnConf es)
175-
pure (Map.empty,
176-
HM.fromList [(LSP.fromNormalizedFilePath file, inspectionsIds)],
177-
[])
178-
ResultL warnings stanConfig -> do
179-
-- A Map from *relative* file paths (just one, in this case) to language extension info.
180-
cabalExtensionsMap <- liftIO $ createCabalExtensionsMap isLoud (stanArgsCabalFilePath stanArgs) [hieRelative]
175+
-- If we can't read the config file, default to using all inspections:
176+
let allInspections = HM.fromList [(relativeHsFilePath, inspectionsIds)]
177+
pure (allInspections, [])
178+
ResultL _warnings stanConfig -> do
181179
-- HashMap of *relative* file paths to info about enabled checks for those file paths.
182180
let checksMap = applyConfig [relativeHsFilePath] stanConfig
183-
pure (cabalExtensionsMap, checksMap, configIgnored stanConfig)
181+
pure (checksMap, configIgnored stanConfig)
184182

185-
let analysis = runAnalysis cabalExtensionsMap checksMap confIgnored [hieRelative]
183+
-- A Map from *relative* file paths (just one, in this case) to language extension info:
184+
cabalExtensionsMap <- liftIO $ createCabalExtensionsMap isLoud (stanArgsCabalFilePath stanArgs) [hieRelative]
185+
let analysis = runAnalysis cabalExtensionsMap checksMap ignoredObservations [hieRelative]
186186
return (analysisToDiagnostics file analysis, Just ())
187187
else return ([], Nothing)
188188

0 commit comments

Comments
 (0)