Commit graph

415 commits

Author SHA1 Message Date
Lukas Wirth
f615efdfc3 Factor out pick_best_token ide pattern into ide_db 2021-06-22 17:50:15 +02:00
Lukas Wirth
2113c46797 Cleanup insert_use tests 2021-06-19 22:33:29 +02:00
Lukas Wirth
344cb5e76a Don't insert imports outside of cfg attributed items 2021-06-18 23:56:43 +02:00
bors[bot]
d9666ce509
Merge #9334
9334: feat: Allow to disable import insertion on single path glob imports r=Veykril a=Veykril

On by default as I feel like this is something the majority would prefer.

Closes #8490

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-18 21:23:22 +00:00
Lukas Wirth
2ee090faaf Allow to disable import insertion on single path glob imports 2021-06-18 23:11:56 +02:00
rdambrosio
8e08b86304 Feat: inline generics in const and func trait completions 2021-06-17 19:54:28 -04:00
Aleksey Kladov
66673eae2b internal: retire famous_defs_fixture
This is now done declaratively via `minicore`.
2021-06-18 00:42:32 +03:00
Aleksey Kladov
ebb591a570 internal: add derive and ord support to minicore 2021-06-18 00:30:22 +03:00
Aleksey Kladov
ca99aaa053 internal: add From to minicore 2021-06-17 21:04:12 +03:00
Aleksey Kladov
82c7afc703 minor: dead code 2021-06-17 20:51:34 +03:00
Aleksey Kladov
08c220ab2c internal: add default to minicore 2021-06-17 20:49:49 +03:00
Aleksey Kladov
ac35645455 internal: remove dead code 2021-06-17 11:42:43 +03:00
Aleksey Kladov
a43bba760e internal: switch some tests to minicore 2021-06-17 11:41:36 +03:00
Aleksey Kladov
1e100e8b3e internal: cleanup tests
* ensure standard, non-indented style (should add this check to
  `fixture` some day)
* removed a couple of ignores
2021-06-15 12:48:05 +03:00
Aleksey Kladov
c2015e7d18 internal: more natural order of sources for TypeParam
We usually use first (left) variant of `Either` for "usual" case, and
use right for odd things. For example, pat source is Pat | SelfParam.
2021-06-14 22:42:43 +03:00
Aleksey Kladov
94f7b63522 minor: less ambiguous name 2021-06-14 19:16:03 +03:00
Aleksey Kladov
9fb67e7477 internal: document rename challenges 2021-06-14 19:08:12 +03:00
Aleksey Kladov
26c978f258 internal: adapt diagnostics to the new rename API 2021-06-14 18:46:54 +03:00
Aleksey Kladov
a91071b57b internal: cut deps between assists and diagnostics 2021-06-14 17:45:17 +03:00
Maan2003
5ac6804bb3
cargo fmt 2021-06-13 09:48:15 +05:30
Maan2003
c9b4ac5be4
clippy::redudant_borrow 2021-06-13 09:24:16 +05:30
Aleksey Kladov
0463d76a1f internal: cross-crate cov-marks 2021-06-12 23:40:52 +03:00
bors[bot]
21d4416235
Merge #9218
9218: Item search now respects trait impl items r=Veykril a=Veykril

Fixes #2977

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-11 17:33:34 +00:00
Lukas Wirth
48f65b3b15 Item search now respects trait impl items 2021-06-11 19:24:52 +02:00
Jonas Schievink
1d6eef1350 Update ungrammar 2021-06-11 18:34:30 +02:00
Kirill Bulatov
3aaf07b8cb Add more profiling for flyimports 2021-06-10 23:43:46 +03:00
Lukas Wirth
26c869ddc0 Don't classify attributes on macro-calls are the macro itself 2021-06-10 00:26:15 +02:00
Lukas Wirth
31aad2528f Fix edge case for ImportGranularity guessing 2021-06-08 22:14:30 +02:00
Lukas Wirth
aa29364f83 Reorder CompletionContext fields 2021-06-07 19:06:03 +02:00
Lukas Wirth
fc06058a76 Unescape generated clippy lints 2021-06-05 19:14:53 +02:00
Lukas Wirth
0c89f38378 Replace - with _ in generated lint names 2021-06-04 19:10:52 +02:00
Lukas Wirth
0b9ba4977e Generate default lint groups 2021-06-04 18:55:08 +02:00
Lukas Wirth
343df88ac7 Generate default lint completions 2021-06-04 18:35:19 +02:00
Jonas Schievink
9fdb8f9037 Make it opt-in 2021-06-03 18:09:21 +02:00
Jonas Schievink
f96c1a0414 Implement per-edition preludes 2021-06-01 13:39:19 +02:00
bors[bot]
e9a797748d
Merge #8866
8866: Update salsa r=matklad a=jonas-schievink

