Skip to content

Commit d3d4b6e

Browse files
committed
Support for aeson-2 and extra-1.7.10
1 parent bc13e9c commit d3d4b6e

File tree

15 files changed

+61
-42
lines changed

15 files changed

+61
-42
lines changed

cabal-ghc901.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ package *
4646

4747
write-ghc-environment-files: never
4848

49-
index-state: 2021-12-14T16:48:45Z
49+
index-state: 2021-12-27T14:48:54Z
5050

5151
constraints:
5252
-- These plugins don't work on GHC9 yet

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ package *
4646

4747
write-ghc-environment-files: never
4848

49-
index-state: 2021-12-14T16:48:45Z
49+
index-state: 2021-12-27T14:48:54Z
5050

5151
constraints:
5252
hyphenation +embed

ghcide/src/Control/Concurrent/Strict.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module Control.Concurrent.Strict
22
(modifyVar', modifyVarIO'
33
,modifyVar, modifyVar_
4+
,module Control.Concurrent.Extra
45
) where
56

7+
import Control.Concurrent.Extra hiding (modifyVar, modifyVar',
8+
modifyVar_)
69
import qualified Control.Concurrent.Extra as Extra
710
import Control.Exception (evaluate)
811
import Control.Monad (void)

ghcide/src/Development/IDE/GHC/Orphans.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ instance ToJSON RealSrcSpan where
142142

143143
instance FromJSON RealSrcSpan where
144144
parseJSON = withObject "object" $ \obj -> do
145-
file <- fromString <$> (obj .: srcSpanFileTag)
145+
file <- fromString <$> (obj .: toJsonKey srcSpanFileTag)
146146
mkRealSrcSpan
147147
<$> (mkRealSrcLoc file
148-
<$> obj .: srcSpanStartLineTag
149-
<*> obj .: srcSpanStartColTag
148+
<$> obj .: toJsonKey srcSpanStartLineTag
149+
<*> obj .: toJsonKey srcSpanStartColTag
150150
)
151151
<*> (mkRealSrcLoc file
152-
<$> obj .: srcSpanEndLineTag
153-
<*> obj .: srcSpanEndColTag
152+
<$> obj .: toJsonKey srcSpanEndLineTag
153+
<*> obj .: toJsonKey srcSpanEndColTag
154154
)
155155

