File tree 2 files changed +16
-3
lines changed
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
65
65
66
66
67
67
import qualified Data.Text ()
68
+ import Distribution.Parsec.Error
68
69
import qualified Ide.Plugin.Cabal.CabalAdd as CabalAdd
69
70
70
71
data Log
@@ -247,7 +248,19 @@ cabalRules recorder plId = do
247
248
let warningDiags = fmap (Diagnostics. warningDiagnostic file) pWarnings
248
249
case pm of
249
250
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
251
264
allDiags = errorDiags <> warningDiags
252
265
pure (allDiags, Nothing )
253
266
Right gpd -> do
Original file line number Diff line number Diff line change @@ -107,14 +107,14 @@ pluginTests =
107
107
length diags @?= 1
108
108
unknownLicenseDiag ^. L. range @?= Range (Position 3 24 ) (Position 4 0 )
109
109
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
111
111
_ <- openDoc " unsupportedVersion.cabal" " cabal"
112
112
diags <- cabalCaptureKick
113
113
unknownVersionDiag <- liftIO $ inspectDiagnostic diags [" Unsupported cabal-version 99999.0" ]
114
114
liftIO $ do
115
115
length diags @?= 1
116
116
unknownVersionDiag ^. L. range @?= Range (Position 0 0 ) (Position 1 0 )
117
- unknownVersionDiag ^. L. severity @?= Just DiagnosticSeverity_Error
117
+ unknownVersionDiag ^. L. severity @?= Just DiagnosticSeverity_Warning
118
118
, runCabalTestCaseSession " Clears diagnostics" " " $ do
119
119
doc <- openDoc " invalid.cabal" " cabal"
120
120
diags <- cabalCaptureKick
You can’t perform that action at this time.
0 commit comments