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

Solve formatting issues (stylish-haskell, pre-commit CI) #3171

Merged
merged 5 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions ghcide/src/Development/IDE/Core/Preprocessor.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}

module Development.IDE.Core.Preprocessor
( preprocessor
Expand Down Expand Up @@ -30,8 +30,8 @@ import qualified GHC.LanguageExtensions as LangExt
import System.FilePath
import System.IO.Extra
#if MIN_VERSION_ghc(9,3,0)
import GHC.Utils.Logger (LogFlags(..))
import GHC.Utils.Outputable (renderWithContext)
import GHC.Utils.Logger (LogFlags (..))
import GHC.Utils.Outputable (renderWithContext)
#endif

-- | Given a file and some contents, apply any necessary preprocessors,
Expand Down
9 changes: 4 additions & 5 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
Expand All @@ -10,7 +11,6 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE CPP #-}

-- | A Shake implementation of the compiler service.
--
Expand Down Expand Up @@ -130,11 +130,10 @@ import Development.IDE.GHC.Compat (NameCache,
NameCacheUpdater (..),
initNameCache,
knownKeyNames,
mkSplitUniqSupply)
#if !MIN_VERSION_ghc(9,3,0)
andys8 marked this conversation as resolved.
Show resolved Hide resolved
upNameCache,
import Development.IDE.GHC.Compat (upNameCache)
#endif
mkSplitUniqSupply
)
import Development.IDE.GHC.Orphans ()
import Development.IDE.Graph hiding (ShakeValue)
import qualified Development.IDE.Graph as Shake
Expand Down Expand Up @@ -162,7 +161,7 @@ import GHC.Stack (HasCallStack)
import HieDb.Types
import Ide.Plugin.Config
import qualified Ide.PluginUtils as HLS
import Ide.Types (PluginId, IdePlugins)
import Ide.Types (IdePlugins, PluginId)
import Language.LSP.Diagnostics
import qualified Language.LSP.Server as LSP
import Language.LSP.Types
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/GHC/CPP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import DynFlags
#endif
#endif
#if MIN_VERSION_ghc(9,3,0)
import qualified GHC.Driver.Pipeline.Execute as Pipeline
import qualified GHC.Driver.Pipeline.Execute as Pipeline
#endif

addOptP :: String -> DynFlags -> DynFlags
Expand Down
10 changes: 5 additions & 5 deletions ghcide/src/Development/IDE/GHC/Compat/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ import HscTypes as Env
import Module
#endif

#if MIN_VERSION_ghc(9,3,0)
hsc_EPS :: HscEnv -> UnitEnv
hsc_EPS = hsc_unit_env
#endif

#if MIN_VERSION_ghc(9,0,0)
#if !MIN_VERSION_ghc(9,2,0)
import qualified Data.Set as Set
Expand All @@ -105,6 +100,11 @@ import qualified Data.Set as Set
import Data.IORef
#endif

#if MIN_VERSION_ghc(9,3,0)
hsc_EPS :: HscEnv -> UnitEnv
hsc_EPS = hsc_unit_env
#endif

#if !MIN_VERSION_ghc(9,2,0)
type UnitEnv = ()
newtype Logger = Logger { log_action :: LogAction }
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/GHC/Compat/Logger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import DynFlags
import Outputable (queryQual)
#endif
#if MIN_VERSION_ghc(9,3,0)
import GHC.Types.Error
import GHC.Types.Error
#endif

