Skip to content

Commit

Permalink
add comments and use custom newness check in ghcide too
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Oct 24, 2021
1 parent 49f2f6a commit 7dfc9eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ghcide/src/Development/IDE/Core/RuleTypes.hs
Expand Up @@ -49,6 +49,9 @@ data LinkableType = ObjectLinkable | BCOLinkable
instance Hashable LinkableType
instance NFData LinkableType

-- | Encode the linkable into an ordered bytestring.
-- This is used to drive an ordered "newness" predicate in the
-- 'NeedsCompilation' build rule.
encodeLinkableType :: Maybe LinkableType -> ByteString
encodeLinkableType Nothing = "0"
encodeLinkableType (Just BCOLinkable) = "1"
Expand Down
8 changes: 7 additions & 1 deletion ghcide/src/Development/IDE/Core/Rules.hs
Expand Up @@ -1080,7 +1080,13 @@ mainRule = do
getClientSettingsRule
getHieAstsRule
getBindingsRule
defineEarlyCutoff $ RuleNoDiagnostics $ \NeedsCompilation file ->
-- This rule uses a custom newness check that relies on the encoding
-- produced by 'encodeLinkable'. This works as follows:
-- * <previous> -> <new>
-- * ObjectLinkable -> BCOLinkable : the prev linkable can be reused, signal "no change"
-- * Object/BCO -> NoLinkable : the prev linkable can be ignored, signal "no change"
-- * otherwise : the prev linkable cannot be reused, signal "value has changed"
defineEarlyCutoff $ RuleWithCustomNewnessCheck (<=) $ \NeedsCompilation file ->
needsCompilationRule file
generateCoreRule
getImportMapRule
Expand Down

0 comments on commit 7dfc9eb

Please sign in to comment.