-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Implement ra_proc_macro client logic #3738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ra_proc_macro client logic #3738
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took quick and dirty look.
I wonder how should we handle running proc macros for code with syntax errors? Do we remove some parts of code or fix it by inserting missing syntax?
crates/ra_proc_macro/src/msg.rs
Outdated
| return Ok(None); | ||
| } | ||
| if !buf.ends_with("\r\n") { | ||
| return Err(invalid_data!("malformed header: {:?}", buf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider using anyhow for error-handling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below, I just copy and paste from https://github.com/rust-analyzer/lsp-server/blob/master/src/msg.rs , but I am okay to change it if you want.
617f2cd to
26f7270
Compare
In general, I don't think we can, since we have no information about what structure the proc macro expects :( For attribute proc macros in particular though, we should probably try to 'complete' erroneous code before passing it to the proc macro somehow. At least in easy cases. |
d8c859d to
799bcba
Compare
|
Conflicts fixed. |
799bcba to
0f48ab4
Compare
crates/ra_proc_macro/src/process.rs
Outdated
| code: ErrorCode::ServerErrorEnd, | ||
| message: "Server closed".into(), | ||
| }); | ||
| if result_tx.send(res.into()).is_err() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, lets make this an unwrap, and make sure that the opposite side of the channel is not dropped to early
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
The recv side of this channel would not be dropped as it was passed by the task channel:
|
lets land this, so that it doesn't conflict with other stuff... bors r+ |
3738: Implement ra_proc_macro client logic r=matklad a=edwin0cheng This PR add the actual client logic for `ra_proc_macro` crate: 1. Define all necessary rpc serialization data structure, which include `ra_tt` related data and some task messages. Although adding `Serialize` and `Deserialize` trait to ra_tt directly seem to be much easier, we deliberately duplicate the `ra_tt` struct with `#[serde(with = "XXDef")]` for separation of code responsibility. 2. Define a simplified version of lsp base protocol for rpc, which basically copy from lsp-server code base. 3. Implement the actual `IO` for the client side progress spawning and message passing. Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
|
bors r- |
Canceled |
|
ouch, sorry, this might now actually conflict with #3790, which I intended to land after this PR, but messed up :( Anyway, r=me |
94a068b to
3bc1670
Compare
|
bors r=matklad |
3738: Implement ra_proc_macro client logic r=matklad a=edwin0cheng This PR add the actual client logic for `ra_proc_macro` crate: 1. Define all necessary rpc serialization data structure, which include `ra_tt` related data and some task messages. Although adding `Serialize` and `Deserialize` trait to ra_tt directly seem to be much easier, we deliberately duplicate the `ra_tt` struct with `#[serde(with = "XXDef")]` for separation of code responsibility. 2. Define a simplified version of lsp base protocol for rpc, which basically copy from lsp-server code base. 3. Implement the actual `IO` for the client side progress spawning and message passing. Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Build failed |
|
bors retry |
Build succeeded |
This PR add the actual client logic for
ra_proc_macrocrate:ra_ttrelated data and some task messages. Although addingSerializeandDeserializetrait to ra_tt directly seem to be much easier, we deliberately duplicate thera_ttstruct with#[serde(with = "XXDef")]for separation of code responsibility.IOfor the client side progress spawning and message passing.