diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 07eae0ee39..0b3024d29b 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -319,7 +319,7 @@ common qualifyImportedNames cpp-options: -Dhls_qualifyImportedNames common codeRange - if flag(codeRange) && (impl(ghc < 9.4.1) || flag(ignore-plugins-ghc-bounds)) + if flag(codeRange) build-depends: hls-code-range-plugin ^>= 1.0 cpp-options: -Dhls_codeRange diff --git a/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal b/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal index 3d50d0c764..e51ad55268 100644 --- a/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal +++ b/plugins/hls-code-range-plugin/hls-code-range-plugin.cabal @@ -21,10 +21,6 @@ extra-source-files: test/testdata/selection-range/*.txt library - if impl(ghc >= 9.3) - buildable: False - else - buildable: True exposed-modules: Ide.Plugin.CodeRange Ide.Plugin.CodeRange.Rules @@ -42,7 +38,6 @@ library , ghcide ^>=1.6 || ^>=1.7 , hashable , hls-plugin-api ^>=1.3 || ^>=1.4 - , hls-refactor-plugin , lens , lsp , mtl @@ -52,10 +47,6 @@ library , vector test-suite tests - if impl(ghc >= 9.3) - buildable: False - else - buildable: True type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test diff --git a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs index 23a02cfb60..0a48a3467b 100644 --- a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs +++ b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange.hs @@ -31,8 +31,6 @@ import Development.IDE.Core.PositionMapping (PositionMapping, fromCurrentPosition, toCurrentRange) import Development.IDE.Types.Logger (Pretty (..)) -import qualified Development.IDE.GHC.ExactPrint as E -import Development.IDE.Plugin.CodeAction import Ide.Plugin.CodeRange.Rules (CodeRange (..), GetCodeRange (..), codeRangeRule) @@ -57,7 +55,7 @@ import Language.LSP.Types (List (List), import Prelude hiding (log, span) descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState -descriptor recorder plId = mkExactprintPluginDescriptor (cmapWithPrio LogExactPrint recorder) $ (defaultPluginDescriptor plId) +descriptor recorder plId = (defaultPluginDescriptor plId) { pluginHandlers = mkPluginHandler STextDocumentSelectionRange selectionRangeHandler -- TODO @sloorush add folding range -- <> mkPluginHandler STextDocumentFoldingRange foldingRangeHandler @@ -65,12 +63,10 @@ descriptor recorder plId = mkExactprintPluginDescriptor (cmapWithPrio LogExactPr } data Log = LogRules Rules.Log - | LogExactPrint E.Log instance Pretty Log where pretty log = case log of LogRules codeRangeLog -> pretty codeRangeLog - LogExactPrint exactPrintLog -> pretty exactPrintLog selectionRangeHandler :: IdeState -> PluginId -> SelectionRangeParams -> LspM c (Either ResponseError (List SelectionRange)) selectionRangeHandler ide _ SelectionRangeParams{..} = do diff --git a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs index fcd96ffea1..992bf6ca28 100644 --- a/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs +++ b/plugins/hls-code-range-plugin/src/Ide/Plugin/CodeRange/Rules.hs @@ -44,12 +44,10 @@ import qualified Data.Vector as V import Development.IDE import Development.IDE.Core.Rules (toIdeResult) import qualified Development.IDE.Core.Shake as Shake -import Development.IDE.GHC.Compat.ExactPrint (Annotated) import Development.IDE.GHC.Compat (HieAST (..), HieASTs (getAsts), - ParsedSource, RefMap) + RefMap) import Development.IDE.GHC.Compat.Util -import Development.IDE.GHC.ExactPrint (GetAnnotatedParsedSource (GetAnnotatedParsedSource)) import GHC.Generics (Generic) import Ide.Plugin.CodeRange.ASTPreProcess (CustomNodeType (..), PreProcessEnv (..), @@ -105,8 +103,8 @@ instance Ord CodeRange where -- | Construct a 'CodeRange'. A valid CodeRange will be returned in any case. If anything go wrong, -- a list of warnings will be returned as 'Log' -buildCodeRange :: HieAST a -> RefMap a -> Annotated ParsedSource -> Writer [Log] CodeRange -buildCodeRange ast refMap _ = do +buildCodeRange :: HieAST a -> RefMap a -> Writer [Log] CodeRange +buildCodeRange ast refMap = do -- We work on 'HieAST', then convert it to 'CodeRange', so that applications such as selection range and folding -- range don't need to care about 'HieAST' -- TODO @sloorush actually use 'Annotated ParsedSource' to handle structures not in 'HieAST' properly (for example comments) @@ -178,9 +176,7 @@ codeRangeRule recorder = HAR{hieAst, refMap} <- lift $ use_ GetHieAst file ast <- maybeToExceptT LogNoAST . MaybeT . pure $ getAsts hieAst Map.!? (coerce . mkFastString . fromNormalizedFilePath) file - annPS <- lift $ use_ GetAnnotatedParsedSource file - - let (codeRange, warnings) = runWriter (buildCodeRange ast refMap annPS) + let (codeRange, warnings) = runWriter (buildCodeRange ast refMap) traverse_ (logWith recorder Warning) warnings pure codeRange