This updates salsa to include https://github.com/salsa-rs/salsa/pull/265, and removes all cancellation-related code from rust-analyzer

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-31 12:42:32 +00:00
Lukas Wirth
a6b92a8cc0 simplify 2021-05-28 20:46:09 +02:00
Jonas Schievink
33debc4065 Update salsa 2021-05-27 15:05:41 +02:00
Kirill Bulatov
050c592b8c Exclude inherent traits more eagerly 2021-05-27 02:00:23 +03:00
bors[bot]
495c9586ec
Merge #8945
8945: fix: Make expected type work in more situations r=flodiebold a=flodiebold

Also makes call info show the correct types for generic methods.

![2021-05-23-182952_1134x616_scrot](https://user-images.githubusercontent.com/906069/119269023-dd5a5b00-bbf5-11eb-993a-b6e122c3b9a6.png)
![2021-05-23-183117_922x696_scrot](https://user-images.githubusercontent.com/906069/119269025-dfbcb500-bbf5-11eb-983c-fc415b8428e0.png)


Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-05-23 21:55:51 +00:00
Florian Diebold
b8262099cc Get rid of field_type again 2021-05-23 23:54:35 +02:00
Aleksey Kladov
8d5f59e0f1 minor: align import style with styleguide 2021-05-23 23:40:19 +03:00
Florian Diebold
4a6cdd776d Record method call substs and use them in call info 2021-05-23 18:24:21 +02:00
Lukas Tobias Wirth
da7f1eb756 Don't compare ast::Visibility by stringifying 2021-05-20 17:45:59 +02:00
bors[bot]
8bb37737c9
Merge #8873
8873: Implement import-granularity guessing  r=matklad a=Veykril

This renames our `MergeBehavior` to `ImportGranularity` as rustfmt has it as the purpose of them are basically the same. `ImportGranularity::Preserve` currently has no specific purpose for us as we don't have an organize imports assist yet, so it currently acts the same as `ImportGranularity::Item`.

We now try to guess the import style on a per file basis and fall back to the user granularity setting if the file has no specific style yet or where it is ambiguous. This can be turned off by setting `import.enforceGranularity` to `true`.

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8870

Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
2021-05-20 08:27:16 +00:00
Lukas Tobias Wirth
2bf720900f Check for differing attributes in granularity guessing 2021-05-20 10:25:04 +02:00
Jonas Schievink
ea8555b155 Simplify eager macro representation 2021-05-19 20:19:08 +02:00
Lukas Tobias Wirth
b4fe479236 Replace ImportGranularity::Guess with guessing boolean flag 2021-05-19 15:57:10 +02:00
Lukas Tobias Wirth
5fd9f6c7b9 Add ImportGranularity::Guess 2021-05-18 20:21:47 +02:00
Lukas Tobias Wirth
b8a99692d1 Implement import-granularity guessing 2021-05-18 20:10:39 +02:00
Lukas Tobias Wirth
64f7072c25 MergeBehavior -> ImportGranularity 2021-05-18 19:53:20 +02:00
alcroito
1f7d2a6c22 Add new LSP extension for workspace symbol lookup
The new extension allows filtering of workspace symbool lookup
results by search scope or search kind.

Filtering can be configured in 3 different ways:

 - The '#' or '*' markers can be added inline with the symbol lookup
   query.

   The '#' marker means symbols should be looked up in the current
   workspace and any dependencies. If not specified, only current
   workspace is considered.

   The '*' marker means all kinds of symbols should be looked up
   (types, functions, etc). If not specified, only type symbols are
   returned.

 - Each LSP request can take an optional search_scope or search_kind
   argument query parameter.

 - Finally there are 2 global config options that can be set for all
   requests served by the active RA instance.

Add support for setting the global config options to the VSCode
extension.
The extension does not use the per-request way, but it's useful for
other IDEs.

The latest version of VSCode filters out the inline markers, so
currently the only reasonable way to use the new functionality is
via the global config.
2021-05-18 00:40:30 +02:00
Aleksey Kladov
73123a7550 internal: remove SyntaxRewriter 2021-05-14 16:40:11 +03:00
Aleksey Kladov
0650f77dd9 internal: remove one more immutable tree 2021-05-14 16:19:27 +03:00
Lukas Wirth
6a8d47e7f0 Give MergeBehaviour variants better names 2021-05-10 21:14:59 +02:00
Aleksey Kladov
4f3c0adc5a internal: introduce ast::make::ext module with common shortcuts
There's a tension between keeping a well-architectured minimal
orthogonal set of constructs, and providing convenience functions.
Relieve this pressure by introducing an dedicated module for
non-orthogonal shortcuts.

This is inspired by the django.shortcuts module which serves a similar
purpose architecturally.
2021-05-09 19:55:43 +03:00
Lukas Wirth
3a346412cf Don't handle Self as a usage for TraitDefs 2021-05-08 23:35:18 +02:00
Lukas Wirth
04717b9bd2 Fix builtintype def_to_ty 2021-05-08 22:43:26 +02:00
Lukas Wirth
41f470fea8 Correctly support SelfType when searching for usages 2021-05-08 22:34:55 +02:00
Aleksey Kladov
6a16ec52aa internal: use API stabilized in 1.52 2021-05-06 20:12:15 +03:00
Lukas Wirth
050c69c19d Split out merge_imports module from helpers::insert_use 2021-04-24 13:31:43 +02:00
bors[bot]
5cbde9f531
Merge #8591 #8638
8591: Remove SyntaxRewriter usage in insert_use in favor of mutable syntax trees r=matklad a=Veykril

Unfortunately changing `insert_use` to not use `SyntaxRewriter` creates a lot of changes since so much relies on that. But on the other hand this should be the biggest usage of `SyntaxRewriter` I believe.

8638: Remove SyntaxRewriter::from_fn r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-23 16:49:08 +00:00
bors[bot]
85bab7539a
Merge #8317
8317: Convert tuple struct to named struct assist r=Veykril a=unexge

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8192

Co-authored-by: unexge <unexge@gmail.com>
2021-04-23 13:37:48 +00:00
unexge
322cd1fa7f Use multiple loops instead of Iterator::chain in FindUsages 2021-04-21 16:42:47 +03:00
Lukas Wirth
b290cd5782 Add cov_marks to insert_use tests 2021-04-20 19:34:43 +02:00
Lukas Wirth
fa20a5064b Remove SyntaxRewriter usage in insert_use in favor of ted 2021-04-20 02:09:12 +02:00
Lukas Wirth
2f62c0117a Check for rust doc code attributes like rustdoc does 2021-04-19 13:32:52 +02:00
bors[bot]
3f432730df
Merge #8467
8467: Adds impl Deref assist r=jhgg a=jhgg

This PR adds a new `generate_deref` assist that automatically generates a deref impl for a given struct field.

Check out this gif:

![2021-04-11_00-33-33](https://user-images.githubusercontent.com/5489149/114296006-b38e1000-9a5d-11eb-9112-807c01b8fd0a.gif)

--

I have a few Q's:
 - [x] Should I write more tests, if so, what precisely should I test for?
 - [x] I have an inline question on line 65, can someone provide guidance? :) 
 - [x] I can implement this for `ast::TupleField` too. But should it be a separate assist fn, or should I try and jam both into the `generate_deref`?
 - [x] I want to follow this up with an assist on `impl $0Deref for T {` which would automatically generate a `DerefMut` impl that mirrors the Deref as well, however, I could probably use some pointers on how to do that, since I'll have to reach into the ast of `fn deref` to grab the field that it's referencing for the `DerefMut` impl. 

Co-authored-by: jake <jh@discordapp.com>
2021-04-19 04:54:04 +00:00
bors[bot]
52585df24a
Merge #8546
8546: Return CallInfo for unclosed call expressions r=Veykril a=Veykril

Closes #8522
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-16 21:00:55 +00:00
Lukas Wirth
992965cd82 Return CallInfo for unclosed call expressions 2021-04-16 22:57:33 +02:00
Kirill Bulatov
739edfd5cf Exclude inherent traits from flyimports 2021-04-16 11:13:17 +03:00
Kirill Bulatov
af8a6049a5 Profile trait solving for all invocations 2021-04-14 19:11:17 +03:00
jake
a624e2ea8d Adds impl Deref assist 2021-04-11 00:42:05 -07:00
Jonas Schievink
035d84558c Avoid O(n²) when constructing AttrSourceMap 2021-04-06 22:25:44 +02:00
unexge
8d4be829e0 Add convert tuple struct to named struct assist 2021-04-04 20:52:43 +03:00
unexge
d3a112d68c Allow including Self kw references to FindUsages 2021-04-04 20:48:31 +03:00
Graeme Coupar
ee03849017 Convert Into to From assist
This adds a "Convert Into to From" assist, useful since clippy has
recently started adding lints on every `Into`.

It covers converting the signature, and converting any `self`/`Self`
references within the body to the correct types.

It does assume that every instance of `Into` can be converted to a
`From`, which I _think_ is the case now.  Let me know if there's
something I'm not thinking of and I can try and make it smarter.
2021-04-03 15:48:35 +01:00
bors[bot]
55d7d71590
Merge #8267
8267: Adding gifs and screenshots for features in manual r=matklad a=MozarellaMan

For #6539

This includes most of gif or screenshot examples of most items in the "Features" header. With the exceptions of:

- **On Typing Assists** - couldn't get it to work for a demo, I'm probably missing something?
- **Structural search and replace** - looked to be already a visual example of the feature
- **Workspace symbol** - wasn't sure how best to show this, all of the examples maybe? Also wasn't sure of the best code example to show it off
- **Semantic Syntax Highlighting** - seemed obvious enough to not need a screenshot, but I could easily add this

All the gifs/pngs are hosted in this [comment](https://github.com/rust-analyzer/rust-analyzer/issues/6539#issuecomment-809574840). Please let me know if any of them aren't suitable (and why) and I'll improve it! Or if you don't like the theme/font

Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
2021-03-31 10:01:56 +00:00
Ayomide Bamidele
276022682b Gifs and screenshots for features in manual 2021-03-31 00:08:10 +01:00
bors[bot]
fd7c454d51
Merge #8186
8186: Lower traits to `TraitRef` instead of `TypeRef` r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-30 16:45:05 +00:00
Jonas Schievink
41c7448e12 Accurately classify assoc. types in paths 2021-03-30 02:09:17 +02:00
Lukas Wirth
c2a63b97a8 Rename target_ty to self_ty 2021-03-29 17:47:47 +02:00
bors[bot]
bb1d925dab
Merge #8212
8212: Basic support macro 2.0 r=jonas-schievink a=edwin0cheng

Turn out it is quite straight forward :)

r @jonas-schievink 

![m2](https://user-images.githubusercontent.com/11014119/112712565-6eb99380-8f0b-11eb-88de-5d7f974dfe6d.png)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-28 15:43:11 +00:00
Lukas Wirth
1ef55002c2 Cleanup ide_db imports 2021-03-27 21:51:00 +01:00
Edwin Cheng
4520002b63 Unleash macro 2.0 in hightlight and more 2021-03-27 14:42:49 +08:00
cynecx
5ff3299dd6 syntax: return owned string instead of leaking string 2021-03-26 18:30:59 +01:00
Jonas Schievink
4781479ab2 Sweep the new TraitEnvironmentQuery 2021-03-24 18:59:35 +01:00
Lukas Wirth
395183e0b7 Cleanup Definition::search_scope 2021-03-23 13:03:55 +01:00
Lukas Wirth
7c4eb66c1a Merge hir::MacroDef::is_* into hir::MacroDef::kind 2021-03-23 11:32:14 +01:00
Lukas Wirth
bad4e48672 Set up a search scope when searching for mbe macro references 2021-03-23 11:32:10 +01:00
Aleksey Kladov
45a8f37b6a Compute more mathematically well-rounded notion of transitive deps
By including the crate itself, we make the resulting set closed with
respect to `transitve_reveres_dependencies` operation, as it becomes a
proper transitive closure. This just feels more proper and mathy.

And, indeed, this actually allows us to simplify call sites somewhat.
2021-03-23 12:49:55 +03:00
Aleksey Kladov
9cbf09ec4f rewrite merge use trees assist to use muatable syntax trees
changelog internal
2021-03-22 20:47:46 +03:00
Edwin Cheng
7784cadc3d Reexport PrefixKind to remove deps to hir 2021-03-22 13:39:13 +08:00
Kirill Bulatov
b17d99c070 Fix the profile string 2021-03-21 11:45:37 +02:00
Kirill Bulatov
eaa4fcbbde Less reallocations 2021-03-21 11:45:37 +02:00
Kirill Bulatov
ec731e19df Use smart case in flyimport items lookup 2021-03-21 11:45:37 +02:00
bors[bot]
09412d85fc
Merge #8123
8123: Do not display unqualified assoc item completions r=SomeoneToIgnore a=SomeoneToIgnore

Part of https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/autoimport.20weirdness

Removes all flyimport completions for any unqualified associated type, effectively reverting https://github.com/rust-analyzer/rust-analyzer/pull/8095 
I've explained the reasoning in the corresponding FIXME and open to discussions.
As an alternative way, we could add yet another parameter in the method that's used by the `qualify_path` and enable it for the qualify assists only.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-03-21 09:37:08 +00:00
Lukas Wirth
38048c35d8 Don't use an untyped String for ActiveParam tracking 2021-03-20 23:22:09 +01:00
Kirill Bulatov
56a7d246d5 Disable unqualified assoc items completion for now 2021-03-20 23:08:44 +02:00
Kirill Bulatov
879432452d Docs 2021-03-20 22:55:34 +02:00
Kirill Bulatov
a631108d2d Do not query item search by name eagerly 2021-03-20 22:33:54 +02:00
Kirill Bulatov
81961dc035 Do not propose assoc items without qualifiers 2021-03-20 22:18:43 +02:00
Lukas Wirth
34464ede3f Fix associated items not being appended to paths in import_assets 2021-03-18 21:36:52 +01:00
Jonas Schievink
5fbb97a0f0 Rename item_tree query to file_item_tree 2021-03-18 01:53:37 +01:00
Lukas Wirth
5734b347dd Fix incorrect newline emission in Attrs::docs 2021-03-17 17:00:08 +01:00
Matthias Krüger
ff5f90d8ae use simpler .map(|x| y) instead of .and_then(|x| Some(y)) for Options. (clippy::bind_instead_of_map) 2021-03-17 02:36:29 +01:00
Matthias Krüger
966c23f529 avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
2021-03-17 01:27:56 +01:00
bors[bot]
979e788957
Merge #8034
8034: Implement Crate::transitive_reverse_dependencies r=matklad a=Veykril

changelog internal Implement Crate::transitive_reverse_dependencies

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-16 14:54:12 +00:00
Aleksey Kladov
f5a81ec468 Upgrade rowan
Notably, new rowan comes with support for mutable syntax trees.
2021-03-16 16:10:49 +03:00
Lukas Wirth
e97cd709cd Implement Crate::transitive_reverse_dependencies 2021-03-15 18:28:31 +01:00
Laurențiu Nicola
88cee24c6c Enable thread-local coverage marks 2021-03-15 16:02:50 +02:00
Lukas Wirth
41745f48d5 move Semantics::visit_file_defs to ide_db::helpers 2021-03-15 12:18:52 +01:00
bors[bot]
5138baf2ac
Merge #8021 #8022
8021: Enable searching for builtin types r=matklad a=Veykril

Not too sure how useful this is for reference search overall, but for completeness sake it should be there 
![image](https://user-images.githubusercontent.com/3757771/111132711-f69db600-8579-11eb-8c90-22fd6862d11f.png)

Also enables document highlighting for them.


8022: some clippy::performance fixes r=matklad a=matthiaskrgr

use vec![] instead of Vec::new() + push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unnecessary resizing

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
2021-03-15 10:05:49 +00:00
Aleksey Kladov
5dcdf2ceee Move code to the appropriate layer
StructureNodeKind is a type which is specific to a particular feature,
file_structure. It shouldn't be in the "code shared by all ide features"
part.
2021-03-15 12:55:27 +03:00
Lukas Wirth
9763d9e8c4 Enable searching for builtin types 2021-03-15 09:32:06 +01:00
ivan770
7d48e04f31
Introduce StructureNodeKind 2021-03-14 19:00:41 +02:00
ivan770
71a97a2d8c
Provide regions in file structure 2021-03-14 18:53:37 +02:00
bors[bot]
7accf6bc37
Merge #7799
7799: Related tests r=matklad a=vsrs

![tests](https://user-images.githubusercontent.com/62505555/109397453-a9013680-7947-11eb-8b11-ac03079f7645.gif)
This adds an ability to look for tests for the item under the cursor: function, constant, data type, etc

The LSP part is bound to change. But the feature itself already works and I'm looking for a feedback :)



Co-authored-by: vsrs <vit@conrlab.com>
2021-03-13 13:50:35 +00:00
vsrs
daa2637486 Apply review suggestions 2021-03-11 17:39:41 +03:00
Aleksey Kladov
842d8ad9c8 Compilation speed 2021-03-09 22:30:58 +03:00
Kirill Bulatov
778deb38fe Better strip turbofishes 2021-03-08 23:59:39 +02:00
Kirill Bulatov
5168ab16e1 Add rustdocs and use better names 2021-03-08 23:59:37 +02:00
Kirill Bulatov
dccbb38d2e Less lifetines: derive SemanticsScope in place 2021-03-08 23:59:20 +02:00
Kirill Bulatov
84c575a212 Restrict fuzzy qualifiers for now 2021-03-08 23:59:20 +02:00
Kirill Bulatov
5b7d928075 Enforce the located imports' order 2021-03-08 23:59:20 +02:00
Kirill Bulatov
24a5d3b19d Fix the completion labels and tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
33c83e72b9 Work towards better import labels 2021-03-08 23:59:20 +02:00
Kirill Bulatov
4d4ac1d4fa Profile import_assets better 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e214c3a6bd Simplify 2021-03-08 23:59:20 +02:00
Kirill Bulatov
e74c55bb4a Refactor the import location 2021-03-08 23:59:20 +02:00
Kirill Bulatov
89d410cef5 Do not propose already imported imports 2021-03-08 23:59:20 +02:00
Kirill Bulatov
9482353fa8 Properly handle turbofishes in qualifiers 2021-03-08 23:59:20 +02:00
Kirill Bulatov
d386481fac Fix some tests 2021-03-08 23:59:20 +02:00
Kirill Bulatov
582cee2cdf Return more data about located imports 2021-03-08 23:59:18 +02:00
Kirill Bulatov
309421c117 Draft the qualifier import resolution 2021-03-08 23:58:48 +02:00
Kirill Bulatov
c395c3311d Filter out path items by the qualifier 2021-03-08 23:58:33 +02:00
Kirill Bulatov
f08c0cdd2a Simplify 2021-03-08 23:58:33 +02:00
Kirill Bulatov
7584260b9a Find the code to change 2021-03-08 23:58:33 +02:00
Kirill Bulatov
005bc49d74 Test and initial refactoring 2021-03-08 23:58:32 +02:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
asv
96fc01a30b Make group imports configurable 2021-03-07 10:15:17 +02:00
Lukas Wirth
8d305680e6 Show docs on hover for keywords and primitives 2021-03-02 14:41:01 +01:00
Vincent Esche
c4e2f32d73 Fixed remaining references to AnalysisChange (now: Change)
(The type was renamed/moved in 8716c4cec3)
2021-02-28 12:57:41 +01:00
vsrs
5d23d8bc29 Add runnables::related_tests 2021-02-27 18:00:17 +03:00
lbrande
9db970ee08 De Morgan's Law assist now correctly inverts <, <=, >, >=. 2021-02-24 11:58:37 +01:00
Lukas Wirth
9e8f4d31a4 Pickup ConstReference patterns in FindUsages 2021-02-23 23:31:53 +01:00
Lukas Wirth
e52bdc55ef Implement ast::AstNode for NameLike and move it to node_ext 2021-02-16 19:27:08 +01:00
Jonas Schievink
50d18eb0a6 Use cfg(target_arch) instead of a Cargo feature
Not that WASM works right now anyways...
2021-02-16 18:50:06 +01:00
bors[bot]
c9672a0539
Merge #7657
7657: utf8 r=matklad a=matklad

- Prepare for utf-8 offsets
- reduce code duplication in tests
- Make utf8 default, implement utf16 in terms of it
- Make it easy to add additional context for offset conversion
- Implement utf8 offsets

closes #7453

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-02-16 16:34:22 +00:00
Aleksey Kladov
95209aa3f8 Make utf8 default, implement utf16 in terms of it 2021-02-16 19:17:32 +03:00
Aleksey Kladov
00cc778c8c reduce code duplication in tests 2021-02-16 19:17:32 +03:00
Aleksey Kladov
2cb4ac9eb4 Prepare for utf-8 offsets 2021-02-16 19:17:32 +03:00
kjeremy
f9bb398cc5 Fix a few clippy::perf warnings 2021-02-16 10:55:34 -05:00
Lukas Wirth
403a63d2b4 Don't classify attribute macros as their path unless it's a function with the proc_macro_attribute attribute 2021-02-13 22:11:31 +01:00
Lukas Wirth
c5be0b2589 Use NameLike in FileReference directly as its not exported from ide anymore 2021-02-12 18:58:29 +01:00
Lukas Wirth
d644728d82 Refactor reference searching to work with the ast 2021-02-12 18:58:28 +01:00
Jonas Schievink
5d99ba1d9a Make ModPath's representation private 2021-02-04 20:49:24 +01:00
Aleksey Kladov
d35bda6429 Make always-assert crate reusable 2021-01-26 22:13:42 +03:00
bors[bot]
3a5cd6bbc6
Merge #7406
7406: if_let_match: don't assume happy path r=matklad a=bugadani

Closes #7392

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2021-01-26 12:12:45 +00:00
Lukas Wirth
a872ebf81f Support unions in symbol search 2021-01-24 01:32:52 +01:00
Dániel Buga
24f0cd8293 replace_if_let_with_match: don't assume sad pattern 2021-01-22 23:29:51 +01:00
bors[bot]
0c37b3a0fc
Merge #7353
7353: Add LifetimeParam and ConstParam to CompletionItemKind r=matklad a=Veykril

Adds `LifetimeParam` and `ConstParam` to `CompletionItemKind` and maps them both to `TypeParam` in the protocol conversion as there are no equivalents, so nothing really changes there.
`ConstParam` could be mapped to `Const` I guess but I'm split on whether that would be better?

Additions were solely inspired by (the single) test output for const params.

Also sorts the variants of `CompletionItemKind` and its to_proto match.



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-22 15:31:47 +00:00
Jonas Schievink
896dfacfc4 Add name resolution query for block expressions 2021-01-21 15:22:17 +01:00
Jonas Schievink
82146737ac Treat BlockExpr as a potential module origin 2021-01-20 20:05:48 +01:00
Lukas Wirth
f2cb7dbcb7 Partially unify SymbolKind and CompletionItemKind 2021-01-20 18:39:46 +01:00
Jonas Schievink
0587b99fde Make public DefMap fields private 2021-01-20 15:41:18 +01:00
Lukas Wirth
563a175fdb Move SymbolKind to ide_db 2021-01-20 15:25:34 +01:00
Aleksey Kladov
46b4f89c92 . 2021-01-20 01:56:11 +03:00
bors[bot]
342bf41022
Merge #7297 #7338
7297: Propose trait associated items and autoimport traits on completion r=matklad a=SomeoneToIgnore

![trait_imports](https://user-images.githubusercontent.com/2690773/104819998-6faeb480-583a-11eb-8b45-b7351b51b90e.gif)

Closes #7248

7338: Parse `impl const Trait` r=Veykril a=Veykril

Closes #7313

bors r+

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-18 19:40:11 +00:00
bors[bot]
9daba961f2
Merge #7291
7291: Wrap remaining self/super/crate in Name{Ref} r=matklad a=Veykril

That should be the remaining special casing for `self` 🎉 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-18 16:13:06 +00:00
bors[bot]
9eb37fbdeb
Merge #7292
7292: Swap assert_eq_text\!(expected, actual) r=matklad a=u5surf

Fixes #7283 

Swap assert_eq_text parameters in the order (expected, actual)

Co-authored-by: yugo-horie <u5.horie@gmail.com>
2021-01-18 10:12:54 +00:00
Kirill Bulatov
09c11054a1 Do trait solving in batch 2021-01-17 02:57:38 +02:00
Kirill Bulatov
68626e4ef5 Draft the working completion 2021-01-17 02:57:34 +02:00
Kirill Bulatov
db335a1bbf Add flyimport completion for trait assoc items 2021-01-16 20:44:12 +02:00
Kirill Bulatov
6742f38e49 Share import_assets and related entities 2021-01-16 19:33:36 +02:00
yugo-horie
f273995a25 Swap assert_eq_text\!(expected, actual) 2021-01-16 13:30:26 +09:00
Lukas Wirth
98718e0544 Wrap remaining self/super/crate in Name{Ref} 2021-01-15 22:18:43 +01:00
unexge
a3a722de9f Add Unmerge Use assist 2021-01-15 22:14:51 +03:00
Lukas Wirth
cb863390f2 Handle self/super/crate in PathSegment as NameRef 2021-01-15 19:21:23 +01:00
Lukas Wirth
d5095329a1 Phase out SourceFileEdits in favour of a plain HashMap 2021-01-14 22:43:36 +01:00
Lukas Wirth
f51457a643 Group file source edits by FileId 2021-01-14 18:35:22 +01:00
bors[bot]
39167b97d8
Merge #7260
7260: Render Fn* trait objects and impl types as rust does r=matklad a=Veykril

Also fixes raw ptr impl types being rendered ambiguously with multiple predicates.
This moves out the `FamousDefs::Fixture` into its own file as well, cause I figured it is big enough to get its own file at this point + we also get highlighting this way when editing it.

Fixes #3012

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-14 09:07:15 +00:00
Lukas Wirth
3d6480bc31 Render Fn* trait objects and impl types as rust does 2021-01-13 13:29:47 +01:00
Lukas Wirth
e9e3ab549d Move FamousDefs fixture out into its own file 2021-01-12 17:26:08 +01:00
Lukas Wirth
aff9102afb Rename FileReferences -> UsageSearchResult 2021-01-12 15:56:24 +01:00
Lukas Wirth
2c1777a2e2 Ensure uniqueness of file ids in reference search via hashmap 2021-01-12 15:51:02 +01:00
Lukas Wirth
fbdb32adfc Group references by FileId 2021-01-12 01:03:04 +01:00
bors[bot]
607b9ea160
Merge #7218
7218: Fix typos r=Veykril a=regexident

Apart from the very last commit on this PR (which fixes a public type's name) all changes are non-breaking.

Co-authored-by: Vincent Esche <regexident@gmail.com>
2021-01-10 18:16:29 +00:00
Lukas Wirth
b795128dde Use hir::GenericParam in ide_db::Definition instead of relisting all 3 2021-01-10 12:33:47 +01:00
Vincent Esche
21f8239ac8 Fixed typos in code comments 2021-01-09 15:41:29 +01:00
bors[bot]
1a29934c37
Merge #7145
7145: Proper handling $crate Take 2 [DO NOT MERGE] r=edwin0cheng a=edwin0cheng

Similar to previous PR (#7133) , but improved the following things :

1. Instead of storing the whole `ExpansionInfo`, we store a similar but stripped version `HygieneInfo`.
2. Instread of storing the `SyntaxNode` (because every token we are interested are IDENT), we store the `TextRange` only.
3. Because of 2, we now can put it in Salsa.
4. And most important improvement: Instead of computing the whole frames every single time, we compute it recursively through salsa: (Such that in the best scenario, we only need to compute the first layer of frame)

```rust
        let def_site = db.hygiene_frame(info.def.file_id);
        let call_site = db.hygiene_frame(info.arg.file_id);

        HygieneFrame { expansion: Some(info), local_inner, krate, call_site, def_site }
```

The overall speed compared to previous PR is much faster (65s vs 45s) :
```
[WITH old PR]
Database loaded 644.86ms, 284mi
Crates in this dir: 36
Total modules found: 576
Total declarations: 11153
Total functions: 8715
Item Collection: 15.78s, 91562mi
Total expressions: 240721
Expressions of unknown type: 2635 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 865
Inference: 49.84s, 250747mi
Total: 65.62s, 342310mi
rust-analyzer -q analysis-stats .  66.72s user 0.57s system 99% cpu 1:07.40 total

[WITH this PR]
Database loaded 665.83ms, 284mi
Crates in this dir: 36
Total modules found: 577
Total declarations: 11188
Total functions: 8743
Item Collection: 15.28s, 84919mi
Total expressions: 241229
Expressions of unknown type: 2637 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 868
Inference: 30.15s, 135293mi
Total: 45.43s, 220213mi   
rust-analyzer -q analysis-stats .  46.26s user 0.74s system 99% cpu 47.294 total
```

*HOWEVER*,  it is still a perf regression (35s vs 45s):
```
[WITHOUT this PR]
Database loaded 657.42ms, 284mi
Crates in this dir: 36
Total modules found: 577
Total declarations: 11177
Total functions: 8735
Item Collection: 12.87s, 72407mi
Total expressions: 239380
Expressions of unknown type: 2643 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 868
Inference: 22.88s, 97889mi
Total: 35.74s, 170297mi
rust-analyzer -q analysis-stats .  36.71s user 0.63s system 99% cpu 37.498 total
```



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-08 03:57:11 +00:00
Kevaundray Wedderburn
72b9a4fbd3 Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
Aleksey Kladov
c8ace3a295 Remove some stale deprecations 2021-01-07 13:54:18 +03:00
Edwin Cheng
76f2b9d2ef Proper handling $crate Take 2 2021-01-07 13:08:32 +08:00
Aleksey Kladov
f8a0561178 Align config's API with usage
The config now is mostly immutable, optimize for that.
2021-01-06 21:22:24 +03:00
Kirill Bulatov
ca42a52051 Code review fixes 2021-01-04 18:33:05 +02:00
Jesse Bakker
c7e0c7f43a Upgrade expect-test to 1.1 2021-01-03 14:43:29 +01:00
Nick Spain
71c9a884d1 Fix type error with .and_then 2021-01-02 21:53:52 +11:00
Nick Spain
68b4efd536 Handle not finding range in Definition::search_scope
The `LifetimeParam` and `Local` variants use `source()` to find their
range. Now that `source()` returns an `Option` we need to handle the
`None` case.
2021-01-02 21:53:52 +11:00
Nick Spain
ea4708c444 Mark HasSource::source_old as deprecated but allow at all call sites 2021-01-02 21:53:51 +11:00