putLogHook :: Logger -> HscEnv -> HscEnv
Expand Down
13 changes: 6 additions & 7 deletions ghcide/src/Development/IDE/GHC/Compat/Plugins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import qualified GHC.Driver.Env as Env
import GHC.Driver.Plugins (Plugin (..),
PluginWithArgs (..),
StaticPlugin (..),
defaultPlugin, withPlugins)
#if MIN_VERSION_ghc(9,3,0)
staticPlugins,
ParsedResult(..),
PsMessages(..),
import GHC.Driver.Plugins (ParsedResult (..),
PsMessages (..),
staticPlugins)
#endif
defaultPlugin, withPlugins)
import qualified GHC.Runtime.Loader as Loader
#elif MIN_VERSION_ghc(8,8,0)
import qualified DynamicLoading as Loader
Expand All @@ -48,11 +48,10 @@ applyPluginsParsedResultAction env dflags ms hpm_annotations parsed = do
-- Apply parsedResultAction of plugins
let applyPluginAction p opts = parsedResultAction p opts ms
#if MIN_VERSION_ghc(9,3,0)
fmap (hpm_module . parsedResultModule) $
fmap (hpm_module . parsedResultModule) $ runHsc env $ withPlugins
#else
fmap hpm_module $
fmap hpm_module $ runHsc env $ withPlugins
#endif
runHsc env $ withPlugins
#if MIN_VERSION_ghc(9,3,0)
(Env.hsc_plugins env)
#elif MIN_VERSION_ghc(9,2,0)
Expand Down
8 changes: 4 additions & 4 deletions ghcide/src/Development/IDE/GHC/Compat/Units.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ module Development.IDE.GHC.Compat.Units (
showSDocForUser',
) where

import qualified Data.List.NonEmpty as NE
import qualified Data.Map.Strict as Map
import Control.Monad
import Control.Monad
import qualified Data.List.NonEmpty as NE
import qualified Data.Map.Strict as Map
#if MIN_VERSION_ghc(9,3,0)
import GHC.Unit.Home.ModInfo
import GHC.Unit.Home.ModInfo
#endif
#if MIN_VERSION_ghc(9,0,0)
#if MIN_VERSION_ghc(9,2,0)
Expand Down
6 changes: 3 additions & 3 deletions ghcide/src/Development/IDE/GHC/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import GHC.ByteCode.Types
import ByteCodeTypes
#endif
#if MIN_VERSION_ghc(9,3,0)
import GHC.Types.PkgQual
import GHC.Types.PkgQual
#endif

-- Orphan instances for types from the GHC API.
Expand Down Expand Up @@ -217,8 +217,8 @@ instance NFData HomeModInfo where

#if MIN_VERSION_ghc(9,3,0)
instance NFData PkgQual where
rnf NoPkgQual = ()
rnf (ThisPkg uid) = rnf uid
rnf NoPkgQual = ()
rnf (ThisPkg uid) = rnf uid
rnf (OtherPkg uid) = rnf uid

instance NFData UnitId where
Expand Down
6 changes: 3 additions & 3 deletions ghcide/src/Development/IDE/GHC/Warnings.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE CPP #-}

module Development.IDE.GHC.Warnings(withWarnings) where

Expand Down Expand Up @@ -49,8 +49,8 @@ attachReason Nothing d = d
attachReason (Just wr) d = d{_code = InR <$> showReason wr}
where
showReason = \case
WarningWithFlag flag -> showFlag flag
_ -> Nothing
WarningWithFlag flag -> showFlag flag
_ -> Nothing
#else
attachReason :: WarnReason -> Diagnostic -> Diagnostic
attachReason wr d = d{_code = InR <$> showReason wr}
Expand Down
47 changes: 23 additions & 24 deletions ghcide/src/Development/IDE/Plugin/Completions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,45 @@ module Development.IDE.Plugin.Completions
, ghcideCompletionsPluginPriority
) where

