Skip to content

Commit dab3b7f

Browse files
committed
Remove GetDependencyInformation in favour of GetModuleGraph
1 parent 3b05bde commit dab3b7f

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

@@ -401,11 +396,6 @@ data NeedsCompilation = NeedsCompilation
401396
instance Hashable NeedsCompilation
402397
instance NFData NeedsCompilation
403398

404-
data GetDependencyInformation = GetDependencyInformation
405-
deriving (Eq, Show, Typeable, Generic)
406-
instance Hashable GetDependencyInformation
407-
instance NFData GetDependencyInformation
408-
409399
data GetModuleGraph = GetModuleGraph
410400
deriving (Eq, Show, Typeable, Generic)
411401
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
@@ -518,16 +517,10 @@ rawDependencyInformation fs = do
518517
dropBootSuffix :: FilePath -> FilePath
519518
dropBootSuffix hs_src = reverse . drop (length @[] "-boot") . reverse $ hs_src
520519

521-
getDependencyInformationRule :: Recorder (WithPriority Log) -> Rules ()
522-
getDependencyInformationRule recorder =
523-
define (cmapWithPrio LogShake recorder) $ \GetDependencyInformation file -> do
524-
rawDepInfo <- rawDependencyInformation [file]
525-
pure ([], Just $ processDependencyInformation rawDepInfo)
526-
527520
reportImportCyclesRule :: Recorder (WithPriority Log) -> Rules ()
528521
reportImportCyclesRule recorder =
529522
define (cmapWithPrio LogShake recorder) $ \ReportImportCycles file -> fmap (\errs -> if null errs then ([], Just ()) else (errs, Nothing)) $ do
530-
DependencyInformation{..} <- use_ GetDependencyInformation file
523+
DependencyInformation{..} <- useNoFile_ GetModuleGraph
531524
let fileId = pathToId depPathIdMap file
532525
case IntMap.lookup (getFilePathId fileId) depErrorNodes of
533526
Nothing -> pure []
@@ -1222,7 +1215,6 @@ mainRule recorder RulesConfig{..} = do
12221215
getParsedModuleRule recorder
12231216
getParsedModuleWithCommentsRule recorder
12241217
getLocatedImportsRule recorder
1225-
getDependencyInformationRule recorder
12261218
reportImportCyclesRule recorder
12271219
typeCheckRule recorder
12281220
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
@@ -48,7 +48,7 @@ import Data.Text (Text)
4848
import qualified Data.Text as T
4949
import Data.Time (getCurrentTime)
5050
import Data.Typeable (Typeable)
51-
import Development.IDE (GetDependencyInformation (..),
51+
import Development.IDE (GetModuleGraph (..),
5252
GetLinkable (..),
5353
GetModSummary (..),
5454
GhcSessionIO (..),
@@ -324,7 +324,7 @@ runEvalCmd plId st EvalParams{..} =
324324
-- This can be optimised to only get the linkables for the symbols depended on by
325325
-- the statement we are parsing
326326
lbs <- liftIO $ runAction "eval: GetLinkables" st $ do
327-
linkables_needed <- reachableModules <$> use_ GetDependencyInformation nfp
327+
linkables_needed <- reachableModules <$> useNoFile_ GetModuleGraph
328328
uses_ GetLinkable (filter (/= nfp) linkables_needed) -- We don't need the linkable for the current module
329329
let hscEnv'' = hscEnv' { hsc_HPT = addListToHpt (hsc_HPT hscEnv') [(moduleName $ mi_module $ hm_iface hm, hm) | lb <- lbs, let hm = linkableHomeMod lb] }
330330

0 commit comments

Comments
 (0)