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

Should have better IDE support #2214

Closed
ralfbiedert opened this issue Jun 21, 2020 · 7 comments
Closed

Should have better IDE support #2214

ralfbiedert opened this issue Jun 21, 2020 · 7 comments

Comments

@ralfbiedert
Copy link

Motivation

I have the same problem as @panstromek in this PR. With the changes that landed there code completion in IntelliJ broke; and in turn yew + web-sys became unusable for me.

One could argue this is an IDE issue and having them fix the problem would be nice, but for example the underlying IntelliJ ticket has been around for 3 years, so it's unlikely to happen soon.

For most other libs I'd just switch to something with autocomplete support, but web-sys has a quasi monopoly on client-web interop, so one could also argue there is some shared responsibility.

Possible Solution?

Microsoft's win-rt uses build.rs + proc macros to create a winrt.rs, as described here, which can be included via include!(concat!(env!("OUT_DIR"), "/winrt.rs"));. This works really well for me. I am wondering if something similar is possible here?

@ralfbiedert ralfbiedert changed the title Should have better IDEs support Should have better IDE support Jun 22, 2020
@alexcrichton
Copy link
Contributor

Thanks for the report! I'm happy to review PRs and/or discuss possible ways to solve this, but unfortunately I don't have time to work on this myself. That PR is beneficial enough that I do not think it's worth reverting, additionally.

@vlad20012
Copy link

Do I understand correctly that previously all wasm-bindgen work was done in during build.rs step yielding complete IDE-supported code, but now most of the wasm-bindgen work is done by procedural macros?

@panstromek
Copy link

@vlad20012 no, this was true only for web-sys crate. All wasm-bindgen stuff is done through proc-macros, just the web-sys crate used to be
an exception generated with a build script (I guess for historical reasons). That mentioned PR just unified it with js-sys and all other user code that uses wasm-bindgen.

@panstromek
Copy link

panstromek commented Sep 5, 2020

@vlad20012 now, when you're here, I thought about this some more and I think it shouldn't be that complicated to support it in the plugin, if you're willing to special case it, because wasm-bindgen uses pretty predictable structure and the support is already "almost there". Plugin can already resolve the functions and types but namespaces them incorrectly.

Basically this is the failing structure:

#[wasm_bindgen]
extern "C" {
  type SomeJsType;
  #[wasm_bindgen]
  fn method(this: &SomeJsType);
}

Plugin sees this as a function and unrelated type but it should interpret it as:

struct SomeJsType;
impl SomeJsType {
  fn method(&self){}
}

This would make the resolution correct.

@vlad20012
Copy link

Oh, let's just support proc macros

@panstromek
Copy link

Well.. if you think that's simpler solution 😄 😄

@ralfbiedert
Copy link
Author

Closing since the latest IntelliJ update fixed the situation for me. Feel free to reopen if someone has stronger opinions about IDE support.

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

4 participants