Skip to content

Commit c4be6be

Browse files
committed
Report warning diagnostics, formatting edits
1 parent f90d3aa commit c4be6be

File tree

3 files changed

+10
-9
lines changed
  • ghcide/session-loader/Development/IDE
  • plugins/hls-cabal-project-plugin

3 files changed

+10
-9
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Development.IDE.Session
1414
,retryOnException
1515
,Log(..)
1616
,runWithDb
17+
, cacheDir
1718
) where
1819

1920
-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses

plugins/hls-cabal-project-plugin/src/Ide/Plugin/CabalProject/Parse.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import qualified Data.ByteString.Char8 as B
1212
import Data.List.NonEmpty (NonEmpty (..))
1313
import qualified Data.List.NonEmpty as NE
1414
import Development.IDE
15+
import Development.IDE.Session (cacheDir)
1516
import Distribution.Client.HttpUtils (configureTransport)
1617
import Distribution.Client.ProjectConfig.Parsec (ProjectConfigSkeleton,
1718
parseProject,
@@ -30,7 +31,7 @@ import System.Directory.Extra (XdgDirectory (..),
3031
import System.FilePath (takeBaseName,
3132
takeDirectory, (</>))
3233

33-
-- High level parsing of cabal.project file to produce errors, warnings, and ProjectConfigSkeleton
34+
-- | High level parsing of cabal.project file to produce errors, warnings, and ProjectConfigSkeleton
3435
parseCabalProjectFileContents
3536
:: FilePath
3637
-> BS.ByteString
@@ -47,21 +48,22 @@ parseCabalProjectFileContents fp bytes = do
4748

4849
pure (PR.runParseResult parseRes)
4950

50-
-- Extract fields from cabal.project file
51+
-- | Extract fields from cabal.project file
5152
readCabalProjectFields
5253
:: NormalizedFilePath
5354
-> BS.ByteString
5455
-> Either [FileDiagnostic] [Syntax.Field Syntax.Position]
5556
readCabalProjectFields file contents =
5657
case PR.runParseResult (readPreprocessFields contents) of
57-
-- we don't want to double report diagnostics, all diagnostics are produced by 'parseCabalProjectFileContents'.
58-
(_warnings, Left (_mbVer, errs)) ->
59-
Left (map (Diagnostics.errorDiagnostic file) (NE.toList errs))
58+
(warnings, Left (_mbVer, errs)) ->
59+
let errorDiags = map (Diagnostics.errorDiagnostic file) (NE.toList errs)
60+
warningDiags = map (Diagnostics.warningDiagnostic file) warnings
61+
in Left (errorDiags ++ warningDiags)
6062

6163
(_warnings, Right fields) ->
6264
Right fields
6365

64-
-- Helper for parseCabalProjectFileContents, returns unique cache directory for given cabal.project file
66+
-- | Returns unique cache directory for given cabal.project file
6567
getCabalProjectCacheDir :: FilePath -> IO FilePath
6668
getCabalProjectCacheDir fp = do
6769
getXdgDirectory XdgCache (cacheDir </> prefix ++ "-" ++ opts_hash)
@@ -70,5 +72,3 @@ getCabalProjectCacheDir fp = do
7072
-- Create a unique folder per cabal.project file
7173
opts_hash = B.unpack $ B16.encode $ H.finalize $ H.updates H.init [B.pack fp]
7274

73-
cacheDir :: String
74-
cacheDir = "ghcide"

plugins/hls-cabal-project-plugin/test/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ cabalProjectParserUnitTests =
6565
False @? "Expected parse to fail (missing import), but it succeeded"
6666
]
6767

68-
-- ------------------------ ------------------------------------------------
68+
-- ------------------------------------------------------------------------
6969
-- Integration Tests
7070
-- ------------------------------------------------------------------------
7171

0 commit comments

Comments
 (0)