import Control.Concurrent.Async (concurrently)
import Control.Concurrent.STM.Stats (readTVarIO)
import Control.Concurrent.Async (concurrently)
import Control.Concurrent.STM.Stats (readTVarIO)
import Control.Monad.Extra
import Control.Monad.IO.Class
import Control.Monad.Trans.Maybe
import Data.Aeson
import qualified Data.HashMap.Strict as Map
import qualified Data.HashSet as Set
import Data.List (find)
import qualified Data.HashMap.Strict as Map
import qualified Data.HashSet as Set
import Data.List (find)
import Data.Maybe
import qualified Data.Text as T
import qualified Data.Text as T
import Development.IDE.Core.PositionMapping
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Service hiding (Log,
LogShake)
import Development.IDE.Core.Shake hiding (Log)
import qualified Development.IDE.Core.Shake as Shake
import Development.IDE.Core.Service hiding (Log, LogShake)
import Development.IDE.Core.Shake hiding (Log)
import qualified Development.IDE.Core.Shake as Shake
import Development.IDE.GHC.Compat
import Development.IDE.GHC.Error (rangeToSrcSpan)
import Development.IDE.GHC.Util (printOutputable)
import Development.IDE.GHC.Error (rangeToSrcSpan)
import Development.IDE.GHC.Util (printOutputable)
import Development.IDE.Graph
import Development.IDE.Plugin.Completions.Logic
import Development.IDE.Plugin.Completions.Types
import Development.IDE.Types.Exports
import Development.IDE.Types.HscEnvEq (HscEnvEq (envPackageExports),
hscEnv)
import qualified Development.IDE.Types.KnownTargets as KT
import Development.IDE.Types.HscEnvEq (HscEnvEq (envPackageExports),
hscEnv)
import qualified Development.IDE.Types.KnownTargets as KT
import Development.IDE.Types.Location
import Development.IDE.Types.Logger (Pretty (pretty),
Recorder,
WithPriority,
cmapWithPrio)
import GHC.Exts (fromList, toList)
import Ide.Plugin.Config (Config)
import Development.IDE.Types.Logger (Pretty (pretty),
Recorder,
WithPriority,
cmapWithPrio)
import GHC.Exts (fromList, toList)
import Ide.Plugin.Config (Config)
import Ide.Types
import qualified Language.LSP.Server as LSP
import qualified Language.LSP.Server as LSP
import Language.LSP.Types
import qualified Language.LSP.VFS as VFS
import qualified Language.LSP.VFS as VFS
import Numeric.Natural
import Text.Fuzzy.Parallel (Scored (..))
import Text.Fuzzy.Parallel (Scored (..))

data Log = LogShake Shake.Log deriving Show

Expand Down
3 changes: 2 additions & 1 deletion ghcide/src/Development/IDE/Spans/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ safeTyThingId (AConLike (RealDataCon dataCon)) = Just (dataConWrapId dataCon)
safeTyThingId _ = Nothing

-- Possible documentation for an element in the code
data SpanDoc
#if MIN_VERSION_ghc(9,3,0)
data SpanDoc
= SpanDocString [HsDocString] SpanDocUris
#else
data SpanDoc
= SpanDocString HsDocString SpanDocUris
#endif
| SpanDocText [T.Text] SpanDocUris
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Spans/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import System.FilePath

import Language.LSP.Types (filePathToUri, getUri)
#if MIN_VERSION_ghc(9,3,0)
import GHC.Types.Unique.Map
import GHC.Types.Unique.Map
#endif

mkDocMap
Expand Down
6 changes: 3 additions & 3 deletions hls-plugin-api/src/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Control.Monad (void)
import qualified System.Posix.Process as P (getProcessID)
import System.Posix.Signals
#endif
import Control.Applicative ((<|>))
import Control.Arrow ((&&&))
import Control.Lens ((^.))
import Data.Aeson hiding (defaultOptions)
Expand All @@ -67,7 +68,7 @@ import Data.GADT.Compare
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import Data.List.Extra (sortOn, find)
import Data.List.Extra (find, sortOn)
import Data.List.NonEmpty (NonEmpty (..), toList)
import qualified Data.Map as Map
import Data.Maybe
Expand Down Expand Up @@ -107,12 +108,11 @@ import Options.Applicative (ParserInfo)
import System.FilePath
import System.IO.Unsafe
import Text.Regex.TDFA.Text ()
import Control.Applicative ((<|>))

-- ---------------------------------------------------------------------

