Skip to content

Commit e561e41

Browse files
authored
Merge branch 'master' into jhrcek/ghcide-hlint
2 parents eeaa52c + 0d9fd23 commit e561e41

File tree

19 files changed

+65
-46
lines changed

19 files changed

+65
-46
lines changed

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
steps:
5050
- uses: actions/checkout@v3
5151

52-
- uses: cachix/install-nix-action@v24
52+
- uses: cachix/install-nix-action@v25
5353
with:
5454
extra_nix_config: |
5555
experimental-features = nix-command flakes

cabal.project

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ packages:
3636
./plugins/hls-overloaded-record-dot-plugin
3737
./plugins/hls-semantic-tokens-plugin
3838

39-
index-state: 2024-01-13T19:06:05Z
39+
index-state: 2024-01-17T16:04:21Z
4040

4141
tests: True
4242
test-show-details: direct
@@ -91,10 +91,6 @@ if impl(ghc >= 9.1)
9191
if impl(ghc >= 9.7)
9292
allow-newer:
9393
ekg-core:text,
94-
-- https://github.com/maoe/ghc-trace-events/issues/12
95-
ghc-trace-events:base,
96-
ghc-trace-events:bytestring,
97-
ghc-trace-events:text,
9894
-- https://github.com/haskell-primitive/primitive-unlifted/issues/39
9995
primitive-unlifted:bytestring,
10096
-- https://github.com/obsidiansystems/commutative-semigroups/issues/13

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ source-repository head
2121
type: git
2222
location: https://github.com/haskell/haskell-language-server.git
2323

24+
common warnings
25+
ghc-options: -Wall -Wunused-packages
26+
2427
library
28+
import: warnings
2529
exposed-modules: Ide.Plugin.AlternateNumberFormat, Ide.Plugin.Conversion
2630
other-modules: Ide.Plugin.Literals
2731
hs-source-dirs: src
28-
ghc-options: -Wall
2932
build-depends:
30-
aeson
3133
, base >=4.12 && < 5
3234
, containers
3335
, extra
3436
, ghcide == 2.6.0.0
3537
, ghc-boot-th
3638
, hls-graph
3739
, hls-plugin-api == 2.6.0.0
38-
, hie-compat
3940
, lens
4041
, lsp ^>=2.3.0.0
4142
, mtl
4243
, regex-tdfa
4344
, syb
4445
, text
45-
, unordered-containers
4646

4747
default-language: Haskell2010
4848
default-extensions:
@@ -52,6 +52,7 @@ library
5252
RecordWildCards
5353

5454
test-suite tests
55+
import: warnings
5556
type: exitcode-stdio-1.0
5657
default-language: Haskell2010
5758
hs-source-dirs: test
@@ -63,8 +64,6 @@ test-suite tests
6364
, filepath
6465
, hls-alternate-number-format-plugin
6566
, hls-test-utils == 2.6.0.0
66-
, lsp
67-
, QuickCheck
6867
, regex-tdfa
6968
, tasty-quickcheck
7069
, text

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ module Ide.Plugin.AlternateNumberFormat (descriptor, Log(..)) where
66

77
import Control.Lens ((^.))
88
import Control.Monad.Except (ExceptT)
9-
import Control.Monad.IO.Class (MonadIO, liftIO)
9+
import Control.Monad.IO.Class (MonadIO)
1010
import qualified Data.Map as Map
1111
import Data.Text (Text, unpack)
1212
import qualified Data.Text as T
1313
import Development.IDE (GetParsedModule (GetParsedModule),
1414
IdeState, RuleResult, Rules,
1515
define, realSrcSpanToRange,
16-
runAction, use)
16+
use)
1717
import Development.IDE.Core.PluginUtils
1818
import qualified Development.IDE.Core.Shake as Shake
1919
import Development.IDE.GHC.Compat hiding (getSrcSpan)
@@ -36,12 +36,11 @@ import qualified Language.LSP.Protocol.Lens as L
3636
import Language.LSP.Protocol.Message
3737
import Language.LSP.Protocol.Types
3838

