Commit Graph

463 Commits

Author SHA1 Message Date
Jake Heinz
b0c7ff39b8 remove one need for semantics 2021-11-30 04:50:09 +00:00
Jake Heinz
54fc98920b consts with inners?? 2021-11-30 03:21:17 +00:00
Jake Heinz
492b169224 pr feedbacks 2021-11-30 03:09:38 +00:00
Jake Heinz
0abf236445 test the one thing this pr was trying to accomplish lol... 2021-11-29 10:43:51 +00:00
Jake Heinz
f0bfe310a2 add a test 2021-11-29 10:36:22 +00:00
Jake Heinz
97105e1288 some more cleanups 2021-11-29 09:52:03 +00:00
Jake Heinz
1280887561 do something with library_symbols 2021-11-29 09:36:00 +00:00
Jake Heinz
176f4da77a simplify work 2021-11-29 07:17:18 +00:00
Jake Heinz
6e89fb6f73 🧹 2021-11-29 05:42:46 +00:00
Jake Heinz
6cf9969546 collect macro_rules! macros into macro declarations 2021-11-29 05:28:22 +00:00
Jake Heinz
1ed5699355 collect macros 2021-11-29 05:22:30 +00:00
Jake Heinz
d69e0dab56 cleanup the whole thing... 2021-11-29 03:54:52 +00:00
Jake Heinz
aecb9a378c traverse even more... 2021-11-29 02:07:16 +00:00
Jake Heinz
9387e2d919 populate container name when traversing down blocks 2021-11-29 01:32:47 +00:00
Jake Heinz
8fa1d9bb47 collect blocks from unnamed consts too 2021-11-29 01:11:31 +00:00
Jake Heinz
8850ea0b4f collect defs from body blocks 2021-11-29 01:09:39 +00:00
Jake Heinz
8307d38dc1 cleanups 2021-11-28 00:42:42 +00:00
Jake Heinz
e033d8c2a2 make navigation target go to original file location 2021-11-27 13:48:50 +00:00
Jake Heinz
a7370c5725 remove file symbols 2021-11-27 13:00:02 +00:00
Jake Heinz
377162c0f8 container name? 2021-11-27 12:27:43 +00:00
Jake Heinz
a69af9daa3 sema parse_or_expand 2021-11-27 11:49:51 +00:00
Jake Heinz
0447be7589 wip 2021-11-27 11:25:05 +00:00
rainy-me
0bb08ccb8f fix: derive path handling 2021-11-25 00:21:29 +09:00
Emil Gardström
3dc898389f
Make lint groups work correctly with warningsAsInfo and warningsAsHint 2021-11-22 18:38:28 +01:00
bors[bot]
b69eee6487
Merge #10809
10809: fix: don't discard formatting of `use` lines r=Veykril a=iDawer

Use mutable syntax trees in `merge_imports`, `split_imports`. This tries to resolve #9013. But I haven't much managed to simplify code of merging.

Also resolve #9361. It reuses a use tree under the cursor so that comments+indentation are preserved. Merged trees are just appended to the end.

This touches bunch of tests. I removed the sorting of use trees as it needs a proper implementation that takes into account comments and line wrapping. I think it is rustfmt's job or at least until we get a close implementation.

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-11-22 14:29:24 +00:00
Lukas Wirth
77f08d0fc3 Split parts of ide_db::call_info off into ide 2021-11-22 13:23:34 +01:00
iDawer
601413df8f Use mutable syntax trees in merge_imports, split_imports 2021-11-19 20:02:27 +05:00
Lukas Wirth
92f7db447c minor: Lift out FxIndex{Map/Set} types into ide_db 2021-11-16 12:15:47 +01:00
Lukas Wirth
5c0b895f69 Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
Lukas Wirth
a510021065 Replace some more ide usages of ModuleDef with Definition 2021-11-11 18:20:54 +01:00
Lukas Wirth
7776aad166 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
Lukas Wirth
26419c0379 Fix proc-macro attributes being shadowed by their functions in IDE layer 2021-11-08 14:49:50 +01:00
Lukas Wirth
439a8194b0 Replace more Name::to_string usages with Name::to_smol_str 2021-11-04 18:12:05 +01:00
bors[bot]
962be38004
Merge #10645
10645: fix: make `rename` multi-token mapping aware r=Veykril a=spookyvision



Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Co-authored-by: Anatol Ulrich <45840+spookyvision@users.noreply.github.com>
2021-11-04 16:31:16 +00:00
bors[bot]
c96481e25f
Merge #10691
10691: minor: Use array `into_iter` in more places r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-11-04 05:52:05 +00:00
Laurențiu Nicola
139bf9b4e1 Use array into_iter in more places 2021-11-04 07:51:20 +02:00
Lukas Wirth
96db0d8bdd Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
Lukas Wirth
3018ffd85e Refactor ide handling for paths in derive inputs 2021-10-28 16:47:19 +02:00
Anatol Ulrich
8d3ac328ee remove resolved TODO questions 2021-10-27 15:40:30 +02:00
Anatol Ulrich
6decfceae1 WIP: fix: make rename multi-token mapping aware 2021-10-27 04:31:14 +02:00
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
bors[bot]
fe7c516084
Merge #10602
10602: Add qualify method call assist r=Veykril a=qepasa

