Commit Graph

1186 Commits

Author SHA1 Message Date
lhvy
2b3baa8503
Give defaultLibrary semantic token modifier to items from standard library 2021-10-01 01:19:24 +10:00
bors[bot]
ee12b0f173
Merge #10181
10181: Begining of lsif r=HKalbasi a=HKalbasi

This PR adds a `lsif` command to cli, which can be used as `rust-analyzer lsif /path/to/project > dump.lsif`. It now generates a valid, but pretty useless lsif (only supports folding ranges). The propose of this PR is to discussing about the structure of lsif generator, before starting anything serious.

cc `@matklad` #8696 #3098


Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-29 13:13:03 +00:00
hamidreza kalbasi
5bd0f50111 remove glob import and cancellables 2021-09-29 16:25:10 +03:30
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
Lukas Wirth
151afdfe5c Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
hamidreza kalbasi
7377120fee add some tests 2021-09-26 12:48:53 +03:30
hamidreza kalbasi
48bebeaa32 support goto definition and find references 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
f2775ac2e9 reuse hover results with resultset 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
e803bd25c4 add hover 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
5163201847 use utf16 instead of utf8 2021-09-26 10:04:02 +03:30
hamidreza kalbasi
557210a688 Begining of lsif 2021-09-26 10:04:02 +03:30
Lukas Wirth
e60f3d265f Split the hover module up 2021-09-23 20:36:15 +02:00
Lukas Wirth
22c6f0a8a5 Support goto_def for intra-doc-links in macro invocations 2021-09-23 19:17:29 +02:00
Lukas Wirth
d99adc5738 Make hover work for intra doc links in macro invocations 2021-09-23 17:32:39 +02:00
Lukas Wirth
42eb4efb5b Cleanup 2021-09-23 16:28:03 +02:00
bors[bot]
8a82e6c492
Merge #10284
10284: internal: definition based hover functions r=Veykril a=HKalbasi

This is part of #10181 but since it is blocked and `hover.rs` is moving quickly so will cause conflicts, I submitted this PR.

This PR extract some parts of `hover` to `find_definition` (maybe this need to be moved to some other file?) and `hover_for_definition`, with those functions I will be able to calculate definition of every token, and calculate hover (and probably other queries) for each definition only once.

Co-authored-by: hamidreza kalbasi <hamidrezakalbasi@protonmail.com>
2021-09-22 15:23:23 +00:00
hamidreza kalbasi
589c1dfa04 move function to defs.rs 2021-09-22 18:35:54 +03:30
hamidreza kalbasi
18e6b508dd remove dead code 2021-09-22 11:44:23 +03:30
hamidreza kalbasi
569ac5bee1 use find_definition in go to 2021-09-22 11:37:26 +03:30
hamidreza kalbasi
887b7ddc37 fix derive hover in macro 2021-09-21 19:55:57 +04:30
Lukas Wirth
ba84b91e78 Add a mirror function-like proc-macro expander for tests 2021-09-21 14:55:54 +02:00
hamidreza kalbasi
0777698f29 internal: definition based hover functions 2021-09-19 16:15:44 +04:30
Lukas Wirth
6465868449 Make inlay hints work in attributed items 2021-09-18 13:19:29 +02:00
Lukas Wirth
11a17c803f Add multi-token mapping test for goto_definition 2021-09-18 12:00:12 +02:00
zhoufan
227450f9b9 do comment handling on the original token 2021-09-18 08:22:57 +08:00
zhoufan
ea3535cefc fix: multi-token mapping aware goto definition 2021-09-16 09:44:22 +08:00
bors[bot]
959c7ef563
Merge #10250
10250: internal: Improve call_hierarchy and incoming/outgoing_calls r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-16 00:26:32 +00:00
Lukas Wirth
d777eddf0d Improve call_hierarchy and incoming/outgoing_calls 2021-09-16 02:25:02 +02:00
bors[bot]
4c9eef7ede
Merge #10233
10233: fix: add multi-token mapping support to hovers r=Veykril a=spookyvision

implement #10070 in [`hover`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/hover.rs)

