Skip to content

Commit 080cbb7

Browse files
authored
Merge branch 'master' into lockless-diagnostics
2 parents 0051a77 + 77d0429 commit 080cbb7

File tree

17 files changed

+463
-455
lines changed

17 files changed

+463
-455
lines changed

ghcide/.hlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
- Development.IDE.Spans.Documentation
113113
- Development.IDE.Spans.Common
114114
- Development.IDE.Spans.AtPoint
115+
- Development.IDE.Spans.Pragmas
115116
- Development.IDE.Plugin.CodeAction
116117
- Development.IDE.Plugin.Completions
117118
- Development.IDE.Plugin.Completions.Logic

ghcide/ghcide.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ library
186186
Development.IDE.Spans.Documentation
187187
Development.IDE.Spans.AtPoint
188188
Development.IDE.Spans.LocalBindings
189+
Development.IDE.Spans.Pragmas
189190
Development.IDE.Types.Diagnostics
190191
Development.IDE.Types.Exports
191192
Development.IDE.Types.HscEnvEq

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Data.List.Extra as List hiding
2020
import qualified Data.Map as Map
2121

2222
import Data.Maybe (fromMaybe, isJust,
23-
listToMaybe,
2423
mapMaybe)
2524
import qualified Data.Text as T
2625
import qualified Text.Fuzzy.Parallel as Fuzzy
@@ -480,7 +479,7 @@ findRecordCompl uri pmod mn DataDecl {tcdLName, tcdDataDefn} = result
480479
(showGhc . unLoc $ con_name) field_labels mn doc Nothing
481480
| ConDeclH98{..} <- unLoc <$> dd_cons tcdDataDefn
482481
, Just con_details <- [getFlds con_args]
483-
, let field_names = mapMaybe extract con_details
482+
, let field_names = concatMap extract con_details
484483
, let field_labels = showGhc . unLoc <$> field_names
485484
, (not . List.null) field_labels
486485
]
@@ -493,11 +492,18 @@ findRecordCompl uri pmod mn DataDecl {tcdLName, tcdDataDefn} = result
493492
_ -> Nothing
494493

495494
extract ConDeclField{..}
496-
-- TODO: Why is cd_fld_names a list?
497-
| Just fld_name <- rdrNameFieldOcc . unLoc <$> listToMaybe cd_fld_names = Just fld_name
498-
| otherwise = Nothing
495+
-- NOTE: 'cd_fld_names' is grouped so that the fields
496+
-- sharing the same type declaration to fit in the same group; e.g.
497+
--
498+
-- @
499+
-- data Foo = Foo {arg1, arg2 :: Int, arg3 :: Int, arg4 :: Bool}
500+
-- @
501+
--
502+
-- is encoded as @[[arg1, arg2], [arg3], [arg4]]@
503+
-- Hence, we must concat nested arguments into one to get all the fields.
504+
= map (rdrNameFieldOcc . unLoc) cd_fld_names
499505
-- XConDeclField
500-
extract _ = Nothing
506+
extract _ = []
501507
findRecordCompl _ _ _ _ = []
502508

503509
ppr :: Outputable a => a -> T.Text

ghcide/src/Development/IDE/Spans/Pragmas.hs

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.

hls-plugin-api/hls-plugin-api.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ library
4343
, dependent-sum
4444
, Diff ^>=0.4.0
4545
, dlist
46+
, extra
4647
, ghc
4748
, hashable
4849
, hls-graph >=1.4 && < 1.6
@@ -54,6 +55,7 @@ library
5455
, process
5556
, regex-tdfa >=1.3.1.0
5657
, text
58+
, transformers
5759
, unordered-containers
5860

5961
if os(windows)

hls-plugin-api/src/Ide/PluginUtils.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ module Ide.PluginUtils
2626
installSigUsr1Handler,
2727
subRange,
2828
usePropertyLsp,
29+
response,
30+
handleMaybe,
31+
handleMaybeM,
2932
)
3033
where
3134

3235

36+
import Control.Monad.Extra (maybeM)
37+
import Control.Monad.Trans.Class (lift)
38+
import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
3339
import Data.Algorithm.Diff
3440
import Data.Algorithm.DiffOutput
41+
import Data.Bifunctor (Bifunctor (first))
3542
import Data.Containers.ListUtils (nubOrdOn)
3643
import qualified Data.HashMap.Strict as H
44+
import Data.String (IsString (fromString))
3745
import qualified Data.Text as T
3846
import Ide.Plugin.Config
3947
import Ide.Plugin.Properties
@@ -236,3 +244,15 @@ allLspCmdIds pid commands = concatMap go commands
236244
where
237245
go (plid, cmds) = map (mkLspCmdId pid plid . commandId) cmds
238246