data IdePlugins ideState = IdePlugins_
{ ipMap_ :: HashMap PluginId (PluginDescriptor ideState)
{ ipMap_ :: HashMap PluginId (PluginDescriptor ideState)
, lookupCommandProvider :: CommandId -> Maybe PluginId
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ import Development.IDE
import Development.IDE.Core.Rules (toIdeResult)
import qualified Development.IDE.Core.Shake as Shake
import Development.IDE.GHC.Compat (HieAST (..),
HieASTs (getAsts),
RefMap)
HieASTs (getAsts), RefMap)
import Development.IDE.GHC.Compat.Util
import GHC.Generics (Generic)
import Ide.Plugin.CodeRange.ASTPreProcess (CustomNodeType (..),
Expand Down
10 changes: 5 additions & 5 deletions plugins/hls-refactor-plugin/src/Development/IDE/GHC/Dump.hs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{-# LANGUAGE CPP #-}
module Development.IDE.GHC.Dump(showAstDataHtml) where
import Data.Data hiding (Fixity)
import Development.IDE.GHC.Compat hiding (NameAnn)
import Data.Data hiding (Fixity)
import Development.IDE.GHC.Compat hiding (NameAnn)
import Development.IDE.GHC.Compat.ExactPrint
#if MIN_VERSION_ghc(8,10,1)
import GHC.Hs.Dump
#else
import HsDumpAst
#endif
#if MIN_VERSION_ghc(9,2,1)
import qualified Data.ByteString as B
import qualified Data.ByteString as B
import Development.IDE.GHC.Compat.Util
import Generics.SYB (ext1Q, ext2Q, extQ)
import Generics.SYB (ext1Q, ext2Q, extQ)
import GHC.Hs
#endif
#if MIN_VERSION_ghc(9,0,1)
import GHC.Plugins
#else
import GhcPlugins
#endif
import Prelude hiding ((<>))
import Prelude hiding ((<>))

-- | Show a GHC syntax tree in HTML.
#if MIN_VERSION_ghc(9,2,1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
module Development.IDE.Plugin.CodeAction.Util where

#if MIN_VERSION_ghc(9,2,0)
import GHC.Utils.Outputable
#else
import Development.IDE.GHC.Util
import Development.IDE.GHC.Compat.Util
import Development.IDE.GHC.Compat
#endif
import Data.Data (Data)
import qualified Data.Unique as U
import Debug.Trace
Expand All @@ -18,6 +11,13 @@ import Text.Printf
import Development.IDE.GHC.Dump (showAstDataHtml)
import Data.Time.Clock.POSIX (POSIXTime, getCurrentTime,
utcTimeToPOSIXSeconds)
#if MIN_VERSION_ghc(9,2,0)
import GHC.Utils.Outputable
#else
import Development.IDE.GHC.Util
import Development.IDE.GHC.Compat.Util
import Development.IDE.GHC.Compat
#endif
--------------------------------------------------------------------------------
-- Tracing exactprint terms

Expand Down
6 changes: 3 additions & 3 deletions plugins/hls-rename-plugin/src/Ide/Plugin/Rename.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import qualified Data.Map as M
import Data.Maybe
import Data.Mod.Word
import qualified Data.Text as T
import Development.IDE (Recorder, WithPriority)
import Development.IDE (Recorder, WithPriority)
import Development.IDE.Core.PositionMapping
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Service
Expand All @@ -40,10 +40,10 @@ import Development.IDE.GHC.Compat.Parser
import Development.IDE.GHC.Compat.Units
import Development.IDE.GHC.Error
import Development.IDE.GHC.ExactPrint
import qualified Development.IDE.GHC.ExactPrint as E
import qualified Development.IDE.GHC.ExactPrint as E
import Development.IDE.Plugin.CodeAction
import Development.IDE.Spans.AtPoint
import Development.IDE.Types.Location
import Development.IDE.Plugin.CodeAction
import HieDb.Query
import Ide.Plugin.Properties
import Ide.PluginUtils
Expand Down
Loading