@@ -21,6 +21,7 @@ import Data.List
21
21
import qualified Data.Map.Strict as Map
22
22
import Data.Maybe
23
23
import qualified Data.Text as T
24
+ import qualified Data.Set as Set
24
25
import Development.IDE hiding (pluginHandlers )
25
26
import Development.IDE.Core.PositionMapping (fromCurrentRange ,
26
27
toCurrentRange )
@@ -217,33 +218,19 @@ codeAction state plId (CodeActionParams _ _ docId _ context) = liftIO $ fmap (fr
217
218
HAR {hieAst = hf} ->
218
219
pure
219
220
$ head . head
220
- #if MIN_VERSION_ghc(9,2,0)
221
- $ pointCommand hf (fromJust (fromCurrentRange pmap range) ^. J. start & J. character +~ 1 )
222
- (Map. keys . Map. filter isClassNodeIdentifier . Compat. getNodeIds)
223
- #elif MIN_VERSION_ghc(9,0,0)
224
221
$ pointCommand hf (fromJust (fromCurrentRange pmap range) ^. J. start & J. character -~ 1 )
225
222
( (Map. keys . Map. filter isClassNodeIdentifier . Compat. getNodeIds)
226
223
<=< nodeChildren
227
224
)
228
- #else
229
- $ pointCommand hf (fromJust (fromCurrentRange pmap range) ^. J. start & J. character -~ 1 )
230
- ( (Map. keys . Map. filter isClassNodeIdentifier . Compat. getNodeIds)
231
- <=< nodeChildren
232
- )
233
- #endif
234
225
235
226
findClassFromIdentifier docPath (Right name) = do
236
227
(hscEnv -> hscenv, _) <- MaybeT . runAction " classplugin" state $ useWithStale GhcSessionDeps docPath
237
228
(tmrTypechecked -> thisMod, _) <- MaybeT . runAction " classplugin" state $ useWithStale TypeCheck docPath
238
229
MaybeT . fmap snd . initTcWithGbl hscenv thisMod ghostSpan $ do
239
230
tcthing <- tcLookup name
240
231
case tcthing of
241
- #if !MIN_VERSION_ghc(9,2,0)
242
232
AGlobal (AConLike (RealDataCon con))
243
233
| Just cls <- tyConClass_maybe (dataConOrigTyCon con) -> pure cls
244
- #else
245
- AGlobal (ATyCon tycon) | Just cls <- tyConClass_maybe tycon -> pure cls
246
- #endif
247
234
_ -> panic " Ide.Plugin.Class.findClassFromIdentifier"
248
235
findClassFromIdentifier _ (Left _) = panic " Ide.Plugin.Class.findClassIdentifier"
249
236
@@ -254,7 +241,7 @@ containRange :: Range -> SrcSpan -> Bool
254
241
containRange range x = isInsideSrcSpan (range ^. J. start) x || isInsideSrcSpan (range ^. J. end) x
255
242
256
243
isClassNodeIdentifier :: IdentifierDetails a -> Bool
257
- isClassNodeIdentifier = isNothing . identType
244
+ isClassNodeIdentifier ident = ( isNothing . identType) ident && Use `Set.member` (identInfo ident)
258
245
259
246
isClassMethodWarning :: T. Text -> Bool
260
247
isClassMethodWarning = T. isPrefixOf " • No explicit implementation for"
0 commit comments