Commit graph

282 commits

Author SHA1 Message Date
Aleksey Kladov
c3a4c4429d Refactor primary IDE API
This introduces the new type -- Semantics.
Semantics maps SyntaxNodes to various semantic info, such as type,
name resolution or macro expansions.

To do so, Semantics maintains a HashMap which maps every node it saw
to the file from which the node originated. This is enough to get all
the necessary hir bits just from syntax.
2020-02-26 12:55:50 +01:00
Aleksey Kladov
8046622871 Actually drop unicase dependency 2020-02-26 11:38:33 +01:00
kjeremy
fa355d6339 Rename back to highlight and check event's again highlight range 2020-02-25 14:44:47 -05:00
Jeremy Kolb
8f6f864547 Semantic Ranges 2020-02-25 11:37:43 -05:00
Aleksey Kladov
d7da42bd40 Simplify 2020-02-25 14:59:13 +01:00
Aleksey Kladov
6542ab89ce Simplify 2020-02-25 13:49:34 +01:00
kjeremy
9f0cfb7ad2 Teach the server about Semantic Tokens proposed LSP 2020-02-24 20:59:58 -05:00
Aleksey Kladov
f551e50c16 When joining lines, unwrap trivial diverging blocks 2020-02-24 17:17:05 +01:00
Kirill Bulatov
7f3c0e8564 Omit type hints for enum variant bind pats 2020-02-24 10:32:46 +03:00
Kirill Bulatov
b2a7b29bb9 Style fixes 2020-02-23 13:02:00 +03:00
Kirill Bulatov
c200dba167 Add basic parameter name hints heuristics 2020-02-23 12:49:53 +03:00
Kirill Bulatov
ca4557ac52 Fix the tests 2020-02-23 01:44:15 +03:00
Kirill Bulatov
6670868d09 Show more parameter name hints 2020-02-23 01:44:15 +03:00
Kirill Bulatov
4ca22f3a88 Simplify inlay hints processing 2020-02-23 01:44:15 +03:00
Aleksey Kladov
fda118f4e9 Simplify 2020-02-22 16:59:31 +01:00
bors[bot]
f9acb4333f
Merge #3260
3260: Refactor how builtins are resolved r=matklad a=flodiebold

