Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix -Wall and -Wunused-packages in eval plugin #3981

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 #-}
Copy link
Collaborator Author

@jhrcek jhrcek Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change unrelated to eval plugin, but pre-commit check (which checks styling-haskell formatting) was failing after this PR was merged to master.

{-# 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
Loading