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

No autocomplete from generated bindings even with Evaluate Build Scripts enabled #6571

Closed
druerridge opened this issue Dec 29, 2020 · 4 comments
Labels
answered Issues that have an answer and don't require additional action from maintainers subsystem::build scripts subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. subsystem::IDE Issues related to general IDE functionality (tool windows, actions, etc.)

Comments

@druerridge
Copy link

Environment

  • IntelliJ Rust plugin version: 0.3.138.3572-203
  • Rust toolchain version: rustup 1.23.1 (3df2264a9 2020-11-30) + rustc 1.48.0 (7eac88abb 2020-11-16) (stable-x86_64-pc-windows-msvc)
  • IDE name and version: IntelliJ IDEA 2020.3 (Ultimate Edition) Build #IU-203.5981.155, built on November 30, 2020
  • Operating system: Windows 10

Problem description

Not receiving auto-complete (or related features, go-to defintion, etc.) for generated bindings even with (Experimental) org.rust.cargo.evaluate.build.scripts = true OR org.rust.cargo.fetch.out.dir = true In my example, I'm writing rust code to be used by the Godot game engine via Godot-Rust and the gdnative crate, which generates bindings to Godot's gdnative interface.

VS Code will give auto-completion on this sort of thing, when enabling fetchOutDir in the rust analyzer plugin.

Reading through related issues like (#1908 and #6135), most of which seem closed/working, it seems relevant that the bindings in use are being generated inside of the dependency gdnative (https://github.com/godot-rust/godot-rust) and that gdnative uses a couple lines like this to include the bindings it generates from include!(concat!(env!("OUT_DIR"), "/generated.rs"));

This is my first bug report so I hope I didn't miss something obvious, but none of the answers I found worked for me. I'd really prefer to use IntelliJ / CLion on Godot projects, especially given it seems evaluate.build.scripts will be more performant than fetching OUT_DIR.

Steps to reproduce

Using the very bare-bones Godot-Rust hello_world example project:

  1. In IntelliJ: ctrl-shift-a > Experimental Features... > org.rust.cargo.evaluate.build.scripts = true OR org.rust.cargo.fetch.out.dir = true
  2. git clone https://github.com/godot-rust/godot-rust/ (latest is probably fine, but I did it at this commit: 57973d71f0ef32fcf0e6e616ff37537d4b6a93b4)
  3. cd to examples/hello_world
  4. cargo check
  5. Open IntelliJ to /examples/hello_world/src/lib.rs
  6. Attempt to add a new line below line 15 and begin typing this: _owner.set_script(script)
  7. Expect set_script to autocomplete, as it will with VS Code + rust analyzer (when fetchOutDir is enabled)

Note that the project compiles and runs exactly as expected. All of the example projects in there suffer from the same problem with autocomplete though.

@Undin Undin added the subsystem::IDE Issues related to general IDE functionality (tool windows, actions, etc.) label Dec 29, 2020
@Undin
Copy link
Member

Undin commented Dec 29, 2020

@druerridge Thanks for the report!
As I can see, the problem is in the size of generated file by gdnative-bindings package. Try to open generated.rs produced by gdnative-bindings and you should see something like
image

It's because all IntelliJ-based IDEs have a limit of file size where code insight is available. By default, the limit is 2.56 MB and since generated.rs takes more space, it is not properly processed by your IDE.
You can increase this limit. To do it:

  • open custom VM options dialog (Help | Find Action and type Edit Custom VM Options)
  • add -Didea.max.intellisense.filesize=limitValue line where limitValue is desired limit in KB, for example, 10240. Note, it cannot be more than 20 MB.
  • restart IDE

It should solve your issue

@Undin Undin added the subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. label Dec 29, 2020
@druerridge
Copy link
Author

This fixed my issue, thank you so much! I'll submit a PR to godot-rust tutorial to make sure others can find it.

@Undin Undin added the answered Issues that have an answer and don't require additional action from maintainers label Dec 31, 2020
@Undin
Copy link
Member

Undin commented Dec 31, 2020

@druerridge Great!

I'll submit a PR to godot-rust tutorial to make sure others can find it.

Note, org.rust.cargo.fetch.out.dir experimental feature breaks incremental compilation and most likely it will be removed in the future so it's better to mention only org.rust.cargo.evaluate.build.scripts in the tutorial

@Cightline
Copy link

For anybody that comes across this do ctrl+shift+A then search for "experimental features".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Issues that have an answer and don't require additional action from maintainers subsystem::build scripts subsystem::code insight General label for issues related to code understanding: highlighting, completion, annotation, etc. subsystem::IDE Issues related to general IDE functionality (tool windows, actions, etc.)
Projects
None yet
Development

No branches or pull requests

3 participants