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

Remove exactprint dependencies from ghcide by introducing hls-refactor-plugin. #3091

Merged
merged 4 commits into from
Aug 30, 2022
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
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ jobs:
name: Test hls-brittany-plugin
run: cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || cabal test hls-brittany-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-brittany-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-refactor-plugin
run: cabal test hls-refactor-plugin --test-options="$TEST_OPTS" || cabal test hls-refactor-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-refactor-plugin --test-options="$TEST_OPTS"

- if: matrix.test
name: Test hls-floskell-plugin
run: cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-floskell-plugin --test-options="$TEST_OPTS"
Expand Down
3 changes: 3 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
within:
- Development.IDE.Core.Shake
- Development.IDE.GHC.Util
- Development.IDE.Plugin.CodeAction.Util
- Development.IDE.Graph.Internal.Database
- Development.IDE.Graph.Internal.Paths
- Development.IDE.Graph.Internal.Profile
Expand Down Expand Up @@ -184,6 +185,7 @@
- Development.IDE.Core.Shake
- Development.IDE.Plugin.Completions
- Development.IDE.Plugin.CodeAction.ExactPrint
- Development.IDE.Plugin.CodeAction
- Development.IDE.Test
- Development.IDE.Graph.Internal.Profile
- Development.IDE.Graph.Internal.Rules
Expand Down Expand Up @@ -221,6 +223,7 @@
- Development.IDE.Core.Compile
- Development.IDE.Graph.Internal.Database
- Development.IDE.GHC.Util
- Development.IDE.Plugin.CodeAction.Util
- Wingman.Debug

# We really do not want novel usages of restricted functions, and mere
Expand Down
5 changes: 3 additions & 2 deletions bench/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ configurations:
- ghcide-type-lenses
- pragmas
- Ghcide:
- ghcide-completions
- ghcide-type-lenses
- Refactor:
- ghcide-code-actions-bindings
- ghcide-code-actions-fill-holes
- ghcide-code-actions-imports-exports
- ghcide-code-actions-type-signatures
- ghcide-completions
- ghcide-type-lenses
- All:
- alternateNumberFormat
- callHierarchy
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ packages:
./hls-graph
./ghcide
./ghcide-bench
./ghcide/test
./hls-plugin-api
./hls-test-utils
./plugins/hls-tactics-plugin
Expand Down Expand Up @@ -32,6 +33,7 @@ packages:
./plugins/hls-stan-plugin
./plugins/hls-gadt-plugin
./plugins/hls-explicit-fixity-plugin
./plugins/hls-refactor-plugin

-- Standard location for temporary packages needed for particular environments
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
Expand Down
3 changes: 1 addition & 2 deletions ghcide-bench/ghcide-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ library
exposed-modules:
Experiments.Types
Experiments
other-modules:
Development.IDE.Test.Diagnostic
build-depends:
aeson,
async,
Expand All @@ -76,6 +74,7 @@ library
extra,
filepath,
ghcide,
ghcide-test-utils,
hashable,
lens,
lsp-test,
Expand Down
48 changes: 0 additions & 48 deletions ghcide-bench/src/Development/IDE/Test/Diagnostic.hs

This file was deleted.