This adds `qualify_method_call` assist that allows to replace a method (or trait) call that resolves with its fully qualified path.

For example, for stuct method:
```rust
struct Foo;
impl Foo {
    fn foo(&self) {}
}
```
```
let foo = Foo {};
foo.fo$0o();
```

becomes
```rust
let foo = Foo {};
Foo::foo(&foo);
```

for a trait method:

```rust
struct Foo;
trait FooTrait {
    fn foo(&self) {}
}
impl FooTrait for Foo {
    fn foo(&self) {}
}
```
following call:
```rust
let foo = Foo {};
foo.fo$0o();
```

becomes:
```rust
let foo = Foo {};
FooTrait::foo(&foo);
```

fixes #10453 

Co-authored-by: Paweł Palenica <pawelpalenica11@gmail.com>
2021-10-23 08:34:51 +00:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00
bors[bot]
6aeeb4ef33
Merge #10603
10603: fix: Don't resolve attributes to non attribute macros r=Veykril a=Veykril

Also changes `const`s to `static`s for `Limit`s as we have interior mutability in those(though only used with a certain feature flag enabled).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-21 10:39:26 +00:00
Lukas Wirth
ea2a2c52fc Don't resolve attributes to non attribute macros 2021-10-21 12:22:40 +02:00
Paweł Palenica
9f31f59fdf Cleanup - remove unnecessary pub 2021-10-20 23:37:31 -07:00
Paweł Palenica
bb00b09d22 Add qualify method call assist 2021-10-20 23:28:30 -07:00
bors[bot]
6877240fdf
Merge #10563
10563: feat: Make "Generate getter" assist use semantic info r=agluszak a=agluszak

This PR makes "Generate getter" assist use semantic info instead of dealing with types encoded as strings.
Getters for types which are:
- `Copy` no longer return references
- `AsRef<str>` (i.e. `String`) return `&str` (instead of `&String`)
- `AsRef<[T]>` (i.e. `Vec<T>`) return `&[T]` (instead of `&Vec<T>`)
- `AsRef<T>` (i.e. `Box<T>`) return `&T` (instead of `&Box<T>`)
- `Option<T>` return `Option<&T>` (instead of `&Option<T>`)
- `Result<T, E>` return `Result<&T, &E>` (instead of `&Result<T, E>`)

String, Vec, Box and Option were previously handled as special cases.

Closes #10295


Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2021-10-20 21:02:46 +00:00
Lukas Wirth
6c9b8d7ce5 Generate rustdoc lints 2021-10-20 13:48:05 +02:00
Lukas Wirth
aa9d093488 Resolve derive attributes even when shadowed 2021-10-19 13:42:36 +02:00
Andrzej Głuszak
98676efdc5 Semantic getter 2021-10-17 16:33:14 +02:00
Dezhi Wu
93ae993ec4 resolve ControlFlow ourself instead of hard coding. 2021-10-13 21:19:41 +08:00
Mirko Rainer
eccfa1645b Saw a FIXME comment and decided to fix it.
This renames `descend_into_macros` to  `descend_into_macros_single` and `descend_into_macros_many` into `descend_into_macros`.
 However, this does not touch a function in `SemanticsImpl` of same name.
2021-10-12 11:52:31 -04:00
Lukas Wirth
d71a4f40d9 Regenerate lints 2021-10-12 09:35:02 +02:00
Lukas Wirth
ed7c2948b3 Move lint source generator 2021-10-12 08:59:39 +02:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
bors[bot]
f30b62b751
Merge #10479
10479: fix: fix "index out of bounds" panic in name resolution r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10084
Closes https://github.com/rust-analyzer/rust-analyzer/issues/9163

