about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/ide
AgeCommit message (Collapse)AuthorLines
2024-10-23Add text edit to adjustment hintsLukas Wirth-21/+42
2024-10-22Implement semitransparent hygieneChayim Refael Friedman-0/+20
Or macro_rules hygiene, or mixed site hygiene. In other words, hygiene for variables and labels but not items. The realization that made me implement this was that while "full" hygiene (aka. def site hygiene) is really hard for us to implement, and will likely involve intrusive changes and performance losses, since every `Name` will have to carry hygiene, mixed site hygiene is very local: it applies only to bodies, and we very well can save it in a side map with minor losses. This fixes one diagnostic in r-a that was about `izip!()` using hygiene (yay!) but it introduces a huge number of others, because of #18262. Up until now this issue wasn't a major problem because it only affected few cases, but with hygiene identifiers referred by macros like that are not resolved at all. The next commit will fix that.
2024-10-22Merge binding_mode inlay hints into oneLukas Wirth-11/+29
2024-10-22Merge adjustment inlay hints into oneLukas Wirth-145/+83
2024-10-22Merge closure capture inlay hints into oneLukas Wirth-90/+41
2024-10-22Auto merge of #18370 - duncpro:goto-def-ranges, r=Veykrilbors-6/+87
feat: resolve range patterns to their structs Closes #18367
2024-10-22Auto merge of #18349 - dqkqd:issue-18344, r=Veykrilbors-0/+153
feat: render docs from aliased type when type has no docs Trying to close #18344 - [x] ~Find the docs by traversing upwards if the type itself has none but aliasing for another type that might have.~ - [x] Show docs from aliased type. - [x] Showing description that we are displaying documentation for different definition in hover box. ![image](https://github.com/user-attachments/assets/820d6f97-aa2c-4dc4-8a25-75746e32d950)
2024-10-22feat: render docs from aliased type when docs are missingKhanh Duong Quoc-0/+153
2024-10-22tidyDuncan Proctor-5/+5
2024-10-22remove duplicate testDuncan Proctor-16/+0
2024-10-22resolve range patterns to the their struct typesDuncan Proctor-6/+103
2024-10-22Auto merge of #18362 - duncpro:goto-def-ranges, r=Veykrilbors-3/+86
feat: goto definition on range operators Closes #18342
2024-10-22tidyDuncan Proctor-14/+26
2024-10-22goto definition on RangeFrom, RangeFull, RangeTo, and RangeToInclusive links ↵Duncan Proctor-33/+54
to respective struct
2024-10-21Move explicit range handling out of goto_definition, use OperatorClass insteadduncanproctor-23/+24
2024-10-21GotoDefinition on a Range or InclusiveRange operator will link to the struct ↵duncanproctor-3/+52
definition
2024-10-21fix: Fix token downmapping failing for include! inputsLukas Wirth-0/+59
2024-10-21Update ide testsLukas Wirth-131/+131
2024-10-14Auto merge of #18292 - roife:fix-issue-17427, r=Veykrilbors-12/+41
feat: handle self-param outside of methods when renaming close #17427
2024-10-14feat: handle self-param outside of methods when renamingroife-12/+41
2024-10-14chore: rename salsa to ra_salsaDavid Barsky-4/+4
2024-10-14Auto merge of #18291 - roife:fix-issue-18212, r=Veykrilbors-11/+125
feat: respect references.exclude_tests in call-hierarchy close #18212 ### Changes 1. feat: respect `references.exclude_tests` in call-hierarchy 2. Modified the description of `references.exclude_tests`
2024-10-14Auto merge of #18242 - Veykril:veykril/push-tnynzqsmtnqw, r=Veykrilbors-3/+18
internal: Don't resolve extern crates in import fix point resolution The fix point loop won't progress them given the potential extern crate candidates are set up at build time.
2024-10-14Auto merge of #18152 - CryZe:highlight-async-block-exit-points, r=Veykrilbors-73/+101
feat: Highlight exit points of async blocks Async blocks act similar to async functions in that the await keywords are related, but also act like functions where the exit points are related. Fixes #18147
2024-10-13feat: respect references.exclude_tests in call-hierarchyroife-11/+125
2024-10-08Only Highlight Exit Points on `async` TokenChristopher Serr-7/+13
This ensures that when being on an `await` token, it still only highlights the yield points and not the exit points.
2024-10-05Fix `prettify_macro_expansion()` when the node isn't the whole fileChayim Refael Friedman-0/+30
2024-10-05Fix IDE layer not correctly resolving opt-in extern cratesLukas Wirth-2/+10
2024-10-05Add excluded extern-prelude IDE resolution testLukas Wirth-3/+9
2024-10-05Remove ImportSource::ExternCrate as the fixed point loop can't affect itLukas Wirth-0/+1
2024-10-04Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykrilbors-4/+5
internal: Filter out opaque tokens in some IDE feature macro descensions
2024-10-04internal: Filter out opaque tokens in some of IDE feature macro descensionsLukas Wirth-4/+5
2024-10-01Fix: Handle block exprs as modules when finding their parentsShoyu Vanilla-2/+36
2024-09-30Auto merge of #18210 - ChayimFriedman2:label-macro, r=Veykrilbors-0/+18
fix: Fix resolution of label inside macro When working on Something Else (TM) (I left a hint in the commits :P), I noticed to my surprise that labels inside macros are not resolved. This led to a discovery of *two* unrelated bugs, which are hereby fixed in two commits.
2024-09-30When resolving labels in `break` and `continue` for the IDE, do not resolve ↵Chayim Refael Friedman-0/+18
them textually, instead reuse the results of HIR lowering This fixes a bug where labels inside macros were not resolved, but more importantly this prepares us to a future where we have hygiene, and textual equivalence isn't enough to resolve identifiers.
2024-09-30Auto merge of #18167 - SomeoneToIgnore:fat-completions, r=Veykrilbors-2/+2
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-29Rename object_safety to dyn_compatibilityNoah Bright-25/+25
Up to a trait implemented by another package, linking to $CARGO_HOME/registry/cache/index.crates.io-6f17d22bba15001f/
2024-09-24Auto merge of #18166 - ChayimFriedman2:dollar-crate-root, r=Veykrilbors-3/+9
fix: Fix a bug in span map merge, and add explanations of how span maps are stored Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`. The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity. Fixes #18163.
2024-09-24Auto merge of #18160 - ChayimFriedman2:fix-18138, r=Veykrilbors-0/+32
fix: Fix name resolution when an import is resolved to some namespace and then later in the algorithm another namespace is added The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it. This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully. That PR is also why IDE features did work: the import at the end was resolved correctly, so IDE features that re-resolved the macro path resolved it correctly. I was concerned about the performance of this, but this doesn't seem to regress `analysis-stats .`, so I guess it's fine to land this. I have no idea about the incremental perf however and I don't know how to measure that, although when typing in `zbus` (including creating a new function, which should recompute the def map) completion was fast enough. I didn't check what rustc does, so maybe it does something more performant, like keeping track of only possibly problematic imports. Fixes #18138. Probably fixes #17630.
2024-09-23Support expect in attribute completion and hoverLaurențiu Nicola-3/+27
2024-09-23Prepare for omittiong parts of completion data that need to be resolvedKirill Bulatov-2/+2
2024-09-23Fix a bug in span map merge, and add explanations of how span maps are storedChayim Refael Friedman-3/+9
Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`. The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.
2024-09-22Fix name resolution when an import is resolved to some namespace and then ↵Chayim Refael Friedman-0/+32
later in the algorithm another namespace is added The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it. This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully.
2024-09-19feat: Highlight exit points of async blocksChristopher Serr-71/+93
Async blocks act similar to async functions in that the await keywords are related, but also act like functions where the exit points are related.
2024-09-18Auto merge of #18131 - ChayimFriedman2:macro-expand-dollar-crate, r=Veykrilbors-27/+117
fix: Get rid of `$crate` in expansions shown to the user Be it "Expand Macro Recursively", "Inline macro" or few other things. We replace it with the crate name, as should've always been. Probably fixes some issues, but I don't know what they are.
2024-09-18Get rid of `$crate` in expansions shown to the userChayim Refael Friedman-27/+117
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-17Always cache macro expansions' root node in SemanticsChayim Refael Friedman-0/+70
Previously some expansions were not cached, but were cached in the expansion cache, which caused panics when later queries tried to lookup the node from the expansion cache.
2024-09-16Fix printing of constants greater than `i128::MAX`Chayim Refael Friedman-0/+18
2024-09-12Auto merge of #18107 - Veykril:push-oopkquknxqxs, r=Veykrilbors-38/+24
fix: Don't emit empty inlay hint parts
2024-09-12fix: Don't emit empty inlay hint partsLukas Wirth-38/+24