Skip to content

Commit aa07967

Browse files
committed
Make hls-code-range-plugin buildable on 9.4 by removing usused exactprint dependencies
1 parent fed71a8 commit aa07967

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

haskell-language-server.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ common qualifyImportedNames
319319
cpp-options: -Dhls_qualifyImportedNames
320320

321321
common codeRange
322-
if flag(codeRange) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds))
322+
if flag(codeRange)
323323
build-depends: hls-code-range-plugin ^>= 1.0
324324
cpp-options: -Dhls_codeRange
325325

plugins/hls-code-range-plugin/hls-code-range-plugin.cabal

-9
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ extra-source-files:
2121
test/testdata/selection-range/*.txt
2222

2323
library
24-
if impl(ghc >= 9.3)
25-
buildable: False
26-
else
27-
buildable: True
2824
exposed-modules:
2925
Ide.Plugin.CodeRange
3026
Ide.Plugin.CodeRange.Rules
@@ -42,7 +38,6 @@ library
4238
, ghcide ^>=1.6 || ^>=1.7
4339
, hashable
4440
, hls-plugin-api ^>=1.3 || ^>=1.4
45-
, hls-refactor-plugin
4641
, lens
4742
, lsp
4843
, mtl
@@ -52,10 +47,6 @@ library
5247
, vector
5348

5449
test-suite tests
55-
if impl(ghc >= 9.3)
56-
buildable: False
57-
else
58-
buildable: True
5950
type: exitcode-stdio-1.0
6051
default-language: Haskell2010
6152
hs-source-dirs: test

plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs

+1-5
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ import Development.IDE.Core.PositionMapping (PositionMapping,
3131
fromCurrentPosition,
3232
toCurrentRange)
3333
import Development.IDE.Types.Logger (Pretty (..))
34-
import qualified Development.IDE.GHC.ExactPrint as E
35-
import Development.IDE.Plugin.CodeAction
3634
import Ide.Plugin.CodeRange.Rules (CodeRange (..),
3735
GetCodeRange (..),
3836
codeRangeRule)
@@ -57,20 +55,18 @@ import Language.LSP.Types (List (List),
5755
import Prelude hiding (log, span)
5856

5957
descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState
60-
descriptor recorder plId = mkExactprintPluginDescriptor (cmapWithPrio LogExactPrint recorder) $ (defaultPluginDescriptor plId)
58+
descriptor recorder plId = (defaultPluginDescriptor plId)
6159
{ pluginHandlers = mkPluginHandler STextDocumentSelectionRange selectionRangeHandler
6260
-- TODO @sloorush add folding range
6361
-- <> mkPluginHandler STextDocumentFoldingRange foldingRangeHandler
6462
, pluginRules = codeRangeRule (cmapWithPrio LogRules recorder)
6563
}
6664

6765
data Log = LogRules Rules.Log
68-
| LogExactPrint E.Log
6966

7067
instance Pretty Log where
7168
pretty log = case log of
7269
LogRules codeRangeLog -> pretty codeRangeLog
73-
LogExactPrint exactPrintLog -> pretty exactPrintLog
7470

7571
selectionRangeHandler :: IdeState -> PluginId -> SelectionRangeParams -> LspM c (Either ResponseError (List SelectionRange))
7672
selectionRangeHandler ide _ SelectionRangeParams{..} = do

plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs

+4-8
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ import qualified Data.Vector as V
4444
import Development.IDE
4545
import Development.IDE.Core.Rules (toIdeResult)
4646
import qualified Development.IDE.Core.Shake as Shake
47-
import Development.IDE.GHC.Compat.ExactPrint (Annotated)
4847
import Development.IDE.GHC.Compat (HieAST (..),
4948
HieASTs (getAsts),
50-
ParsedSource, RefMap)
49+
RefMap)
5150
import Development.IDE.GHC.Compat.Util
52-
import Development.IDE.GHC.ExactPrint (GetAnnotatedParsedSource (GetAnnotatedParsedSource))
5351
import GHC.Generics (Generic)
5452
import Ide.Plugin.CodeRange.ASTPreProcess (CustomNodeType (..),
5553
PreProcessEnv (..),
@@ -105,8 +103,8 @@ instance Ord CodeRange where
105103

106104
-- | Construct a 'CodeRange'. A valid CodeRange will be returned in any case. If anything go wrong,
107105
-- a list of warnings will be returned as 'Log'
108-
buildCodeRange :: HieAST a -> RefMap a -> Annotated ParsedSource -> Writer [Log] CodeRange
109-
buildCodeRange ast refMap _ = do
106+
buildCodeRange :: HieAST a -> RefMap a -> Writer [Log] CodeRange
107+
buildCodeRange ast refMap = do
110108
-- We work on 'HieAST', then convert it to 'CodeRange', so that applications such as selection range and folding
111109
-- range don't need to care about 'HieAST'
112110
-- TODO @sloorush actually use 'Annotated ParsedSource' to handle structures not in 'HieAST' properly (for example comments)
@@ -178,9 +176,7 @@ codeRangeRule recorder =
178176
HAR{hieAst, refMap} <- lift $ use_ GetHieAst file
179177
ast <- maybeToExceptT LogNoAST . MaybeT . pure $
180178
getAsts hieAst Map.!? (coerce . mkFastString . fromNormalizedFilePath) file
181-
annPS <- lift $ use_ GetAnnotatedParsedSource file
182-
183-
let (codeRange, warnings) = runWriter (buildCodeRange ast refMap annPS)
179+
let (codeRange, warnings) = runWriter (buildCodeRange ast refMap)
184180
traverse_ (logWith recorder Warning) warnings
185181

186182
pure codeRange

0 commit comments

Comments
 (0)