Commit graph

253 commits

Author SHA1 Message Date
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
Tetsuharu Ohzeki
f4a4b6681b ide-completion: Fix warnings about clippy str_to_string rule 2024-02-10 01:00:40 +09:00
Lukas Wirth
15bffe25bd feat: Add break and return postfix keyword completions 2024-02-08 14:56:10 +01:00
Laurențiu Nicola
2c4152847a Add lete to postfix completion list 2024-02-06 13:13:51 +02:00
bors
3e47532dd4 Auto merge of #16474 - davidbarsky:david/import-on-the-fly-improvements, r=lnicola
internal: even more `tracing`

As part of profiling completions, I added some additional spans and moved `TyBuilder::subst_for_def` closer to its usage site (the latter had a small impact on completion performance. Thanks for the tip, Lukas!)
2024-02-05 09:01:58 +00:00
David Barsky
f9bef39d48 internal: add some more tracing spans inside of hir-ty 2024-02-01 16:10:32 -05:00
bors
850ba2fb63 Auto merge of #16451 - Urhengulas:satisfy-clippy, r=Veykril
internal: Work through temporarily allowed clippy lints, part 2

Another follow-up to https://github.com/rust-lang/rust-analyzer/pull/16401.
2024-02-01 14:23:18 +00:00
clubby789
a1fdb876c3 Remove abi_amdgpu_kernel references 2024-01-31 19:06:10 +00:00
Johann Hemmann
f15ee8a380 unnecessary_filter_map 2024-01-31 19:06:18 +01:00
Johann Hemmann
386d438e17 skip_while_next 2024-01-31 19:06:18 +01:00
bors
355c9444e1 Auto merge of #16448 - Young-Flash:typos, r=lnicola
minor: correct typos

