File tree Expand file tree Collapse file tree 5 files changed +34
-2
lines changed
Expand file tree Collapse file tree 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
9090 getBindSpanWithoutSig ClsInstDecl {.. } =
9191 let bindNames = mapMaybe go (bagToList cid_binds)
9292 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
94101 _ -> Nothing
95102 -- Existed signatures' name
96103 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
8888 [ " (==) :: B -> B -> Bool"
8989 , " (==) :: A -> A -> Bool"
9090 ]
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
9196 , goldenCodeLens " Apply code lens" " CodeLensSimple" 1
9297 , goldenCodeLens " Apply code lens for local class" " LocalClassDefine" 0
9398 , 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 11cradle :
22 direct :
3- arguments : [-XHaskell2010, QualifiedA]
3+ arguments : [-XHaskell2010, QualifiedA, THDef ]
You can’t perform that action at this time.
0 commit comments