Skip to content

Commit

Permalink
Fix -Wall and -Wunused-packages in eval plugin (haskell#3981)
Browse files Browse the repository at this point in the history
* Fix -Wall and -Wunused-packages in eval plugin

* Ah, so that's why -Wno-unticked-promoted-constructors

* stylish-haskell

* Fix pre-commit check

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and josephsumabat committed Jan 22, 2024
1 parent 1773262 commit e0db3b5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 37 deletions.
2 changes: 1 addition & 1 deletion plugins/hls-class-plugin/src/Ide/Plugin/Class/Types.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE CPP #-}

module Ide.Plugin.Class.Types where

Expand Down
18 changes: 6 additions & 12 deletions plugins/hls-eval-plugin/hls-eval-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ source-repository head
type: git
location: https://github.com/haskell/haskell-language-server

common warnings
ghc-options:
-Wall -Wunused-packages -Wno-name-shadowing -Wno-unticked-promoted-constructors -fno-ignore-asserts

library
import: warnings
exposed-modules:
Ide.Plugin.Eval
Ide.Plugin.Eval.Types
Expand All @@ -57,18 +62,14 @@ library
, base >=4.12 && <5
, bytestring
, containers
, data-default
, deepseq
, Diff ^>=0.4.0
, directory
, dlist
, extra
, filepath
, ghc
, ghc-boot-th
, ghc-paths
, ghcide == 2.6.0.0
, hashable
, hls-graph
, hls-plugin-api == 2.6.0.0
, lens
Expand All @@ -77,18 +78,11 @@ library
, megaparsec >=9.0
, mtl
, parser-combinators >=1.2
, pretty-simple
, QuickCheck
, safe-exceptions
, text
, time
, transformers
, unliftio
, unordered-containers

ghc-options:
-Wall -Wno-name-shadowing -Wno-unticked-promoted-constructors -fno-ignore-asserts

if flag(pedantic)
ghc-options: -Werror

Expand All @@ -98,6 +92,7 @@ library
TypeOperators

test-suite tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: test
Expand All @@ -107,7 +102,6 @@ test-suite tests
, aeson
, base
, containers
, directory
, extra
, filepath
, hls-eval-plugin
Expand Down
46 changes: 22 additions & 24 deletions plugins/hls-eval-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,25 @@ module Main
( main
) where

import Control.Lens (_Just, folded, preview,
toListOf, view, (^..))
import Data.Aeson (Value (Object), fromJSON,
object, toJSON, (.=))
import Data.Aeson.Types (Pair, Result (Success))
import Data.List (isInfixOf)
import Data.List.Extra (nubOrdOn)
import qualified Data.Map as Map
import Control.Lens (_Just, folded, preview, view, (^.),
(^..))
import Data.Aeson (Value (Object), fromJSON, object,
(.=))
import Data.Aeson.Types (Pair, Result (Success))
import Data.List (isInfixOf)
import Data.List.Extra (nubOrdOn)
import qualified Data.Map as Map
import Data.Row
import qualified Data.Text as T
import Ide.Plugin.Config (Config)
import qualified Ide.Plugin.Config as Plugin
import qualified Ide.Plugin.Eval as Eval
import Ide.Plugin.Eval.Types (EvalParams (..), Section (..),
testOutput)
import Ide.Types (IdePlugins (IdePlugins))
import Language.LSP.Protocol.Lens (arguments, command, range,
title)
import Language.LSP.Protocol.Message hiding (error)
import System.FilePath ((<.>), (</>))
import qualified Data.Text as T
import Ide.Plugin.Config (Config)
import qualified Ide.Plugin.Config as Plugin
import qualified Ide.Plugin.Eval as Eval
import Ide.Plugin.Eval.Types (EvalParams (..), Section (..),
testOutput)
import Language.LSP.Protocol.Lens (command, range, title)
import System.FilePath ((<.>), (</>))
import Test.Hls
import qualified Test.Hls.FileSystem as FS
import qualified Test.Hls.FileSystem as FS

main :: IO ()
main = defaultTestRunner tests
Expand Down Expand Up @@ -215,16 +212,17 @@ tests =
, testCase "Interfaces are reused after Eval" $ do
runSessionWithServerInTmpDir def evalPlugin (mkFs $ FS.directProjectMulti ["TLocalImport.hs", "Util.hs"]) $ do
doc <- openDoc "TLocalImport.hs" "haskell"
waitForTypecheck doc
_ <- waitForTypecheck doc
lenses <- getCodeLenses doc
let ~cmds@[cmd] = lenses^..folded.command._Just
liftIO $ cmds^..folded.title @?= ["Evaluate..."]
cmd <- liftIO $ case lenses^..folded.command._Just of
[cmd] -> (cmd^.title @?= "Evaluate...") >> pure cmd
cmds -> assertFailure $ "Expected a single command, got " <> show (length cmds)

executeCmd cmd

-- trigger a rebuild and check that dependency interfaces are not rebuilt
changeDoc doc []
waitForTypecheck doc
_ <- waitForTypecheck doc
Right keys <- getLastBuildKeys
let ifaceKeys = filter ("GetModIface" `T.isPrefixOf`) keys
liftIO $ ifaceKeys @?= []
Expand Down

0 comments on commit e0db3b5

Please sign in to comment.