File tree 8 files changed +38
-13
lines changed 8 files changed +38
-13
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ import qualified Language.LSP.Types.Lens as J
36
36
addMethodPlaceholders :: PluginId -> CommandFunction IdeState AddMinimalMethodsParams
37
37
addMethodPlaceholders plId state param@ AddMinimalMethodsParams {.. } = do
38
38
caps <- getClientCapabilities
39
- response $ do
39
+ pluginResponse $ do
40
40
nfp <- getNormalizedFilePath plId uri
41
41
pm <- handleMaybeM " Unable to GetParsedModule"
42
42
$ liftIO
@@ -77,7 +77,7 @@ addMethodPlaceholders plId state param@AddMinimalMethodsParams{..} = do
77
77
-- This implementation is ad-hoc in a sense that the diagnostic detection mechanism is
78
78
-- sensitive to the format of diagnostic messages from GHC.
79
79
codeAction :: PluginMethodHandler IdeState TextDocumentCodeAction
80
- codeAction state plId (CodeActionParams _ _ docId _ context) = response $ do
80
+ codeAction state plId (CodeActionParams _ _ docId _ context) = pluginResponse $ do
81
81
nfp <- getNormalizedFilePath plId uri
82
82
actions <- join <$> mapM (mkActions nfp) methodDiags
83
83
pure $ List actions
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import qualified Language.LSP.Types.Lens as J
25
25
codeLens :: PluginMethodHandler IdeState TextDocumentCodeLens
26
26
codeLens state plId CodeLensParams {.. } = do
27
27
enabled <- enableTypeLens <$> getCompletionsConfig plId
28
- if not enabled then pure $ pure $ List [] else response $ do
28
+ if not enabled then pure $ pure $ List [] else pluginResponse $ do
29
29
nfp <- getNormalizedFilePath plId uri
30
30
tmr <- handleMaybeM " Unable to typecheak"
31
31
$ liftIO
Original file line number Diff line number Diff line change @@ -93,17 +93,20 @@ rules recorder = do
93
93
(_, maybe [] catMaybes -> instanceBinds) <-
94
94
initTcWithGbl hsc gblEnv ghostSpan $ traverse bindToSig binds
95
95
pure $ Just $ InstanceBindTypeSigsResult instanceBinds
96
+ where
97
+ rdrEnv = tcg_rdr_env gblEnv
98
+ showDoc ty = showSDocForUser' hsc (mkPrintUnqualifiedDefault hsc rdrEnv) (pprSigmaType ty)
99
+
100
+ bindToSig id = do
101
+ let name = idName id
102
+ whenMaybe (isBindingName name) $ do
103
+ env <- tcInitTidyEnv
104
+ let (_, ty) = tidyOpenType env (idType id )
105
+ pure $ InstanceBindTypeSig name
106
+ (prettyBindingNameString (printOutputable name) <> " :: " <> T. pack (showDoc ty))
107
+ Nothing
96
108
instanceBindType _ _ = pure Nothing
97
109
98
- bindToSig id = do
99
- let name = idName id
100
- whenMaybe (isBindingName name) $ do
101
- env <- tcInitTidyEnv
102
- let (_, ty) = tidyOpenType env (idType id )
103
- pure $ InstanceBindTypeSig name
104
- (prettyBindingNameString (printOutputable name) <> " :: " <> printOutputable (pprSigmaType ty))
105
- Nothing
106
-
107
110
properties :: Properties
108
111
'[ 'PropertyKey " typelensOn" 'TBoolean]
109
112
properties = emptyProperties
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ codeLensTests = testGroup
98
98
, goldenCodeLens " Don't insert pragma while existing" " T13" 0
99
99
, onlyRunForGhcVersions [GHC92 ] " Only ghc-9.2 enabled GHC2021 implicitly" $
100
100
goldenCodeLens " Don't insert pragma while GHC2021 enabled" " T14" 0
101
+ , goldenCodeLens " Qualified name" " T15" 0
101
102
]
102
103
103
104
_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
+ module T15 where
2
+ import qualified T15A
3
+
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
1
cradle :
2
2
direct :
3
- arguments : [-XHaskell2010]
3
+ arguments : [-XHaskell2010, T15A ]
You can’t perform that action at this time.
0 commit comments