Commit Graph

300 Commits

Author SHA1 Message Date
David Barsky
ab8c112573 Revert "Auto merge of #17073 - roife:better-inline-preview, r=Veykril"
af728741de
2024-04-15 18:24:15 -04:00
bors
af728741de Auto merge of #17073 - roife:better-inline-preview, r=Veykril
Better inline preview for postfix completion

Better inline preview for postfix completion, a proper implementation of c5686c8941.

Here editors may filter completion item with the text within `delete_range`, so we need to include the `receiver text` in the `lookup` (aka `FilterText` in LSP spec) for editors to find the completion item. (See https://github.com/rust-lang/rust-analyzer/issues/17036#issuecomment-2056614180, Thanks to [pascalkuthe](https://github.com/pascalkuthe))
2024-04-15 14:33:38 +00:00
roife
8db1c64268 tests: fix tests for postfix 2024-04-15 22:21:15 +08:00
roife
76a8a976f3 fix: better inline preview for postfix completion 2024-04-15 22:21:06 +08:00
Lukas Wirth
1915980031 fix: Fix impl Trait<Self> causing stackoverflows 2024-04-15 15:41:20 +02:00
Lukas Wirth
a483d3bc37 internal: Thread edition through to parsing/tt-to-syntax-tree routines for macros 2024-04-14 16:02:38 +02:00
bors
9b1946250f Auto merge of #17054 - roife:fix-issue-17036, r=Veykril
Revert "fix: set the right postfix snippets competion source range"

This reverts commit c5686c8941.

Fix #17036. See https://github.com/rust-lang/rust-analyzer/issues/17036#issuecomment-2050185641
2024-04-13 19:34:45 +00:00
roife
7528460151 Revert "fix: set the right postfix snippets competion source range"
This reverts commit c5686c8941.
2024-04-12 19:20:41 +08:00
Lukas Wirth
8078c3d9e8 Bump chalk 2024-04-08 11:03:19 +02:00
Lukas Wirth
2b62d4b2ba Fix some cfg censoring bugs 2024-04-03 16:43:08 +02:00
Milo Moisson
c5686c8941
fix: set the right postfix snippets competion source range
Changed the completion item source_range to match
the replaced text. Though in VS Code it may not be
disturbing because the snippet is previewed in a
box, but in Helix editor, it's previewed by applying
the main text edit.
2024-04-03 00:00:34 +02:00
bors
0583aaa555 Auto merge of #16805 - dfireBird:lifetime_lowering, r=Veykril
feat: Implement resolving and lowering of Lifetimes (no inference yet)
2024-03-26 07:58:43 +00:00
Lukas Wirth
928d847cc2 Keep the span for Attr::Literal 2024-03-21 10:28:25 +01:00
dfireBird
a555e95c9a
fix make HirDisplay format lifetimes first 2024-03-18 17:18:08 +05:30
dfireBird
490391f576
fix HirDisplay inserting anonymous lifetimes and update tests 2024-03-18 17:18:08 +05:30
bors
7c2bb75bc8 Auto merge of #16860 - Veykril:macarons, r=Veykril
feat: Syntax highlighting improvements

Specifically
- Adds a new `constant` modifier, attached to keyword `const` (except for `*const ()` and `&raw const ()`), `const` items and `const` functions
- Adds (or rather reveals) `associated` modifier for associated items
- Fixes usage of the standard `static` modifier, now it acts like `associated` except being omitted for methods.
- Splits `SymbolKind::Function` into `Function` and `Method`. We already split other things like that (notable self param from params), so the split makes sense in general as a lot special cases around it anyways.
2024-03-18 09:14:08 +00:00
Matthias Krüger
2a8edaa14d remove redundant clone()s 2024-03-17 14:06:21 +01:00
Lukas Wirth
23fff55f0c Split SymbolKind::Function into Function and Method 2024-03-17 11:07:22 +01:00
Lukas Wirth
d085ade631 Remove dead test code 2024-03-14 16:24:51 +01:00
Lukas Wirth
d2f8eae2ec feat: Support macro calls in eager macros for IDE features 2024-03-14 15:40:35 +01:00
Lukas Wirth
9ba4493918 internal: Improve rooted upmapping 2024-03-12 13:46:58 +01:00
Shoyu Vanilla
fc11216ad5 feat: Add proc macro semantic token type 2024-03-11 22:14:59 +09:00
DropDemBits
bc381837e3
fix: Preserve $ and \ in postfix format completions
`parse_format_exprs` doesn't escape these two anymore, so they have to be escaped as a separate step.
2024-03-07 16:55:09 -05:00
bors
99a1b8f7a8 Auto merge of #16747 - Veykril:cleanup, r=Veykril
internal: Clean some stuff up

Just a bunch of small refactorings, mainly from browsing through `hir-def`
2024-03-04 10:30:17 +00:00
Lukas Wirth
4303e741de Cleanup 2024-03-04 11:10:06 +01:00
Vladislav Mamon
1d28aecd13
fix: autocomplete constants inside format strings 2024-03-01 14:23:31 +03:00
bors
6b250a22c4 Auto merge of #16687 - kilpkonn:master, r=Veykril
feat: Add "make tuple" tactic to term search

Follow up to https://github.com/rust-lang/rust-analyzer/pull/16092

Now term search also supports tuples.
```rust
let a: i32 = 1;
let b: f64 = 0.0;
let c: (i32, (f64, i32)) = todo!(); // Finds (a, (b, a))
```
In addition to new tactic that handles tuples I changed how the generics are handled.
Previously it tried all possible options from types we had in scope but now it only tries useful ones that help us directly towards the goal or at least towards calling some other function.
This changes O(2^n) to O(n^2) where n is amount of rounds which in practice allows using types that take generics for multiple rounds (previously limited to 1). Average case that also used to be exponential is now roughly linear.
This means that deeply nested generics also work.
````rust
// Finds all valid combos, including `Some(Some(Some(...)))`
let a: Option<Option<Option<bool>>> = todo!();
````

_Note that although the complexity is smaller allowing more types with generics the search overall slows down considerably. I hope it's fine tho as the autocomplete is disabled by default and for code actions it's not super slow. Might have to tweak the depth hyper parameter tho_

This resulted in a huge increase of results found (benchmarks on `ripgrep` crate):
Before
````
Tail Expr syntactic hits: 149/1692 (8%)
Tail Exprs found: 749/1692 (44%)
Term search avg time: 18ms
```
After
```
Tail Expr syntactic hits: 291/1692 (17%)
Tail Exprs found: 1253/1692 (74%)
Term search avg time: 139ms
````

Most changes are local to term search except some tuple related stuff on `hir::Type`.
2024-02-27 09:41:14 +00:00
Lukas Wirth
cc7fe32ba3 fix: Fix completions panicking with certain macro setups 2024-02-27 09:35:57 +01:00
Tavo Annus
8bd30e9b3f Improve generics handling in term search 2024-02-26 20:17:09 +02:00
David Barsky
c246a93046 completions: speed up completions by filtering non-applicable traits 2024-02-26 12:49:11 -05:00
Lukas Wirth
d93096ecc0 internal: Fetch toolchain and datalayout for DetachedFiles 2024-02-20 10:40:39 +01:00
Young-Flash
f3d84e86c8 minor: fix typo 2024-02-19 18:12:08 +08:00
Lukas Wirth
b1404d387a fix: Split toolchain and datalayout out of CrateData 2024-02-16 14:48:25 +01:00
bors
fc1ee6136c Auto merge of #16544 - dfireBird:impl_trait_completion, r=Veykril
Add completions to show only traits in trait `impl` statement

This is prerequisite PR for adding the assist mentioned in #12500

P.S: If wanted, I will add the implementation of the assist in this PR as well.
2024-02-13 16:38:35 +00:00
Lukas Wirth
7f661782cd
Simplify 2024-02-13 17:26:14 +01:00
dfireBird
0e47befaf3
fix flyimport showing other types in impl trait statement 2024-02-13 19:31:04 +05:30
dfireBird
9897662bf7
add completions to show only traits with qualified path prefix 2024-02-13 18:41:24 +05:30
Mohammad Mustakim Ali
2c761048d4
fix: clippy 2024-02-13 10:11:17 +00:00
Mohammad Mustakim Ali
0af14ef8c3 chore: optimise 2024-02-12 23:11:06 +00:00
Mohammad Mustakim Ali
24a3c42bd6 feat: completion list suggests constructor like & builder methods first 2024-02-12 22:34:59 +00:00
dfireBird
0209c28136
add completions to show only traits in trait impl statement 2024-02-12 22:56:03 +05:30
bors
cf8733353d Auto merge of #16540 - Veykril:macro-arg, r=Veykril
internal: macro_arg query always returns a TokenTree
2024-02-12 16:32:40 +00:00
Lukas Wirth
2fa57d90bc internal: macro_arg query always returns a TokenTree 2024-02-12 17:19:41 +01:00
Tavo Annus
125791386d Cleanup term search related changes 2024-02-11 14:35:54 +02:00
Tavo Annus
88964c0b6a Optionally disable term search for autocompletion 2024-02-11 13:33:29 +02:00
Tavo Annus
0b838e3e23 Expand target for autocompletion 2024-02-11 13:33:29 +02:00
Tavo Annus
a946970e2d Add quantified trees to reduce autocomplete options 2024-02-11 13:33:29 +02:00
Tavo Annus
bdbdd83ec1 Initial version of term_search for autocomplete 2024-02-11 13:33:29 +02:00
bors
1ef7a2329b Auto merge of #16525 - Veykril:item-loc, r=Veykril
Abstract more over ItemTreeLoc-like structs

Allows reducing some code duplication by using functions generic over said structs. The diff isn't negative due to me adding some additional impls for completeness.
2024-02-10 10:47:37 +00:00
Lukas Wirth
2ebf0c87c2 Deduplicate some code 2024-02-10 01:51:22 +01:00