Skip to content

Commit 267686b

Browse files
committed
Remove GetDependencyInformation in favour of GetModuleGraph
1 parent f7d0219 commit 267686b

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

ghcide/src/Development/IDE/Core/RuleTypes.hs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ type instance RuleResult GetParsedModule = ParsedModule
6969
-- all comments included using Opt_KeepRawTokenStream
7070
type instance RuleResult GetParsedModuleWithComments = ParsedModule
7171

72-
-- | The dependency information produced by following the imports recursively.
73-
-- This rule will succeed even if there is an error, e.g., a module could not be located,
74-
-- a module could not be parsed or an import cycle.
75-
type instance RuleResult GetDependencyInformation = DependencyInformation
76-
7772
type instance RuleResult GetModuleGraph = DependencyInformation
7873

7974
data GetKnownTargets = GetKnownTargets
@@ -262,8 +257,8 @@ type instance RuleResult GhcSessionDeps = HscEnvEq
262257
-- | Resolve the imports in a module to the file path of a module in the same package
263258
type instance RuleResult GetLocatedImports = [(Located ModuleName, Maybe ArtifactsLocation)]
264259

265-
-- | This rule is used to report import cycles. It depends on GetDependencyInformation.
266-
-- We cannot report the cycles directly from GetDependencyInformation since
260+
-- | This rule is used to report import cycles. It depends on GetModuleGraph.
261+
-- We cannot report the cycles directly from GetModuleGraph since
267262
-- we can only report diagnostics for the current file.
268263
type instance RuleResult ReportImportCycles = ()
269264

@@ -395,11 +390,6 @@ data NeedsCompilation = NeedsCompilation
395390
instance Hashable NeedsCompilation
396391
instance NFData NeedsCompilation
397392

398-
data GetDependencyInformation = GetDependencyInformation
399-
deriving (Eq, Show, Typeable, Generic)
400-
instance Hashable GetDependencyInformation
401-
instance NFData GetDependencyInformation
402-
403393
data GetModuleGraph = GetModuleGraph
404394
deriving (Eq, Show, Typeable, Generic)
405395
instance Hashable GetModuleGraph

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module Development.IDE.Core.Rules(
3434
getParsedModuleRule,
3535
getParsedModuleWithCommentsRule,
3636
getLocatedImportsRule,
37-
getDependencyInformationRule,
3837
reportImportCyclesRule,
3938
typeCheckRule,
4039
getDocMapRule,
@@ -209,7 +208,7 @@ toIdeResult = either (, Nothing) (([],) . Just)
209208
-- Does not include the file itself.
210209
getDependencies :: NormalizedFilePath -> Action (Maybe [NormalizedFilePath])
211210
getDependencies file =
212-
fmap transitiveModuleDeps . (`transitiveDeps` file) <$> use_ GetDependencyInformation file
211+
fmap transitiveModuleDeps . (`transitiveDeps` file) <$> useNoFile_ GetModuleGraph
213212

214213
getSourceFileSource :: NormalizedFilePath -> Action BS.ByteString
215214
getSourceFileSource nfp = do
@@ -521,16 +520,10 @@ rawDependencyInformation fs = do
521520
dropBootSuffix :: FilePath -> FilePath
522521
dropBootSuffix hs_src = reverse . drop (length @[] "-boot") . reverse $ hs_src
523522

524-
getDependencyInformationRule :: Recorder (WithPriority Log) -> Rules ()
525-
getDependencyInformationRule recorder =
526-
define (cmapWithPrio LogShake recorder) $ \GetDependencyInformation file -> do
527-
rawDepInfo <- rawDependencyInformation [file]
528-
pure ([], Just $ processDependencyInformation rawDepInfo)
529-
530523
reportImportCyclesRule :: Recorder (WithPriority Log) -> Rules ()
531524
reportImportCyclesRule recorder =
532525
define (cmapWithPrio LogShake recorder) $ \ReportImportCycles file -> fmap (\errs -> if null errs then ([], Just ()) else (errs, Nothing)) $ do
533-
DependencyInformation{..} <- use_ GetDependencyInformation file
526+
DependencyInformation{..} <- useNoFile_ GetModuleGraph
534527
let fileId = pathToId depPathIdMap file
535528
case IntMap.lookup (getFilePathId fileId) depErrorNodes of
536529
Nothing -> pure []
@@ -1224,7 +1217,6 @@ mainRule recorder RulesConfig{..} = do
12241217
getParsedModuleRule recorder
12251218
getParsedModuleWithCommentsRule recorder
12261219
getLocatedImportsRule recorder
1227-
getDependencyInformationRule recorder
12281220
reportImportCyclesRule recorder
12291221
typeCheckRule recorder
12301222
getDocMapRule recorder

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import Data.Text (Text)
4949
import qualified Data.Text as T
5050
import Data.Time (getCurrentTime)
5151
import Data.Typeable (Typeable)
52-
import Development.IDE (GetDependencyInformation (..),
52+
import Development.IDE (GetModuleGraph (..),
5353
GetLinkable (..),
5454
GetModSummary (..),
5555
GhcSessionIO (..),
@@ -326,7 +326,7 @@ runEvalCmd plId st EvalParams{..} =
326326
-- This can be optimised to only get the linkables for the symbols depended on by
327327
-- the statement we are parsing
328328
lbs <- liftIO $ runAction "eval: GetLinkables" st $ do
329-
linkables_needed <- reachableModules <$> use_ GetDependencyInformation nfp
329+
linkables_needed <- reachableModules <$> useNoFile_ GetModuleGraph
330330
uses_ GetLinkable (filter (/= nfp) linkables_needed) -- We don't need the linkable for the current module
331331
let hscEnv'' = hscEnv' { hsc_HPT = addListToHpt (hsc_HPT hscEnv') [(moduleName $ mi_module $ hm_iface hm, hm) | lb <- lbs, let hm = linkableHomeMod lb] }
332332

0 commit comments

Comments
 (0)