Go to file
bors[bot] 9ee96dcf4a
Merge #3816
3816: vscode: add goto ast node definition from rust source code r=Veetaha a=Veetaha

By holding the `Ctrl` key you can now goto-definition of the appropriate syntax token in the syntax tree read-only editor. But actually going to the definition is not very convenient, since it opens the new editor, you'd rather just hold the `Ctrl` and look at the syntax tree because it is automatically scrolled to the proper node and the node itself is enclosed with text selection.

Unfortunately, the algorithm is very simple (because we don't do any elaborate parsing of the syntax tree text received from the server), but it is enough to debug not very large source files.
I tested the performance and in a bad case (rust source file with 5K lines of code) it takes `1.3` seconds to build the `rust -> ast` mapping index (lazily once on the first goto definition request) and each lookup in this worst-case is approx `20-120` ms. I think this is good enough. In the simple case where the file is < 100 lines of code, it is instant.

One peculiarity that I've noticed is that vscode doesn't trigger the goto-definition provider when the user triggers it on some punctuation characters (i.e. it doesn't underline them and invoke te goto-definition provider), but if you explicitly click `Ctrl+LMB` it will only then invoke the provider and navigate to the definition in a new editor. I think this is fine ;D

![rust2ast](https://user-images.githubusercontent.com/36276403/78198718-24d1d500-7492-11ea-91f6-2687cedf26ee.gif)


Related: #3682 

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-02 08:34:03 +00:00
.cargo Alternative quite tests alias 2019-11-20 22:22:32 +03:00
.github Enable backtrace on CI 2020-03-30 10:49:11 +02:00
.vscode Rewrite auto-update 2020-03-19 09:04:59 +01:00
crates Merge #3820 2020-04-02 07:55:11 +00:00
docs vscode: move docks about syntax tree to dev/README.md 2020-04-02 11:23:56 +03:00
editors/code vscode: postrefactor 2020-04-02 11:13:38 +03:00
xtask Get rid of ItemOrMacro 2020-03-26 16:10:01 +01:00
.gitattributes Set text to autodetect and use LF 2019-11-14 19:44:37 -05:00
.gitignore cargo xtask dist 2020-03-04 18:18:20 +01:00
bors.toml Gate CI on windows build 2020-01-26 14:15:57 +01:00
Cargo.lock filetime and proc-macro-hack 2020-04-01 10:36:00 -04:00
Cargo.toml Extend analysis-stats a bit 2020-02-15 18:04:01 +01:00
LICENSE-APACHE
LICENSE-MIT
README.md Link proper docs from readme 2020-03-05 17:26:47 +01:00
rustfmt.toml Remove forcing \n via rustfmt 2019-11-02 22:19:59 +03:00

rust-analyzer logo

rust-analyzer is an experimental modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust. If you want to get involved, check the rls-2.0 working group:

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0

Work on rust-analyzer is sponsored by

Ferrous Systems

Quick Start

https://rust-analyzer.github.io/manual.html#installation

Documentation

If you want to contribute to rust-analyzer or are just curious about how things work under the hood, check the ./docs/dev folder.

If you want to use rust-analyzer's language server with your editor of choice, check the manual folder. It also contains some tips & tricks to help you be more productive when using rust-analyzer.

Getting in touch

We are on the rust-lang Zulip!

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0

License

Rust analyzer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.