39-
4039
newtype Log = LogShake Shake.Log deriving Show
4140

4241
instance Pretty Log where
4342
pretty = \case
44-
LogShake log -> pretty log
43+
LogShake msg -> pretty msg
4544

4645
descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
4746
descriptor recorder pId = (defaultPluginDescriptor pId "Provides code actions to convert numeric literals to different formats")
@@ -93,7 +92,7 @@ codeActionHandler state pId (CodeActionParams _ _ docId currRange _) = do
9392
literalPairs = map (\lit -> (lit, alternateFormat lit)) litsInRange
9493
-- make a code action for every literal and its' alternates (then flatten the result)
9594
actions = concatMap (\(lit, alts) -> map (mkCodeAction nfp lit enabledExtensions pragma) alts) literalPairs
96-
pure $ InL $ actions
95+
pure $ InL actions
9796
where
9897
mkCodeAction :: NormalizedFilePath -> Literal -> [GhcExtension] -> NextPragmaInfo -> AlternateFormat -> Command |? CodeAction
9998
mkCodeAction nfp lit enabled npi af@(alt, ext) = InR CodeAction {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module Ide.Plugin.Conversion (
2121
, ExtensionNeeded(..)
2222
) where
2323

24-
import Data.Char (toUpper)
2524
import Data.List (delete)
2625
import Data.List.Extra (enumerate, upper)
2726
import Data.Maybe (mapMaybe)
@@ -168,10 +167,10 @@ toDecimal :: Integral a => a -> String
168167
toDecimal = toBase showInt ""
169168

170169
toBinary :: (Integral a, Show a) => a -> String
171-
toBinary = toBase showBin "0b"
170+
toBinary = toBase showBin_ "0b"
172171
where
173172
-- this is not defined in versions of Base < 4.16-ish
174-
showBin = showIntAtBase 2 intToDigit
173+
showBin_ = showIntAtBase 2 intToDigit
175174

176175
toHex :: (Integral a, Show a) => a -> String
177176
toHex = toBase showHex "0x"

plugins/hls-alternate-number-format-plugin/test/Main.hs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import Data.Text (Text)
99
import qualified Data.Text as T
1010
import qualified Ide.Plugin.AlternateNumberFormat as AlternateNumberFormat
1111
import qualified Ide.Plugin.Conversion as Conversion
12-
import Language.LSP.Protocol.Lens (kind)
13-
import Language.LSP.Protocol.Types (toEither)
1412
import Properties.Conversion (conversions)
1513
import System.FilePath ((<.>), (</>))
1614
import Test.Hls
@@ -110,21 +108,12 @@ codeActionTitle :: (Command |? CodeAction) -> Maybe Text
110108
codeActionTitle (InR CodeAction {_title}) = Just _title
111109
codeActionTitle _ = Nothing
112110

113-
codeActionTitle' :: CodeAction -> Text
114-
codeActionTitle' CodeAction{_title} = _title
115-
116111
pointRange :: Int -> Int -> Range
117112
pointRange
118113
(subtract 1 -> fromIntegral -> line)
119114
(subtract 1 -> fromIntegral -> col) =
120115
Range (Position line col) (Position line $ col + 1)
121116

122-
contains :: [CodeAction] -> Text -> Bool
123-
acts `contains` regex = any (\action -> codeActionTitle' action =~ regex) acts
124-
125-
doesNotContain :: [CodeAction] -> Text -> Bool
126-
acts `doesNotContain` regex = not $ acts `contains` regex
127-
128117
convertPrefix, intoInfix, maybeExtension, hexRegex, hexFloatRegex, binaryRegex, octalRegex, numDecimalRegex, decimalRegex :: Text
129118
convertPrefix = "Convert (" <> T.intercalate "|" [Conversion.hexRegex, Conversion.hexFloatRegex, Conversion.binaryRegex, Conversion.octalRegex, Conversion.numDecimalRegex, Conversion.decimalRegex] <> ")"
130119
intoInfix = " into "

plugins/hls-alternate-number-format-plugin/test/Properties/Conversion.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ import Test.Tasty.QuickCheck (testProperty)
77
import Text.Regex.TDFA ((=~))
88

99
conversions :: TestTree
10-
conversions = testGroup "Conversions" $ map (uncurry testProperty) [("Match NumDecimal", prop_regexMatchesNumDecimal)
10+
conversions = testGroup "Conversions" $
11+
map (uncurry testProperty)
12+
[ ("Match NumDecimal", prop_regexMatchesNumDecimal)
1113
, ("Match Hex", prop_regexMatchesHex)
1214
, ("Match Octal", prop_regexMatchesOctal)
1315
, ("Match Binary", prop_regexMatchesBinary)
14-
] <> map (uncurry testProperty) [("Match HexFloat", prop_regexMatchesHexFloat @Double)
16+
]
17+
<>
18+
map (uncurry testProperty)
19+
[ ("Match HexFloat", prop_regexMatchesHexFloat @Double)
1520
, ("Match FloatDecimal", prop_regexMatchesFloatDecimal)
1621
, ("Match FloatExpDecimal", prop_regexMatchesFloatExpDecimal)
1722
]
1823

1924
prop_regexMatchesNumDecimal :: Integer -> Bool
20-
prop_regexMatchesNumDecimal = (=~ numDecimalRegex) . toFloatExpDecimal . fromInteger
25+
prop_regexMatchesNumDecimal = (=~ numDecimalRegex) . toFloatExpDecimal @Double . fromInteger
2126

2227
prop_regexMatchesHex :: (Integral a, Show a) => a -> Bool
2328
prop_regexMatchesHex = (=~ hexRegex ) . toHex

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ descriptor recorder plId =
114114
deleteFileOfInterest recorder ide file
115115
restartCabalShakeSession (shakeExtras ide) vfs file "(closed)"
116116
]
117+
, pluginConfigDescriptor = defaultConfigDescriptor
118+
{ configHasDiagnostics = True
119+
}
117120
}
118121
where
119122
log' = logWith recorder

plugins/hls-change-type-signature-plugin/hls-change-type-signature-plugin.cabal

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ source-repository head
2222
type: git
2323
location: https://github.com/haskell/haskell-language-server.git
2424

25+
common warnings
26+
ghc-options: -Wall -Wunused-packages
27+
2528
library
29+
import: warnings
2630
exposed-modules: Ide.Plugin.ChangeTypeSignature
2731
hs-source-dirs: src
2832
build-depends:
@@ -34,9 +38,7 @@ library
3438
, syb
3539
, text
3640
, transformers
37-
, unordered-containers
3841
, containers
39-
ghc-options: -Wall
4042
default-language: Haskell2010
4143
default-extensions:
4244
ConstraintKinds
@@ -50,18 +52,17 @@ library
5052

5153

5254
test-suite tests
55+
import: warnings
5356
type: exitcode-stdio-1.0
5457
default-language: Haskell2010
5558
hs-source-dirs: test
5659
main-is: Main.hs
57-
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-ignore-asserts -Wall
60+
ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-ignore-asserts
5861
build-depends:
5962
, base >=4.12 && < 5
6063
, filepath
6164
, hls-change-type-signature-plugin
6265
, hls-test-utils == 2.6.0.0
63-
, lsp
64-
, QuickCheck
6566
, regex-tdfa
6667
, text
6768
default-extensions:

plugins/hls-change-type-signature-plugin/src/Ide/Plugin/ChangeTypeSignature.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ codeActionHandler plId ideState _ CodeActionParams {_textDocument = TextDocument
4646
getDecls :: MonadIO m => PluginId -> IdeState -> NormalizedFilePath -> ExceptT PluginError m [LHsDecl GhcPs]
4747
getDecls (PluginId changeTypeSignatureId) state =
4848
runActionE (T.unpack changeTypeSignatureId <> ".GetParsedModule") state
49-
. (fmap (hsmodDecls . unLoc . pm_parsed_source))
49+
. fmap (hsmodDecls . unLoc . pm_parsed_source)
5050
. useE GetParsedModule
5151

5252
-- | Text representing a Declaration's Name

0 commit comments

Comments
 (0)