This is really just a salsa update to a version that removes the problematic code (see https://github.com/rust-analyzer/rust-analyzer/issues/10084#issuecomment-934445711)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-06 20:54:27 +00:00
Jonas Schievink
cda9668289 Update salsa 2021-10-06 22:42:54 +02:00
crauzer
05e58afde2 Add replace_try_expr_with_match assist 2021-10-06 20:11:00 +02:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
bors[bot]
e28aa1928b
Merge #10439
10439: fix: fix insert_use incorrectly merging glob imports r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6800
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 12:19:02 +00:00
Lukas Wirth
5b0c91d118 fix: fix insert_use incorrectly merging glob imports 2021-10-03 14:06:44 +02:00
Lukas Wirth
e684235329 Move module private logic down 2021-10-03 13:52:40 +02:00
bors[bot]
ebe6c38a44
Merge #10438
10438: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 11:06:06 +00:00
Lukas Wirth
0943c4be8b minor: Simplify 2021-10-03 13:05:42 +02:00
Lukas Wirth
86e5406539 Fix rename trying to edit the same range multiple times 2021-10-02 18:50:21 +02:00
Aleksey Kladov
46eb03d99a internal: use naming that matches intended use-case 2021-10-02 12:18:18 +03:00
Lucas
6606b49710
Reduce allocation in builtin_crates
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-01 01:56:30 +10:00
lhvy
2b3baa8503
Give defaultLibrary semantic token modifier to items from standard library 2021-10-01 01:19:24 +10:00
Lukas Wirth
774a8cf08b Fix inline_call breaking RecordExprField shorthands 2021-09-28 19:22:32 +02:00
Lukas Wirth
b6ed91a6de Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
Aleksey Kladov
2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00
bors[bot]
c51a3c78cf
Merge #10358
10358: internal: Remove inherent methods from ast nodes that do non-syntactic complex tasks  r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-26 14:49:25 +00:00
Lukas Wirth
151afdfe5c Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
Lukas Wirth
215a077ee4 Remove imports when inlining all calls in a file 2021-09-26 16:01:54 +02:00
Lukas Wirth
1a50f904ef Reject recursive calls in inline_call 2021-09-26 14:55:03 +02:00
Lukas Wirth
42eb4efb5b Cleanup 2021-09-23 16:28:03 +02:00
hamidreza kalbasi
589c1dfa04 move function to defs.rs 2021-09-22 18:35:54 +03:30
Aleksey Kladov
73b0f9dc04 internal: remove dead code 2021-09-15 21:22:06 +03:00
Lukas Wirth
6f9de71402 fix: Use original definition ranges for ide_db::search instead of the expanded ranges 2021-09-14 02:49:06 +02:00
toyboot4e
89e46b40c3 Minor: replace old name CrateDefMap 2021-09-05 19:22:34 +09:00
Lukas Wirth
e2ede38d47 Use correct search scopes for macros 2021-09-02 17:30:55 +02:00
Jonas Schievink
bdba35cc93 fix: multi-token mapping aware find references 2021-09-01 19:19:16 +02:00
Lukas Wirth
68bf359363 fix: make goto_implementation multi-token mapping aware 2021-09-01 14:51:37 +02:00
Dezhi Wu
ba0947dded switch log crate to tracing 2021-08-30 15:11:42 +08:00
Aleksey Kladov
78365c64c8 internal: slightly improve compile times
As per style guide, avoid monomorphisations
2021-08-29 12:53:56 +03:00
Lukas Wirth
99f1e66997 Only report unique text ranges in highlight_related 2021-08-29 01:11:29 +02:00
Lukas Wirth
72bfbb0691 Return all usages inside macros in usage searches 2021-08-29 00:49:57 +02:00
Lukas Wirth
512135920d Highlight all related tokens in macro inputs 2021-08-29 00:49:57 +02:00
Jonas Schievink
002ef7d50a Use ManuallyDrop in RootDatabase 2021-08-28 23:05:40 +02:00
Lukas Wirth
c67ecbebc4 Rename fails on renaming definitions created by macros 2021-08-20 00:12:47 +02:00
Lukas Wirth
daf3094958 Emit more concise text edits in ide_db::rename 2021-08-17 15:24:01 +02:00
Lukas Wirth
995c8f50a2 some code docs for the ide_db/rename module 2021-08-16 23:06:51 +02:00
Lukas Wirth
5e533e5900 Handle all rename special cases for all record pattern fields 2021-08-16 22:48:38 +02:00
Lukas Wirth
894a09b749 Simplify 2021-08-14 18:02:51 +02:00
Aleksey Kladov
90357a9090 internal: merge hir::BinaryOp and ast::BinOp 2021-08-14 18:10:01 +03:00
Lukas Wirth
7e6eb67f0d Substitute generic types in inline_call 2021-08-10 14:39:56 +02:00
Lukas Wirth
b7d7dd6163 Implement bool_then_to_if assist 2021-08-10 13:17:45 +02:00
Michał Muskała
33c7c23b03 Remove unused structs in ide_db 2021-08-05 12:04:37 +01:00