247+
-- ---------------------------------------------------------------------
248+
249+
handleMaybe :: Monad m => e -> Maybe b -> ExceptT e m b
250+
handleMaybe msg = maybe (throwE msg) return
251+
252+
handleMaybeM :: Monad m => e -> m (Maybe b) -> ExceptT e m b
253+
handleMaybeM msg act = maybeM (throwE msg) return $ lift act
254+
255+
response :: Monad m => ExceptT String m a -> m (Either ResponseError a)
256+
response =
257+
fmap (first (\msg -> ResponseError InternalError (fromString msg) Nothing))
258+
. runExceptT

plugins/hls-alternate-number-format-plugin/hls-alternate-number-format-plugin.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ library
2929
, ghc-boot-th
3030
, hls-graph
3131
, hls-plugin-api >=1.1 && < 1.3
32-
, hls-retrie-plugin
3332
, hie-compat
3433
, lens
3534
, lsp
@@ -41,7 +40,6 @@ library
4140

4241
default-language: Haskell2010
4342
default-extensions:
44-
CPP
4543
LambdaCase
4644
NamedFieldPuns
4745
OverloadedStrings

plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/AlternateNumberFormat.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Ide.Plugin.Conversion (FormatType, alternateFormat,
2323
toFormatTypes)
2424
import Ide.Plugin.Literals (Literal (..), collectLiterals,
2525
getSrcSpan, getSrcText)
26-
import Ide.Plugin.Retrie (handleMaybe, handleMaybeM,
26+
import Ide.PluginUtils (handleMaybe, handleMaybeM,
2727
response)
2828
import Ide.Types
2929
import Language.LSP.Types

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ import Ide.Plugin.Eval.Parse.Comments (commentsToSections)
9090
import Ide.Plugin.Eval.Parse.Option (parseSetFlags)
9191
import Ide.Plugin.Eval.Rules (queueForEvaluation)
9292
import Ide.Plugin.Eval.Types
93-
import Ide.Plugin.Eval.Util (asS, gStrictTry, handleMaybe,
94-
handleMaybeM, isLiterate,
95-
logWith, response, response',
96-
timed)
93+
import Ide.Plugin.Eval.Util (asS, gStrictTry, isLiterate,
94+
logWith, response', timed)
95+
import Ide.PluginUtils (handleMaybe, handleMaybeM,
96+
response)
9797
import Ide.Types
9898
import Language.LSP.Server
9999
import Language.LSP.Types hiding

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Util.hs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,15 @@ module Ide.Plugin.Eval.Util (
77
asS,
88
timed,
99
isLiterate,
10-
handleMaybe,
11-
handleMaybeM,
12-
response,
1310
response',
1411
gStrictTry,
1512
logWith,
1613
) where
1714

1815
import Control.Exception (SomeException, evaluate)
19-
import Control.Monad.Extra (maybeM)
2016
import Control.Monad.IO.Class (MonadIO (liftIO))
21-
import Control.Monad.Trans.Class (lift)
22-
import Control.Monad.Trans.Except (ExceptT (..), runExceptT,
23-
throwE)
17+
import Control.Monad.Trans.Except (ExceptT (..), runExceptT)
2418
import Data.Aeson (Value (Null))
25-
import Data.Bifunctor (first)
2619
import Data.String (IsString (fromString))
2720
import qualified Data.Text as T
2821
import Development.IDE (IdeState, Priority (..),
@@ -71,17 +64,6 @@ logLevel = Debug -- Info
7164
isLiterate :: FilePath -> Bool
7265
isLiterate x = takeExtension x `elem` [".lhs", ".lhs-boot"]
7366

74-
handleMaybe :: Monad m => e -> Maybe b -> ExceptT e m b
75-
handleMaybe msg = maybe (throwE msg) return
76-
77-
handleMaybeM :: Monad m => e -> m (Maybe b) -> ExceptT e m b
78-
handleMaybeM msg act = maybeM (throwE msg) return $ lift act
79-
80-
response :: Functor f => ExceptT String f c -> f (Either ResponseError c)
81-
response =
82-
fmap (first (\msg -> ResponseError InternalError (fromString msg) Nothing))
83-
. runExceptT
84-
8567
response' :: ExceptT String (LspM c) WorkspaceEdit -> LspM c (Either ResponseError Value)
8668
response' act = do
8769
res <- runExceptT act

0 commit comments

Comments
 (0)