summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/ide-completion
AgeCommit message (Collapse)AuthorLines
2024-12-20Fix a case where completion was unable to expand a macroChayim Refael Friedman-290/+510
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-18internal: Cleanup label structure of `CompletionItem`Lukas Wirth-1062/+1190
2024-12-16fix: Fix path qualified auto-importing completions not working with re-exportsLukas Wirth-0/+42
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-13Show expansion errors in expand_macro featureLukas Wirth-4/+7
2024-12-11Properly handle different defaults for severity of lintsChayim Refael Friedman-1/+1
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-09Draft completion hashingKirill Bulatov-2/+2
2024-12-05Parse lifetime bounds in lifetime param into TypeBoundListLukas Wirth-33/+25
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-04Merge pull request #18604 from ChayimFriedman2/complete-helpersLukas Wirth-4/+95
feat: Complete derive helper attributes
2024-12-04Complete derive helper attributesChayim Refael Friedman-4/+95
Only their names, anything can go inside.
2024-12-03Remove references to platform-intrinsic ABIMark Murphy-1/+0
2024-12-03Advertise completions and inlay hints resolve server capabilities based on ↵Kirill Bulatov-1/+13
the client capabilities.
2024-10-30Merge pull request #18382 from dqkqd/issue-17042Lukas Wirth-3/+72
fix: auto-complete import for aliased function and module
2024-10-28Merge pull request #18420 from ChayimFriedman2/cfg-true-falseLukas Wirth-0/+2
feat: Support `cfg(true)` and `cfg(false)`
2024-10-28Move text-edit into ide-dbLukas Wirth-14/+15
2024-10-27Support `cfg(true)` and `cfg(false)`Chayim Refael Friedman-0/+2
As per RFC 3695.
2024-10-26Use method syntaxMoskalykA-1/+1
2024-10-26Start using `Option::is_none_or`MoskalykA-2/+1
2024-10-24fix: handle aliased pattern and simplify testcaseKhanh Duong Quoc-23/+32
2024-10-24refactor: separate function for getting import nameKhanh Duong Quoc-7/+19
2024-10-23fix: auto-complete import for aliased function and moduleKhanh Duong Quoc-2/+50
2024-10-21Auto merge of #18360 - roife:safe-kw-3, r=Veykrilbors-54/+146
feat: better completions for extern blcoks This PR refactors `add_keywords` (making it much clearer!) and enhances completion for `extern` blocks. It is recommended to reviewing the changes in order of the commits: - The first commit (f3c4dde0a4917a2bac98605cc045eecfb4d69872) doesn’t change any logic but refactors parts of the `add_keywords` function and adds detailed comments. - The second commit (5dcc1ab649bf8a49cadf006d620871b12f093a2f) improves completion for `extern` kw and extern blocks.
2024-10-22minor: refactor completions in item_listroife-27/+24
2024-10-21feat: better completions for extern blcoksroife-18/+104
2024-10-21refactor add_keywords in ide-completions for clarityroife-47/+56
2024-10-21Auto merge of #18337 - dqkqd:issue-18287, r=Veykrilbors-0/+18
fix: private items are shown in completions for modules in fn body Close: #18287
2024-10-21fix: private items are shown in completions for modules in fn bodyKhanh Duong Quoc-0/+18
2024-10-21Update ide testsLukas Wirth-1/+1
2024-10-01Fix: Handle block exprs as modules when finding their parentsShoyu Vanilla-2/+8
2024-09-30Auto merge of #18167 - SomeoneToIgnore:fat-completions, r=Veykrilbors-3/+30
internal: Send less data during `textDocument/completion` if possible Similar to https://github.com/rust-lang/rust-analyzer/pull/15522, stops sending extra data during `textDocument/completion` if that data was set in the client completions resolve capabilities, and sends those only during `completionItem/resolve` requests. Currently, rust-analyzer sends back all fields (including potentially huge docs) for every completion item which might get large. Same as the other one, this PR aims to keep the changes minimal and does not remove extra computations for such fields — instead, it just filters them out before sending to the client. The PR omits primitive, boolean and integer, types such as `deprecated`, `preselect`, `insertTextFormat`, `insertTextMode`, etc. AND `additionalTextEdits` — this one looks very dangerous to compute for each completion item (as the spec says we ought to if there's no corresponding resolve capabilities provided) due to the diff computations and the fact that this code had been in the resolution for some time. It would be good to resolve this lazily too, please let me know if it's ok to do. When tested with Zed which only defines `documentation` and `additionalTextEdits` in its client completion resolve capabilities, rust-analyzer starts to send almost 3 times less characters: Request: ```json {"jsonrpc":"2.0","id":104,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///Users/someonetoignore/work/rust-analyzer/crates/ide/src/inlay_hints.rs"},"position":{"line":90,"character":14},"context":{"triggerKind":1}}} ``` <img width="1338" alt="image" src="https://github.com/user-attachments/assets/104f19b5-7095-4fc1-b008-5d829623b2e2"> Before: 381944 characters [before.json](https://github.com/user-attachments/files/17092385/before.json) After: 140503 characters [after.json](https://github.com/user-attachments/files/17092386/after.json) After Zed's [patch](https://github.com/zed-industries/zed/pull/18212) to enable all resolving possible: 84452 characters [after-after.json](https://github.com/user-attachments/files/17092755/after-after.json)
2024-09-25Merge from rust-lang/rustLaurențiu Nicola-0/+1
2024-09-24Auto merge of #18161 - ChayimFriedman2:postfix-mut, r=Veykrilbors-1/+52
fix: Better support references in consuming postfix completions Fixes #18155.
2024-09-23internal: Make COMPLETION_MARKER more explicitly r-aWilfred Hughes-1/+1
If a user ever sees the completion marker, it's confusing to see text about IntelliJ. Use a string that's more explicitly about completion for rust-analyzer.
2024-09-23Support expect in attribute completion and hoverLaurențiu Nicola-2/+25
2024-09-23Omit completion fields to be resolved laterKirill Bulatov-4/+0
2024-09-23Prepare for omittiong parts of completion data that need to be resolvedKirill Bulatov-3/+34
2024-09-22Include dereferences in consuming postfix completions (e.g. `call`)Chayim Refael Friedman-0/+31
2024-09-22Properly account for mutable references when postfix-completing consuming ↵Chayim Refael Friedman-1/+21
completions (e.g. `call`)
2024-09-21add `C-cmse-nonsecure-entry` ABIFolkert de Vries-0/+1
2024-09-20Auto merge of #18132 - ChayimFriedman2:fix-closure-semi, r=Veykrilbors-32/+100
fix: Don't complete `;` when in closure return expression Completing it will break syntax. Fixes #18130.
2024-09-18Get rid of `$crate` in expansions shown to the userChayim Refael Friedman-10/+22
Be it "Expand Macro Recursively", "Inline macro" or few other things. We replace it with the crate name, as should've always been.
2024-09-18Extract logic to decide how to complete semicolon for unit-returning ↵Chayim Refael Friedman-39/+73
function into `CompletionContext` So that we don't recompute it for every item.
2024-09-18Don't complete `;` when in closure return expressionChayim Refael Friedman-24/+58
Completing it will break syntax.
2024-09-12Auto merge of #18038 - roife:fix-issue-18034, r=Veykrilbors-1/+2
feat: generate names for tuple-struct in add-missing-match-arms fix #18034. This PR includes the following enhancement: - Introduced a `NameGenerator` in `suggest_name`, which implements an automatic renaming algorithm to avoid name conflicts. Here are a few examples: ```rust let mut generator = NameGenerator::new(); assert_eq!(generator.suggest_name("a"), "a"); assert_eq!(generator.suggest_name("a"), "a1"); assert_eq!(generator.suggest_name("a"), "a2"); assert_eq!(generator.suggest_name("b"), "b"); assert_eq!(generator.suggest_name("b"), "b1"); assert_eq!(generator.suggest_name("b2"), "b2"); assert_eq!(generator.suggest_name("b"), "b3"); assert_eq!(generator.suggest_name("b"), "b4"); assert_eq!(generator.suggest_name("b3"), "b5"); ``` - Updated existing testcases in ide-assists for the new `NameGenerator` (only modified generated names). - Generate names for tuple structs instead of using wildcard patterns in `add-missing-match-arms`.
2024-09-10refactor: introduce NameGenerator in suggest_nameroife-1/+2
2024-09-08Automatically add semicolon when completing unit-returning functionsChayim Refael Friedman-40/+192
But provide a config to suppress that. I didn't check whether we are in statement expression position, because this is hard in completion (due to the natural incompleteness of source code when completion is invoked), and anyway using function returning unit as an argument to something seems... dubious.
2024-09-05Add Definition kind for asm register classesLukas Wirth-0/+1
2024-09-03Auto merge of #18031 - roife:suggest-name-in-completion, r=Veykrilbors-0/+110
feat: Suggest name in completion for let_stmt and fn_param fix #17780 1. Refactor: move `ide_assist::utils::suggest_name` to `ide-db::syntax_helpers::suggest_name` for reuse. 2. When completing `IdentPat`, detecte if the current node is a `let_stmt` or `fn_param`, and suggesting a new name based on the context.
2024-09-03tests: suggesting names in completions for let_stmt and fn_paramroife-0/+73
2024-09-03feat: suggest name in let_stmt and fn_paramroife-0/+37
2024-09-02Adjust completions scoringLukas Wirth-50/+46