Skip to content

Commit 7dfc9eb

Browse files
committed
add comments and use custom newness check in ghcide too
1 parent 49f2f6a commit 7dfc9eb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ data LinkableType = ObjectLinkable | BCOLinkable
4949
instance Hashable LinkableType
5050
instance NFData LinkableType
5151

52+
-- | Encode the linkable into an ordered bytestring.
53+
-- This is used to drive an ordered "newness" predicate in the
54+
-- 'NeedsCompilation' build rule.
5255
encodeLinkableType :: Maybe LinkableType -> ByteString
5356
encodeLinkableType Nothing = "0"
5457
encodeLinkableType (Just BCOLinkable) = "1"

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,13 @@ mainRule = do
10801080
getClientSettingsRule
10811081
getHieAstsRule
10821082
getBindingsRule
1083-
defineEarlyCutoff $ RuleNoDiagnostics $ \NeedsCompilation file ->
1083+
-- This rule uses a custom newness check that relies on the encoding
1084+
-- produced by 'encodeLinkable'. This works as follows:
1085+
-- * <previous> -> <new>
1086+
-- * ObjectLinkable -> BCOLinkable : the prev linkable can be reused, signal "no change"
1087+
-- * Object/BCO -> NoLinkable : the prev linkable can be ignored, signal "no change"
1088+
-- * otherwise : the prev linkable cannot be reused, signal "value has changed"
1089+
defineEarlyCutoff $ RuleWithCustomNewnessCheck (<=) $ \NeedsCompilation file ->
10841090
needsCompilationRule file
10851091
generateCoreRule
10861092
getImportMapRule

0 commit comments

Comments
 (0)