Commit graph

6879 commits

Author SHA1 Message Date
Aleksey Kladov
3c72fc0573 Anchor file-system operations to the file, and not to the source root.
Anchoring to the SourceRoot wont' work if the path is absolute:

  #[path = "/tmp/foo.rs"]
  mod foo;

Anchoring to a file will.

However, we *should* anchor, instead of just producing an abs path.

I can imagine a situation where, for example, rust-analyzer processes
crates from different machines (or, for example, from in-memory git
branch), where the same absolute path in different crates might refer
to different files in the end!
2020-06-16 18:45:58 +02:00
bors[bot]
6b2175878d
Merge #4891
4891: New VFS API r=matklad a=matklad

cc @flodiebold , @jonas-schievink 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-16 11:48:36 +00:00
Aleksey Kladov
c002322bde New VFS API 2020-06-16 13:42:29 +02:00
bors[bot]
4342b71715
Merge #4876
4876: Syntactic highlighting of NAME_REF for injections r=matklad a=ltentrup

This commit adds a function that tries to determine the syntax highlighting class of NAME_REFs based on the usage.
It is used for highlighting injections (such as highlighting of doctests) as the semantic logic will most of the time result in unresolved references.
It also adds a color to unresolved references in HTML encoding.

Follow up of #4683.
Fixes #4809.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-16 11:40:51 +00:00
bors[bot]
83a16e825d
Merge #4878
4878: Make "Replace qualified name with use" replace *all* mentions of the path r=matklad a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/4836

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-16 05:29:05 +00:00
Jonas Schievink
4295a004ed Operate only on AST paths instead of HIR 2020-06-16 00:49:59 +02:00
Jonas Schievink
aaaa68b56c Simplify 2020-06-15 22:59:49 +02:00
Jonas Schievink
71c002e589 It's fookin' raw 2020-06-15 22:39:26 +02:00
Leander Tentrup
c4b3db0c2f Syntactic highlighting of NAME_REF for injections
This commit adds a function that tries to determine the syntax highlighting class of NAME_REFs based on the usage.
It is used for highlighting injections (such as highlighting of doctests) as the semantic logic will most of the time result in unresolved references.
It also adds a color to unresolved references in HTML encoding.
2020-06-15 22:13:53 +02:00
bors[bot]
f4f51171ca
Merge #4860
4860: Accept relative paths in rust-project.json r=matklad a=tweksteen

If a relative path is found as part of Crate.root_module or Root.path, interpret it as relative to the location of the rust-project.json file.

Fixes: #4816 

Co-authored-by: Thiébaud Weksteen <tweek@google.com>
2020-06-15 15:03:31 +00:00
bors[bot]
5b013e5665
Merge #4877
4877: Fix syntax highlighting of recursive macros r=matklad a=ltentrup

Add syntax highlighting for the BANG (`!`) token if the parent is `MACRO_CALL`.

Before:
<img width="514" alt="before" src="https://user-images.githubusercontent.com/201808/84595030-11f65c00-ae56-11ea-9bb2-b1abe2236990.png">

After:
<img width="516" alt="recursive-macro" src="https://user-images.githubusercontent.com/201808/84594981-d196de00-ae55-11ea-8636-f877d5d795ff.png">


Fixes #4694.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-15 13:44:46 +00:00
Leander Tentrup
06f89e5f3a Fix syntax highlighting of recursive macros
Add syntax highlighting for the BANG (`!`) token if the parent is `MACRO_CALL`.
2020-06-15 15:03:13 +02:00
David Lattimore
fe7d35d477 Make ra_syntax::{SyntaxNodeChildren, SyntaxElementChildren} public.
SyntaxNode::children and SyntaxNode::children_with_tokens return these types, but there's currently no way AFAIK to name them.
2020-06-15 21:36:30 +10:00
Thiébaud Weksteen
44f28f65af Accept relative paths in rust-project.json
If a relative path is found as part of Crate.root_module or Root.path,
interpret it as relative to the location of the rust-project.json file.
2020-06-15 13:11:53 +02:00
bors[bot]
db6100dbaa
Merge #4889
4889: Deprecate hir::Path::from_ast r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-15 09:02:53 +00:00
Aleksey Kladov
b5c4f2faa2 Update parser tests with env var 2020-06-15 11:02:17 +02:00
Aleksey Kladov
d739731830 Allow attributes on expressions
https://github.com/rust-lang/rust/pull/69201/
2020-06-15 10:59:05 +02:00
Aleksey Kladov
52a220cece Deprecate hir::Path::from_ast 2020-06-15 10:55:48 +02:00
bors[bot]
6609e71b16
Merge #4882
4882: _match.rs: improve comment formatting r=matklad a=jonas-schievink

