Commit graph

460 commits

Author SHA1 Message Date
Chayim Refael Friedman
f7746cffc2 Don't complete doc(hidden) enum variants and use trees
Also refactor the check a bit.
2025-01-26 00:13:11 +02:00
Lukas Wirth
ae74cc3b88 Skip redundant path search in resolve_completion_edits 2025-01-25 13:03:01 +01:00
Lukas Wirth
b31f53e0d6 Fix flyimport not filtering via stability of import path 2025-01-25 12:18:54 +01:00
Lukas Wirth
3a163faba1
Merge pull request #19012 from ShoyuVanilla/arbitrary-self
feat: Implement `arbitrary-self-types`
2025-01-24 14:04:34 +00:00
Shoyu Vanilla
f4dfbc38c8 feat: Implement arbitrary-self-types 2025-01-24 22:50:59 +09:00
Lukas Wirth
1329e6be49
Merge pull request #18993 from ChayimFriedman2/iter-config
feat: Provide a config to control auto-insertion of `await` and `iter()`
2025-01-24 13:31:30 +00:00
Chayim Refael Friedman
47f4f3f0b2 Provide a config to control auto-insertion of await and iter() 2025-01-21 18:51:09 +02:00
Chayim Refael Friedman
8e0bc9f67f Sort completion items that skip await and iter() behind those that don't
I don't think my ranking is perfect, because it places them even behind snippet completions, but this is something.
2025-01-21 11:44:38 +02:00
Lukas Wirth
76585539f5 Cleanup Name string rendering 2025-01-21 10:05:32 +01:00
Lukas Wirth
c78cc2baa9
Merge pull request #18977 from ChayimFriedman2/fix-upmapping
fix: Fix missing upmapping in trait impls completion
2025-01-21 07:41:22 +00:00
Chayim Refael Friedman
ce1759635b Fix another bug with completion of trait items inside macros
This time, when completing the keyword (e.g. `fn` + whitespace).

The bug was actually a double-bug:
First, we did not resolve the impl in the macro-expanded file but in the real file, which of course cannot work.
Second, in analysis the whitespace was correlated with the `impl` and not the incomplete `fn`, which caused fake (where we insert an identifier after the whitespace) and real expansions to go out of sync, which failed analysis. The fix is to skip whitespaces in analysis.
2025-01-20 21:21:42 +02:00
Lukas Wirth
a06606c802 Fix import search not discarding rawness 2025-01-20 14:29:11 +01:00
Lukas Wirth
51cc1a4614 Properly record meaningful imports as re-exports in symbol index 2025-01-20 14:29:11 +01:00
Chayim Refael Friedman
a2826598f5 Fix missing upmapping in trait impls completion 2025-01-19 12:47:19 +02:00
Lukas Wirth
903bc8133c
Merge pull request #18952 from lh123/add-raw-keyword-complete
feat: complete raw, const keyword
2025-01-16 14:24:53 +00:00
lh123
a282733b49 don't complete raw in &mut $0 2025-01-16 19:40:42 +08:00
lh123
9809143562 feat: complete raw, const keyword 2025-01-16 18:27:59 +08:00
Lukas Wirth
24e1db2f0c Minor docs improvement 2025-01-16 11:05:20 +01:00
Lukas Wirth
71f1c4470d Add edit test for await skipping completions 2025-01-16 10:56:57 +01:00
Lukas Wirth
3e2848dc59 Add missing #[rust_analyzer::rust_fixture] annotations 2025-01-16 10:51:57 +01:00
Lukas Wirth
c7f187430f
Merge pull request #18927 from ChayimFriedman2/skip-iter-await
feat: Add smart completions that skip `await` or `iter()` and `into_iter()`
2025-01-16 08:47:26 +00:00
Chayim Refael Friedman
cec9fa1606 Add smart completions that skip await or iter() and into_iter()
E.g. complete `await.foo()`.
2025-01-15 22:32:07 +02:00
boattime
41687437af feat: Add dereferencing autocomplete 2025-01-13 17:00:49 -08:00
Lukas Wirth
bf669dab84 Re-implement rust string highlighting via tool attribute 2025-01-10 13:49:35 +01:00
Lukas Wirth
cc016df54b
Merge pull request #18889 from ChayimFriedman2/subtle-completion
fix: Fix actual token lookup in completion's `expand()`
2025-01-09 12:12:38 +00:00
Chayim Refael Friedman
0c77bce011 Fix actual token lookup in completion's expand()
It should be left biased, not right biased, because when e.g. the use has typed `h` then requested completion, the `h` is what we want to find, not the next token (which might indeed be inside a macro call).

I'm not sure why I wrote `right_biased()` to begin with (I remember I had a reason and not just "both should work"), I might've copied the code in `expand_and_analyze()` (which is wrong, because there it lookups on the speculative file, where right biased will always find the correct token and left biased not).

