@@ -106,29 +106,19 @@ retrieCommand =
106
106
data RunRetrieParams = RunRetrieParams
107
107
{ description :: T. Text ,
108
108
rewrites :: [RewriteSpec ],
109
- originatingFile :: NormalizedUriJSON ,
109
+ originatingFile :: Uri ,
110
110
restrictToOriginatingFile :: Bool
111
111
}
112
112
deriving (Eq , Show , Generic , FromJSON , ToJSON )
113
-
114
- newtype NormalizedUriJSON = NormalizedUriJSON NormalizedUri
115
- deriving (Eq , Show )
116
-
117
- instance FromJSON NormalizedUriJSON where
118
- parseJSON = fmap NormalizedUriJSON . genericParseJSON Aeson. defaultOptions
119
-
120
- instance ToJSON NormalizedUriJSON where
121
- toJSON (NormalizedUriJSON x) = Aeson. genericToJSON Aeson. defaultOptions x
122
-
123
113
runRetrieCmd ::
124
114
LspFuncs a ->
125
115
IdeState ->
126
116
RunRetrieParams ->
127
117
IO (Either ResponseError Value , Maybe (ServerMethod , ApplyWorkspaceEditParams ))
128
- runRetrieCmd lsp state RunRetrieParams {originatingFile = NormalizedUriJSON nuri , .. } =
118
+ runRetrieCmd lsp state RunRetrieParams {originatingFile = uri , .. } =
129
119
withIndefiniteProgress lsp description Cancellable $ do
130
120
res <- runMaybeT $ do
131
- nfp <- MaybeT $ return $ uriToNormalizedFilePath nuri
121
+ nfp <- MaybeT $ return $ uriToNormalizedFilePath $ toNormalizedUri uri
132
122
(session, _) <- MaybeT $
133
123
runAction " Retrie.GhcSessionDeps" state $
134
124
useWithStale GhcSessionDeps $
@@ -181,20 +171,19 @@ provider :: CodeActionProvider IdeState
181
171
provider _a state plId (TextDocumentIdentifier uri) range ca = response $ do
182
172
let (J. CodeActionContext _diags _monly) = ca
183
173
nuri = toNormalizedUri uri
184
- nuriJson = NormalizedUriJSON nuri
185
174
nfp <- handleMaybe " uri" $ uriToNormalizedFilePath nuri
186
175
187
176
(ModSummary {ms_mod}, topLevelBinds, posMapping, hs_ruleds, hs_tyclds)
188
177
<- handleMaybeM " typecheck" $ runAction " retrie" state $ getBinds nfp
189
178
190
179
pos <- handleMaybe " pos" $ _start <$> fromCurrentRange posMapping range
191
180
let rewrites =
192
- concatMap (suggestBindRewrites nuriJson pos ms_mod) topLevelBinds
193
- ++ concatMap (suggestRuleRewrites nuriJson pos ms_mod) hs_ruleds
181
+ concatMap (suggestBindRewrites uri pos ms_mod) topLevelBinds
182
+ ++ concatMap (suggestRuleRewrites uri pos ms_mod) hs_ruleds
194
183
++ [ r
195
184
| TyClGroup {group_tyclds} <- hs_tyclds,
196
185
L l g <- group_tyclds,
197
- r <- suggestTypeRewrites nuriJson ms_mod g,
186
+ r <- suggestTypeRewrites uri ms_mod g,
198
187
pos `isInsideSrcSpan` l
199
188
200
189
]
@@ -233,7 +222,7 @@ getBinds nfp = runMaybeT $ do
233
222
return (tmrModSummary tm, topLevelBinds, posMapping, hs_ruleds, hs_tyclds)
234
223
235
224
suggestBindRewrites ::
236
- NormalizedUriJSON ->
225
+ Uri ->
237
226
Position ->
238
227
GHC. Module ->
239
228
HsBindLR GhcRn GhcRn ->
@@ -260,7 +249,7 @@ describeRestriction restrictToOriginatingFile =
260
249
261
250
suggestTypeRewrites ::
262
251
(Outputable (IdP pass )) =>
263
- NormalizedUriJSON ->
252
+ Uri ->
264
253
GHC. Module ->
265
254
TyClDecl pass ->
266
255
[(T. Text , CodeActionKind , RunRetrieParams )]
@@ -279,7 +268,7 @@ suggestTypeRewrites originatingFile ms_mod (SynDecl {tcdLName = L _ rdrName}) =
279
268
suggestTypeRewrites _ _ _ = []
280
269
281
270
suggestRuleRewrites ::
282
- NormalizedUriJSON ->
271
+ Uri ->
283
272
Position ->
284
273
GHC. Module ->
285
274
LRuleDecls pass ->
@@ -351,7 +340,6 @@ callRetrie ::
351
340
IO ([CallRetrieError ], WorkspaceEdit )
352
341
callRetrie state session rewrites origin restrictToOriginatingFile = do
353
342
knownFiles <- toKnownFiles . unhashed <$> readVar (knownTargetsVar $ shakeExtras state)
354
- print knownFiles
355
343
let reuseParsedModule f = do
356
344
pm <-
357
345
useOrFail " GetParsedModule" NoParse GetParsedModule f
0 commit comments