From 3966f334befe29b4074649bf7eb7fd58ca05a0bb Mon Sep 17 00:00:00 2001 From: Jakub Janaszkiewicz Date: Tue, 27 Aug 2024 20:10:35 +0200 Subject: [PATCH] Update code for GHC 9.6.6 --- .github/workflows/ci.yml | 4 +-- app/Main.hs | 23 +++++++------- package.yaml | 2 +- rsl-language-server.cabal | 2 +- src/Raise/CodeLens.hs | 15 +++++---- src/Raise/DiagnosticParser.hs | 20 ++++++------ src/Raise/Diagnostics.hs | 24 +++++++------- src/Raise/Handlers.hs | 12 +++---- stack.yaml | 13 ++------ stack.yaml.lock | 59 +++-------------------------------- 10 files changed, 61 insertions(+), 113 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 049f17f..578d662 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - uses: haskell/actions/setup@v1 name: Setup Haskell Stack with: - ghc-version: 9.2.2 + ghc-version: 9.6.6 enable-stack: true stack-version: 'latest' @@ -32,7 +32,7 @@ jobs: name: Cache ~/.stack with: path: ~/.stack - key: ${{ runner.os }}-9.2.2-stack + key: ${{ runner.os }}-9.6.6-stack - name: Install dependencies run: | diff --git a/app/Main.hs b/app/Main.hs index b9e7923..ed43964 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -5,17 +5,17 @@ module Main ( ) where import ArgParse -import Control.Monad.IO.Class (liftIO) -import Data.Version (showVersion) +import Control.Monad.IO.Class (liftIO) +import Data.Version (showVersion) +import Language.LSP.Protocol.Types import Language.LSP.Server -import Language.LSP.Types -import qualified Paths_rsl_language_server as Paths -import Raise.Handlers (handlers) +import qualified Paths_rsl_language_server as Paths +import Raise.Handlers (handlers) syncOptions :: TextDocumentSyncOptions syncOptions = TextDocumentSyncOptions { _openClose = Just True - , _change = Just TdSyncIncremental + , _change = Just TextDocumentSyncKind_Incremental , _willSave = Just False , _willSaveWaitUntil = Just False , _save = Just $ InR $ SaveOptions $ Just False @@ -23,18 +23,19 @@ syncOptions = TextDocumentSyncOptions lspOptions :: Options lspOptions = defaultOptions - { textDocumentSync = Just syncOptions - , executeCommandCommands = Just [] + { optTextDocumentSync = Just syncOptions } serverDef :: Bool -> ServerDefinition () serverDef compile = ServerDefinition - { onConfigurationChange = const $ pure $ Right () + { parseConfig = const $ const $ Right () + , onConfigChange = const $ pure () + , defaultConfig = () + , configSection = "rsl-language-server" , doInitialize = \env _ -> pure $ Right env - , staticHandlers = handlers compile + , staticHandlers = const $ handlers compile , interpretHandler = \env -> Iso (runLspT env) liftIO , options = lspOptions - , defaultConfig = undefined } main :: IO Int diff --git a/package.yaml b/package.yaml index 10bc8a1..f422086 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: rsl-language-server -version: 0.1.1.2 +version: 0.1.2.0 github: "JakuJ/rsl-language-server" license: BSD3 author: "Jakub Janaszkiewicz" diff --git a/rsl-language-server.cabal b/rsl-language-server.cabal index 508368f..43b15b9 100644 --- a/rsl-language-server.cabal +++ b/rsl-language-server.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: rsl-language-server -version: 0.1.1.2 +version: 0.1.2.0 description: Please see the README on GitHub at homepage: https://github.com/JakuJ/rsl-language-server#readme bug-reports: https://github.com/JakuJ/rsl-language-server/issues diff --git a/src/Raise/CodeLens.hs b/src/Raise/CodeLens.hs index 3fe57d9..844f8bf 100644 --- a/src/Raise/CodeLens.hs +++ b/src/Raise/CodeLens.hs @@ -2,19 +2,20 @@ module Raise.CodeLens ( registerLenses ) where -import Control.Monad (void) -import qualified Data.Text as T +import Control.Monad.IO.Class +import qualified Data.Text as T +import Language.LSP.Protocol.Message +import Language.LSP.Protocol.Types import Language.LSP.Server -import Language.LSP.Types regOpts :: CodeLensRegistrationOptions -regOpts = CodeLensRegistrationOptions Nothing Nothing (Just False) +regOpts = CodeLensRegistrationOptions (InR Null) Nothing (Just False) registerCommand :: T.Text -> T.Text -> CodeLens registerCommand name command = CodeLens { _range = mkRange 0 0 0 100 , _command = Just $ Command name command Nothing - , _xdata = Nothing + , _data_ = Nothing } cmdList :: [(T.Text, T.Text)] @@ -26,4 +27,6 @@ cmdList = [ ("Typecheck", "raise.typeCheck") registerLenses :: LspM () () registerLenses = do let rsp = map (uncurry registerCommand) cmdList - void $ registerCapability STextDocumentCodeLens regOpts $ \_ responder -> responder (Right (List rsp)) + _ <- registerCapability SMethod_TextDocumentCodeLens regOpts $ \_ responder -> do + responder (Right (InL rsp)) + pure () diff --git a/src/Raise/DiagnosticParser.hs b/src/Raise/DiagnosticParser.hs index 013f92e..f6703fd 100644 --- a/src/Raise/DiagnosticParser.hs +++ b/src/Raise/DiagnosticParser.hs @@ -1,26 +1,28 @@ module Raise.DiagnosticParser where -import Control.Monad (void) -import Data.Foldable (asum) -import Data.Maybe (fromMaybe) -import qualified Data.Text as T -import Data.Void (Void) -import Language.LSP.Types +import Control.Monad (void) +import Data.Foldable (asum) +import Data.Maybe (fromMaybe) +import qualified Data.Text as T +import Data.Void (Void) +import Language.LSP.Protocol.Types import Text.Megaparsec import Text.Megaparsec.Char -import Text.Megaparsec.Char.Lexer (skipLineComment) +import Text.Megaparsec.Char.Lexer (skipLineComment) type Parser = Parsec Void T.Text mkDiagnostic :: UInt -> UInt -> T.Text -> Diagnostic mkDiagnostic row column msg = Diagnostic { _range = Range (Position row column) (Position row column) - , _severity = Just DsError + , _severity = Just DiagnosticSeverity_Error , _code = Nothing + , _codeDescription = Nothing , _source = Just "rsl-language-server" , _message = msg , _tags = Nothing - , _relatedInformation = Just $ List [] + , _relatedInformation = Just [] + , _data_ = Nothing } -- Discarded output diff --git a/src/Raise/Diagnostics.hs b/src/Raise/Diagnostics.hs index 82c07b3..ee6d664 100644 --- a/src/Raise/Diagnostics.hs +++ b/src/Raise/Diagnostics.hs @@ -4,17 +4,17 @@ module Raise.Diagnostics ( diagnosticHandler ) where -import Control.Lens ((^.)) -import Control.Monad.IO.Class (liftIO) -import Data.Either (fromRight) -import Data.Maybe (fromJust) -import qualified Data.Text as T -import Language.LSP.Diagnostics (partitionBySource) +import Control.Lens ((^.)) +import Control.Monad.IO.Class (liftIO) +import Data.Either (fromRight) +import Data.Maybe (fromJust) +import qualified Data.Text as T +import Language.LSP.Diagnostics (partitionBySource) +import qualified Language.LSP.Protocol.Lens as J +import qualified Language.LSP.Protocol.Types as J import Language.LSP.Server -import qualified Language.LSP.Types as J -import qualified Language.LSP.Types.Lens as J -import Raise.DiagnosticParser (parseRSLTC) -import System.Process (readProcessWithExitCode) +import Raise.DiagnosticParser (parseRSLTC) +import System.Process (readProcessWithExitCode) runTool :: String -> [String] -> IO T.Text runTool tool args = do @@ -30,8 +30,8 @@ runCompiler path = runTool "rsltc" ["-m", path] sendDiagnostics :: Bool -> J.NormalizedUri -> FilePath -> LspM () () sendDiagnostics compile fileUri filePath = do tcDiags <- fromRight [] . parseRSLTC <$> liftIO (runChecker filePath) - compilerDiags <- if not compile then pure [] else - fmap (\x -> x {J._severity = Just J.DsWarning} ) . fromRight [] . parseRSLTC <$> liftIO (runCompiler filePath) + compilerDiags <- if not compile then pure [] else + fmap (\x -> x {J._severity = Just J.DiagnosticSeverity_Warning} ) . fromRight [] . parseRSLTC <$> liftIO (runCompiler filePath) let diags = tcDiags ++ compilerDiags if null diags then flushDiagnosticsBySource 100 (Just "rsl-language-server") diff --git a/src/Raise/Handlers.hs b/src/Raise/Handlers.hs index 983a6fb..994a551 100644 --- a/src/Raise/Handlers.hs +++ b/src/Raise/Handlers.hs @@ -2,15 +2,15 @@ module Raise.Handlers ( handlers ) where +import Language.LSP.Protocol.Message import Language.LSP.Server -import Language.LSP.Types -import Raise.CodeLens (registerLenses) -import Raise.Diagnostics (diagnosticHandler) +import Raise.CodeLens (registerLenses) +import Raise.Diagnostics (diagnosticHandler) handlers :: Bool -> Handlers (LspM ()) handlers compile = mconcat - [ notificationHandler SInitialized $ const registerLenses - , notificationHandler STextDocumentDidSave $ diagnosticHandler compile - , notificationHandler STextDocumentDidOpen $ diagnosticHandler compile + [ notificationHandler SMethod_Initialized $ const registerLenses + , notificationHandler SMethod_TextDocumentDidSave $ diagnosticHandler compile + , notificationHandler SMethod_TextDocumentDidOpen $ diagnosticHandler compile ] diff --git a/stack.yaml b/stack.yaml index c96f8ba..81da206 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,16 +1,7 @@ -resolver: nightly-2022-06-06 +resolver: lts-22.33 -compiler: ghc-9.2.2 +compiler: ghc-9.6.6 compiler-check: match-exact packages: - . - -extra-deps: -- lsp-1.4.0.0@sha256:d992cb88d6212f113baf372404c141a6bea14c436baa64ea6e4f01b6188c575b,5088 -- lsp-types-1.4.0.1@sha256:b902952df7becc1827947ee3ff1cd8c746aa8f9f80db330db20e2fdf1b6089e8,4504 -- lsp-test-0.14.0.2@sha256:d62d2af45508f04c5fcad23e469c45b37ca19760cee15b025a0eb499cbd28050,4663 -- rope-utf16-splay-0.4.0.0@sha256:2237ca21b950f5a45971f09ea2d38532a8e06949c82629095351e4bff5207aed,2034 -- text-2.0@sha256:86e64bc76fefb8f0f6529d28ddf24b2a29d43591a8b9b7c7094f481a0db2fb7d,7788 -- Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459 -- parsec-3.1.15.0@sha256:a162d4cc8884014ba35192545cad293af0529fe11497aad8834bbaaa3dfffc26,4429 diff --git a/stack.yaml.lock b/stack.yaml.lock index 4736028..a905563 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,59 +3,10 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: -- completed: - hackage: lsp-1.4.0.0@sha256:d992cb88d6212f113baf372404c141a6bea14c436baa64ea6e4f01b6188c575b,5088 - pantry-tree: - size: 1417 - sha256: 92dccca5b6429616c0467d7c0dc665001d67cda76250bc70d7d30025c28d4216 - original: - hackage: lsp-1.4.0.0@sha256:d992cb88d6212f113baf372404c141a6bea14c436baa64ea6e4f01b6188c575b,5088 -- completed: - hackage: lsp-types-1.4.0.1@sha256:b902952df7becc1827947ee3ff1cd8c746aa8f9f80db330db20e2fdf1b6089e8,4504 - pantry-tree: - size: 4225 - sha256: 9b4ee01ae646c359ac24551816f6e83a22519c503fc0b4d1da5e46d135abf985 - original: - hackage: lsp-types-1.4.0.1@sha256:b902952df7becc1827947ee3ff1cd8c746aa8f9f80db330db20e2fdf1b6089e8,4504 -- completed: - hackage: lsp-test-0.14.0.2@sha256:d62d2af45508f04c5fcad23e469c45b37ca19760cee15b025a0eb499cbd28050,4663 - pantry-tree: - size: 1559 - sha256: 7fba61926846deb098a82b51e58f127ae9c53256db881d446c1a76c85ba2ecc7 - original: - hackage: lsp-test-0.14.0.2@sha256:d62d2af45508f04c5fcad23e469c45b37ca19760cee15b025a0eb499cbd28050,4663 -- completed: - hackage: rope-utf16-splay-0.4.0.0@sha256:2237ca21b950f5a45971f09ea2d38532a8e06949c82629095351e4bff5207aed,2034 - pantry-tree: - size: 667 - sha256: 8f8650b21381dee11be10d327b8df1999f1ba00e303cd1ed3ed52dfd63e1ca69 - original: - hackage: rope-utf16-splay-0.4.0.0@sha256:2237ca21b950f5a45971f09ea2d38532a8e06949c82629095351e4bff5207aed,2034 -- completed: - hackage: text-2.0@sha256:86e64bc76fefb8f0f6529d28ddf24b2a29d43591a8b9b7c7094f481a0db2fb7d,7788 - pantry-tree: - size: 7364 - sha256: 894b84358fbad3cb8c16f224d3d8b7a1d7b6bcae68cda5a9998dd964904a6560 - original: - hackage: text-2.0@sha256:86e64bc76fefb8f0f6529d28ddf24b2a29d43591a8b9b7c7094f481a0db2fb7d,7788 -- completed: - hackage: Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459 - pantry-tree: - size: 19757 - sha256: b250a53bdb56844f047a2927833bb565b936a289abfa85dfc2a63148d776368a - original: - hackage: Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459 -- completed: - hackage: parsec-3.1.15.0@sha256:a162d4cc8884014ba35192545cad293af0529fe11497aad8834bbaaa3dfffc26,4429 - pantry-tree: - size: 2630 - sha256: cbddc1e3c5ada6925354850cc0a8fadcd8643689098a504a0ed25ef9e0b932b8 - original: - hackage: parsec-3.1.15.0@sha256:a162d4cc8884014ba35192545cad293af0529fe11497aad8834bbaaa3dfffc26,4429 +packages: [] snapshots: - completed: - size: 605110 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2022/6/6.yaml - sha256: 26ea900ee8601fee24ff84981e92f304d384c73ee32d5504299133b5eb177e87 - original: nightly-2022-06-06 + sha256: 098936027eaa1ef14e2b8eb39d9933a973894bb70a68684a1bbf00730249879b + size: 720001 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/33.yaml + original: lts-22.33