59 changes: 40 additions & 19 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ library
filepath,
fingertree,
focus,
ghc-exactprint < 1 || >= 1.4,
ghc-trace-events,
Glob,
haddock-library >= 1.8 && < 1.11,
Expand All @@ -74,16 +73,13 @@ library
lsp ^>= 1.5.0.0 ,
monoid-subclasses,
mtl,
network-uri,
optparse-applicative,
parallel,
prettyprinter-ansi-terminal,
prettyprinter >= 1.6,
random,
regex-tdfa >= 1.3.1.0,
retrie,
text-rope,
safe,
safe-exceptions,
hls-graph ^>= 1.7,
sorted-list,
Expand All @@ -95,9 +91,7 @@ library
time,
transformers,
unordered-containers >= 0.2.10.0,
utf8-string,
vector,
vector-algorithms,
hslogger,
Diff ^>=0.4.0,
vector,
Expand All @@ -114,9 +108,6 @@ library
hie-bios ^>= 0.9.1,
implicit-hie-cradle ^>= 0.3.0.5 || ^>= 0.5,
base16-bytestring >=0.1.1 && <1.1
if impl(ghc >= 9.2)
build-depends:
ghc-exactprint >= 1.4
if os(windows)
build-depends:
Win32
Expand Down Expand Up @@ -172,7 +163,6 @@ library
Development.IDE.GHC.Compat
Development.IDE.GHC.Compat.Core
Development.IDE.GHC.Compat.Env
Development.IDE.GHC.Compat.ExactPrint
Development.IDE.GHC.Compat.Iface
Development.IDE.GHC.Compat.Logger
Development.IDE.GHC.Compat.Outputable
Expand All @@ -182,9 +172,7 @@ library
Development.IDE.GHC.Compat.Util
Development.IDE.Core.Compile
Development.IDE.GHC.CoreFile
Development.IDE.GHC.Dump
Development.IDE.GHC.Error
Development.IDE.GHC.ExactPrint
Development.IDE.GHC.Orphans
Development.IDE.GHC.Util
Development.IDE.Import.DependencyInformation
Expand Down Expand Up @@ -214,8 +202,6 @@ library
Development.IDE.Plugin
Development.IDE.Plugin.Completions
Development.IDE.Plugin.Completions.Types
Development.IDE.Plugin.CodeAction
Development.IDE.Plugin.CodeAction.ExactPrint
Development.IDE.Plugin.HLS
Development.IDE.Plugin.HLS.GhcIde
Development.IDE.Plugin.Test
Expand All @@ -226,8 +212,6 @@ library
Development.IDE.Core.FileExists
Development.IDE.GHC.CPP
Development.IDE.GHC.Warnings
Development.IDE.Plugin.CodeAction.PositionIndexed
Development.IDE.Plugin.CodeAction.Args
Development.IDE.Plugin.Completions.Logic
Development.IDE.Session.VersionCheck
Development.IDE.Types.Action
Expand Down Expand Up @@ -365,6 +349,7 @@ test-suite ghcide-tests
ghc,
--------------------------------------------------------------
ghcide,
ghcide-test-utils-internal,
ghc-typelits-knownnat,
lsp,
lsp-types,
Expand Down Expand Up @@ -393,12 +378,10 @@ test-suite ghcide-tests
build-depends:
record-dot-preprocessor,
record-hasfield
hs-source-dirs: test/cabal test/exe test/src bench/lib
hs-source-dirs: test/cabal test/exe bench/lib
ghc-options: -threaded -Wall -Wno-name-shadowing -O0 -Wno-unticked-promoted-constructors
main-is: Main.hs
other-modules:
Development.IDE.Test
Development.IDE.Test.Diagnostic
Development.IDE.Test.Runfiles
FuzzySearch
Progress
Expand All @@ -418,3 +401,41 @@ test-suite ghcide-tests
TupleSections
TypeApplications
ViewPatterns

library ghcide-test-utils-internal
default-language: Haskell2010
build-depends:
aeson,
base,
containers,
data-default,
directory,
extra,
filepath,
ghcide,
lsp-types,
hls-plugin-api,
lens,
lsp-test ^>= 0.14,
tasty-hunit >= 0.10,
text,
hs-source-dirs: test/src
ghc-options: -Wunused-packages
exposed-modules:
Development.IDE.Test
Development.IDE.Test.Diagnostic
default-extensions:
BangPatterns
DeriveFunctor
DeriveGeneric
FlexibleContexts
GeneralizedNewtypeDeriving
LambdaCase
NamedFieldPuns
OverloadedStrings
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
TupleSections
TypeApplications
ViewPatterns
5 changes: 0 additions & 5 deletions ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ import Development.IDE.GHC.Compat hiding
import qualified Development.IDE.GHC.Compat as Compat hiding (vcat, nest)
import qualified Development.IDE.GHC.Compat.Util as Util
import Development.IDE.GHC.Error
import Development.IDE.GHC.ExactPrint hiding (LogShake, Log)
import Development.IDE.GHC.Util hiding
(modifyDynFlags)
import Development.IDE.Graph
Expand Down Expand Up @@ -154,7 +153,6 @@ import System.Info.Extra (isWindows)
import HIE.Bios.Ghc.Gap (hostIsDynamic)
import Development.IDE.Types.Logger (Recorder, logWith, cmapWithPrio, WithPriority, Pretty (pretty), (<+>), nest, vcat)
import qualified Development.IDE.Core.Shake as Shake
import qualified Development.IDE.GHC.ExactPrint as ExactPrint hiding (LogShake)
import qualified Development.IDE.Types.Logger as Logger
import qualified Development.IDE.Types.Shake as Shake
import Development.IDE.GHC.CoreFile
Expand All @@ -167,7 +165,6 @@ data Log
| LogLoadingHieFile !NormalizedFilePath
| LogLoadingHieFileFail !FilePath !SomeException
| LogLoadingHieFileSuccess !FilePath
| LogExactPrint ExactPrint.Log
| LogTypecheckedFOI !NormalizedFilePath
deriving Show

