@@ -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
@@ -220,8 +221,9 @@ cabalRules recorder plId = do
220
221
fields <- use_ ParseCabalFields file
221
222
let commonSections = Maybe. mapMaybe (\ case
222
223
commonSection@ (Syntax. Section (Syntax. Name _ " common" ) _ _) -> Just commonSection
223
- _ -> Nothing )
224
- fields
224
+ _ -> Nothing
225
+ )
226
+ fields
225
227
pure ([] , Just commonSections)
226
228
227
229
define (cmapWithPrio LogShake recorder) $ \ ParseCabalFile file -> do
@@ -247,7 +249,19 @@ cabalRules recorder plId = do
247
249
let warningDiags = fmap (Diagnostics. warningDiagnostic file) pWarnings
248
250
case pm of
249
251
Left (_cabalVersion, pErrorNE) -> do
250
- let errorDiags = NE. toList $ NE. map (Diagnostics. errorDiagnostic file) pErrorNE
252
+ let regex :: T. Text
253
+ -- We don't support the cabal version, this should not be an error, as the
254
+ -- user did not do anything wrong. Instead we cast it to a warning
255
+ regex = " Unsupported cabal-version [0-9]+.[0-9]*"
256
+ errorDiags =
257
+ NE. toList $
258
+ NE. map
259
+ ( \ pe@ (PError pos text) ->
260
+ if text =~ regex
261
+ then Diagnostics. warningDiagnostic file (Syntax. PWarning Syntax. PWTOther pos text)
262
+ else Diagnostics. errorDiagnostic file pe
263
+ )
264
+ pErrorNE
251
265
allDiags = errorDiags <> warningDiags
252
266
pure (allDiags, Nothing )
253
267
Right gpd -> do
0 commit comments