File tree 1 file changed +9
-2
lines changed
plugins/default/src/Ide/Plugin
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 2
2
{-# LANGUAGE NamedFieldPuns #-}
3
3
{-# LANGUAGE OverloadedStrings #-}
4
4
{-# LANGUAGE ViewPatterns #-}
5
+ {-# LANGUAGE CPP #-}
5
6
6
7
-- | Provides code actions to add missing pragmas (whenever GHC suggests to)
7
8
module Ide.Plugin.Pragmas (descriptor ) where
@@ -23,7 +24,12 @@ import qualified Language.LSP.Types as J
23
24
import qualified Language.LSP.Types.Lens as J
24
25
import qualified Language.LSP.VFS as VFS
25
26
import qualified Text.Fuzzy as Fuzzy
26
-
27
+ #if __GLASGOW_HASKELL__ < 810
28
+ import HsDumpAst
29
+ #else
30
+ import GHC.Hs.Dump
31
+ #endif
32
+ import Data.Bifunctor (second )
27
33
-- ---------------------------------------------------------------------
28
34
29
35
descriptor :: PluginId -> PluginDescriptor IdeState
@@ -48,7 +54,8 @@ codeActionProvider state _plId (CodeActionParams _ _ docId _ (J.CodeActionContex
48
54
let dflags = ms_hspp_opts . pm_mod_summary <$> pm
49
55
insertRange = maybe (Range (Position 0 0 ) (Position 0 0 )) endOfModuleHeader pm
50
56
pedits = nubOrdOn snd . concat $ suggest dflags <$> diags
51
- return $ Right $ List $ pragmaEditToAction uri insertRange <$> pedits
57
+ printed = maybe " No parse!" (unsafePrintSDoc . showAstData NoBlankSrcSpan . pm_parsed_source) pm
58
+ return $ Right $ List $ pragmaEditToAction uri insertRange <$> (second (const $ LangExt $ T. pack printed) <$> pedits) -- TODO
52
59
53
60
-- | Add a Pragma to the given URI at the top of the file.
54
61
-- It is assumed that the pragma name is a valid pragma,
You can’t perform that action at this time.
0 commit comments