Co-authored-by: Anatol Ulrich <anatol.ulrich@ferrous-systems.com>
2021-09-15 16:36:33 +00:00
Anatol Ulrich
45090e4f4b add multi-token mappings for hover 2021-09-15 18:05:53 +02:00
Anatol Ulrich
b251a30819 # This is a combination of 3 commits.
# This is the 1st commit message:

add multi-token mappings for hover

# The commit message #2 will be skipped:

# make fallback an Option instead of vec

# The commit message #3 will be skipped:

# fix indentation
2021-09-15 18:04:45 +02:00
Lukas Wirth
33cdc21832 Don't highlight unsafe traits as unsafe in safe impls 2021-09-15 15:46:45 +02:00
Lukas Wirth
64fb7be247 Revert attributed items inlay hints 2021-09-14 20:30:28 +02:00
bors[bot]
f750eebd0d
Merge #10232
10232: internal: Add more tests for ide functionality in attributed items r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/9868

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-14 12:54:00 +00:00
Lukas Wirth
0f4463e45e fix source_to_def trying to use attribute macro calls as containers 2021-09-14 14:42:14 +02:00
Lukas Wirth
538ac599d2 Add some more attribute ide tests 2021-09-14 03:57:29 +02: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
bors[bot]
e896def412
Merge #10204
10204: feat: Show the type of what is being dereferenced in a deref expression. r=theo-lw a=theo-lw

Addresses issue #10106.

In-progress - I'm trying to figure out why `hover_deref_expr_with_coercion` is failing.

Co-authored-by: Teddy_Wang <wangtheo662@gmail.com>
2021-09-14 00:41:17 +00:00
Teddy_Wang
8de5d66e25 Improve hover over derference message 2021-09-13 20:19:30 -04:00
Lukas Wirth
e193e3b076 feat: Make inlay hints work in attributed items 2021-09-14 01:59:45 +02:00
Teddy_Wang
4d9728ccb2 Fix hover tests 2021-09-13 19:47:53 -04:00
Lukas Wirth
8f76e41e18 Enable attribte macros in ide fixtures 2021-09-14 01:23:13 +02:00
Lukas Wirth
bb946f78f6 fix: fix expansion order for fn-like macros and attributes in token descending 2021-09-14 01:20:43 +02:00
Teddy_Wang
0c6a993f59 Fix spelling 2021-09-13 19:16:10 -04:00
Lukas Wirth
95746a99b4 Use correct file syntax node for decl_access computation in find_all_refs 2021-09-12 23:19:23 +02:00
bors[bot]
317059985a
Merge #10202
10202: fix: Type param hover shows correct sized bounds. r=flodiebold a=iDawer

Closes  #9949

This adds implicit `: Sized` bound to type parameters at lowering step.

Hovering on type parameter does not show it's `: Sized` bound be it set explicitly or implicitly. This is because it doesn't track that the bound was set implicitly.

### Perf

```rust
./target/rust-analyzer-baseline-3dae94bf -q analysis-stats --memory-usage .
Database loaded:     4.51s, 311minstr, 110mb (metadata 1.08s, 22minstr, 743kb; build 3.20s, 8730kinstr, -237kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.63s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           118.25s, 284ginstr, 601mb
Total:               147.88s, 370ginstr, 973mb

./target/rust-analyzer-hover-ty-param-dfb15292 -q analysis-stats --memory-usage .
Database loaded:     4.53s, 311minstr, 110mb (metadata 1.10s, 22minstr, 743kb; build 3.20s, 8672kinstr, -189kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.59s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           121.69s, 296ginstr, 601mb
Total:               151.28s, 382ginstr, 974mb

```

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-12 07:54:56 +00:00
Teddy_Wang
1d4d9a1e1a Fix tests by importing core::ops::Deref 2021-09-11 11:40:16 -04:00
Dawer
964c7b3211 minor: fix tests. 2021-09-10 23:02:37 +05:00
Dawer
dfb15292c2 fix: Type param hover shows correct sized bounds. 2021-09-10 20:48:39 +05:00