Commit Graph

456 Commits

Author SHA1 Message Date
Steffen Lyngbaek
15ed114a49 Next steps in assoc item completion #3183
Allow trait autocompletions for unimplemented associated fn's, types,
and consts without using explicit keywords before hand (fn, type,
const).

The sequel to #3108.
2020-03-06 17:35:39 -08:00
Aleksey Kladov
80909f7698 Don't creat public APIs with typos 2020-03-06 18:38:56 +01:00
Aleksey Kladov
3ff170d658 Trigger parameter info automatically
See https://github.com/Microsoft/vscode/issues/64023
2020-03-06 18:00:06 +01:00
Aleksey Kladov
4e7f6c2354 Feature flag for arg snippets 2020-03-06 17:51:10 +01:00
Aleksey Kladov
21f40f2b8f Fix comment order 2020-03-06 17:44:30 +01:00
Florian Diebold
073a1ef834 Support aliases and Self in struct literals
Fixes #3306.
2020-03-06 15:43:14 +01:00
Aleksey Kladov
fc970d188e Prime open files on load 2020-03-05 13:40:53 +01:00
bors[bot]
94189d0a1c
Merge #3442
3442: Skip self param when completing methods r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-04 12:02:06 +00:00
Aleksey Kladov
7d2ddfd3c8 Skip self param when completing methods 2020-03-04 13:01:16 +01:00
Aleksey Kladov
98d68fa6be Cleanup API 2020-03-04 12:46:40 +01:00
Aleksey Kladov
072ec1a8ae Fix tests 2020-03-04 12:24:28 +01:00
Aleksey Kladov
994000b5dd Use method instead of a free function 2020-03-04 12:22:47 +01:00
Aleksey Kladov
e839d793ae Drop one once_cell dep 2020-03-04 12:22:47 +01:00
Aleksey Kladov
f79719b8ae Move find_refs_to_def 2020-03-04 12:22:47 +01:00
Aleksey Kladov
2638bec66c Merge refs_to_def and process_def 2020-03-04 12:22:06 +01:00
Aleksey Kladov
1874b6738a Move ReferenceKind 2020-03-04 12:22:06 +01:00
Aleksey Kladov
a549da7e3e Move SearchScope 2020-03-04 12:22:06 +01:00
bors[bot]
66ec6bdfb0
Merge #3432
3432: Feature/snippet completions r=matklad a=iTZAvishay

This PR implements #1705 and is based on #3430 to avoid future conflicts.