This fixes autocompletion suggesting e.g. `self::usize`. (I thought we had a bug for that, but I didn't find it.)

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-02-22 11:25:09 +00:00
adamrk
fe8ce4c41d remove unneeded collect 2020-02-21 23:51:30 +01:00
Adam Bratschi-Kaye
7be1044104 use Vec::extend instead of Vec::push in loop
Co-Authored-By: Laurențiu Nicola <lnicola@users.noreply.github.com>
2020-02-21 23:51:30 +01:00
adamrk
8b3f449b5f rename module references 2020-02-21 23:51:30 +01:00
Florian Diebold
31af774254 Refactor how builtins are resolved
This fixes autocompletion suggesting e.g. self::usize.
2020-02-21 15:39:51 +01:00
Laurențiu Nicola
5cd311d64e Fix off by one in onEnter 2020-02-20 11:24:47 +02:00
Aleksey Kladov
9549aad525 Fill missing fields of enum variants 2020-02-19 18:17:09 +01:00
bors[bot]
27587f3501
Merge #3236
3236: Merge NameDefinition and NameKind r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-19 13:57:03 +00:00
Aleksey Kladov
372439dec8 Merge NameDefinition and NameKind 2020-02-19 14:56:22 +01:00
bors[bot]
ff41558296
Merge #3235
3235: Derive visibility as well r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-19 13:46:48 +00:00
Aleksey Kladov
0d5ae89948 Derive visibility as well 2020-02-19 14:45:49 +01:00
bors[bot]
b560de4117
Merge #3234
3234: Don't store deriveable Module info in NameDefinition r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-19 13:33:30 +00:00
Aleksey Kladov
86b66067f6 Don't store deriveable Module info in NameDefinition 2020-02-19 14:32:22 +01:00
Aleksey Kladov
bcb5f1b65c Extend selection handles commas in tuple pats 2020-02-19 13:59:19 +01:00
bors[bot]
eb804261dc
Merge #3228
3228: Use proper range for hover on macro arguments r=matklad a=edwin0cheng

This PR use `original_range` to remap the range of found syntax node in `hover` and thus it should return the proper text range now.

fixed #3000 
fixed #3135 


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-19 10:46:00 +00:00
Shotaro Yamada
d06733efeb Cleanup 2020-02-19 13:36:59 +09:00
Shotaro Yamada
dd0c3c41b9 Fix a crash with non-ascii whitespace in doc-comments 2020-02-19 13:13:29 +09:00
Edwin Cheng
b9d94d73a2 Use proper range for hover on macro arguments 2020-02-19 11:56:27 +08:00
Aleksey Kladov
b4450b1043 Cleanup imports 2020-02-18 23:52:53 +01:00
Aleksey Kladov
97ab471b6d Minor simplification 2020-02-18 18:52:33 +01:00
Kirill Bulatov
f6816c253b Update versions 2020-02-18 16:12:40 +02:00
Kirill Bulatov
eceaf94f19 More manual clippy fixes 2020-02-18 16:12:37 +02:00
bors[bot]
eab80cd961
Merge #3218
3218: Cut some deps r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-18 13:46:54 +00:00
Aleksey Kladov
b643ccfaed Drop extra deps 2020-02-18 14:44:52 +01:00
Veetaha
e00922d113 ra_syntax: SyntaxError::range() now returns by value 2020-02-17 22:24:38 +02:00
Veetaha
9fdf984958 ra_syntax: reshape SyntaxError for the sake of removing redundancy 2020-02-17 22:24:33 +02:00
Aleksey Kladov
57140f1730 Drop proptest tests
It takes waaay to long to compile.

We should add quickcheck tests when we touch the relevant code next
time.
2020-02-17 16:57:06 +01:00
bors[bot]
fcf15cc05a
Merge #3169
3169: Show record field names in Enum completion r=flodiebold a=adamrk

Adresses https://github.com/rust-analyzer/rust-analyzer/issues/2947.
Previously the details shown when autocompleting an Enum variant would look like the variant was a tuple even if it was a record:
![2020-02-16-15:59:32_crop](https://user-images.githubusercontent.com/16367467/74607233-64f21980-50d7-11ea-99db-e973e29c71d7.png)

This change will show the names of the fields for a record and use curly braces instead of parentheses:
![2020-02-16-15:33:00_crop](https://user-images.githubusercontent.com/16367467/74607251-8ce17d00-50d7-11ea-9d4d-38d198a4aec0.png)

This required exposing the type `adt::StructKind` from `ra_hir` and adding a function 
```
kind(self, db: &impl HirDatabase) -> StructKind
```
in the `impl` of `EnumVariant`. 

There was also a previously existing function `is_unit(self, db: &impl HirDatabase) -> bool` for `EnumVariant` which I removed because it seemed redundant after adding `kind`.

Co-authored-by: adamrk <ark.email@gmail.com>
2020-02-17 10:54:32 +00:00
bors[bot]
93d28fb50c
Merge #3099
3099: Init implementation of structural search replace r=matklad a=mikhail-m1

next steps:
* ignore space and other minor difference
* add support to ra_cli
* call rust parser to check pattern
* documentation

original issue #2267 

Co-authored-by: Mikhail Modin <mikhailm1@gmail.com>
2020-02-17 10:02:54 +00:00
bors[bot]
8d8d542dfa
Merge #3108
3108: Magic Completion for `impl Trait for` Associated Items r=matklad a=kdelorey

# Summary
This PR adds a set of magic completions to auto complete associated trait items (functions/consts/types). 

![Associated Trait Impl](https://user-images.githubusercontent.com/2295721/74493144-d8f1af00-4e96-11ea-93a4-82725bf89646.gif)

## Notes
Since the assist and completion share the same logic when figuring out the associated items that are missing, a shared utility was created in the `ra_assists::utils` module.

Resolves #1046 

As this is my first PR to the rust-analyzer project, I'm new to the codebase, feedback welcomed!

Co-authored-by: Kevin DeLorey <2295721+kdelorey@users.noreply.github.com>
2020-02-17 09:34:08 +00:00
bors[bot]
c9989a524c
Merge #3153
3153: When a single test is run, do not run others with overlapping names r=matklad a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-17 08:52:45 +00:00
Kirill Bulatov
dabdb57067 Simplify module retrieval 2020-02-16 18:44:46 +02:00
Aleksey Kladov
28fa5edbce Add module colors to css 2020-02-16 17:06:01 +01:00
adamrk
e88eb89132 add space before/after wrapping braces 2020-02-16 16:33:15 +01:00
adamrk
04aff742b1 show names for record fields in enum completion 2020-02-16 16:10:23 +01:00