@@ -181,7 +181,7 @@ import System.FilePath hiding (makeRelative)
181
181
import System.IO.Unsafe (unsafePerformIO )
182
182
import System.Time.Extra
183
183
import UnliftIO (MonadUnliftIO (withRunInIO ))
184
- import Development.IDE.Graph.Internal.RuleInput (RuleInput , HasInput )
184
+ import Development.IDE.Graph.Internal.RuleInput (RuleInput , HasInput , Input ( NoFile ) )
185
185
186
186
187
187
data Log
@@ -345,7 +345,7 @@ type WithProgressFunc = forall a.
345
345
type WithIndefiniteProgressFunc = forall a .
346
346
T. Text -> LSP. ProgressCancellable -> IO a -> IO a
347
347
348
- type GetStalePersistent = InputPath i -> IdeAction (Maybe (Dynamic ,PositionDelta ,Maybe Int32 ))
348
+ type GetStalePersistent = NormalizedFilePath -> IdeAction (Maybe (Dynamic ,PositionDelta ,Maybe Int32 ))
349
349
350
350
getShakeExtras :: Action ShakeExtras
351
351
getShakeExtras = do
@@ -387,7 +387,7 @@ getPluginConfigAction plId = do
387
387
-- This is called when we don't already have a result, or computing the rule failed.
388
388
-- The result of this function will always be marked as 'stale', and a 'proper' rebuild of the rule will
389
389
-- be queued if the rule hasn't run before.
390
- addPersistentRule :: IdeRule k i is v => k -> (InputPath i -> IdeAction (Maybe (v ,PositionDelta ,Maybe Int32 ))) -> Rules ()
390
+ addPersistentRule :: IdeRule k i is v => k -> (NormalizedFilePath -> IdeAction (Maybe (v ,PositionDelta ,Maybe Int32 ))) -> Rules ()
391
391
addPersistentRule k getVal = do
392
392
ShakeExtras {persistentKeys} <- getShakeExtrasRules
393
393
void $ liftIO $ atomically $ modifyTVar' persistentKeys $ insertKeyMap (newKey k) (fmap (fmap (first3 toDyn)) . getVal)
@@ -456,7 +456,7 @@ getIdeOptionsIO ide = do
456
456
-- | Return the most recent, potentially stale, value and a PositionMapping
457
457
-- for the version of that value.
458
458
lastValueIO :: IdeRule k i is v => ShakeExtras -> k -> InputPath i -> IO (Maybe (v , PositionMapping ))
459
- lastValueIO s@ ShakeExtras {positionMapping,persistentKeys,state} k file = do
459
+ lastValueIO s@ ShakeExtras {positionMapping,persistentKeys,state} k ( InputPath file) = do
460
460
461
461
let readPersistent
462
462
| IdeTesting testing <- ideTesting s -- Don't read stale persistent values in tests
@@ -593,7 +593,7 @@ setValues :: IdeRule k i is v
593
593
-> Value v
594
594
-> Vector FileDiagnostic
595
595
-> STM ()
596
- setValues state key file val diags =
596
+ setValues state key ( InputPath file) val diags =
597
597
STM. insert (ValueWithDiagnostics (fmap toDyn val) diags) (toKey key file) state
598
598
599
599
@@ -618,7 +618,7 @@ getValues ::
618
618
k ->
619
619
InputPath i ->
620
620
STM (Maybe (Value v , Vector FileDiagnostic ))
621
- getValues state key file = do
621
+ getValues state key ( InputPath file) = do
622
622
STM. lookup (toKey key file) state >>= \ case
623
623
Nothing -> pure Nothing
624
624
Just (ValueWithDiagnostics v diagsV) -> do
@@ -1094,7 +1094,7 @@ useWithStaleFast' key file = do
1094
1094
1095
1095
-- Async trigger the key to be built anyway because we want to
1096
1096
-- keep updating the value in the key.
1097
- waitValue <- delayedAction $ mkDelayedAction (" C:" ++ show key ++ " :" ++ fromNormalizedFilePath file) Debug $ use key file
1097
+ waitValue <- delayedAction $ mkDelayedAction (" C:" ++ show key ++ " :" ++ fromNormalizedFilePath (unInputPath file) ) Debug $ use key file
1098
1098
1099
1099
s@ ShakeExtras {state} <- askShake
1100
1100
r <- liftIO $ atomicallyNamed " useStateFast" $ getValues state key file
@@ -1113,8 +1113,8 @@ useWithStaleFast' key file = do
1113
1113
res <- lastValueIO s key file
1114
1114
pure $ FastResult res waitValue
1115
1115
1116
- useNoFile :: IdeRule k i is v => k -> Action (Maybe v )
1117
- useNoFile key = use key emptyFilePath
1116
+ useNoFile :: forall k is v . IdeRule k NoFile is v => k -> Action (Maybe v )
1117
+ useNoFile key = use key ( InputPath @ NoFile emptyFilePath)
1118
1118
1119
1119
-- Requests a rule if available.
1120
1120
--
@@ -1125,8 +1125,8 @@ useNoFile key = use key emptyFilePath
1125
1125
use_ :: IdeRule k i is v => k -> InputPath i -> Action v
1126
1126
use_ key file = runIdentity <$> uses_ key (Identity file)
1127
1127
1128
- useNoFile_ :: IdeRule k i is v => k -> Action v
1129
- useNoFile_ key = use_ key emptyFilePath
1128
+ useNoFile_ :: forall k is v . IdeRule k NoFile is v => k -> Action v
1129
+ useNoFile_ key = use_ key ( InputPath @ NoFile emptyFilePath)
1130
1130
1131
1131
-- | Plural version of `use_`
1132
1132
--
@@ -1144,21 +1144,21 @@ uses_ key files = do
1144
1144
-- | Plural version of 'use'
1145
1145
uses :: (Traversable f , IdeRule k i is v )
1146
1146
=> k -> f (InputPath i ) -> Action (f (Maybe v ))
1147
- uses key files = fmap (\ (A value) -> currentValue value) <$> apply (fmap (Q . (key,)) files)
1147
+ uses key files = fmap (\ (A value) -> currentValue value) <$> apply (fmap (Q . (key,) . unInputPath ) files)
1148
1148
1149
1149
-- | Return the last computed result which might be stale.
1150
1150
usesWithStale :: (Traversable f , IdeRule k i is v )
1151
1151
=> k -> f (InputPath i ) -> Action (f (Maybe (v , PositionMapping )))
1152
1152
usesWithStale key files = do
1153
- _ <- apply (fmap (Q . (key,)) files)
1153
+ _ <- apply (fmap (Q . (key,) . unInputPath ) files)
1154
1154
-- We don't look at the result of the 'apply' since 'lastValue' will
1155
1155
-- return the most recent successfully computed value regardless of
1156
1156
-- whether the rule succeeded or not.
1157
1157
traverse (lastValue key) files
1158
1158
1159
1159
useWithoutDependency :: IdeRule k i is v
1160
1160
=> k -> InputPath i -> Action (Maybe v )
1161
- useWithoutDependency key file =
1161
+ useWithoutDependency key ( InputPath file) =
1162
1162
(\ (Identity (A value)) -> currentValue value) <$> applyWithoutDependency (Identity (Q (key, file)))
1163
1163
1164
1164
data RuleBody k i v
@@ -1172,7 +1172,8 @@ data RuleBody k i v
1172
1172
1173
1173
-- | Define a new Rule with early cutoff
1174
1174
defineEarlyCutoff
1175
- :: IdeRule k i is v
1175
+ :: forall k i is v
1176
+ . IdeRule k i is v
1176
1177
=> Recorder (WithPriority Log )
1177
1178
-> RuleBody k i v
1178
1179
-> Rules ()
@@ -1181,35 +1182,35 @@ defineEarlyCutoff recorder (Rule op) = addRule $ \(Q (key, file)) (old :: Maybe
1181
1182
let diagnostics ver diags = do
1182
1183
traceDiagnostics diags
1183
1184
updateFileDiagnostics recorder file ver (newKey key) extras . map (\ (_,y,z) -> (y,z)) $ diags
1184
- defineEarlyCutoff' diagnostics (==) key file old mode $ const $ op key file
1185
+ defineEarlyCutoff' diagnostics (==) key ( InputPath @ i file) old mode $ const $ op key ( InputPath @ i file)
1185
1186
defineEarlyCutoff recorder (RuleNoDiagnostics op) = addRule $ \ (Q (key, file)) (old :: Maybe BS. ByteString ) mode -> otTracedAction key file mode traceA $ \ traceDiagnostics -> do
1186
1187
let diagnostics _ver diags = do
1187
1188
traceDiagnostics diags
1188
1189
mapM_ (logWith recorder Warning . LogDefineEarlyCutoffRuleNoDiagHasDiag ) diags
1189
- defineEarlyCutoff' diagnostics (==) key file old mode $ const $ second (mempty ,) <$> op key file
1190
+ defineEarlyCutoff' diagnostics (==) key ( InputPath @ i file) old mode $ const $ second (mempty ,) <$> op key ( InputPath @ i file)
1190
1191
defineEarlyCutoff recorder RuleWithCustomNewnessCheck {.. } =
1191
1192
addRule $ \ (Q (key, file)) (old :: Maybe BS. ByteString ) mode ->
1192
1193
otTracedAction key file mode traceA $ \ traceDiagnostics -> do
1193
1194
let diagnostics _ver diags = do
1194
1195
traceDiagnostics diags
1195
1196
mapM_ (logWith recorder Warning . LogDefineEarlyCutoffRuleCustomNewnessHasDiag ) diags
1196
- defineEarlyCutoff' diagnostics newnessCheck key file old mode $
1197
- const $ second (mempty ,) <$> build key file
1197
+ defineEarlyCutoff' diagnostics newnessCheck key ( InputPath @ i file) old mode $
1198
+ const $ second (mempty ,) <$> build key ( InputPath @ i file)
1198
1199
defineEarlyCutoff recorder (RuleWithOldValue op) = addRule $ \ (Q (key, file)) (old :: Maybe BS. ByteString ) mode -> otTracedAction key file mode traceA $ \ traceDiagnostics -> do
1199
1200
extras <- getShakeExtras
1200
1201
let diagnostics ver diags = do
1201
1202
traceDiagnostics diags
1202
1203
updateFileDiagnostics recorder file ver (newKey key) extras . map (\ (_,y,z) -> (y,z)) $ diags
1203
- defineEarlyCutoff' diagnostics (==) key file old mode $ op key file
1204
+ defineEarlyCutoff' diagnostics (==) key ( InputPath @ i file) old mode $ op key ( InputPath @ i file)
1204
1205
1205
- defineNoFile :: IdeRule k i is v => Recorder (WithPriority Log ) -> (k -> Action v ) -> Rules ()
1206
+ defineNoFile :: forall k i is v . IdeRule k i is v => Recorder (WithPriority Log ) -> (k -> Action v ) -> Rules ()
1206
1207
defineNoFile recorder f = defineNoDiagnostics recorder $ \ k file -> do
1207
- if file == emptyFilePath then do res <- f k; return (Just res) else
1208
+ if file == ( InputPath @ i emptyFilePath) then do res <- f k; return (Just res) else
1208
1209
fail $ " Rule " ++ show k ++ " should always be called with the empty string for a file"
1209
1210
1210
- defineEarlyCutOffNoFile :: IdeRule k i is v => Recorder (WithPriority Log ) -> (k -> Action (BS. ByteString , v )) -> Rules ()
1211
- defineEarlyCutOffNoFile recorder f = defineEarlyCutoff recorder $ RuleNoDiagnostics $ \ k ( InputPath file) -> do
1212
- if file == emptyFilePath then do (hashString, res) <- f k; return (Just hashString, Just res) else
1211
+ defineEarlyCutOffNoFile :: forall k i is v . IdeRule k i is v => Recorder (WithPriority Log ) -> (k -> Action (BS. ByteString , v )) -> Rules ()
1212
+ defineEarlyCutOffNoFile recorder f = defineEarlyCutoff recorder $ RuleNoDiagnostics $ \ k file -> do
1213
+ if file == ( InputPath @ i emptyFilePath) then do (hashString, res) <- f k; return (Just hashString, Just res) else
1213
1214
fail $ " Rule " ++ show k ++ " should always be called with the empty string for a file"
1214
1215
1215
1216
defineEarlyCutoff'
0 commit comments