From d2058fbe6adb57c73ed55f2149bc9f74799def51 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Sun, 18 Apr 2021 13:52:59 +0100 Subject: [PATCH 1/3] Add a new project hls-graph, shadowing Shake and reexporting it --- cabal.project | 1 + ghcide/exe/Main.hs | 3 +- ghcide/ghcide.cabal | 6 +- .../session-loader/Development/IDE/Session.hs | 2 +- ghcide/src/Development/IDE.hs | 2 +- ghcide/src/Development/IDE/Core/Actions.hs | 2 +- ghcide/src/Development/IDE/Core/FileExists.hs | 2 +- ghcide/src/Development/IDE/Core/FileStore.hs | 2 +- .../Development/IDE/Core/IdeConfiguration.hs | 2 +- ghcide/src/Development/IDE/Core/OfInterest.hs | 3 +- ghcide/src/Development/IDE/Core/RuleTypes.hs | 2 +- ghcide/src/Development/IDE/Core/Rules.hs | 4 +- ghcide/src/Development/IDE/Core/Service.hs | 2 +- ghcide/src/Development/IDE/Core/Shake.hs | 10 +- ghcide/src/Development/IDE/Core/Tracing.hs | 3 +- ghcide/src/Development/IDE/GHC/ExactPrint.hs | 4 +- ghcide/src/Development/IDE/Main.hs | 2 +- ghcide/src/Development/IDE/Plugin.hs | 2 +- .../IDE/Plugin/CodeAction/RuleTypes.hs | 2 +- .../src/Development/IDE/Plugin/Completions.hs | 4 +- ghcide/src/Development/IDE/Plugin/HLS.hs | 2 +- ghcide/src/Development/IDE/Plugin/Test.hs | 2 +- .../src/Development/IDE/Plugin/TypeLenses.hs | 2 +- ghcide/src/Development/IDE/Types/Action.hs | 2 +- ghcide/src/Development/IDE/Types/HscEnvEq.hs | 3 +- ghcide/src/Development/IDE/Types/Options.hs | 2 +- ghcide/src/Development/IDE/Types/Shake.hs | 4 +- ghcide/src/Generics/SYB/GHC.hs | 3 +- haskell-language-server.cabal | 4 +- hls-graph/LICENSE | 201 ++++++++++++++++++ hls-graph/hls-graph.cabal | 50 +++++ hls-graph/src/Development/IDE/Graph.hs | 4 + .../src/Development/IDE/Graph/Classes.hs | 4 + .../src/Development/IDE/Graph/Database.hs | 4 + hls-graph/src/Development/IDE/Graph/Rule.hs | 4 + hls-plugin-api/hls-plugin-api.cabal | 2 +- hls-plugin-api/src/Ide/Types.hs | 2 +- hls-test-utils/hls-test-utils.cabal | 2 +- hls-test-utils/src/Test/Hls.hs | 2 +- nix/default.nix | 1 + .../hls-explicit-imports-plugin.cabal | 2 +- .../src/Ide/Plugin/ExplicitImports.hs | 2 +- .../hls-tactics-plugin.cabal | 2 +- .../src/Wingman/LanguageServer.hs | 5 +- src/Ide/Main.hs | 2 +- stack-8.10.2.yaml | 1 + stack-8.10.3.yaml | 1 + stack-8.10.4.yaml | 1 + stack-8.6.4.yaml | 1 + stack-8.6.5.yaml | 1 + stack-8.8.2.yaml | 1 + stack-8.8.3.yaml | 1 + stack-8.8.4.yaml | 1 + stack.yaml | 3 +- 54 files changed, 329 insertions(+), 55 deletions(-) create mode 100644 hls-graph/LICENSE create mode 100644 hls-graph/hls-graph.cabal create mode 100644 hls-graph/src/Development/IDE/Graph.hs create mode 100644 hls-graph/src/Development/IDE/Graph/Classes.hs create mode 100644 hls-graph/src/Development/IDE/Graph/Database.hs create mode 100644 hls-graph/src/Development/IDE/Graph/Rule.hs diff --git a/cabal.project b/cabal.project index be4fd619e0..07a87eb750 100644 --- a/cabal.project +++ b/cabal.project @@ -2,6 +2,7 @@ packages: ./ ./hie-compat ./shake-bench + ./hls-graph ./ghcide ./hls-plugin-api ./hls-test-utils diff --git a/ghcide/exe/Main.hs b/ghcide/exe/Main.hs index 4597732f6b..99b6c18d7a 100644 --- a/ghcide/exe/Main.hs +++ b/ghcide/exe/Main.hs @@ -26,7 +26,7 @@ import qualified Development.IDE.Main as Main import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde import qualified Development.IDE.Plugin.Test as Test import Development.IDE.Types.Options -import Development.Shake (ShakeOptions (shakeThreads)) +import Development.IDE.Graph (ShakeOptions (shakeThreads)) import Ide.Plugin.Config (Config (checkParents, checkProject)) import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig, pluginsToVSCodeExtensionSchema) @@ -109,4 +109,3 @@ main = do , optCheckProject = pure $ checkProject config } } - diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 0df844e4e5..216fb1f5f0 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -74,7 +74,7 @@ library rope-utf16-splay, safe, safe-exceptions, - shake >= 0.18.4, + hls-graph, sorted-list, sqlite-simple, stm, @@ -288,7 +288,7 @@ executable ghcide ghcide, lens, optparse-applicative, - shake, + hls-graph, text, unordered-containers, aeson-pretty @@ -358,6 +358,7 @@ test-suite ghcide-tests safe, safe-exceptions, shake, + hls-graph, tasty, tasty-expected-failure, tasty-hunit, @@ -410,6 +411,7 @@ executable ghcide-bench optparse-applicative, process, safe-exceptions, + hls-graph, shake, text hs-source-dirs: bench/lib bench/exe diff --git a/ghcide/session-loader/Development/IDE/Session.hs b/ghcide/session-loader/Development/IDE/Session.hs index 91f0428788..3c776cb36b 100644 --- a/ghcide/session-loader/Development/IDE/Session.hs +++ b/ghcide/session-loader/Development/IDE/Session.hs @@ -56,7 +56,7 @@ import Development.IDE.Types.HscEnvEq (HscEnvEq, newHscEnvEq, import Development.IDE.Types.Location import Development.IDE.Types.Logger import Development.IDE.Types.Options -import Development.Shake (Action) +import Development.IDE.Graph (Action) import GHC.Check import qualified HIE.Bios as HieBios import HIE.Bios.Environment hiding (getCacheDir) diff --git a/ghcide/src/Development/IDE.hs b/ghcide/src/Development/IDE.hs index e50ce462dd..9e8bce5a03 100644 --- a/ghcide/src/Development/IDE.hs +++ b/ghcide/src/Development/IDE.hs @@ -51,5 +51,5 @@ import Development.IDE.Types.HscEnvEq as X (HscEnvEq (..), hscEnvWithImportPaths) import Development.IDE.Types.Location as X import Development.IDE.Types.Logger as X -import Development.Shake as X (Action, RuleResult, +import Development.IDE.Graph as X (Action, RuleResult, Rules, action) diff --git a/ghcide/src/Development/IDE/Core/Actions.hs b/ghcide/src/Development/IDE/Core/Actions.hs index 2f7455c36a..794ad8e56c 100644 --- a/ghcide/src/Development/IDE/Core/Actions.hs +++ b/ghcide/src/Development/IDE/Core/Actions.hs @@ -30,7 +30,7 @@ import Development.IDE.GHC.Compat hiding (TargetFile, writeHieFile) import qualified Development.IDE.Spans.AtPoint as AtPoint import Development.IDE.Types.Location -import Development.Shake hiding (Diagnostic) +import Development.IDE.Graph hiding (Diagnostic) import qualified HieDb import Language.LSP.Types (DocumentHighlight (..), SymbolInformation (..)) diff --git a/ghcide/src/Development/IDE/Core/FileExists.hs b/ghcide/src/Development/IDE/Core/FileExists.hs index 31eb97804e..17a79cc8d8 100644 --- a/ghcide/src/Development/IDE/Core/FileExists.hs +++ b/ghcide/src/Development/IDE/Core/FileExists.hs @@ -24,7 +24,7 @@ import Development.IDE.Core.RuleTypes import Development.IDE.Core.Shake import Development.IDE.Types.Location import Development.IDE.Types.Options -import Development.Shake +import Development.IDE.Graph import Language.LSP.Server hiding (getVirtualFile) import Language.LSP.Types import Language.LSP.Types.Capabilities diff --git a/ghcide/src/Development/IDE/Core/FileStore.hs b/ghcide/src/Development/IDE/Core/FileStore.hs index 17b418714d..5fc511d327 100644 --- a/ghcide/src/Development/IDE/Core/FileStore.hs +++ b/ghcide/src/Development/IDE/Core/FileStore.hs @@ -46,7 +46,7 @@ import Development.IDE.Import.DependencyInformation import Development.IDE.Types.Diagnostics import Development.IDE.Types.Location import Development.IDE.Types.Options -import Development.Shake +import Development.IDE.Graph import HieDb.Create (deleteMissingRealFiles) import Ide.Plugin.Config (CheckParents (..)) import System.IO.Error diff --git a/ghcide/src/Development/IDE/Core/IdeConfiguration.hs b/ghcide/src/Development/IDE/Core/IdeConfiguration.hs index a198a96ec4..2cc3a67e97 100644 --- a/ghcide/src/Development/IDE/Core/IdeConfiguration.hs +++ b/ghcide/src/Development/IDE/Core/IdeConfiguration.hs @@ -21,7 +21,7 @@ import Data.Hashable (Hashed, hashed, unhashed) import Data.Text (Text, isPrefixOf) import Development.IDE.Core.Shake import Development.IDE.Types.Location -import Development.Shake +import Development.IDE.Graph import Language.LSP.Types import System.FilePath (isRelative) diff --git a/ghcide/src/Development/IDE/Core/OfInterest.hs b/ghcide/src/Development/IDE/Core/OfInterest.hs index da01d08ce2..ee56addafa 100644 --- a/ghcide/src/Development/IDE/Core/OfInterest.hs +++ b/ghcide/src/Development/IDE/Core/OfInterest.hs @@ -24,7 +24,7 @@ import qualified Data.HashMap.Strict as HashMap import Data.Hashable import qualified Data.Text as T import Data.Typeable -import Development.Shake +import Development.IDE.Graph import GHC.Generics import Control.Monad.Trans.Class @@ -117,4 +117,3 @@ kick = do void $ liftIO $ modifyVar' exportsMap $ (exportsMap'' <>) . (exportsMap' <>) liftIO $ progressUpdate KickCompleted - diff --git a/ghcide/src/Development/IDE/Core/RuleTypes.hs b/ghcide/src/Development/IDE/Core/RuleTypes.hs index e7601aa1df..ff1282abdf 100644 --- a/ghcide/src/Development/IDE/Core/RuleTypes.hs +++ b/ghcide/src/Development/IDE/Core/RuleTypes.hs @@ -28,7 +28,7 @@ import Development.IDE.GHC.Util import Development.IDE.Import.DependencyInformation import Development.IDE.Types.HscEnvEq (HscEnvEq) import Development.IDE.Types.KnownTargets -import Development.Shake +import Development.IDE.Graph import GHC.Generics (Generic) import HscTypes (HomeModInfo, diff --git a/ghcide/src/Development/IDE/Core/Rules.hs b/ghcide/src/Development/IDE/Core/Rules.hs index 4d38774e22..9ef7d78875 100644 --- a/ghcide/src/Development/IDE/Core/Rules.hs +++ b/ghcide/src/Development/IDE/Core/Rules.hs @@ -123,9 +123,9 @@ import Development.IDE.Types.HscEnvEq import Development.IDE.Types.Location import qualified Development.IDE.Types.Logger as L import Development.IDE.Types.Options -import Development.Shake hiding +import Development.IDE.Graph hiding (Diagnostic) -import Development.Shake.Classes hiding (get, put) +import Development.IDE.Graph.Classes hiding (get, put) import Fingerprint import GHC.Generics (Generic) import GHC.IO.Encoding diff --git a/ghcide/src/Development/IDE/Core/Service.hs b/ghcide/src/Development/IDE/Core/Service.hs index 87c6148446..b03da9fd42 100644 --- a/ghcide/src/Development/IDE/Core/Service.hs +++ b/ghcide/src/Development/IDE/Core/Service.hs @@ -23,7 +23,7 @@ import Development.IDE.Core.FileExists (fileExistsRules) import Development.IDE.Core.OfInterest import Development.IDE.Types.Logger as Logger import Development.IDE.Types.Options (IdeOptions (..)) -import Development.Shake +import Development.IDE.Graph import Ide.Plugin.Config import qualified Language.LSP.Server as LSP import qualified Language.LSP.Types as LSP diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index 68cc99c553..8c2c9ade18 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -119,12 +119,12 @@ import Development.IDE.Types.Logger hiding (Priority) import qualified Development.IDE.Types.Logger as Logger import Development.IDE.Types.Options import Development.IDE.Types.Shake -import Development.Shake hiding (Info, ShakeValue, +import Development.IDE.Graph hiding (Info, ShakeValue, doesFileExist) -import qualified Development.Shake as Shake -import Development.Shake.Classes -import Development.Shake.Database -import Development.Shake.Rule +import qualified Development.IDE.Graph as Shake +import Development.IDE.Graph.Classes +import Development.IDE.Graph.Database +import Development.IDE.Graph.Rule import GHC.Generics import Language.LSP.Diagnostics import qualified Language.LSP.Server as LSP diff --git a/ghcide/src/Development/IDE/Core/Tracing.hs b/ghcide/src/Development/IDE/Core/Tracing.hs index dc1dff8fac..a9ba01eac6 100644 --- a/ghcide/src/Development/IDE/Core/Tracing.hs +++ b/ghcide/src/Development/IDE/Core/Tracing.hs @@ -38,7 +38,7 @@ import Development.IDE.Types.Logger (Logger, logDebug, logInfo) import Development.IDE.Types.Shake (Key (..), Value, ValueWithDiagnostics (..), Values) -import Development.Shake (Action, actionBracket) +import Development.IDE.Graph (Action, actionBracket) import Foreign.Storable (Storable (sizeOf)) import HeapSize (recursiveSize, runHeapsize) import Ide.PluginUtils (installSigUsr1Handler) @@ -230,4 +230,3 @@ repeatUntilJust nattempts action = do case res of Nothing -> repeatUntilJust (nattempts-1) action Just{} -> return res - diff --git a/ghcide/src/Development/IDE/GHC/ExactPrint.hs b/ghcide/src/Development/IDE/GHC/ExactPrint.hs index 659ceacb47..703b3e3ec0 100644 --- a/ghcide/src/Development/IDE/GHC/ExactPrint.hs +++ b/ghcide/src/Development/IDE/GHC/ExactPrint.hs @@ -50,8 +50,8 @@ import Development.IDE.Core.Service (runAction) import Development.IDE.Core.Shake import Development.IDE.GHC.Compat hiding (parseExpr) import Development.IDE.Types.Location -import Development.Shake (RuleResult, Rules) -import Development.Shake.Classes +import Development.IDE.Graph (RuleResult, Rules) +import Development.IDE.Graph.Classes import qualified GHC.Generics as GHC import Generics.SYB import Generics.SYB.GHC diff --git a/ghcide/src/Development/IDE/Main.hs b/ghcide/src/Development/IDE/Main.hs index 3202654469..1942fb6b7c 100644 --- a/ghcide/src/Development/IDE/Main.hs +++ b/ghcide/src/Development/IDE/Main.hs @@ -61,7 +61,7 @@ import Development.IDE.Types.Options (IdeGhcSession, clientSupportsProgress, defaultIdeOptions) import Development.IDE.Types.Shake (Key (Key)) -import Development.Shake (action) +import Development.IDE.Graph (action) import GHC.IO.Encoding (setLocaleEncoding) import GHC.IO.Handle (hDuplicate) import HIE.Bios.Cradle (findCradle) diff --git a/ghcide/src/Development/IDE/Plugin.hs b/ghcide/src/Development/IDE/Plugin.hs index 2c7b1fedaf..c29e6a5470 100644 --- a/ghcide/src/Development/IDE/Plugin.hs +++ b/ghcide/src/Development/IDE/Plugin.hs @@ -1,7 +1,7 @@ module Development.IDE.Plugin ( Plugin(..) ) where import Data.Default -import Development.Shake +import Development.IDE.Graph import Development.IDE.LSP.Server import qualified Language.LSP.Server as LSP diff --git a/ghcide/src/Development/IDE/Plugin/CodeAction/RuleTypes.hs b/ghcide/src/Development/IDE/Plugin/CodeAction/RuleTypes.hs index 663757b64a..64590717bb 100644 --- a/ghcide/src/Development/IDE/Plugin/CodeAction/RuleTypes.hs +++ b/ghcide/src/Development/IDE/Plugin/CodeAction/RuleTypes.hs @@ -10,7 +10,7 @@ import Data.Hashable (Hashable) import Data.Typeable (Typeable) import Development.IDE.Types.Exports import Development.IDE.Types.HscEnvEq (HscEnvEq) -import Development.Shake (RuleResult) +import Development.IDE.Graph (RuleResult) import GHC.Generics (Generic) -- Rule type for caching Package Exports diff --git a/ghcide/src/Development/IDE/Plugin/Completions.hs b/ghcide/src/Development/IDE/Plugin/Completions.hs index 0ab0d75c2a..33d3cb8fbd 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions.hs @@ -31,8 +31,8 @@ import Development.IDE.Plugin.Completions.Logic import Development.IDE.Plugin.Completions.Types import Development.IDE.Types.HscEnvEq (hscEnv) import Development.IDE.Types.Location -import Development.Shake -import Development.Shake.Classes +import Development.IDE.Graph +import Development.IDE.Graph.Classes import GHC.Exts (toList) import GHC.Generics import Ide.Plugin.Config (Config) diff --git a/ghcide/src/Development/IDE/Plugin/HLS.hs b/ghcide/src/Development/IDE/Plugin/HLS.hs index e17656203d..c208a2c21e 100644 --- a/ghcide/src/Development/IDE/Plugin/HLS.hs +++ b/ghcide/src/Development/IDE/Plugin/HLS.hs @@ -27,7 +27,7 @@ import Development.IDE.Core.Tracing import Development.IDE.LSP.Server import Development.IDE.Plugin import Development.IDE.Types.Logger -import Development.Shake (Rules) +import Development.IDE.Graph (Rules) import Ide.Plugin.Config import Ide.PluginUtils (getClientConfig) import Ide.Types as HLS diff --git a/ghcide/src/Development/IDE/Plugin/Test.hs b/ghcide/src/Development/IDE/Plugin/Test.hs index 7b89ecfb9d..e8643d9471 100644 --- a/ghcide/src/Development/IDE/Plugin/Test.hs +++ b/ghcide/src/Development/IDE/Plugin/Test.hs @@ -30,7 +30,7 @@ import Development.IDE.Plugin import Development.IDE.Types.Action import Development.IDE.Types.HscEnvEq (HscEnvEq (hscEnv)) import Development.IDE.Types.Location (fromUri) -import Development.Shake (Action) +import Development.IDE.Graph (Action) import GHC.Generics (Generic) import GhcPlugins (HscEnv (hsc_dflags)) import Ide.Types diff --git a/ghcide/src/Development/IDE/Plugin/TypeLenses.hs b/ghcide/src/Development/IDE/Plugin/TypeLenses.hs index dfeed10713..0b117b9fcc 100644 --- a/ghcide/src/Development/IDE/Plugin/TypeLenses.hs +++ b/ghcide/src/Development/IDE/Plugin/TypeLenses.hs @@ -41,7 +41,7 @@ import Development.IDE.Types.Location (Position (Position, _chara Range (Range, _end, _start), toNormalizedFilePath', uriToFilePath') -import Development.Shake.Classes +import Development.IDE.Graph.Classes import GHC.Generics (Generic) import GhcPlugins (GlobalRdrEnv, HscEnv (hsc_dflags), SDoc, diff --git a/ghcide/src/Development/IDE/Types/Action.hs b/ghcide/src/Development/IDE/Types/Action.hs index 56b83fb6f9..00c15238ea 100644 --- a/ghcide/src/Development/IDE/Types/Action.hs +++ b/ghcide/src/Development/IDE/Types/Action.hs @@ -16,7 +16,7 @@ import qualified Data.HashSet as Set import Data.Hashable (Hashable (..)) import Data.Unique (Unique) import Development.IDE.Types.Logger -import Development.Shake (Action) +import Development.IDE.Graph (Action) import Numeric.Natural data DelayedAction a = DelayedAction diff --git a/ghcide/src/Development/IDE/Types/HscEnvEq.hs b/ghcide/src/Development/IDE/Types/HscEnvEq.hs index 38338f4b49..6035479543 100644 --- a/ghcide/src/Development/IDE/Types/HscEnvEq.hs +++ b/ghcide/src/Development/IDE/Types/HscEnvEq.hs @@ -25,7 +25,7 @@ import Development.IDE.GHC.Compat import Development.IDE.GHC.Error (catchSrcErrors) import Development.IDE.GHC.Util (lookupPackageConfig) import Development.IDE.Types.Exports (ExportsMap, createExportsMap) -import Development.Shake.Classes +import Development.IDE.Graph.Classes import GhcPlugins (HscEnv (hsc_dflags), InstalledPackageInfo (exposedModules), Module (..), @@ -164,4 +164,3 @@ onceAsync act = do pure (OnceRunning x, unmask $ run x) data Once a = OncePending | OnceRunning (Async a) - diff --git a/ghcide/src/Development/IDE/Types/Options.hs b/ghcide/src/Development/IDE/Types/Options.hs index 612d2c743b..f2f9bda8e3 100644 --- a/ghcide/src/Development/IDE/Types/Options.hs +++ b/ghcide/src/Development/IDE/Types/Options.hs @@ -23,7 +23,7 @@ import qualified Data.Text as T import Data.Typeable import Development.IDE.Core.RuleTypes import Development.IDE.Types.Diagnostics -import Development.Shake +import Development.IDE.Graph import GHC hiding (parseModule, typecheckModule) import GhcPlugins as GHC hiding (fst3, (<>)) diff --git a/ghcide/src/Development/IDE/Types/Shake.hs b/ghcide/src/Development/IDE/Types/Shake.hs index 86ea711d71..62c0ddaa40 100644 --- a/ghcide/src/Development/IDE/Types/Shake.hs +++ b/ghcide/src/Development/IDE/Types/Shake.hs @@ -26,9 +26,9 @@ import Data.Vector (Vector) import Development.IDE.Core.PositionMapping import Development.IDE.Types.Diagnostics import Development.IDE.Types.Location -import Development.Shake (RuleResult, +import Development.IDE.Graph (RuleResult, ShakeException (shakeExceptionInner)) -import Development.Shake.Classes +import Development.IDE.Graph.Classes import GHC.Generics import Language.LSP.Types diff --git a/ghcide/src/Generics/SYB/GHC.hs b/ghcide/src/Generics/SYB/GHC.hs index 3291d4f72e..dad34f3c5b 100644 --- a/ghcide/src/Generics/SYB/GHC.hs +++ b/ghcide/src/Generics/SYB/GHC.hs @@ -14,7 +14,7 @@ import Control.Monad import Data.Functor.Compose (Compose(Compose)) import Data.Monoid (Any(Any)) import Development.IDE.GHC.Compat -import Development.Shake.Classes +import Development.IDE.Graph.Classes import Generics.SYB @@ -122,4 +122,3 @@ gmapMQ f = runMonadicQuery . gfoldl k pure where k :: Data d => MonadicQuery r f (d -> b) -> d -> MonadicQuery r f b k c x = c <*> MonadicQuery (f x) - diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index b39fbdff75..e4df7a385e 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -73,7 +73,7 @@ library , optparse-applicative , optparse-simple , process - , shake + , hls-graph , safe-exceptions , sqlite-simple , unordered-containers @@ -332,7 +332,7 @@ executable haskell-language-server , mtl , regex-tdfa , safe-exceptions - , shake + , hls-graph , sqlite-simple , temporary , transformers diff --git a/hls-graph/LICENSE b/hls-graph/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/hls-graph/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/hls-graph/hls-graph.cabal b/hls-graph/hls-graph.cabal new file mode 100644 index 0000000000..089036dab5 --- /dev/null +++ b/hls-graph/hls-graph.cabal @@ -0,0 +1,50 @@ +cabal-version: 2.4 +name: hls-graph +version: 1.1.0.0 +synopsis: Haskell Language Server internal graph API +description: + Please see the README on GitHub at + +homepage: https://github.com/haskell/haskell-language-server#readme +bug-reports: https://github.com/haskell/haskell-language-server/issues +license: Apache-2.0 +license-file: LICENSE +author: The Haskell IDE Team +maintainer: alan.zimm@gmail.com +copyright: The Haskell IDE Team +category: Development +build-type: Simple + +flag pedantic + description: Enable -Werror + default: False + manual: True + +source-repository head + type: git + location: https://github.com/haskell/haskell-language-server + +library + exposed-modules: + Development.IDE.Graph + Development.IDE.Graph.Classes + Development.IDE.Graph.Database + Development.IDE.Graph.Rule + + hs-source-dirs: src + build-depends: + , base >=4.12 && <5 + , shake >= 0.18.4 + + ghc-options: + -Wall -Wredundant-constraints -Wno-name-shadowing + -Wno-unticked-promoted-constructors + + if flag(pedantic) + ghc-options: -Werror + + default-language: Haskell2010 + default-extensions: + DataKinds + KindSignatures + TypeOperators diff --git a/hls-graph/src/Development/IDE/Graph.hs b/hls-graph/src/Development/IDE/Graph.hs new file mode 100644 index 0000000000..3cfa0c8f91 --- /dev/null +++ b/hls-graph/src/Development/IDE/Graph.hs @@ -0,0 +1,4 @@ + +module Development.IDE.Graph(module X) where + +import Development.Shake as X diff --git a/hls-graph/src/Development/IDE/Graph/Classes.hs b/hls-graph/src/Development/IDE/Graph/Classes.hs new file mode 100644 index 0000000000..94c99e2c79 --- /dev/null +++ b/hls-graph/src/Development/IDE/Graph/Classes.hs @@ -0,0 +1,4 @@ + +module Development.IDE.Graph.Classes(module X) where + +import Development.Shake.Classes as X diff --git a/hls-graph/src/Development/IDE/Graph/Database.hs b/hls-graph/src/Development/IDE/Graph/Database.hs new file mode 100644 index 0000000000..e191922414 --- /dev/null +++ b/hls-graph/src/Development/IDE/Graph/Database.hs @@ -0,0 +1,4 @@ + +module Development.IDE.Graph.Database(module X) where + +import Development.Shake.Database as X diff --git a/hls-graph/src/Development/IDE/Graph/Rule.hs b/hls-graph/src/Development/IDE/Graph/Rule.hs new file mode 100644 index 0000000000..c7827776ab --- /dev/null +++ b/hls-graph/src/Development/IDE/Graph/Rule.hs @@ -0,0 +1,4 @@ + +module Development.IDE.Graph.Rule(module X) where + +import Development.Shake.Rule as X diff --git a/hls-plugin-api/hls-plugin-api.cabal b/hls-plugin-api/hls-plugin-api.cabal index a54321214d..acec2485d4 100644 --- a/hls-plugin-api/hls-plugin-api.cabal +++ b/hls-plugin-api/hls-plugin-api.cabal @@ -50,7 +50,7 @@ library , opentelemetry , process , regex-tdfa >=1.3.1.0 - , shake >=0.17.5 + , hls-graph , text , unordered-containers diff --git a/hls-plugin-api/src/Ide/Types.hs b/hls-plugin-api/src/Ide/Types.hs index 3ccc4145b7..c8ea4b3c0c 100644 --- a/hls-plugin-api/src/Ide/Types.hs +++ b/hls-plugin-api/src/Ide/Types.hs @@ -38,7 +38,7 @@ import Data.Semigroup import Data.String import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) -import Development.Shake hiding (command) +import Development.IDE.Graph hiding (command) import GHC.Generics import Ide.Plugin.Config import Ide.Plugin.Properties diff --git a/hls-test-utils/hls-test-utils.cabal b/hls-test-utils/hls-test-utils.cabal index 2442b7ccdd..893decad6c 100644 --- a/hls-test-utils/hls-test-utils.cabal +++ b/hls-test-utils/hls-test-utils.cabal @@ -51,7 +51,7 @@ library , lsp ^>=1.2 , lsp-test ==0.14.0.0 , lsp-types ^>=1.2 - , shake + , hls-graph , tasty , tasty-expected-failure , tasty-golden diff --git a/hls-test-utils/src/Test/Hls.hs b/hls-test-utils/src/Test/Hls.hs index 9a7436bd11..71418fe61d 100644 --- a/hls-test-utils/src/Test/Hls.hs +++ b/hls-test-utils/src/Test/Hls.hs @@ -33,7 +33,7 @@ import Development.IDE.Main import qualified Development.IDE.Main as Ghcide import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide import Development.IDE.Types.Options -import Development.Shake (ShakeOptions (shakeThreads)) +import Development.IDE.Graph (ShakeOptions (shakeThreads)) import GHC.IO.Handle import Ide.Plugin.Config (Config, formattingProvider) import Ide.PluginUtils (pluginDescToIdePlugins) diff --git a/nix/default.nix b/nix/default.nix index 251f6efead..7e75682b8f 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -25,6 +25,7 @@ let ourSources = { haskell-language-server = gitignoreSource ../.; ghcide = gitignoreSource ../ghcide; + hls-graph = gitignoreSource ../hls-graph; shake-bench = gitignoreSource ../shake-bench; hie-compat = gitignoreSource ../hie-compat; hls-plugin-api = gitignoreSource ../hls-plugin-api; diff --git a/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal b/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal index 6985aaacf1..0d12befcbd 100644 --- a/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal +++ b/plugins/hls-explicit-imports-plugin/hls-explicit-imports-plugin.cabal @@ -25,7 +25,7 @@ library , hls-plugin-api ^>=1.1.0.0 , lsp , lsp-types - , shake + , hls-graph , text , unordered-containers diff --git a/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs b/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs index 739605c5da..8b2c149d6e 100644 --- a/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs +++ b/plugins/hls-explicit-imports-plugin/src/Ide/Plugin/ExplicitImports.hs @@ -26,7 +26,7 @@ import qualified Data.Text as T import Development.IDE import Development.IDE.Core.PositionMapping import Development.IDE.GHC.Compat -import Development.Shake.Classes +import Development.IDE.Graph.Classes import GHC.Generics (Generic) import Ide.PluginUtils (mkLspCommand) import Ide.Types diff --git a/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal b/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal index 8af40ee91a..bef9698738 100644 --- a/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal +++ b/plugins/hls-tactics-plugin/hls-tactics-plugin.cabal @@ -80,7 +80,7 @@ library , mtl , refinery ^>=0.3 , retrie >=0.1.1.0 - , shake + , hls-graph , syb , text , transformers diff --git a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs index 9dea7bb277..10d008f7f7 100644 --- a/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs +++ b/plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs @@ -38,8 +38,8 @@ import Development.IDE.GHC.Compat import Development.IDE.GHC.Error (realSrcSpanToRange) import Development.IDE.GHC.ExactPrint import Development.IDE.Spans.LocalBindings (Bindings, getDefiningBindings) -import Development.Shake (Action, RuleResult, Rules, action) -import Development.Shake.Classes (Typeable, Binary, Hashable, NFData) +import Development.IDE.Graph (Action, RuleResult, Rules, action) +import Development.IDE.Graph.Classes (Typeable, Binary, Hashable, NFData) import qualified FastString import GHC.Generics (Generic) import GhcPlugins (tupleDataCon, consDataCon, substTyAddInScope, ExternalPackageState, HscEnv (hsc_EPS), liftIO) @@ -541,4 +541,3 @@ mkWorkspaceEdits mkWorkspaceEdits dflags ccs uri pm g = do let response = transform dflags ccs uri g pm in first (InfrastructureError . T.pack) response - diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index 6078569044..acf22e28e4 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -19,7 +19,7 @@ import Development.IDE.Main (isLSP) import qualified Development.IDE.Main as Main import Development.IDE.Types.Logger as G import qualified Development.IDE.Types.Options as Ghcide -import Development.Shake (ShakeOptions (shakeThreads)) +import Development.IDE.Graph (ShakeOptions (shakeThreads)) import Ide.Arguments import Ide.Logger import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig, diff --git a/stack-8.10.2.yaml b/stack-8.10.2.yaml index 39210d0fb9..29f6e6cff0 100644 --- a/stack-8.10.2.yaml +++ b/stack-8.10.2.yaml @@ -3,6 +3,7 @@ resolver: nightly-2020-12-09 packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./hls-plugin-api - ./hls-test-utils diff --git a/stack-8.10.3.yaml b/stack-8.10.3.yaml index 5d8a13fa41..fb852a6d7c 100644 --- a/stack-8.10.3.yaml +++ b/stack-8.10.3.yaml @@ -3,6 +3,7 @@ resolver: lts-17.2 # Last ghc-8.10.3 lts packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./hls-plugin-api - ./hls-test-utils diff --git a/stack-8.10.4.yaml b/stack-8.10.4.yaml index 5768b2a257..45ad563f6f 100644 --- a/stack-8.10.4.yaml +++ b/stack-8.10.4.yaml @@ -3,6 +3,7 @@ resolver: lts-17.4 packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./hls-plugin-api - ./hls-test-utils diff --git a/stack-8.6.4.yaml b/stack-8.6.4.yaml index 6ee16c62b9..6980327c43 100644 --- a/stack-8.6.4.yaml +++ b/stack-8.6.4.yaml @@ -4,6 +4,7 @@ compiler: ghc-8.6.4 packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ # - ./shake-bench - ./hls-plugin-api diff --git a/stack-8.6.5.yaml b/stack-8.6.5.yaml index 8ba6ff4853..f4a758a8b7 100644 --- a/stack-8.6.5.yaml +++ b/stack-8.6.5.yaml @@ -3,6 +3,7 @@ resolver: lts-14.27 # Last 8.6.5 packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./hls-plugin-api - ./hls-test-utils diff --git a/stack-8.8.2.yaml b/stack-8.8.2.yaml index 665746a4bd..fb8f807dcd 100644 --- a/stack-8.8.2.yaml +++ b/stack-8.8.2.yaml @@ -3,6 +3,7 @@ resolver: lts-15.3 # Last 8.8.2 packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./hls-plugin-api - ./hls-test-utils diff --git a/stack-8.8.3.yaml b/stack-8.8.3.yaml index a6e724fc1c..4b05b421a5 100644 --- a/stack-8.8.3.yaml +++ b/stack-8.8.3.yaml @@ -3,6 +3,7 @@ resolver: lts-16.11 # Last 8.8.3 packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./shake-bench - ./hls-plugin-api diff --git a/stack-8.8.4.yaml b/stack-8.8.4.yaml index 06a0187a56..b27bf847cc 100644 --- a/stack-8.8.4.yaml +++ b/stack-8.8.4.yaml @@ -3,6 +3,7 @@ resolver: lts-16.31 # last 8.8.4 lts packages: - . - ./hie-compat + - ./hls-graph - ./ghcide/ - ./shake-bench - ./hls-plugin-api diff --git a/stack.yaml b/stack.yaml index 3e681a6bcc..e825cacf66 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,7 +3,8 @@ resolver: lts-14.27 # Last 8.6.5 packages: - . - ./hie-compat - - ./ghcide/ + - ./hls-graph + - ./ghcide - ./hls-plugin-api - ./hls-test-utils # - ./shake-bench From 3413cdf4ff3e567d3362b58e2aee0df64cfca1fb Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Sat, 17 Apr 2021 15:44:21 +0100 Subject: [PATCH 2/3] Make hls-graph use explicit exports rather than module-level exports --- hls-graph/src/Development/IDE/Graph.hs | 70 ++++++++++++++++++- .../src/Development/IDE/Graph/Classes.hs | 6 +- .../src/Development/IDE/Graph/Database.hs | 14 +++- hls-graph/src/Development/IDE/Graph/Rule.hs | 24 ++++++- 4 files changed, 106 insertions(+), 8 deletions(-) diff --git a/hls-graph/src/Development/IDE/Graph.hs b/hls-graph/src/Development/IDE/Graph.hs index 3cfa0c8f91..016bbf294f 100644 --- a/hls-graph/src/Development/IDE/Graph.hs +++ b/hls-graph/src/Development/IDE/Graph.hs @@ -1,4 +1,70 @@ +{-# LANGUAGE PatternSynonyms #-} -module Development.IDE.Graph(module X) where +module Development.IDE.Graph( + shake, + shakeOptions, + Rules, action, withoutActions, alternatives, priority, versioned, + Action, traced, + liftIO, actionOnException, actionFinally, actionBracket, actionCatch, actionRetry, runAfter, + ShakeException(..), + -- * Configuration + ShakeOptions(..), Rebuild(..), Lint(..), Change(..), + getShakeOptions, getShakeOptionsRules, getHashedShakeVersion, + getShakeExtra, getShakeExtraRules, addShakeExtra, + -- ** Command line + shakeArgs, shakeArgsWith, shakeArgsOptionsWith, shakeOptDescrs, addHelpSuffix, + -- ** Targets + getTargets, addTarget, withTargetDocs, withoutTargets, + -- ** Progress reporting + Progress(..), progressSimple, progressDisplay, progressTitlebar, progressProgram, getProgress, + -- ** Verbosity + Verbosity(..), getVerbosity, putVerbose, putInfo, putWarn, putError, withVerbosity, quietly, + -- * Running commands + command, command_, cmd, cmd_, unit, + Stdout(..), StdoutTrim(..), Stderr(..), Stdouterr(..), Exit(..), Process(..), CmdTime(..), CmdLine(..), FSATrace(..), + CmdResult, CmdString, CmdOption(..), + addPath, addEnv, + -- * Explicit parallelism + parallel, forP, par, + -- * Utility functions + copyFile', copyFileChanged, + readFile', readFileLines, + writeFile', writeFileLines, writeFileChanged, + removeFiles, removeFilesAfter, + withTempFile, withTempDir, + withTempFileWithin, withTempDirWithin, + -- * File rules + need, want, (%>), (|%>), (?>), phony, (~>), phonys, + (&%>), (&?>), + orderOnly, orderOnlyAction, + FilePattern, (?==), (), filePattern, + needed, trackRead, trackWrite, trackAllow, + -- * Directory rules + doesFileExist, doesDirectoryExist, getDirectoryContents, getDirectoryFiles, getDirectoryDirs, + getDirectoryFilesIO, + -- * Environment rules + getEnv, getEnvWithDefault, getEnvError, + -- * Oracle rules + ShakeValue, RuleResult, addOracle, addOracleCache, addOracleHash, askOracle, askOracles, + -- * Special rules + alwaysRerun, + -- * Resources + Resource, newResource, newResourceIO, withResource, withResources, + newThrottle, newThrottleIO, + unsafeExtraThread, + -- * Cache + newCache, newCacheIO, + historyDisable, produces, + -- * Batching + needHasChanged, + resultHasChanged, + batch, + reschedule, + -- * Deprecated + askOracleWith, + deprioritize, + pattern Quiet, pattern Normal, pattern Loud, pattern Chatty, + putLoud, putNormal, putQuiet + ) where -import Development.Shake as X +import Development.Shake diff --git a/hls-graph/src/Development/IDE/Graph/Classes.hs b/hls-graph/src/Development/IDE/Graph/Classes.hs index 94c99e2c79..0ea003caa8 100644 --- a/hls-graph/src/Development/IDE/Graph/Classes.hs +++ b/hls-graph/src/Development/IDE/Graph/Classes.hs @@ -1,4 +1,6 @@ -module Development.IDE.Graph.Classes(module X) where +module Development.IDE.Graph.Classes( + Show(..), Typeable, Eq(..), Hashable(..), Binary(..), NFData(..) + ) where -import Development.Shake.Classes as X +import Development.Shake.Classes diff --git a/hls-graph/src/Development/IDE/Graph/Database.hs b/hls-graph/src/Development/IDE/Graph/Database.hs index e191922414..250450a489 100644 --- a/hls-graph/src/Development/IDE/Graph/Database.hs +++ b/hls-graph/src/Development/IDE/Graph/Database.hs @@ -1,4 +1,14 @@ -module Development.IDE.Graph.Database(module X) where +module Development.IDE.Graph.Database( + ShakeDatabase, + shakeOpenDatabase, + shakeWithDatabase, + shakeOneShotDatabase, + shakeRunDatabase, + shakeLiveFilesDatabase, + shakeProfileDatabase, + shakeErrorsDatabase, + shakeRunAfter + ) where -import Development.Shake.Database as X +import Development.Shake.Database diff --git a/hls-graph/src/Development/IDE/Graph/Rule.hs b/hls-graph/src/Development/IDE/Graph/Rule.hs index c7827776ab..19093f30df 100644 --- a/hls-graph/src/Development/IDE/Graph/Rule.hs +++ b/hls-graph/src/Development/IDE/Graph/Rule.hs @@ -1,4 +1,24 @@ -module Development.IDE.Graph.Rule(module X) where +module Development.IDE.Graph.Rule( + -- * Defining builtin rules + -- | Functions and types for defining new types of Shake rules. + addBuiltinRule, + BuiltinLint, noLint, BuiltinIdentity, noIdentity, BuiltinRun, RunMode(..), RunChanged(..), RunResult(..), + -- * Calling builtin rules + -- | Wrappers around calling Shake rules. In general these should be specialised to a builtin rule. + apply, apply1, + -- * User rules + -- | Define user rules that can be used by builtin rules. + -- Absent any builtin rule making use of a user rule at a given type, a user rule will have on effect - + -- they have no inherent effect or interpretation on their own. + addUserRule, getUserRuleList, getUserRuleMaybe, getUserRuleOne, + -- * Lint integration + -- | Provide lint warnings when running code. + lintTrackRead, lintTrackWrite, lintTrackAllow, + -- * History caching + -- | Interact with the non-local cache. When using the cache it is important that all + -- rules have accurate 'BuiltinIdentity' functions. + historyIsEnabled, historySave, historyLoad + ) where -import Development.Shake.Rule as X +import Development.Shake.Rule From 208962d2aeb2746588fa22dd7226e6c1bab5de06 Mon Sep 17 00:00:00 2001 From: Neil Mitchell Date: Sun, 18 Apr 2021 09:54:23 +0100 Subject: [PATCH 3/3] Cut down on what hls-graph exports Delete unnecesssary hiding --- ghcide/src/Development/IDE/Core/Actions.hs | 2 +- ghcide/src/Development/IDE/Core/Rules.hs | 3 +- ghcide/src/Development/IDE/Core/Shake.hs | 3 +- hls-graph/src/Development/IDE/Graph.hs | 60 ++----------------- .../src/Development/IDE/Graph/Database.hs | 5 -- hls-graph/src/Development/IDE/Graph/Rule.hs | 12 ---- hls-plugin-api/src/Ide/Types.hs | 2 +- 7 files changed, 10 insertions(+), 77 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Actions.hs b/ghcide/src/Development/IDE/Core/Actions.hs index 794ad8e56c..e43033a477 100644 --- a/ghcide/src/Development/IDE/Core/Actions.hs +++ b/ghcide/src/Development/IDE/Core/Actions.hs @@ -30,7 +30,7 @@ import Development.IDE.GHC.Compat hiding (TargetFile, writeHieFile) import qualified Development.IDE.Spans.AtPoint as AtPoint import Development.IDE.Types.Location -import Development.IDE.Graph hiding (Diagnostic) +import Development.IDE.Graph import qualified HieDb import Language.LSP.Types (DocumentHighlight (..), SymbolInformation (..)) diff --git a/ghcide/src/Development/IDE/Core/Rules.hs b/ghcide/src/Development/IDE/Core/Rules.hs index 9ef7d78875..f63da383a0 100644 --- a/ghcide/src/Development/IDE/Core/Rules.hs +++ b/ghcide/src/Development/IDE/Core/Rules.hs @@ -123,8 +123,7 @@ import Development.IDE.Types.HscEnvEq import Development.IDE.Types.Location import qualified Development.IDE.Types.Logger as L import Development.IDE.Types.Options -import Development.IDE.Graph hiding - (Diagnostic) +import Development.IDE.Graph import Development.IDE.Graph.Classes hiding (get, put) import Fingerprint import GHC.Generics (Generic) diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index 8c2c9ade18..7a778df402 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -119,8 +119,7 @@ import Development.IDE.Types.Logger hiding (Priority) import qualified Development.IDE.Types.Logger as Logger import Development.IDE.Types.Options import Development.IDE.Types.Shake -import Development.IDE.Graph hiding (Info, ShakeValue, - doesFileExist) +import Development.IDE.Graph hiding (ShakeValue) import qualified Development.IDE.Graph as Shake import Development.IDE.Graph.Classes import Development.IDE.Graph.Database diff --git a/hls-graph/src/Development/IDE/Graph.hs b/hls-graph/src/Development/IDE/Graph.hs index 016bbf294f..d76a8e504a 100644 --- a/hls-graph/src/Development/IDE/Graph.hs +++ b/hls-graph/src/Development/IDE/Graph.hs @@ -1,70 +1,22 @@ {-# LANGUAGE PatternSynonyms #-} module Development.IDE.Graph( - shake, shakeOptions, - Rules, action, withoutActions, alternatives, priority, versioned, - Action, traced, - liftIO, actionOnException, actionFinally, actionBracket, actionCatch, actionRetry, runAfter, + Rules, + Action, action, + actionFinally, actionBracket, actionCatch, ShakeException(..), -- * Configuration - ShakeOptions(..), Rebuild(..), Lint(..), Change(..), - getShakeOptions, getShakeOptionsRules, getHashedShakeVersion, + ShakeOptions(shakeThreads, shakeFiles, shakeExtra), getShakeExtra, getShakeExtraRules, addShakeExtra, - -- ** Command line - shakeArgs, shakeArgsWith, shakeArgsOptionsWith, shakeOptDescrs, addHelpSuffix, - -- ** Targets - getTargets, addTarget, withTargetDocs, withoutTargets, - -- ** Progress reporting - Progress(..), progressSimple, progressDisplay, progressTitlebar, progressProgram, getProgress, - -- ** Verbosity - Verbosity(..), getVerbosity, putVerbose, putInfo, putWarn, putError, withVerbosity, quietly, - -- * Running commands - command, command_, cmd, cmd_, unit, - Stdout(..), StdoutTrim(..), Stderr(..), Stdouterr(..), Exit(..), Process(..), CmdTime(..), CmdLine(..), FSATrace(..), - CmdResult, CmdString, CmdOption(..), - addPath, addEnv, -- * Explicit parallelism - parallel, forP, par, - -- * Utility functions - copyFile', copyFileChanged, - readFile', readFileLines, - writeFile', writeFileLines, writeFileChanged, - removeFiles, removeFilesAfter, - withTempFile, withTempDir, - withTempFileWithin, withTempDirWithin, - -- * File rules - need, want, (%>), (|%>), (?>), phony, (~>), phonys, - (&%>), (&?>), - orderOnly, orderOnlyAction, - FilePattern, (?==), (), filePattern, - needed, trackRead, trackWrite, trackAllow, - -- * Directory rules - doesFileExist, doesDirectoryExist, getDirectoryContents, getDirectoryFiles, getDirectoryDirs, - getDirectoryFilesIO, - -- * Environment rules - getEnv, getEnvWithDefault, getEnvError, + parallel, -- * Oracle rules - ShakeValue, RuleResult, addOracle, addOracleCache, addOracleHash, askOracle, askOracles, + ShakeValue, RuleResult, -- * Special rules alwaysRerun, - -- * Resources - Resource, newResource, newResourceIO, withResource, withResources, - newThrottle, newThrottleIO, - unsafeExtraThread, - -- * Cache - newCache, newCacheIO, - historyDisable, produces, -- * Batching - needHasChanged, - resultHasChanged, - batch, reschedule, - -- * Deprecated - askOracleWith, - deprioritize, - pattern Quiet, pattern Normal, pattern Loud, pattern Chatty, - putLoud, putNormal, putQuiet ) where import Development.Shake diff --git a/hls-graph/src/Development/IDE/Graph/Database.hs b/hls-graph/src/Development/IDE/Graph/Database.hs index 250450a489..b740029a16 100644 --- a/hls-graph/src/Development/IDE/Graph/Database.hs +++ b/hls-graph/src/Development/IDE/Graph/Database.hs @@ -2,13 +2,8 @@ module Development.IDE.Graph.Database( ShakeDatabase, shakeOpenDatabase, - shakeWithDatabase, - shakeOneShotDatabase, shakeRunDatabase, - shakeLiveFilesDatabase, shakeProfileDatabase, - shakeErrorsDatabase, - shakeRunAfter ) where import Development.Shake.Database diff --git a/hls-graph/src/Development/IDE/Graph/Rule.hs b/hls-graph/src/Development/IDE/Graph/Rule.hs index 19093f30df..7773d1d9c6 100644 --- a/hls-graph/src/Development/IDE/Graph/Rule.hs +++ b/hls-graph/src/Development/IDE/Graph/Rule.hs @@ -7,18 +7,6 @@ module Development.IDE.Graph.Rule( -- * Calling builtin rules -- | Wrappers around calling Shake rules. In general these should be specialised to a builtin rule. apply, apply1, - -- * User rules - -- | Define user rules that can be used by builtin rules. - -- Absent any builtin rule making use of a user rule at a given type, a user rule will have on effect - - -- they have no inherent effect or interpretation on their own. - addUserRule, getUserRuleList, getUserRuleMaybe, getUserRuleOne, - -- * Lint integration - -- | Provide lint warnings when running code. - lintTrackRead, lintTrackWrite, lintTrackAllow, - -- * History caching - -- | Interact with the non-local cache. When using the cache it is important that all - -- rules have accurate 'BuiltinIdentity' functions. - historyIsEnabled, historySave, historyLoad ) where import Development.Shake.Rule diff --git a/hls-plugin-api/src/Ide/Types.hs b/hls-plugin-api/src/Ide/Types.hs index c8ea4b3c0c..4622707621 100644 --- a/hls-plugin-api/src/Ide/Types.hs +++ b/hls-plugin-api/src/Ide/Types.hs @@ -38,7 +38,7 @@ import Data.Semigroup import Data.String import qualified Data.Text as T import Data.Text.Encoding (encodeUtf8) -import Development.IDE.Graph hiding (command) +import Development.IDE.Graph import GHC.Generics import Ide.Plugin.Config import Ide.Plugin.Properties