Skip to content

Commit

Permalink
Update the metamodel (#556)
Browse files Browse the repository at this point in the history
* Update the metamodel

There are various changes:
- Quite a lot of new "proposed" stuff. I adjusted the codegen to filter
  this stuff out, which is what we want I think. I had to make some PRs
  upstream, I hacked up our metamodel copy to mirror what I think will
  come out of that eventually.
- They created named structs for a lot of the previously anonymous ones.
  This is generally pretty good, using `row-types` for that was always a
  bit awkward. However, I haven't been able to get them to commit to
  actually getting rid of anonymous structs entirely, so we have to keep
  the support :(
    - This change does generate most of the churn, though
- Some random renamings 🤷

* Try to fix on 9.8
  • Loading branch information
michaelpj authored Feb 9, 2024
1 parent 2bba471 commit 3ad32c6
Show file tree
Hide file tree
Showing 117 changed files with 6,336 additions and 2,309 deletions.
8 changes: 4 additions & 4 deletions lsp-test/src/Language/LSP/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ runSessionWithHandles' serverProc serverIn serverOut config' caps rootDir sessio
caps
-- TODO: make this configurable?
(Just $ Object $ lspConfig config')
(Just TraceValues_Off)
(Just TraceValue_Off)
(fmap InL $ initialWorkspaceFolders config)
runSession' serverIn serverOut serverProc listenServer config caps rootDir exitServer $ do
-- Wrap the session around initialize and shutdown calls
Expand Down Expand Up @@ -546,7 +546,7 @@ createDoc ::
-- | The path to the document to open, __relative to the root directory__.
FilePath ->
-- | The text document's language identifier, e.g. @"haskell"@.
T.Text ->
LanguageKind ->
-- | The content of the text document to create.
T.Text ->
-- | The identifier of the document just created.
Expand Down Expand Up @@ -591,7 +591,7 @@ createDoc file languageId contents = do
{- | Opens a text document that /exists on disk/, and sends a
textDocument/didOpen notification to the server.
-}
openDoc :: FilePath -> T.Text -> Session TextDocumentIdentifier
openDoc :: FilePath -> LanguageKind -> Session TextDocumentIdentifier
openDoc file languageId = do
context <- ask
let fp = rootDir context </> file
Expand All @@ -601,7 +601,7 @@ openDoc file languageId = do
{- | This is a variant of `openDoc` that takes the file content as an argument.
Use this is the file exists /outside/ of the current workspace.
-}
openDoc' :: FilePath -> T.Text -> T.Text -> Session TextDocumentIdentifier
openDoc' :: FilePath -> LanguageKind -> T.Text -> Session TextDocumentIdentifier
openDoc' file languageId contents = do
context <- ask
let fp = rootDir context </> file
Expand Down
8 changes: 4 additions & 4 deletions lsp-test/src/Language/LSP/Test/Compat.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
-- For some reason ghc warns about not using
Expand All @@ -10,8 +11,7 @@
module Language.LSP.Test.Compat where

import Data.Maybe
import Data.Row
import Data.Text qualified as T
import Language.LSP.Protocol.Types qualified as L
import System.IO

#if MIN_VERSION_process(1,6,3)
Expand Down Expand Up @@ -118,5 +118,5 @@ withCreateProcess c action =

#endif

lspTestClientInfo :: Rec ("name" .== T.Text .+ "version" .== Maybe T.Text)
lspTestClientInfo = #name .== "lsp-test" .+ #version .== (Just CURRENT_PACKAGE_VERSION)
lspTestClientInfo :: L.ClientInfo
lspTestClientInfo = L.ClientInfo{L._name = "lsp-test", L._version = Just CURRENT_PACKAGE_VERSION}
6 changes: 3 additions & 3 deletions lsp-test/src/Language/LSP/Test/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE TypeInType #-}
Expand Down Expand Up @@ -80,7 +81,6 @@ import System.Process (waitForProcess)
import System.Timeout ( timeout )
import Data.IORef
import Colog.Core (LogAction (..), WithSeverity (..), Severity (..))
import Data.Row
import Data.String (fromString)
import Data.Either (partitionEithers)

Expand Down Expand Up @@ -472,8 +472,8 @@ updateState (FromServerMess SMethod_WorkspaceApplyEdit r) = do

-- TODO: move somewhere reusable
editToChangeEvent :: TextEdit |? AnnotatedTextEdit -> TextDocumentContentChangeEvent
editToChangeEvent (InR e) = TextDocumentContentChangeEvent $ InL $ #range .== (e ^. L.range) .+ #rangeLength .== Nothing .+ #text .== (e ^. L.newText)
editToChangeEvent (InL e) = TextDocumentContentChangeEvent $ InL $ #range .== (e ^. L.range) .+ #rangeLength .== Nothing .+ #text .== (e ^. L.newText)
editToChangeEvent (InR e) = TextDocumentContentChangeEvent $ InL $ TextDocumentContentChangePartial { _range = (e ^. L.range) , _rangeLength = Nothing , _text = (e ^. L.newText) }
editToChangeEvent (InL e) = TextDocumentContentChangeEvent $ InL $ TextDocumentContentChangePartial { _range = (e ^. L.range) , _rangeLength = Nothing , _text = (e ^. L.newText) }

getParamsFromDocumentChange :: DocumentChange -> Maybe DidChangeTextDocumentParams
getParamsFromDocumentChange (InL textDocumentEdit) = getParamsFromTextDocumentEdit textDocumentEdit
Expand Down
5 changes: 5 additions & 0 deletions lsp-types/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Revision history for lsp-types

## Unreleased

- Update the metamodel. This results in a number of breaking changes to the generated code, mostly replacing
anonymous structs with named ones.

## 2.1.1.0 -- 2024-02-24

- Require aeson 2
Expand Down
67 changes: 59 additions & 8 deletions lsp-types/generated/Language/LSP/Protocol/Internal/Meta.hs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions lsp-types/generated/Language/LSP/Protocol/Internal/Method.hs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3ad32c6

Please sign in to comment.