The completions are placing default values with the names of the parameters, demo: 
![call_me_demo](https://user-images.githubusercontent.com/5567310/75828341-461ca400-5db4-11ea-88d8-88e59ac1a197.gif)


Co-authored-by: Avishay Matayev <me@avishay.dev>
2020-03-04 11:05:14 +00:00
Aleksey Kladov
5095573139 Remove stray FIXME 2020-03-04 11:55:25 +01:00
Aleksey Kladov
19115e9fab Support cross-crate marks 2020-03-04 11:55:25 +01:00
Avishay Matayev
fb34a5ba06 Support function's completion snippet
Note that `detail` was replced with `function_signature` to avoid
calling `from` on FunctionSignature twice.

I didn't add new tests because the current ones seem enough.
2020-03-04 11:03:32 +02:00
Florian Diebold
e55fc286fc Fix completion snippet for reexported functions
Fixes #3356.
2020-03-03 20:49:50 +01:00
Aleksey Kladov
53cab1cd21 Fix imports 2020-03-03 18:54:39 +01:00
Aleksey Kladov
177229bfde Move reference classification to ra_ide_db
Lost some marks along the way :-(
2020-03-03 18:50:15 +01:00
Aleksey Kladov
d49a4d1863 Rename NameDefinition -> Definition 2020-03-03 18:40:27 +01:00
Aleksey Kladov
7d71cc72b5 Refactor reference search a bit 2020-03-03 18:22:52 +01:00
bors[bot]
674770ef04
Merge #3422
3422: Add profile call r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-03 16:17:38 +00:00
Aleksey Kladov
2ff2c29a1e Add profile call 2020-03-03 17:11:25 +01:00
Aleksey Kladov
cf0ececb7a Highlight assist tests 2020-03-03 17:03:46 +01:00
Aleksey Kladov
8f3677a94a Remove stray dbg 2020-03-03 16:41:52 +01:00
Aleksey Kladov
1a6f51da66 Simplify: remove couple of useless functions 2020-03-02 19:03:46 +01:00
Aleksey Kladov
2716a1fa3f More principled approach for gotodef for field shorhand
Callers can now decide for themselves if they should prefer field or
local definition. By default, it's the local.
2020-03-02 19:00:38 +01:00
bors[bot]
ea67e2346e
Merge #3384
3384: fix #2377 super::super::* r=flodiebold a=JoshMcguigan

Thanks @matklad for the detailed explanation on #2377. I believe this fixes it.

One thing I'm not sure about is you said the fix would involve changing `crates/ra_hir_def/src/path/lower/lower.rs`, but I only changed `crates/ra_hir_def/src/path/lower/lower_use.rs`. I'm not sure what kind of test code I'd have to write to expose the issue in `lower.rs`, but I'd be happy to add it if you are able to provide additional guidance. 

closes #2377

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2020-03-01 13:36:44 +00:00
Josh Mcguigan
0057d1e10d fix completion for super::super:: 2020-02-29 21:04:21 -08:00
Aleksey Kladov
584c8d9875 Slightly refactor inlay hints 2020-02-29 23:24:50 +01:00
Aleksey Kladov
2e0d89401a Remove debug print 2020-02-29 23:03:49 +01:00
Aleksey Kladov
a1e1869554 Rename ast::ImplBlock -> ast::ImplDef 2020-02-29 21:33:15 +01:00
Aleksey Kladov
5f8b37563e Cleanup editing API 2020-02-29 13:51:23 +01:00
bors[bot]
c692e07b4f
Merge #3367
3367: Fix highlighting of const patterns r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-28 15:56:07 +00:00
Aleksey Kladov
56ce34c6a7 Correctly flag 'lifetime definitions as definitions 2020-02-28 16:53:12 +01:00
Aleksey Kladov
5ebfcb9cb7 Fix highlighting of const patterns 2020-02-28 16:38:36 +01:00
bors[bot]
93f632ca4e
Merge #3366
3366: Simpilfy original_range logic r=matklad a=edwin0cheng

This PR fixed another [bug](https://github.com/rust-analyzer/rust-analyzer/issues/3000#issuecomment-592474844) which incorrectly map the wrong range of `punct` in macro_call and simplify the logic a little bit by introducing an `ascend_call_token` function.



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-28 15:07:33 +00:00
Edwin Cheng
7a5ff0f37c Simpilfy origin_range logic 2020-02-28 22:53:59 +08:00
Aleksey Kladov
209eb32796 Classify name takes const patterns into account 2020-02-28 15:27:52 +01:00
Aleksey Kladov
da40149572 Fix union classification 2020-02-28 15:03:09 +01:00
Aleksey Kladov
9464ca97c9 Fix highlighting test 2020-02-28 14:47:33 +01:00
Aleksey Kladov
701cf43606 Cleanup highlighting tags 2020-02-28 12:13:37 +01:00
Aleksey Kladov
996e18846d add more tags 2020-02-28 10:39:31 +01:00
Edwin Cheng
cda04d2077 Fix typo 2020-02-28 15:39:34 +08:00
Edwin Cheng
5f30dd6f72 Remove hover::type_of 2020-02-28 11:37:22 +08:00
Aleksey Kladov
e74484e133 Refactor string literals 2020-02-27 17:19:53 +01:00
Aleksey Kladov
fedab39011
Merge pull request #3350 from edwin0cheng/give-up-hover-in-builtin-macro
Ignore hover on builtin macro
2020-02-27 16:48:22 +01:00
Aleksey Kladov
c6247f74c7 Basic injections 2020-02-27 16:16:13 +01:00
Edwin Cheng
c42bbc5e37 Ignore hover on builtin macro 2020-02-27 23:03:18 +08:00
Aleksey Kladov
8215b74032 Move tests to a new file 2020-02-27 14:20:22 +01:00
Aleksey Kladov
695460fbf5 More cleanup 2020-02-27 14:14:24 +01:00
Aleksey Kladov
a2dbdbba00 Split loop into orthogonal phases 2020-02-27 11:56:42 +01:00
Aleksey Kladov
9bb1718639 Cleanup 2020-02-27 11:39:54 +01:00
Aleksey Kladov
819bbd0864 Minor cleanup 2020-02-27 11:37:21 +01:00
bors[bot]
50956f89fc
Merge #3285
3285: Handle trivia in Structural Search and Replace r=matklad a=adamrk

Addresses the second point of https://github.com/rust-analyzer/rust-analyzer/issues/3186.

Structural search and replace will now match code that has varies from the pattern in whitespace or comments.

One issue is that it's not clear where comments in the matched code should go in the replacement. With this change they're just tacked on at the end, which can cause some unexpected moving of comments (see the last test example).

Co-authored-by: adamrk <ark.email@gmail.com>
2020-02-27 08:54:18 +00:00
Aleksey Kladov
2374f8ddd8 Renam module 2020-02-27 09:46:41 +01:00
bors[bot]
2180591593
Merge #3335
3335: Refactor highlighting a bit r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-27 08:32:44 +00:00
Aleksey Kladov
9784ab9f39 Move html highlightig to a separate module 2020-02-27 09:32:00 +01:00
Aleksey Kladov
995c46024b Fix html tests 2020-02-27 09:32:00 +01:00
Aleksey Kladov
f7db49bfc6 Better highlightign API 2020-02-27 09:32:00 +01:00
Shotaro Yamada
33de107ed9 Remove unused dependencies 2020-02-27 14:04:13 +09:00
Edwin Cheng
61fd6c6270 Use text_range::extend_to 2020-02-27 10:06:48 +08:00
Aleksey Kladov
913cdcee8f
Merge pull request #3325 from edwin0cheng/skip-trival-token
Skip trival token in original_range
2020-02-26 17:58:32 +01:00
Aleksey Kladov
f38bac48e5 More type safety for highlighting 2020-02-26 17:17:15 +01:00
Edwin Cheng
553254973e Skip trival token in original_range 2020-02-27 00:12:26 +08:00
Edwin Cheng
ffdc740446 Add recursive support in original_range 2020-02-26 20:53:00 +08:00
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
adamrk
b1ee6d17a4 get matches from code.descendants 2020-02-25 23:53:29 +01:00
adamrk
94603d9848 save comments as ra_syntax::ast::Comment 2020-02-25 23:35:16 +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
adamrk
4f1d90e73b Handle trivia in strucural search and replace 2020-02-23 22:14:47 +01: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
Kevin DeLorey
057d0bee55 Added module doc comment to explain the purpose of the completion. 2020-02-15 10:27:04 -06:00
Kevin DeLorey
ae8ae650fc Fixed bug that allowed for completion in a nested method. 2020-02-15 09:50:07 -06:00
Kevin DeLorey
fc13b7fc9a Reordered the use items. 2020-02-14 18:54:00 -06:00
Kirill Bulatov
426c0f26fe If possible, use --exact flag when running tests 2020-02-15 01:06:14 +02:00
Mikhail Modin
f8f454ab5c Init implementation of structural search replace 2020-02-14 21:45:42 +00:00
Kevin DeLorey
be97cbfdb4 Adjusted the completion lookups to filter by just the name. 2020-02-13 19:10:08 -06:00
Kevin DeLorey
0bc9e62374 Completion now replaces whole fn/const/type def with snippet. 2020-02-12 21:00:47 -06:00
Kevin DeLorey
43e62a87ab Cheese const tests as they requre an ident before becoming a CONST_DEF. 2020-02-12 20:46:55 -06:00
Kevin DeLorey
877cfbacf9 Started to refactor the trigger of the trait_impl completion. 2020-02-12 20:21:43 -06:00
Aleksey Kladov
6ec982d54d Simplify 2020-02-12 18:02:00 +01:00
Aleksey Kladov
f3dd0a05bb Return early, return often 2020-02-11 18:36:12 +01:00
Aleksey Kladov
adfed5c689 Fix join lines when two rules match 2020-02-11 18:33:25 +01:00
Kevin DeLorey
6f130e7ef8 Formatting. 2020-02-11 10:07:23 -06:00
Kevin DeLorey
47d314e856 Fixing minor suggestions and added module level documentation. 2020-02-11 10:04:30 -06:00
Kevin DeLorey
e664cd73e3 Removed doc comments entirely from the changes. 2020-02-11 09:48:26 -06:00
bors[bot]
305d921982
Merge #3064
3064: Handle macro token cases for rename r=matklad a=edwin0cheng

Fixes #2957

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-02-11 15:46:05 +00:00
Kevin DeLorey
3aaf46afa1 Formatted changes. 2020-02-11 09:40:08 -06:00
Kevin DeLorey
d7e36c3dd2 Removed docs from private method. 2020-02-11 07:31:39 -06:00
Kevin DeLorey
785723e0d9 Added tests to test associated types and consts. 2020-02-10 21:02:51 -06:00
Kevin DeLorey
52c4324e31 Added some documentation to the complete_trait_impl completion. 2020-02-10 20:55:49 -06:00
Kevin DeLorey
3ffc84fd15 Added associated const magic completion. 2020-02-09 20:59:12 -06:00
Matthew Jasper
8c8d0bb34f Add or- and parenthesized-patterns 2020-02-09 22:06:15 +00:00
Kevin DeLorey
d85abd77b9 Added a utility function that can be used to determine the missing impl items. 2020-02-09 12:24:59 -06:00
Kevin DeLorey
a957c473fd Merge branch 'master' into kdelorey/complete-trait-impl 2020-02-09 10:37:43 -06:00
Aleksey Kladov
9769c5140c Simplify Assists interface
Instead of building a physical tree structure, just "tag" related
assists with the same group
2020-02-09 16:03:54 +01:00
Edwin Cheng
3038470c68 Use get_or_insert_with 2020-02-09 20:41:29 +08:00