File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ import Text.Regex.TDFA
6565
6666
6767import qualified Data.Text ()
68+ import Distribution.Parsec.Error
6869import qualified Ide.Plugin.Cabal.CabalAdd as CabalAdd
6970
7071data Log
@@ -247,7 +248,19 @@ cabalRules recorder plId = do
247248 let warningDiags = fmap (Diagnostics. warningDiagnostic file) pWarnings
248249 case pm of
249250 Left (_cabalVersion, pErrorNE) -> do
250- let errorDiags = NE. toList $ NE. map (Diagnostics. errorDiagnostic file) pErrorNE
251+ let regex :: T. Text
252+ -- We don't support the cabal version, this should not be an error, as the
253+ -- user did not do anything wrong. Instead we cast it to a warning
254+ regex = " Unsupported cabal-version [0-9]+.[0-9]*"
255+ errorDiags =
256+ NE. toList $
257+ NE. map
258+ ( \ pe@ (PError pos text) ->
259+ if text =~ regex
260+ then Diagnostics. warningDiagnostic file (Syntax. PWarning Syntax. PWTOther pos text)
261+ else Diagnostics. errorDiagnostic file pe
262+ )
263+ pErrorNE
251264 allDiags = errorDiags <> warningDiags
252265 pure (allDiags, Nothing )
253266 Right gpd -> do
Original file line number Diff line number Diff line change @@ -107,14 +107,14 @@ pluginTests =
107107 length diags @?= 1
108108 unknownLicenseDiag ^. L. range @?= Range (Position 3 24 ) (Position 4 0 )
109109 unknownLicenseDiag ^. L. severity @?= Just DiagnosticSeverity_Error
110- , runCabalTestCaseSession " Publishes Diagnostics on Error in the first line " " " $ do
110+ , runCabalTestCaseSession " Publishes Diagnostics on unsupported cabal version as Warning " " " $ do
111111 _ <- openDoc " unsupportedVersion.cabal" " cabal"
112112 diags <- cabalCaptureKick
113113 unknownVersionDiag <- liftIO $ inspectDiagnostic diags [" Unsupported cabal-version 99999.0" ]
114114 liftIO $ do
115115 length diags @?= 1
116116 unknownVersionDiag ^. L. range @?= Range (Position 0 0 ) (Position 1 0 )
117- unknownVersionDiag ^. L. severity @?= Just DiagnosticSeverity_Error
117+ unknownVersionDiag ^. L. severity @?= Just DiagnosticSeverity_Warning
118118 , runCabalTestCaseSession " Clears diagnostics" " " $ do
119119 doc <- openDoc " invalid.cabal" " cabal"
120120 diags <- cabalCaptureKick
You can’t perform that action at this time.
0 commit comments