Skip to content

Fix -Wall and -Wunused-packages in code-range plugin #3980

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

Merged
merged 2 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
13 changes: 5 additions & 8 deletions plugins/hls-code-range-plugin/hls-code-range-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ source-repository head
type: git
location: https://github.com/haskell/haskell-language-server.git

common warnings
ghc-options: -Wall -Wunused-packages

library
import: warnings
exposed-modules:
Ide.Plugin.CodeRange
Ide.Plugin.CodeRange.Rules
other-modules:
Ide.Plugin.CodeRange.ASTPreProcess
ghc-options: -Wall
hs-source-dirs: src
default-language: Haskell2010
build-depends:
, aeson
, base >=4.12 && <5
, containers
, deepseq
Expand All @@ -44,11 +46,11 @@ library
, lsp
, mtl
, semigroupoids
, text
, transformers
, vector

test-suite tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: test
Expand All @@ -60,16 +62,11 @@ test-suite tests
build-depends:
, base
, bytestring
, containers
, filepath
, ghcide == 2.6.0.0
, hls-code-range-plugin
, hls-plugin-api
, hls-test-utils == 2.6.0.0
, lens
, lsp
, lsp-test
, tasty-hunit
, text
, transformers
, vector
7 changes: 3 additions & 4 deletions plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -63,11 +62,11 @@ descriptor recorder plId = (defaultPluginDescriptor plId "Provides selection and
, pluginRules = codeRangeRule (cmapWithPrio LogRules recorder)
}

data Log = LogRules Rules.Log
newtype Log = LogRules Rules.Log

instance Pretty Log where
pretty log = case log of
LogRules codeRangeLog -> pretty codeRangeLog
pretty (LogRules codeRangeLog) = pretty codeRangeLog


foldingRangeHandler :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'Method_TextDocumentFoldingRange
foldingRangeHandler _ ide _ FoldingRangeParams{..} =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
module Ide.Plugin.CodeRange.RulesTest (testTree) where

import Control.Monad.Trans.Writer.CPS
import Data.Bifunctor (Bifunctor (first, second))
import Data.Bifunctor (Bifunctor (second))
import qualified Data.Vector as V
import Ide.Plugin.CodeRange.Rules
import Test.Hls
import Test.Tasty.HUnit

testTree :: TestTree
testTree =
Expand Down Expand Up @@ -78,3 +77,4 @@ instance Eq LogEq where
LogEq LogNoAST == LogEq LogNoAST = True
LogEq (LogFoundInterleaving left right) == LogEq (LogFoundInterleaving left' right') =
left == left' && right == right'
LogEq _ == LogEq _ = False
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import qualified Data.Vector as V
import Ide.Plugin.CodeRange
import Ide.Plugin.CodeRange.Rules
import Test.Hls
import Test.Tasty.HUnit

testTree :: TestTree
testTree =
Expand Down
12 changes: 5 additions & 7 deletions plugins/hls-code-range-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ import Control.Lens hiding (List, (<.>))
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy.Char8 as LBSChar8
import Data.String (fromString)
import Ide.Logger (Priority (Debug),
Recorder (Recorder),
WithPriority (WithPriority),
makeDefaultStderrRecorder,
pretty)
import Ide.Plugin.CodeRange (Log, descriptor)
import qualified Ide.Plugin.CodeRange.RulesTest
import qualified Ide.Plugin.CodeRangeTest
import Language.LSP.Protocol.Lens
import Language.LSP.Protocol.Lens (result)
import Language.LSP.Protocol.Message
import Language.LSP.Protocol.Types
import System.FilePath ((<.>), (</>))
Expand Down Expand Up @@ -89,7 +84,10 @@ foldingRangeGoldenTest testName = goldenGitDiff testName (testDataDir </> testN
showFoldingRangesForTest foldingRanges = (LBSChar8.intercalate "\n" $ fmap showFoldingRangeForTest foldingRanges) `LBSChar8.snoc` '\n'

showFoldingRangeForTest :: FoldingRange -> ByteString
showFoldingRangeForTest f@(FoldingRange sl (Just sc) el (Just ec) (Just frk) _) = "((" <> showLBS sl <>", "<> showLBS sc <> ")" <> " : " <> "(" <> showLBS el <>", "<> showLBS ec<> ")) : " <> showFRK frk
showFoldingRangeForTest (FoldingRange sl (Just sc) el (Just ec) (Just frk) _) =
"((" <> showLBS sl <> ", " <> showLBS sc <> ") : (" <> showLBS el <> ", " <> showLBS ec <> ")) : " <> showFRK frk
showFoldingRangeForTest fr =
"unexpected FoldingRange: " <> fromString (show fr)

showLBS = fromString . show
showFRK = fromString . show