+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_workspace): ensure all parameters and result structs on the workspace interface are serializable #2928

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Jul 25, 2022

Summary

This PR adds a new serde_workspace feature to rome_service that automatically derives the Serialize and Deserialize traits from serde on all the types that transit through the Workspace interface (including types declared in other crates and transitively included in this interface). This feature is currently disabled by default but prepares the way for the workspace potentially being callable across IPC or FFI boundaries, and in the meantime still imposes some limitations on how data can transit across the Workspace trait that forces it to work across languages (code actions for instance are now represented as language-agnostic text diffs, instead of language-specific syntax trees)

Test Plan

This code is currently untested since the feature is disabled by default, however since it all relies on the procedural derive macros from serde simply running cargo build -p rome_service --features serde_workspace is enough to verify that everything compiles correctly, maybe this command could be added to the suite of tests being run on GitHub Actions ?

@leops leops requested review from ematipico and xunilrj as code owners July 25, 2022 15:28
@leops leops requested a review from a team July 25, 2022 15:28
@leops leops requested a review from MichaReiser as a code owner July 25, 2022 15:28
@leops leops temporarily deployed to aws July 25, 2022 15:28 Inactive
@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4628e0b
Status: ✅  Deploy successful!
Preview URL: https://fa1cf558.tools-8rn.pages.dev
Branch Preview URL: https://feature-workspace-serde.tools-8rn.pages.dev

View logs

@github-actions
Copy link

@github-actions
Copy link

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45878 45878 0
Passed 44938 44938 0
Failed 940 940 0
Panics 0 0 0
Coverage 97.95% 97.95% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5946 5946 0
Passed 395 395 0
Failed 5551 5551 0
Panics 0 0 0
Coverage 6.64% 6.64% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12393 12393 0
Failed 3864 3864 0
Panics 0 0 0
Coverage 76.23% 76.23% 0.00%

@ematipico
Copy link
Contributor

Re: test plan

I presume that once we start using the new feature internally, we should start seeing its benefits/repercussions?

Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Does that mean that we limit ourself to a Workspace facade that only uses serializable types? Do you see this as a limiting factor e.g. in a long-running CLI service that isn't restricted by the fact that the returned result types must be serializable? Would it be an option to have a specific Workspace facade for consumers that require a serializable/message based interface or is this something you can still see us do in the future/

@leops
Copy link
Contributor Author

leops commented Jul 26, 2022

I presume that once we start using the new feature internally, we should start seeing its benefits/repercussions?

Besides laying out the groundwork for future work on a client-server system with a shared daemon process, one of the immediate application of this change could be in the JavaScript or WebAssembly bindings. Since this change transitively ensures that most of the "public API" types are serializable it opens the possibility of using serde for transmitting objects across FFI boundaries

Does that mean that we limit ourself to a Workspace facade that only uses serializable types?

Yes that's the general intent for the moment, obviously a lot of concepts for our internal client-server model still need to be fleshed out so the idea I'm currently going with is to have this interface as constrained as possible to facilitate future experimentation.
For instance even in the context of a long running CLI process like monitoring a running bundler development server, I think it could still be beneficial to use a Workspace instance shared with a Language Server process, so that both the editor experience and bundler execution can benefit from hot caches primed by the other process.
In general since the Workspace is a high-level, language-agnostic abstraction most of the data going through this interface is going to be strings intended to be directly displayed to the user, either in the form of console messages or editor UI annotations, so requiring everything to be serializable doesn't seem like a constraint that will be hard to keep

@leops leops merged commit e32f523 into main Jul 26, 2022
@leops leops deleted the feature/workspace-serde branch July 26, 2022 09:37
IWANABETHATGUY pushed a commit to IWANABETHATGUY/tools that referenced this pull request Aug 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载