File tree Expand file tree Collapse file tree 11 files changed +45
-20
lines changed Expand file tree Collapse file tree 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
202202 where
203203 go (Var mn) = [[ (T. pack . occNameString . occName $ mn, bindRendered sig)
204204 | sig <- sigs
205- , inRange range (getSrcSpan ( bindName sig) )
205+ , inRange range (getSrcSpan $ bindName sig)
206206 , printOutputable mn == T. drop (T. length bindingPrefix) (printOutputable (bindName sig))
207207 ]]
208208 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
8686 -- Existed signatures' name
8787 sigNames = concat $ mapMaybe (\ (L _ r) -> getSigName r) cid_sigs
8888 toBindInfo (L l (L l' _)) = BindInfo
89- (getLoc l) -- bindSpan
90- (getLoc l') -- bindNameSpan
89+ (locA l) -- bindSpan
90+ (locA l') -- bindNameSpan
9191 in toBindInfo <$> filter (\ (L _ name) -> unLoc name `notElem` sigNames) bindNames
9292 getBindSpanWithoutSig _ = []
9393
Original file line number Diff line number Diff line change @@ -118,5 +118,5 @@ addMethodDecls ps mDecls range withSig = do
118118 foldM (insertAfter d) ps (reverse decls)
119119
120120findInstDecl :: 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
122122#endif
Original file line number Diff line number Diff line change @@ -99,17 +99,20 @@ rules recorder = do
9999 (_, maybe [] catMaybes -> instanceBinds) <-
100100 initTcWithGbl hsc gblEnv ghostSpan $ traverse bindToSig binds
101101 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
102114 instanceBindType _ _ = pure Nothing
103115
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-
113116properties :: Properties
114117 '[ 'PropertyKey " typelensOn" 'TBoolean]
115118properties = emptyProperties
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ isBindingName :: Name -> Bool
2525isBindingName name = isPrefixOf bindingPrefix $ occNameString $ nameOccName name
2626
2727-- | 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 )
3030
3131ghostSpan :: RealSrcSpan
3232ghostSpan = 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
7070 , goldenWithClass recorder " Creates a placeholder for other two methods" " T6" " 2" $ \ (_: _: ghAction: _) -> do
7171 executeCodeAction ghAction
7272 , 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
7474 executeCodeAction eqWithSig
7575 , goldenWithClass recorder " Insert pragma if not exist" " T7" " " $ \ (_: eqWithSig: _) -> do
7676 executeCodeAction eqWithSig
@@ -107,6 +107,7 @@ codeLensTests recorder = testGroup
107107 , goldenCodeLens recorder " Don't insert pragma while existing" " T13" 0
108108 , onlyRunForGhcVersions [GHC92 ] " Only ghc-9.2 enabled GHC2021 implicitly" $
109109 goldenCodeLens recorder " Don't insert pragma while GHC2021 enabled" " T14" 0
110+ , goldenCodeLens recorder " Qualified name" " T15" 0
110111 ]
111112
112113_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#-}
21module T15 where
2+ import qualified T15A
33
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
You can’t perform that action at this time.
0 commit comments