Skip to content

Commit 16551d1

Browse files
author
Jaro Reinders
committed
Resolve fendor's feedback
1 parent 1bc221c commit 16551d1

File tree

7 files changed

+11
-14
lines changed

7 files changed

+11
-14
lines changed

ghcide-bench/src/Experiments.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ experiments =
266266
flip allM docs $ \DocumentPositions{..} -> do
267267
bottom <- pred . length . T.lines <$> documentContents doc
268268
diags <- getCurrentDiagnostics doc
269-
case requireDiagnostic diags (DiagnosticSeverity_Error, (fromIntegral bottom, 8), "Found hole", Just "88464", Nothing) of
269+
case requireDiagnostic diags (DiagnosticSeverity_Error, (fromIntegral bottom, 8), "Found hole", Just "GHC-88464", Nothing) of
270270
Nothing -> pure True
271271
Just _err -> pure False
272272
),

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ computePackageDeps env pkg = do
163163
Nothing ->
164164
return $ Left
165165
[ ideErrorText
166-
Nothing
167166
(toNormalizedFilePath' noFilePath)
168167
(T.pack $ "unknown package: " ++ show pkg)
168+
Nothing
169169
]
170170
Just pkgInfo -> return $ Right $ unitDepends pkgInfo
171171

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ getModificationTimeImpl missingFileDiags file = do
142142
`catch` \(e :: IOException) -> do
143143
let err | isDoesNotExistError e = "File does not exist: " ++ file'
144144
| otherwise = "IO error while reading " ++ file' ++ ", " ++ displayException e
145-
diag = ideErrorText Nothing file (T.pack err)
145+
diag = ideErrorText file (T.pack err) Nothing
146146
if isDoesNotExistError e && not missingFileDiags
147147
then return (Nothing, ([], Nothing))
148148
else return (Nothing, ([diag], Nothing))

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ defineEarlyCutoff' doDiagnostics cmp key file mbOld mode action = do
12481248
(mbBs, (diags, mbRes)) <- actionCatch
12491249
(do v <- action staleV; liftIO $ evaluate $ force v) $
12501250
\(e :: SomeException) -> do
1251-
pure (Nothing, ([ideErrorText Nothing file $ T.pack $ show e | not $ isBadDependency e],Nothing))
1251+
pure (Nothing, ([ideErrorText file (T.pack $ show e) Nothing | not $ isBadDependency e],Nothing))
12521252

12531253
ver <- estimateFileVersionUnsafely key mbRes file
12541254
(bs, res) <- case mbRes of

ghcide/src/Development/IDE/Types/Diagnostics.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ type IdeResult v = ([FileDiagnostic], Maybe v)
7676
-- | an IdeResult with a fingerprint
7777
type IdeResultNoDiagnosticsEarlyCutoff v = (Maybe ByteString, Maybe v)
7878

79-
ideErrorText :: Maybe (MsgEnvelope GhcMessage) -> NormalizedFilePath -> T.Text -> FileDiagnostic
80-
ideErrorText origMsg fdFilePath msg =
79+
ideErrorText :: NormalizedFilePath -> T.Text -> Maybe (MsgEnvelope GhcMessage) -> FileDiagnostic
80+
ideErrorText fdFilePath msg origMsg =
8181
ideErrorWithSource (Just "compiler") (Just DiagnosticSeverity_Error) fdFilePath msg origMsg
8282

8383
ideErrorFromLspDiag
@@ -119,8 +119,6 @@ showGhcCode = T.pack . show
119119
showGhcCode :: DiagnosticCode -> T.Text
120120
showGhcCode (DiagnosticCode prefix c) = T.pack $ prefix ++ "-" ++ printf "%05d" c
121121
#endif
122-
in
123-
FileDiagnostic {..}
124122

125123
attachedReason :: Traversal' Diagnostic (Maybe JSON.Value)
126124
attachedReason = data_ . non (JSON.object []) . JSON.atKey "attachedReason"

hls-test-utils/src/Development/IDE/Test/Diagnostic.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import qualified Data.Text as T
66
import GHC.Stack (HasCallStack)
77
import Language.LSP.Protocol.Lens
88
import Language.LSP.Protocol.Types
9+
import Development.IDE.GHC.Compat (ghcVersion, GhcVersion (..))
910

1011
-- | (0-based line number, 0-based column number)
1112
type Cursor = (UInt, UInt)
@@ -35,15 +36,13 @@ requireDiagnostic actuals expected@(severity, cursor, expectedMsg, mbExpectedCod
3536
&& hasTag expectedTag (d ^. tags)
3637
&& codeMatches d
3738

38-
codeMatches d =
39-
#if MIN_VERSION_GLASGOW_HASKELL(9,5,0,0)
39+
codeMatches d
40+
| ghcVersion >= GHC96 =
4041
case (mbExpectedCode, _code d) of
4142
(Nothing, _) -> True
4243
(Just expectedCode, Nothing) -> False
4344
(Just expectedCode, Just actualCode) -> InR expectedCode == actualCode
44-
#else
45-
True
46-
#endif
45+
| otherwise = True
4746

4847
hasTag :: Maybe DiagnosticTag -> Maybe [DiagnosticTag] -> Bool
4948
hasTag Nothing _ = True

test/functional/Config.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ genericConfigTests = testGroup "generic plugin config"
9090
files <- getFilesOfInterestUntracked
9191
void $ uses_ GetTestDiagnostics $ HM.keys files
9292
define mempty $ \GetTestDiagnostics file -> do
93-
let diags = [ideErrorText Nothing file "testplugin"]
93+
let diags = [ideErrorText file "testplugin" Nothing]
9494
return (diags,Nothing)
9595
}
9696
-- A config that disables the plugin initially

0 commit comments

Comments
 (0)