|
| 1 | +{-# LANGUAGE CPP #-} |
1 | 2 | {-# LANGUAGE DeriveAnyClass #-} |
2 | 3 | {-# LANGUAGE DeriveGeneric #-} |
3 | 4 | {-# LANGUAGE OverloadedStrings #-} |
@@ -32,6 +33,7 @@ import Ide.Types |
32 | 33 | import Language.Haskell.GHC.ExactPrint |
33 | 34 | import Language.Haskell.GHC.ExactPrint.Parsers (parseDecl) |
34 | 35 | import Language.Haskell.GHC.ExactPrint.Types hiding (GhcPs, Parens) |
| 36 | +import Language.Haskell.GHC.ExactPrint.Utils (rs) |
35 | 37 | import Language.LSP.Server |
36 | 38 | import Language.LSP.Types |
37 | 39 | import qualified Language.LSP.Types.Lens as J |
@@ -85,20 +87,20 @@ addMethodPlaceholders state AddMinimalMethodsParams{..} = do |
85 | 87 | Right (ann, d) -> Just (setPrecedingLines d 1 indent ann, d) |
86 | 88 | Left _ -> Nothing |
87 | 89 |
|
88 | | - addMethodDecls :: ParsedSource -> [LHsDecl GhcPs] -> Transform (Located (HsModule GhcPs)) |
| 90 | + -- addMethodDecls :: ParsedSource -> [LHsDecl GhcPs] -> Transform (Located (HsModule GhcPs)) |
89 | 91 | addMethodDecls ps mDecls = do |
90 | 92 | d <- findInstDecl ps |
91 | 93 | newSpan <- uniqueSrcSpanT |
92 | 94 | let |
93 | 95 | annKey = mkAnnKey d |
94 | | - newAnnKey = AnnKey newSpan (CN "HsValBinds") |
| 96 | + newAnnKey = AnnKey (rs newSpan) (CN "HsValBinds") |
95 | 97 | addWhere mkds@(Map.lookup annKey -> Just ann) |
96 | 98 | = Map.insert newAnnKey ann2 mkds2 |
97 | 99 | where |
98 | 100 | ann1 = ann |
99 | 101 | { annsDP = annsDP ann ++ [(G AnnWhere, DP (0, 1))] |
100 | 102 | , annCapturedSpan = Just newAnnKey |
101 | | - , annSortKey = Just (fmap getLoc mDecls) |
| 103 | + , annSortKey = Just (fmap (rs . getLoc) mDecls) |
102 | 104 | } |
103 | 105 | mkds2 = Map.insert annKey ann1 mkds |
104 | 106 | ann2 = annNone |
@@ -168,9 +170,15 @@ codeAction state plId (CodeActionParams _ _ docId _ context) = liftIO $ fmap (fr |
168 | 170 | pure |
169 | 171 | $ head . head |
170 | 172 | $ pointCommand hf (fromJust (fromCurrentRange pmap range) ^. J.start & J.character -~ 1) |
| 173 | +#if !MIN_VERSION_ghc(9,0,0) |
171 | 174 | ( (Map.keys . Map.filter isClassNodeIdentifier . nodeIdentifiers . nodeInfo) |
172 | 175 | <=< nodeChildren |
173 | 176 | ) |
| 177 | +#else |
| 178 | + ( (Map.keys . Map.filter isClassNodeIdentifier . sourcedNodeIdents . sourcedNodeInfo) |
| 179 | + <=< nodeChildren |
| 180 | + ) |
| 181 | +#endif |
174 | 182 |
|
175 | 183 | findClassFromIdentifier docPath (Right name) = do |
176 | 184 | (hscEnv -> hscenv, _) <- MaybeT . runAction "classplugin" state $ useWithStale GhcSessionDeps docPath |
|
0 commit comments