156156
instance NFData Type where

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
{-# LANGUAGE CPP #-}
1+
{-# LANGUAGE CPP #-}
22
module Ide.Compat where
33

44
#if MIN_VERSION_aeson(2,0,0)
5-
import Data.Aeson.Key as A (Key)
6-
import qualified Data.Aeson.Key as A.Key
7-
import qualified Data.Aeson.KeyMap as Map
5+
import Data.Aeson.Key as A (Key)
6+
import qualified Data.Aeson.Key as A.Key
7+
import qualified Data.Aeson.KeyMap as A
8+
import Data.Functor.Identity (Identity (..), runIdentity)
89
#else
9-
import qualified Data.HashMap.Lazy as Map
10+
import qualified Data.HashMap.Lazy as Map
1011
#endif
11-
import Data.Text as T
12+
import Data.Aeson as A (Value)
13+
import Data.Text as T
1214

1315
#if MIN_VERSION_aeson(2,0,0)
1416
toJsonKey :: T.Text -> A.Key
@@ -19,9 +21,18 @@ toJsonKey = id
1921
#endif
2022

2123
#if MIN_VERSION_aeson(2,0,0)
22-
toJsonKey :: T.Text -> A.Key
23-
toJsonKey = A.Key.fromText
24+
insertJson :: A.Key -> A.Value -> A.KeyMap A.Value -> A.KeyMap A.Value
25+
insertJson = A.insert
2426
#else
25-
toJsonKey :: T.Text -> T.Text
26-
toJsonKey = id
27+
insertJson :: T.Text -> A.Value -> Map.HashMap T.Text A.Value -> Map.HashMap T.Text A.Value
28+
insertJson = Map.insert
29+
#endif
30+
31+
32+
#if MIN_VERSION_aeson(2,0,0)
33+
adjustJson :: (A.Value -> A.Value) -> A.Key -> A.KeyMap A.Value -> A.KeyMap A.Value
34+
adjustJson f k = runIdentity . A.alterF (Identity . fmap f) k
35+
#else
36+
adjustJson :: (A.Value -> A.Value) -> T.Text -> Map.HashMap T.Text A.Value -> Map.HashMap T.Text A.Value
37+
adjustJson = Map.adjust
2738
#endif

hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ import qualified Data.Aeson.Types as A
1010
import Data.Default (def)
1111
import qualified Data.Dependent.Map as DMap
1212
import qualified Data.Dependent.Sum as DSum
13-
import Data.Functor.Identity
14-
import qualified Data.HashMap.Lazy as Map
1513
import Data.List (nub)
16-
import Data.Maybe (fromJust)
17-
import Data.Text (Text)
18-
import Ide.Compat (toKey)
14+
import Ide.Compat (adjustJson, insertJson, toJsonKey)
1915
import Ide.Plugin.Config
2016
import Ide.Plugin.Properties (toDefaultJSON, toVSCodeExtensionSchema)
2117
import Ide.Types
@@ -29,10 +25,10 @@ import Language.LSP.Types
2925
-- | Generates a default 'Config', but remains only effective items
3026
pluginsToDefaultConfig :: IdePlugins a -> A.Value
3127
pluginsToDefaultConfig IdePlugins {..} =
32-
A.Object $ runIdentity $
33-
Map.alterF
34-
( \(unsafeValueToObject . fromJust -> o) ->
35-
Identity $ Just $ A.Object $ Map.insert "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged
28+
A.Object $
29+
adjustJson
30+
( \(unsafeValueToObject -> o) ->
31+
A.Object $ insertJson "plugin" elems o -- inplace the "plugin" section with our 'elems', leaving others unchanged
3632
)
3733
"haskell"
3834
(unsafeValueToObject (A.toJSON defaultConfig))
@@ -56,7 +52,7 @@ pluginsToDefaultConfig IdePlugins {..} =
5652
-- }
5753
singlePlugin PluginDescriptor {pluginConfigDescriptor = ConfigDescriptor {..}, ..} =
5854
let x = genericDefaultConfig <> dedicatedDefaultConfig
59-
in [(toKey pId) A..= A.object x | not $ null x]
55+
in [toJsonKey pId A..= A.object x | not $ null x]
6056
where
6157
(PluginHandlers (DMap.toList -> handlers)) = pluginHandlers
6258
customConfigToDedicatedDefaultConfig (CustomConfig p) = toDefaultJSON p

hls-plugin-api/src/Ide/Plugin/Properties.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import Data.Proxy (Proxy (..))
5050
import qualified Data.Text as T
5151
import GHC.OverloadedLabels (IsLabel (..))
5252
import GHC.TypeLits
53-
import Ide.Types (toJsonKey)
53+
import Ide.Compat (toJsonKey)
5454
import Unsafe.Coerce (unsafeCoerce)
5555

5656
-- | Types properties may have
@@ -249,9 +249,9 @@ parseProperty kn k x = case k of
249249
)
250250
x
251251
where
252-
key = toJsonKey . pack $ symbolVal kn
252+
key = toJsonKey . T.pack $ symbolVal kn
253253
parseEither :: forall a. A.FromJSON a => Either String a
254-
parseEither = A.parseEither (A..: keyName) x
254+
parseEither = A.parseEither (A..: key) x
255255

256256
-- ---------------------------------------------------------------------
257257

@@ -354,7 +354,7 @@ toDefaultJSON :: Properties r -> [A.Pair]
354354
toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p]
355355
where
356356
toEntry :: String -> SomePropertyKeyWithMetaData -> A.Pair
357-
toEntry (toJsonKey . pack -> s) = \case
357+
toEntry (toJsonKey . T.pack -> s) = \case
358358
(SomePropertyKeyWithMetaData SNumber MetaData {..}) ->
359359
s A..= defaultValue
360360
(SomePropertyKeyWithMetaData SInteger MetaData {..}) ->
@@ -373,7 +373,7 @@ toDefaultJSON (Properties p) = [toEntry s v | (s, v) <- Map.toList p]
373373
-- | Converts a properties definition into kv pairs as vscode schema
374374
toVSCodeExtensionSchema :: T.Text -> Properties r -> [A.Pair]
375375
toVSCodeExtensionSchema prefix (Properties p) =
376-
[(toJsonKey prefix <> k) A..= toEntry v | (k, v) <- Map.toList p]
376+
[toJsonKey (prefix <> T.pack k) A..= toEntry v | (k, v) <- Map.toList p]
377377
where
378378
toEntry :: SomePropertyKeyWithMetaData -> A.Value
379379
toEntry = \case

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import qualified System.Posix.Process as P (getProcessID)
2828
import System.Posix.Signals
2929
#endif
3030
import Control.Lens ((^.))
31-
import Control.Monad
3231
import Data.Aeson hiding (defaultOptions)
3332
import qualified Data.DList as DList
3433
import qualified Data.Default

plugins/hls-hlint-plugin/hls-hlint-plugin.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ library
9292
-- This mirrors the logic in hlint.cabal for hlint-3.2
9393
-- https://github.com/ndmitchell/hlint/blob/c7354e473c7d09213c8adc3dc94bf50a6eb4a42d/hlint.cabal#L79-L88
9494
build-depends: hlint ^>=3.2
95-
, extra < 1.7.10
9695
if (!flag(ghc-lib) && impl(ghc >=8.10.1) && impl(ghc < 8.11.0))
9796
build-depends: ghc >=8.10 && <9.0
9897
else

stack-8.10.6.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ extra-deps:
3838
- brittany-0.13.1.2@sha256:9922614f1df18c63755a37c144033988788e0769fd9c2630b64ed0dfb49462bd,8197
3939
- bytestring-encoding-0.1.1.0@sha256:1c3b97eb6345fd7153006211c8272215cd78bb0cf440c41185290822f1e3f2c2,1738
4040
- data-tree-print-0.1.0.2@sha256:d845e99f322df70e0c06d6743bf80336f5918d5423498528beb0593a2afc1703,1620
41+
- extra-1.7.10
4142
- floskell-0.10.5@sha256:77f0bc1569573d9666b10975a5357fef631d32266c071733739393ccae521dab,3803
4243
- heapsize-0.3.0.1@sha256:0b69aa97a46d819b700ac7b145f3b5493c3565cf2c5b8298682238d405d0326e,1417
4344
- hie-bios-0.8.0
4445
- hiedb-0.4.1.0
46+
- hlint-3.2.8
4547
- implicit-hie-0.1.2.6@sha256:f50a908979a574a881f753c0f9a5224f023f438b30fdefc5b7fa01803b07a280,2998
4648
- implicit-hie-cradle-0.3.0.5@sha256:5f5e575f549b2a9db664be7650b5c3c9226e313bddc46c79e2e83eb349f8e692,2610
4749
# - lsp-1.2.0.1

0 commit comments

Comments
 (0)