I use [crate-ci/typos](https://github.com/crate-ci/typos) to check typos in codebase, if it's ok with you, I'd like to add a typo check CI using [typos](https://github.com/crate-ci/typos) (with Apache-2.0, MIT licenses).

BTW, we can add a [_typos.toml](https://github.com/crate-ci/typos/blob/master/docs/reference.md) as white list for some intentional typos
2024-01-31 13:29:55 +00:00
David Barsky
e1ea7c8844 internal: switch to tracing from log
This commit also adds `tracing` to NotificationDispatcher/RequestDispatcher,
bumps `rust-analyzer-salsa` to 0.17.0-pre.6, `always-assert` to 0.2, and
removes the homegrown `hprof` implementation in favor of a vendored
tracing-span-tree.
2024-01-30 12:27:31 -05:00
bors
63123ab408 Auto merge of #16417 - davidsemakula:normalize-use-trees, r=Veykril
feat: "Normalize import" assist and utilities for normalizing use trees

- Add import/use tree normalization utilities
- Add "normalize import" assist
- Update "merge imports" assist to always apply to the covering use item except for nested use tree selections
- Update "merge imports" assist to avoid adding unnecessary braces when merging nested use tree selections

See [this discussion](https://github.com/rust-lang/rust-analyzer/pull/16372#discussion_r1457244321) for the motivation for the new "normalize import" assist and changes to the "merge imports" assist.
2024-01-30 14:55:08 +00:00
Young-Flash
db9fd370ee minor: correct typos 2024-01-30 21:43:43 +08:00
davidsemakula
8fab92feb2 normalize use trees when merging imports 2024-01-28 11:55:01 +03:00
Alain Siegrist
7ec32d091a Remove letelse control flow snippets 2024-01-27 14:35:22 +01:00
Alain Siegrist
51d57b9bb6 Make return a snippet 2024-01-27 14:35:22 +01:00
Alain Siegrist
57934ac47a Add postfix completion for let else 2024-01-27 14:35:22 +01:00
Lukas Wirth
8a5829cf28 Re-order mod declarations 2024-01-27 11:02:34 +01:00
Johann Hemmann
b1a0c9ac40 single_match 2024-01-19 18:31:15 +01:00
Johann Hemmann
71d4dba960 redundant_pattern_matching 2024-01-19 17:31:01 +01:00
Johann Hemmann
add40c8660 match_like_matches_macro 2024-01-19 17:31:01 +01:00
Johann Hemmann
4184c6af0d collapsible_match 2024-01-19 17:31:00 +01:00
Johann Hemmann
fad4fa163c cargo clippy --fix 2024-01-18 13:59:49 +01:00
bors
1ab8c7fd27 Auto merge of #16349 - Young-Flash:use_error_recovery, r=Veykril
fix: add error recovery for use_tree_list parsing

This PR adds error recovery for USE_TREE_LIST parsing, avoid the wrong USE_TREE_LIST making the rest parsing incorrectly.

before

![before](https://github.com/rust-lang/rust-analyzer/assets/71162630/c6643690-f25c-4ad9-93d9-e661ba5b1dc3)

after

![after](https://github.com/rust-lang/rust-analyzer/assets/71162630/30a58c40-2711-48d2-b2e5-fb208fc8636c)

close https://github.com/rust-lang/rust-analyzer/issues/16227
2024-01-18 09:52:37 +00:00
Young-Flash
1c61326ca0 add use_tree_completion test 2024-01-18 17:35:01 +08:00
Lukas Wirth
83591268ab minor: Make use of some new SmolStr improvements 2024-01-17 13:47:15 +01:00
dfireBird
257870e09f
add tests to verify relevance of notable traits and some refactors 2024-01-10 16:30:22 +05:30
dfireBird
df5c647982
add notable_trait predicate to CompletionRelevance
implement the predicate set on the case function from traits
2024-01-08 20:34:11 +05:30
Lukas Wirth
cc2b79feeb internal: Speed up import searching some more 2024-01-05 12:58:20 +01:00
Lukas Wirth
4f75e0f910 Remove completion limit for trait importing method completions 2024-01-05 12:03:08 +01:00
Lukas Wirth
2666349392 Remove limit from symbol_index::Query 2024-01-04 19:20:10 +01:00
bors
86e559bf3f Auto merge of #16211 - tetsuharuohzeki:update-lint, r=Veykril
Use Cargo's [workspace.lints.*] to config clippy

This change begin to use [`[workspace.lints.*]`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-lints-table) that is stabilized since [Rust 1.74](https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html).

By this change, we make the configure more readable and simplify `xargo lint` more.
2024-01-02 14:53:22 +00:00
Luiz Carvalho
9a36bc393d
fix(completion): render fn type 2024-01-02 10:30:16 -03:00
Luiz Carvalho
ed216e285d
fix(completion): make the expected type a tad smarter with Fns
This commit changes how the expected type is calculated when working
with Fn pointers, making the parenthesis stop vanishing when completing
the function name.

I've been bugged by the behaviour on parenthesis completion for a long
while now. R-a assumes that the `LetStmt` type is the same as the
function type I've just written. Worse is that all parenthesis vanish,
even from functions that have completely different signatures. It will
now verify if the signature is the same.

While working on this, I noticed that record fields behave the same, so
I also made it prioritize the field type instead of the current
expression when possible, but I'm unsure if this is OK, so input is
appreciated.

ImplTraits as return types will still behave weirdly because lowering is
disallowed at the time it resolves the function types.
2024-01-02 10:28:49 -03:00
bors
60fe5fd98d Auto merge of #16049 - dfireBird:followup-callable-fields, r=Veykril
fix: make callable fields not complete in method access no parens case

Follow up PR for #15879

Fixes the callable field completion appearing in the method access with no parens case.
2024-01-02 10:20:31 +00:00
Tetsuharu Ohzeki
efc87092b3 Use Cargo's [workspace.lints.*] to config clippy 2023-12-29 23:51:32 +09:00
bors
afbb8f31ff Auto merge of #16184 - Veykril:completion-panic, r=Veykril
fix: Fix completions analysis not caching all nodes in Semantics

Fixes https://github.com/rust-lang/rust-analyzer/issues/16161
2023-12-22 12:13:46 +00:00
Lukas Wirth
91046e9e45 fix: Fix completions analysis not caching all nodes in Semantics 2023-12-22 13:01:48 +01:00
bors
23a1280106 Auto merge of #16137 - unexge:complete-macros-in-macro-use, r=Veykril
Complete exported macros in `#[macro_use($0)]`

Closes https://github.com/rust-lang/rust-analyzer/issues/15657.

Originally added a test case for incomplete input:
```rust
#[test]
fn completes_incomplete_syntax() {
    check(
        r#"
//- /dep.rs crate:dep
#[macro_export]
macro_rules! foo {
    () => {};
}

//- /main.rs crate:main deps:dep
#[macro_use($0
extern crate dep;
"#,
        expect![[r#"
                ma foo
            "#]],
    )
}
```

but couldn't make it pass and removed it 😅 Our current recovering logic doesn't work for token trees and for this code:
```rust
#[macro_use(
extern crate lazy_static;

fn main() {}
```

we ended up with this syntax tree:
```
SOURCE_FILE@0..53
  ATTR@0..52
    POUND@0..1 "#"
    L_BRACK@1..2 "["
    META@2..52
      PATH@2..11
        PATH_SEGMENT@2..11
          NAME_REF@2..11
            IDENT@2..11 "macro_use"
      TOKEN_TREE@11..52
        L_PAREN@11..12 "("
        WHITESPACE@12..13 "\n"
        EXTERN_KW@13..19 "extern"
        WHITESPACE@19..20 " "
        CRATE_KW@20..25 "crate"
        WHITESPACE@25..26 " "
        IDENT@26..37 "lazy_static"
        SEMICOLON@37..38 ";"
        WHITESPACE@38..40 "\n\n"
        FN_KW@40..42 "fn"
        WHITESPACE@42..43 " "
        IDENT@43..47 "main"
        TOKEN_TREE@47..49
          L_PAREN@47..48 "("
          R_PAREN@48..49 ")"
        WHITESPACE@49..50 " "
        TOKEN_TREE@50..52
          L_CURLY@50..51 "{"
          R_CURLY@51..52 "}"
  WHITESPACE@52..53 "\n"
```

Maybe we can try to parse the token tree in `crates/ide-completion/src/context/analysis.rs` but I'm not sure what's the best way forward.
2023-12-22 10:42:38 +00:00
Lukas Wirth
f48ecb6e09 Try to support pre and post-change metavars 2023-12-19 20:45:12 +01:00
Lukas Wirth
f49a2fed3f internal: Move out WithFixture into dev-dep only crate 2023-12-18 15:24:08 +01:00
Lukas Wirth
35620306a6 internal: Move proc-macro knowledge out of base-db 2023-12-18 12:37:18 +01:00
unexge
0e4902467f Add missing docs string 2023-12-16 17:10:11 +00:00
unexge
b986d8ac92 Complete exported macros in #[macro_use($0)] 2023-12-16 16:19:58 +00:00
Lukas Wirth
18591ae5c8 Always render the path to be imported in the completion detail 2023-12-11 18:37:12 +01:00
Lukas Wirth
cf083fefc4 fix: Fix completion failing in format_args! with invalid template 2023-12-08 20:35:33 +01:00
bors
b03a0bda18 Auto merge of #15627 - jmintb:sort_imports, r=Veykril
feat: Prioritize import suggestions based on the expected type

Hi, this is a draft PR to solve #15384. `Adt` types work and now I have a few questions :)

1. What other types make sense in this context? Looking at [ModuleDef](05666441ba/crates/hir/src/lib.rs (L275)) I am thinking everything except Modules.
2. Is there an existing way of converting between `ModeuleDef` and `hir::Type` in the rustanalyzer code base?
3. Does this approach seem sound to you?

Ups: Upon writing this I just realised that the enum test is invalided as there are no enum variants and this no variant is passed as a function argument.
2023-12-08 12:39:23 +00:00