File tree 5 files changed +34
-2
lines changed 5 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,14 @@ codeLens state plId CodeLensParams{..} = pluginResponse $ do
90
90
getBindSpanWithoutSig ClsInstDecl {.. } =
91
91
let bindNames = mapMaybe go (bagToList cid_binds)
92
92
go (L l bind) = case bind of
93
- FunBind {.. } -> Just $ L l fun_id
93
+ FunBind {.. }
94
+ -- `Generated` tagged for Template Haskell,
95
+ -- here we filter out nonsence generated bindings
96
+ -- that are nonsense for displaying code lenses.
97
+ --
98
+ -- See https://github.com/haskell/haskell-language-server/issues/3319
99
+ | not $ isGenerated (mg_origin fun_matches)
100
+ -> Just $ L l fun_id
94
101
_ -> Nothing
95
102
-- Existed signatures' name
96
103
sigNames = concat $ mapMaybe (\ (L _ r) -> getSigName r) cid_sigs
Original file line number Diff line number Diff line change @@ -88,6 +88,11 @@ codeLensTests = testGroup
88
88
[ " (==) :: B -> B -> Bool"
89
89
, " (==) :: A -> A -> Bool"
90
90
]
91
+ , testCase " No lens for TH" $ do
92
+ runSessionWithServer classPlugin testDataDir $ do
93
+ doc <- openDoc " TH.hs" " haskell"
94
+ lens <- getCodeLenses doc
95
+ liftIO $ length lens @?= 0
91
96
, goldenCodeLens " Apply code lens" " CodeLensSimple" 1
92
97
, goldenCodeLens " Apply code lens for local class" " LocalClassDefine" 0
93
98
, goldenCodeLens " Apply code lens on the same line" " Inline" 0
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE TemplateHaskell #-}
2
+
3
+ module TH where
4
+
5
+ import THDef
6
+
7
+ gen ''Bool True
8
+ gen ''Char ' a'
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE TemplateHaskell #-}
2
+
3
+ module THDef where
4
+
5
+ import Language.Haskell.TH
6
+ import Language.Haskell.TH.Syntax
7
+
8
+ class F a where
9
+ f :: a
10
+
11
+ gen :: Lift t => Name -> t -> Q [Dec ]
12
+ gen ty v = [d | instance F $(conT ty) where f = v |]
Original file line number Diff line number Diff line change 1
1
cradle :
2
2
direct :
3
- arguments : [-XHaskell2010, QualifiedA]
3
+ arguments : [-XHaskell2010, QualifiedA, THDef ]
You can’t perform that action at this time.
0 commit comments