This results in much nicer rustdoc output

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-15 08:25:05 +00:00
Toby Dimmick
41f5471f3e fill_match_arms bind pattern implementation 2020-06-14 22:44:51 +01:00
Toby Dimmick
34db4edb80 fill_match_arms bind pattern test 2020-06-14 22:43:16 +01:00
Jonas Schievink
4ebafb9005 _match.rs: improve comment formatting 2020-06-14 15:56:02 +02:00
Aleksey Kladov
a32cff333d Introduce paths crate
It's a good idea to distinguish between absolute and relative paths at
the type level, to avoid accidental dependency on the cwd, which
really shouldn't matter for rust-analyzer service
2020-06-14 14:15:36 +02:00
Jonas Schievink
5d66bfe163 Shorten *all* qualified paths when adding use 2020-06-13 19:12:05 +02:00
Jonas Schievink
b65c0a5893 Expose find_insert_use_container 2020-06-13 19:05:46 +02:00
Jonas Schievink
e9eb54c617 Fix rewrite_root when there's only 1 replacement 2020-06-13 19:05:46 +02:00
bors[bot]
246c66a7f7
Merge #4867
4867: Cleanup URL handling r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-13 12:35:44 +00:00
Aleksey Kladov
50bbf7233d Cleanup URL handling 2020-06-13 14:15:38 +02:00
bors[bot]
d00ca86da4
Merge #4868
4868: Fix if and while postfix completions r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-13 12:12:08 +00:00
Aleksey Kladov
7dafe951d4 Fix if and while postfix completions 2020-06-13 14:06:13 +02:00
bors[bot]
c87c4a0a40
Merge #4700
4700: Add top level keywords completion r=matklad a=mcrakhman

This fixes the following issue: https://github.com/rust-analyzer/rust-analyzer/issues/4566. 

Also added simple logic which filters the keywords which can be used with unsafe on the top level.   

Co-authored-by: Mikhail Rakhmanov <rakhmanov.m@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-13 12:02:59 +00:00
Aleksey Kladov
b99b4953c9 More concise completion tests 2020-06-13 13:57:18 +02:00
Aleksey Kladov
ef70076f1d Cleanup 2020-06-13 13:47:30 +02:00
Mikhail Rakhmanov
912f38200f Add keywords completions on source file position 2020-06-13 10:43:39 +02:00
Mikhail Rakhmanov
16bbf4ab7f Merge branch 'master' into keyword_completion
# Conflicts:
#	docs/user/generated_features.adoc
2020-06-13 08:42:15 +02:00
Mikhail Rakhmanov
eeb8b9e236 Fix tests and remove unused methods 2020-06-13 01:21:48 +02:00
Mikhail Rakhmanov
6feb52c12a Add more patterns, tests and fix keywords 2020-06-13 00:55:21 +02:00
Mikhail Rakhmanov
3576671043 Rewrite snapshot checks 2020-06-12 20:30:57 +02:00
Gabriel Valfridsson
66291d19f9 Revert "Hide squiggly for unused and unnecessary"
This reverts commit 599c105e6f.
2020-06-12 18:39:50 +02:00
bors[bot]
b56ad148db
Merge #4857
4857: Fix invalid shorthand initialization diagnostic for tuple structs r=jonas-schievink a=OptimalStrategy

Initializing tuple structs explicitly, like in the example below, produces a "Shorthand struct initialization" diagnostic that leads to a compilation error when applied:
```rust
struct S(usize);

fn main() { 
    let s = S { 0: 0 };  // OK, but triggers the diagnostic
    // let s = S { 0 };  // Compilation error
}
```

This PR adds a check that the field name is not a literal.

Co-authored-by: OptimalStrategy <george@usan-podgornov.com>
Co-authored-by: OptimalStrategy <17456182+OptimalStrategy@users.noreply.github.com>
2020-06-12 14:28:40 +00:00
OptimalStrategy
591b5ec2c1 simplify determining whether the field is a tuple field 2020-06-12 10:16:19 -04:00
bors[bot]
f3d73865d6
Merge #4855
4855: Use more idiomatic style for lifetimes in generated code r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-12 12:49:30 +00:00
bors[bot]
1906655070
Merge #4856
4856: Simplify r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-12 12:41:52 +00:00
Mikhail Rakhmanov
42a719ad25 Remove comment and incorrect assert 2020-06-12 13:14:53 +02:00
Mikhail Rakhmanov
d38bf1624d Return snapshots to tests 2020-06-12 13:09:42 +02:00
Jonas Schievink
0231e4ac77 find_path: return shorter paths for external items
If a containing module is already in scope, there's no need to
use the full path to the item.
2020-06-12 13:01:20 +02:00
Mikhail Rakhmanov
f123539ad2 More assert refactoring 2020-06-12 12:15:53 +02:00
Mikhail Rakhmanov
4c92f2d190 Add more pattern tests 2020-06-12 10:12:15 +02:00
Mikhail Rakhmanov
396167eadb New testing approach for keywords 2020-06-12 08:49:12 +02:00
OptimalStrategy
59f195a323 Fix invalid shorthand initialization diagnostic for tuple structs 2020-06-12 01:11:54 -04:00