Skip to content

Commit 7643361

Browse files
committed
Fail intentionally (for telemetry)
1 parent eebf6b6 commit 7643361

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plugins/default/src/Ide/Plugin/Pragmas.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE OverloadedStrings #-}
44
{-# LANGUAGE ViewPatterns #-}
5+
{-# LANGUAGE CPP #-}
56

67
-- | Provides code actions to add missing pragmas (whenever GHC suggests to)
78
module Ide.Plugin.Pragmas (descriptor) where
@@ -23,7 +24,12 @@ import qualified Language.LSP.Types as J
2324
import qualified Language.LSP.Types.Lens as J
2425
import qualified Language.LSP.VFS as VFS
2526
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)
2733
-- ---------------------------------------------------------------------
2834

2935
descriptor :: PluginId -> PluginDescriptor IdeState
@@ -48,7 +54,8 @@ codeActionProvider state _plId (CodeActionParams _ _ docId _ (J.CodeActionContex
4854
let dflags = ms_hspp_opts . pm_mod_summary <$> pm
4955
insertRange = maybe (Range (Position 0 0) (Position 0 0)) endOfModuleHeader pm
5056
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
5259

5360
-- | Add a Pragma to the given URI at the top of the file.
5461
-- It is assumed that the pragma name is a valid pragma,

0 commit comments

Comments
 (0)