Skip to content

Commit 4390a76

Browse files
authored
Merge branch 'master' into unhandled-exceptions
2 parents 9d875c2 + b7949aa commit 4390a76

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

ghcide/src/Development/IDE/GHC/Compat/Util.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ module Development.IDE.GHC.Compat.Util (
6868
hGetStringBuffer,
6969
stringToStringBuffer,
7070
nextChar,
71-
atEnd
71+
atEnd,
72+
-- * Char
73+
is_ident
7274
) where
7375

7476
#if MIN_VERSION_ghc(9,0,0)
@@ -81,6 +83,7 @@ import GHC.Data.FastString
8183
import GHC.Data.Maybe
8284
import GHC.Data.Pair
8385
import GHC.Data.StringBuffer
86+
import GHC.Parser.CharClass (is_ident)
8487
import GHC.Types.Unique
8588
import GHC.Types.Unique.DFM
8689
import GHC.Utils.Fingerprint
@@ -90,6 +93,7 @@ import GHC.Utils.Panic hiding (try)
9093
#else
9194
import Bag
9295
import BooleanFormula
96+
import Ctype (is_ident)
9397
import EnumSet
9498
import qualified Exception
9599
import FastString

ghcide/src/Development/IDE/LSP/LanguageServer.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ runLanguageServer options inH outH getHieDbLoc defaultConfig onConfigurationChan
9595
[ ideHandlers
9696
, cancelHandler cancelRequest
9797
, exitHandler exit
98+
, shutdownHandler
9899
]
99100
-- Cancel requests are special since they need to be handled
100101
-- out of order to be useful. Existing handlers are run afterwards.
@@ -193,13 +194,16 @@ cancelHandler :: (SomeLspId -> IO ()) -> LSP.Handlers (ServerM c)
193194
cancelHandler cancelRequest = LSP.notificationHandler SCancelRequest $ \NotificationMessage{_params=CancelParams{_id}} ->
194195
liftIO $ cancelRequest (SomeLspId _id)
195196

196-
exitHandler :: IO () -> LSP.Handlers (ServerM c)
197-
exitHandler exit = LSP.notificationHandler SExit $ const $ do
197+
shutdownHandler :: LSP.Handlers (ServerM c)
198+
shutdownHandler = LSP.requestHandler SShutdown $ \_ resp -> do
198199
(_, ide) <- ask
199200
liftIO $ logDebug (ideLogger ide) "Received exit message"
200201
-- flush out the Shake session to record a Shake profile if applicable
201202
liftIO $ shakeShut ide
202-
liftIO exit
203+
resp $ Right Empty
204+
205+
exitHandler :: IO () -> LSP.Handlers (ServerM c)
206+
exitHandler exit = LSP.notificationHandler SExit $ const $ liftIO exit
203207

204208
modifyOptions :: LSP.Options -> LSP.Options
205209
modifyOptions x = x{ LSP.textDocumentSync = Just $ tweakTDS origTDS

ghcide/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ rangesForBindingImport _ _ = []
15251525
wrapOperatorInParens :: String -> String
15261526
wrapOperatorInParens x =
15271527
case uncons x of
1528-
Just (h, _t) -> if isAlpha h then x else "(" <> x <> ")"
1528+
Just (h, _t) -> if is_ident h then x else "(" <> x <> ")"
15291529
Nothing -> mempty
15301530

15311531
smallerRangesForBindingExport :: [LIE GhcPs] -> String -> [Range]

ghcide/test/exe/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,19 +1276,20 @@ removeImportTests = testGroup "remove import actions"
12761276
, "stuffB :: Integer"
12771277
, "stuffB = 123"
12781278
, "stuffC = ()"
1279+
, "_stuffD = '_'"
12791280
]
12801281
_docA <- createDoc "ModuleA.hs" "haskell" contentA
12811282
let contentB = T.unlines
12821283
[ "{-# OPTIONS_GHC -Wunused-imports #-}"
12831284
, "module ModuleB where"
1284-
, "import ModuleA (stuffA, stuffB, stuffC, stuffA)"
1285+
, "import ModuleA (stuffA, stuffB, _stuffD, stuffC, stuffA)"
12851286
, "main = print stuffB"
12861287
]
12871288
docB <- createDoc "ModuleB.hs" "haskell" contentB
12881289
_ <- waitForDiagnostics
12891290
[InR action@CodeAction { _title = actionTitle }, _]
12901291
<- getCodeActions docB (Range (Position 2 0) (Position 2 5))
1291-
liftIO $ "Remove stuffA, stuffC from import" @=? actionTitle
1292+
liftIO $ "Remove _stuffD, stuffA, stuffC from import" @=? actionTitle
12921293
executeCodeAction action
12931294
contentAfterAction <- documentContents docB
12941295
let expectedContentAfterAction = T.unlines

hls-graph/hls-graph.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bug-reports: https://github.com/haskell/haskell-language-server/issues
1010
license: Apache-2.0
1111
license-file: LICENSE
1212
author: The Haskell IDE Team
13-
maintainer: alan.zimm@gmail.com
13+
maintainer: The Haskell IDE Team
1414
copyright: The Haskell IDE Team
1515
category: Development
1616
build-type: Simple

hls-graph/src/Development/IDE/Graph/Internal/Paths.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ import Data.FileEmbed
2020

2121
htmlDataFiles :: [(FilePath, BS.ByteString)]
2222
htmlDataFiles =
23-
[ ("profile.html", $(embedFile "html/profile.html"))
23+
[
24+
#ifdef __GHCIDE__
25+
("profile.html", $(embedFile "hls-graph/html/profile.html"))
26+
, ("shake.js", $(embedFile "hls-graph/html/shake.js"))
27+
#else
28+
("profile.html", $(embedFile "html/profile.html"))
2429
, ("shake.js", $(embedFile "html/shake.js"))
30+
#endif
2531
]
2632

2733
readDataFileHTML :: FilePath -> IO LBS.ByteString

0 commit comments

Comments
 (0)