File tree 11 files changed +45
-20
lines changed
11 files changed +45
-20
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ minDefToMethodGroups range sigs = go
202
202
where
203
203
go (Var mn) = [[ (T. pack . occNameString . occName $ mn, bindRendered sig)
204
204
| sig <- sigs
205
- , inRange range (getSrcSpan ( bindName sig) )
205
+ , inRange range (getSrcSpan $ bindName sig)
206
206
, printOutputable mn == T. drop (T. length bindingPrefix) (printOutputable (bindName sig))
207
207
]]
208
208
go (Or ms) = concatMap (go . unLoc) ms
Original file line number Diff line number Diff line change @@ -86,8 +86,8 @@ codeLens state plId CodeLensParams{..} = do
86
86
-- Existed signatures' name
87
87
sigNames = concat $ mapMaybe (\ (L _ r) -> getSigName r) cid_sigs
88
88
toBindInfo (L l (L l' _)) = BindInfo
89
- (getLoc l) -- bindSpan
90
- (getLoc l') -- bindNameSpan
89
+ (locA l) -- bindSpan
90
+ (locA l') -- bindNameSpan
91
91
in toBindInfo <$> filter (\ (L _ name) -> unLoc name `notElem` sigNames) bindNames
92
92
getBindSpanWithoutSig _ = []
93
93
Original file line number Diff line number Diff line change @@ -118,5 +118,5 @@ addMethodDecls ps mDecls range withSig = do
118
118
foldM (insertAfter d) ps (reverse decls)
119
119
120
120
findInstDecl :: ParsedSource -> Range -> Transform (LHsDecl GhcPs )
121
- findInstDecl ps range = head . filter (inRange range) <$> hsDecls ps
121
+ findInstDecl ps range = head . filter (inRange range . getLoc ) <$> hsDecls ps
122
122
#endif
Original file line number Diff line number Diff line change @@ -99,17 +99,20 @@ rules recorder = do
99
99
(_, maybe [] catMaybes -> instanceBinds) <-
100
100
initTcWithGbl hsc gblEnv ghostSpan $ traverse bindToSig binds
101
101
pure $ Just $ InstanceBindTypeSigsResult instanceBinds
102
+ where
103
+ rdrEnv = tcg_rdr_env gblEnv
104
+ showDoc ty = showSDocForUser' hsc (mkPrintUnqualifiedDefault hsc rdrEnv) (pprSigmaType ty)
105
+
106
+ bindToSig id = do
107
+ let name = idName id
108
+ whenMaybe (isBindingName name) $ do
109
+ env <- tcInitTidyEnv
110
+ let (_, ty) = tidyOpenType env (idType id )
111
+ pure $ InstanceBindTypeSig name
112
+ (prettyBindingNameString (printOutputable name) <> " :: " <> T. pack (showDoc ty))
113
+ Nothing
102
114
instanceBindType _ _ = pure Nothing
103
115
104
- bindToSig id = do
105
- let name = idName id
106
- whenMaybe (isBindingName name) $ do
107
- env <- tcInitTidyEnv
108
- let (_, ty) = tidyOpenType env (idType id )
109
- pure $ InstanceBindTypeSig name
110
- (prettyBindingNameString (printOutputable name) <> " :: " <> printOutputable (pprSigmaType ty))
111
- Nothing
112
-
113
116
properties :: Properties
114
117
'[ 'PropertyKey " typelensOn" 'TBoolean]
115
118
properties = emptyProperties
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ isBindingName :: Name -> Bool
25
25
isBindingName name = isPrefixOf bindingPrefix $ occNameString $ nameOccName name
26
26
27
27
-- | Check if some `HasSrcSpan` value in the given range
28
- inRange :: HasSrcSpan a => Range -> a -> Bool
29
- inRange range s = maybe False (subRange range) (srcSpanToRange (getLoc s) )
28
+ inRange :: Range -> SrcSpan -> Bool
29
+ inRange range s = maybe False (subRange range) (srcSpanToRange s )
30
30
31
31
ghostSpan :: RealSrcSpan
32
32
ghostSpan = realSrcLocSpan $ mkRealSrcLoc (fsLit " <haskell-language-sever>" ) 1 1
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ codeActionTests recorder = testGroup
70
70
, goldenWithClass recorder " Creates a placeholder for other two methods" " T6" " 2" $ \ (_: _: ghAction: _) -> do
71
71
executeCodeAction ghAction
72
72
, onlyRunForGhcVersions [GHC92 ] " Only ghc-9.2 enabled GHC2021 implicitly" $
73
- goldenWithClass recorder " Don't insert pragma with GHC2021" " T15 " " " $ \ (_: eqWithSig: _) -> do
73
+ goldenWithClass recorder " Don't insert pragma with GHC2021" " T16 " " " $ \ (_: eqWithSig: _) -> do
74
74
executeCodeAction eqWithSig
75
75
, goldenWithClass recorder " Insert pragma if not exist" " T7" " " $ \ (_: eqWithSig: _) -> do
76
76
executeCodeAction eqWithSig
@@ -107,6 +107,7 @@ codeLensTests recorder = testGroup
107
107
, goldenCodeLens recorder " Don't insert pragma while existing" " T13" 0
108
108
, onlyRunForGhcVersions [GHC92 ] " Only ghc-9.2 enabled GHC2021 implicitly" $
109
109
goldenCodeLens recorder " Don't insert pragma while GHC2021 enabled" " T14" 0
110
+ , goldenCodeLens recorder " Qualified name" " T15" 0
110
111
]
111
112
112
113
_CACodeAction :: Prism' (Command |? CodeAction ) CodeAction
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE InstanceSigs #-}
2
+ module T15 where
3
+ import qualified T15A
4
+
5
+ class F a where
6
+ f :: a
7
+
8
+ instance F T15A. A where
9
+ f :: T15A. A
10
+ f = undefined
Original file line number Diff line number Diff line change 1
- {-# LANGUAGE GHC2021#-}
2
1
module T15 where
2
+ import qualified T15A
3
3
4
- data A
5
- instance Eq A
4
+ class F a where
5
+ f :: a
6
+
7
+ instance F T15A. A where
8
+ f = undefined
Original file line number Diff line number Diff line change
1
+ module T15A where
2
+
3
+ data A
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE GHC2021#-}
2
+ module T16 where
3
+
4
+ data A
5
+ instance Eq A
Original file line number Diff line number Diff line change 1
1
cradle :
2
2
direct :
3
- arguments : [-XHaskell2010]
3
+ arguments : [-XHaskell2010, T15A ]
You can’t perform that action at this time.
0 commit comments