Skip to content

Commit 3fe80a1

Browse files
committed
delete GetDependencies
1 parent fbaa203 commit 3fe80a1

File tree

4 files changed

+7
-28
lines changed

4 files changed

+7
-28
lines changed

Diff for: ghcide/src/Development/IDE/Core/RuleTypes.hs

+1-9
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ type instance RuleResult GetParsedModuleWithComments = ParsedModule
7373
-- a module could not be parsed or an import cycle.
7474
type instance RuleResult GetDependencyInformation = DependencyInformation
7575

76-
-- | Transitive module and pkg dependencies based on the information produced by GetDependencyInformation.
77-
-- This rule is also responsible for calling ReportImportCycles for each file in the transitive closure.
78-
type instance RuleResult GetDependencies = TransitiveDependencies
79-
8076
type instance RuleResult GetModuleGraph = DependencyInformation
8177

8278
data GetKnownTargets = GetKnownTargets
@@ -234,6 +230,7 @@ type instance RuleResult GetDocMap = DocAndKindMap
234230
type instance RuleResult GhcSession = HscEnvEq
235231

236232
-- | A GHC session preloaded with all the dependencies
233+
-- This rule is also responsible for calling ReportImportCycles for the direct dependencies
237234
type instance RuleResult GhcSessionDeps = HscEnvEq
238235

239236
-- | Resolve the imports in a module to the file path of a module in the same package
@@ -389,11 +386,6 @@ data ReportImportCycles = ReportImportCycles
389386
instance Hashable ReportImportCycles
390387
instance NFData ReportImportCycles
391388

392-
data GetDependencies = GetDependencies
393-
deriving (Eq, Show, Typeable, Generic)
394-
instance Hashable GetDependencies
395-
instance NFData GetDependencies
396-
397389
data TypeCheck = TypeCheck
398390
deriving (Eq, Show, Typeable, Generic)
399391
instance Hashable TypeCheck

Diff for: ghcide/src/Development/IDE/Core/Rules.hs

+3-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
--
1212
module Development.IDE.Core.Rules(
1313
-- * Types
14-
IdeState, GetDependencies(..), GetParsedModule(..), TransitiveDependencies(..),
14+
IdeState, GetParsedModule(..), TransitiveDependencies(..),
1515
Priority(..), GhcSessionIO(..), GetClientSettings(..),
1616
-- * Functions
1717
priorityTypeCheck,
@@ -35,7 +35,6 @@ module Development.IDE.Core.Rules(
3535
getLocatedImportsRule,
3636
getDependencyInformationRule,
3737
reportImportCyclesRule,
38-
getDependenciesRule,
3938
typeCheckRule,
4039
getDocMapRule,
4140
loadGhcSession,
@@ -161,7 +160,8 @@ toIdeResult = either (, Nothing) (([],) . Just)
161160
-- | Get all transitive file dependencies of a given module.
162161
-- Does not include the file itself.
163162
getDependencies :: NormalizedFilePath -> Action (Maybe [NormalizedFilePath])
164-
getDependencies file = fmap transitiveModuleDeps <$> use GetDependencies file
163+
getDependencies file =
164+
fmap transitiveModuleDeps . (`transitiveDeps` file) <$> use_ GetDependencyInformation file
165165

166166
getSourceFileSource :: NormalizedFilePath -> Action BS.ByteString
167167
getSourceFileSource nfp = do
@@ -490,18 +490,6 @@ reportImportCyclesRule =
490490
pure (moduleNameString . moduleName . ms_mod $ ms)
491491
showCycle mods = T.intercalate ", " (map T.pack mods)
492492

493-
-- returns all transitive dependencies in topological order.
494-
-- NOTE: result does not include the argument file.
495-
getDependenciesRule :: Rules ()
496-
getDependenciesRule =
497-
defineEarlyCutoff $ RuleNoDiagnostics $ \GetDependencies file -> do
498-
depInfo <- use_ GetDependencyInformation file
499-
let allFiles = reachableModules depInfo
500-
_ <- uses_ ReportImportCycles allFiles
501-
opts <- getIdeOptions
502-
let mbFingerprints = map (Util.fingerprintString . fromNormalizedFilePath) allFiles <$ optShakeFiles opts
503-
return (fingerprintToBS . Util.fingerprintFingerprints <$> mbFingerprints, transitiveDeps depInfo file)
504-
505493
getHieAstsRule :: Rules ()
506494
getHieAstsRule =
507495
define $ \GetHieAst f -> do
@@ -1065,7 +1053,6 @@ mainRule = do
10651053
getLocatedImportsRule
10661054
getDependencyInformationRule
10671055
reportImportCyclesRule
1068-
getDependenciesRule
10691056
typeCheckRule
10701057
getDocMapRule
10711058
loadGhcSession

Diff for: ghcide/src/Development/IDE/Import/DependencyInformation.hs

+1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ immediateReverseDependencies file DependencyInformation{..} = do
327327
FilePathId cur_id <- lookupPathToId depPathIdMap file
328328
return $ map (idToPath depPathIdMap . FilePathId) (maybe mempty IntSet.toList (IntMap.lookup cur_id depReverseModuleDeps))
329329

330+
-- | returns all transitive dependencies in topological order.
330331
transitiveDeps :: DependencyInformation -> NormalizedFilePath -> Maybe TransitiveDependencies
331332
transitiveDeps DependencyInformation{..} file = do
332333
let !fileId = pathToId depPathIdMap file

Diff for: ghcide/src/Development/IDE/Plugin/Test.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import Development.IDE.Core.RuleTypes
2929
import Development.IDE.Core.Service
3030
import Development.IDE.Core.Shake
3131
import Development.IDE.GHC.Compat
32-
import Development.IDE.Graph (Action)
33-
import Development.IDE.Graph.Database (shakeLastBuildKeys)
32+
import Development.IDE.Graph (Action)
33+
import Development.IDE.Graph.Database (shakeLastBuildKeys)
3434
import Development.IDE.Types.Action
3535
import Development.IDE.Types.HscEnvEq (HscEnvEq (hscEnv))
3636
import Development.IDE.Types.Location (fromUri)
@@ -123,7 +123,6 @@ parseAction "getparsedmodule" fp = Right . isJust <$> use GetParsedModule fp
123123
parseAction "ghcsession" fp = Right . isJust <$> use GhcSession fp
124124
parseAction "ghcsessiondeps" fp = Right . isJust <$> use GhcSessionDeps fp
125125
parseAction "gethieast" fp = Right . isJust <$> use GetHieAst fp
126-
parseAction "getDependencies" fp = Right . isJust <$> use GetDependencies fp
127126
parseAction "getFileContents" fp = Right . isJust <$> use GetFileContents fp
128127
parseAction other _ = return $ Left $ "Cannot parse ide rule: " <> pack (original other)
129128

0 commit comments

Comments
 (0)