This is still not perfect, because there might not be an identifier already typed then we might still end up in a macro call, but this is the best we can do.
2025-01-09 05:22:14 +02:00
Vishruth-Thimmaiah
b21a5f83d2
refactor test helpers within ide-completions 2025-01-08 23:51:18 +05:30
Lukas Wirth
32b86a8378
Merge pull request #18884 from Veykril/push-xwqkorxozzkq
fix: Fix `env`/`option_env` macro check disregarding macro_rules definitions
2025-01-08 10:14:51 +00:00
Lukas Wirth
acccd4bde6 fix: Fix env/option_env macro check disregarding macro_rules definitions 2025-01-08 10:59:58 +01:00
Lukas Wirth
1e975d6ee4
Merge pull request #18855 from Giga-Bowser/migrate-if-let
internal: Migrate `if let` replacement assists to `SyntaxEditor`
2025-01-08 08:59:42 +00:00
Vishruth-Thimmaiah
cb0221d774
fix: do not offer completions within macro strings 2025-01-07 17:02:28 +05:30
Laurențiu Nicola
cd12ef8547
Merge pull request #18853 from ChayimFriedman2/no-completion
Fix case where completion inside macro that expands to `#[test]` was unavailable
2025-01-07 06:44:50 +00:00
Giga Bowser
913d197a04 internal: make::expr_prefix should return ast::PrefixExpr 2025-01-06 15:32:08 -06:00
Chayim Refael Friedman
b24142b50b Fix case where completion inside macro that expands to #[test] was unavailable
We ignore `#[test]` in the def map, so that's why it failed.
2025-01-06 22:02:24 +02:00
Lukas Wirth
4b6007115a minor: New clippy lints 2025-01-06 17:57:17 +01:00
Lukas Wirth
bf7597cd5a Hide synthetic locals from completions 2025-01-04 16:48:08 +01:00
Lukas Wirth
1adc805dfa Cleanup 2025-01-01 15:21:54 +01:00
Lukas Wirth
5303dc5d99 Revamp auto-import exclude config 2025-01-01 15:06:44 +01:00
Lukas Wirth
c5bda0d3f7 Simplify completion config path resolutions 2025-01-01 14:32:45 +01:00
Lukas Wirth
45954ebaa4 Reduce the default autoimport exclusion list 2025-01-01 14:32:45 +01:00
Chayim Refael Friedman
a02a1afc92 Allow flyimporting excluded trait items if there is an exact match in the name
I.e. with `fn foo()`, don't complete at `x.fo|`, but complete (with imports) for `x.foo|`, since this is less likely to have false positives.

I opted to only do that for flyimport, even though for basic imports there can also be snippet completion (completing the params list for a method), since this is less universally applicable and seems not so useful.
2025-01-01 13:54:23 +01:00
Chayim Refael Friedman
7e6ade117c Allow excluding specific traits from completion
To be accurate, only their methods are excluded, the trait themselves are still available.

I also excluded a bunch of std traits by default. Some less opinionated, like `AsRef`, which should never be used directly except in generic scenarios (and won't be excluded there), some more opinionated, like the ops traits, which I know some users sometimes want to use directly. Either way it's configurable.

It should be pretty easy to extend support to excluding only specific methods, but I didn't do that currently.

Traits configured to be excluded are resolved in each completion request from scratch. If this proves too expensive, it is easy enough to cache them in the DB.
2025-01-01 13:49:35 +01:00
Chayim Refael Friedman
02d47f3a81 Fix a case where completion was unable to expand a macro
Which caused the macros of the popular `tracing` crate to not offer completions.

The reason is rather complicated: it boils down to macro ignoring their input and completion always choosing the first expansion.
2024-12-20 13:14:59 +02:00
Lukas Wirth
540ada516a internal: Cleanup label structure of CompletionItem 2024-12-18 13:37:21 +01:00
Lukas Wirth
ada5f2059c fix: Fix path qualified auto-importing completions not working with re-exports
Prior to this commit we used to generate import paths, then zipped them with the existing qualifier to check if they agree on the path to import.
This is brittle when re-exports come into play causing items to have multiple applicable paths that refer to them.
This commit instead rewrites this logic by generating the import path for the qualifier, verifying that the rest of the qualifier resolves and then doing a final lookup on that resolution result for the final segment instead.
2024-12-16 13:20:55 +01:00
Lukas Wirth
28fbecff42 Show expansion errors in expand_macro feature 2024-12-13 09:36:03 +01:00
Chayim Refael Friedman
0b7a6f38d7 Properly handle different defaults for severity of lints
Previously all lints were assumed to be `#[warn]`, and we had a hand-coded list of `#[allow]` exceptions. Now the severity is autogenerated from rustdoc output.

Also support lints that change status between editions, and the `warnings` lint group.
2024-12-11 20:48:41 +02:00
Kirill Bulatov
62d97d9ba7 Draft completion hashing 2024-12-09 22:26:00 +02:00
Lukas Wirth
f3d7415bd6 Parse lifetime bounds in lifetime param into TypeBoundList
This mainly aids in error recovery but also makes it a bit easier to handle lifetime resolution.
While doing so it also came apparent that we were not actually lowering lifetime outlives relationships within lifetime parameter declaration bounds, so this fixes that.
2024-12-05 17:52:02 +01:00
Lukas Wirth
99c9a9942a
Merge pull request #18604 from ChayimFriedman2/complete-helpers
feat: Complete derive helper attributes
2024-12-04 06:33:29 +00:00