Expand All @@ -185,7 +182,6 @@ instance Pretty Log where
, pretty (displayException e) ]
LogLoadingHieFileSuccess path ->
"SUCCEEDED LOADING HIE FILE FOR" <+> pretty path
LogExactPrint log -> pretty log
LogTypecheckedFOI path -> vcat
[ "Typechecked a file which is not currently open in the editor:" <+> pretty (fromNormalizedFilePath path)
, "This can indicate a bug which results in excessive memory usage."
Expand Down Expand Up @@ -1230,7 +1226,6 @@ mainRule recorder RulesConfig{..} = do
else defineNoDiagnostics (cmapWithPrio LogShake recorder) $ \NeedsCompilation _ -> return $ Just Nothing
generateCoreRule recorder
getImportMapRule recorder
getAnnotatedParsedSourceRule (cmapWithPrio LogExactPrint recorder)
persistentHieFileRule recorder
persistentDocMapRule
persistentImportMapRule
Expand Down
5 changes: 4 additions & 1 deletion ghcide/src/Development/IDE/Core/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Development.IDE.Core.Shake hiding (Log)
import qualified Development.IDE.Core.Shake as Shake
import Development.IDE.Types.Monitoring (Monitoring)
import Development.IDE.Types.Shake (WithHieDb)
import Ide.Types (IdePlugins)
import System.Environment (lookupEnv)

data Log
Expand All @@ -61,6 +62,7 @@ instance Pretty Log where
-- | Initialise the Compiler Service.
initialise :: Recorder (WithPriority Log)
-> Config
-> IdePlugins IdeState
-> Rules ()
-> Maybe (LSP.LanguageContextEnv Config)
-> Logger
Expand All @@ -70,7 +72,7 @@ initialise :: Recorder (WithPriority Log)
-> IndexQueue
-> Monitoring
-> IO IdeState
initialise recorder defaultConfig mainRule lspEnv logger debouncer options withHieDb hiedbChan metrics = do
initialise recorder defaultConfig plugins mainRule lspEnv logger debouncer options withHieDb hiedbChan metrics = do
shakeProfiling <- do
let fromConf = optShakeProfiling options
fromEnv <- lookupEnv "GHCIDE_BUILD_PROFILING"
Expand All @@ -79,6 +81,7 @@ initialise recorder defaultConfig mainRule lspEnv logger debouncer options withH
(cmapWithPrio LogShake recorder)
lspEnv
defaultConfig
plugins
logger
debouncer
shakeProfiling
Expand Down
6 changes: 4 additions & 2 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ import GHC.Stack (HasCallStack)
import HieDb.Types
import Ide.Plugin.Config
import qualified Ide.PluginUtils as HLS
import Ide.Types (PluginId)
import Ide.Types (PluginId, IdePlugins)
import Language.LSP.Diagnostics
import qualified Language.LSP.Server as LSP
import Language.LSP.Types
Expand Down Expand Up @@ -239,6 +239,7 @@ data ShakeExtras = ShakeExtras
lspEnv :: Maybe (LSP.LanguageContextEnv Config)
,debouncer :: Debouncer NormalizedUri
,logger :: Logger
,idePlugins :: IdePlugins IdeState
,globals :: TVar (HMap.HashMap TypeRep Dynamic)
-- ^ Registry of global state used by rules.
-- Small and immutable after startup, so not worth using an STM.Map.
Expand Down Expand Up @@ -552,6 +553,7 @@ seqValue val = case val of
shakeOpen :: Recorder (WithPriority Log)
-> Maybe (LSP.LanguageContextEnv Config)
-> Config
-> IdePlugins IdeState
-> Logger
-> Debouncer NormalizedUri
-> Maybe FilePath
Expand All @@ -563,7 +565,7 @@ shakeOpen :: Recorder (WithPriority Log)
-> Monitoring
-> Rules ()
-> IO IdeState
shakeOpen recorder lspEnv defaultConfig logger debouncer
shakeOpen recorder lspEnv defaultConfig idePlugins logger debouncer
shakeProfileDir (IdeReportProgress reportProgress)
ideTesting@(IdeTesting testing)
withHieDb indexQueue opts monitoring rules = mdo
Expand Down
Loading