Skip to content
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

Add IDE support for glue code #408

Open
JasperDeSutter opened this issue Jan 15, 2022 · 0 comments
Open

Add IDE support for glue code #408

JasperDeSutter opened this issue Jan 15, 2022 · 0 comments

Comments

@JasperDeSutter
Copy link
Contributor

Since the glue file is meant to be normal Rust code, editor autocomplete and inline-errors should work.
When trying this with rust-analyzer, it currently fails because the macros (foreign_*) can't be resolved. This is to be expected because they aren't actual macro's, rather markers for the flapigen parser.

I think we can solve this by adding stub macros, simply for the IDE to be happy. This just needs a definition for each macro with ($($tt:tt)*) => {};. These macros would have to be added to a separate crate, not the main flapigen crate so we don't pull in the binding generator in the resulting library.

We could go even further and try to make macros that actually resemble the virtual ones, in this case the editor can help out even more and check that you are writing the rules correctly. For example:

#[allow(unused_macros)]
macro_rules! foreign_enum {
  (enum $enum:ident { $($variant: ident = $value: expr),* $(,)? }) => {
    enum _ {
      $($variant = $value)*
    }
  };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants