Commit Graph

214 Commits

Author SHA1 Message Date
bors[bot]
05261f5aeb
Merge #6176
6176: add eprintln in fmt-like postfix r=SomeoneToIgnore a=bnjjj



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-09 23:16:19 +00:00
Jonas Schievink
5dcbf03d0f adt: correctly inherit field visibility from enum
Previously, "find all references" on a variant field wouldn't find any
references outside the defining module. This is because variant fields
were incorrectly assumed to be private, like struct fields without
explicit visibility, but they actually inherit the enum's visibility.
2020-10-09 20:46:45 +02:00
Jonas Schievink
210456aeaa Treat ast::Name in field patterns as use 2020-10-09 19:56:54 +02:00
Jonas Schievink
468b804856 Fix source_to_def for named enum variant fields 2020-10-09 02:57:35 +02:00
Benjamin Coenen
36459284c7 add eprintln in fmt-like postfix
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-08 20:53:39 +02:00
Zac Pullar-Strecker
3bd4fe96dc Remove methodowner & fix formatting 2020-10-08 15:50:48 +13:00
Zac Pullar-Strecker
8af1dd7337 Rebase fixes 2020-10-08 15:22:57 +13:00
Zac Pullar-Strecker
d2c68809ea Changes from review 2020-10-08 15:05:24 +13:00
Zac Pullar-Strecker
e4a787fcbc Remove outdated part of doc_links module docs 2020-10-08 15:05:23 +13:00
Zac Pullar-Strecker
f6759ba3bb Add ignored test to demonstrate ImportMap bug 2020-10-08 15:05:23 +13:00
Zac Pullar-Strecker
6cae6b8f3c Fix namespace detection & function test 2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
37a4d060a7 Add tests 2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
26086faab2 Change Option::Some bug to a fixme note
IMO this is too much work to be worth fixing at the moment.
2020-10-08 15:04:57 +13:00
Zac Pullar-Strecker
c648884397 Differentiate method/tymethod by determining 'defaultness'
Currently a method only has defaultness if it is a provided trait
method, but this will change when specialisation is available and may
need to become a concept known to hir.

I opted to go for a 'fewest changes' approach given specialisation is
still under development.
2020-10-08 15:04:21 +13:00
Zac Pullar-Strecker
974518fde7 Code reorganisation and field support 2020-10-08 15:04:20 +13:00
Zac Pullar-Strecker
a14194b428 Changes from review 2020-10-08 15:01:30 +13:00
Zac Pullar-Strecker
8c32bdea36 Rename ide::link_rewrite -> ide::doc_links & tidy imports 2020-10-08 15:01:30 +13:00
Zac Pullar-Strecker
a06d736b77 Add support for struct & trait methods 2020-10-08 14:59:31 +13:00
Zac Pullar-Strecker
bfda0d2583 WIP: Command to open docs under cursor 2020-10-08 14:59:31 +13:00
bors[bot]
83a651b123
Merge #6154
6154: Shorten type hints for std::iter Iterators r=SomeoneToIgnore a=Veykril

Fixes #3750.

This re-exports the `hir_expand::name::known` module to be able to fetch the `Iterator` and `iter` names.
I'm not sure if there is anything to do with `Solution::Ambig` in `normalize_trait_assoc_type` or whether discarding those results is always wanted.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-07 11:52:05 +00:00
Lukas Wirth
783af171f7 Clean up inlay_hints 2020-10-07 13:18:12 +02:00
Lukas Wirth
e106857e80 Shorten iterator hints for std::iter iterators behind references 2020-10-07 12:14:08 +02:00
Lukas Wirth
209e9b9926 Shorten iterator chain hints 2020-10-07 11:30:42 +02:00
Lukas Wirth
c133651e0a Move IntoIterator into FamousDefs 2020-10-07 10:14:42 +02:00
Lukas Wirth
c6f1de6ac5 Use FamousDefs for shorten_iterator hint 2020-10-06 21:25:39 +02:00
bors[bot]
bf1043cac2
Merge #6128
6128: Trim all trailing whitespace in onEnter r=matklad a=repnop

Fixes #5848

Co-authored-by: Wesley Norris <repnop@outlook.com>
2020-10-06 18:17:49 +00:00
bors[bot]
57735f2a32
Merge #6140
6140: honour hover.content_format client capability r=lnicola a=robinvd

This removes all markdown when the client does not support the markdown MarkupKind.

Otherwise the output on the editor will have some markdown boilerplate, making it less readable.

For example kak_lsp does not currently support markdown.
![image](https://user-images.githubusercontent.com/22073483/95112949-ef0ff080-0741-11eb-82a7-0594fa2cd736.png)

after:
![image](https://user-images.githubusercontent.com/22073483/95113089-2bdbe780-0742-11eb-94fa-bcfec6d7347a.png)



Co-authored-by: Robin van Dijk <robin@robinjint.nl>
2020-10-06 17:51:20 +00:00
Lukas Wirth
aaa3905fdd Shorten type hints for std::iter Iterators 2020-10-06 19:20:42 +02:00
Robin van Dijk
bd7bf4a276 add break after codeblocks 2020-10-06 16:34:38 +02:00
Robin van Dijk
bc890ed5b0 add doc describing limited capabilities 2020-10-06 16:34:26 +02:00
bors[bot]
8bf13292f0
Merge #6148
6148: Fix trait object hir formatting behind pointer and references r=matklad a=Veykril

Fixes #6064

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-06 13:28:03 +00:00
Lukas Wirth
643bbf15a2 Fix trait object hir formatting behind pointer and references 2020-10-06 14:40:27 +02:00
bors[bot]
87cb840a4e
Merge #6124
6124: Better normalized crate name usage r=jonas-schievink a=SomeoneToIgnore

Closes https://github.com/rust-analyzer/rust-analyzer/issues/5343 
Closes https://github.com/rust-analyzer/rust-analyzer/issues/5932

Uses normalized name for code snippets (to be able to test the fix), hover messages and documentation rewrite links (are there any tests for those?).
Also renamed the field to better resemble the semantics.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-10-06 11:51:15 +00:00
bors[bot]
44587d1bfc
Merge #6127
6127: Correctly complete items with leading underscore r=SomeoneToIgnore a=fmease

Fixes #6091. Let me know if the test is placed into the right file or if it is even desired.

Co-authored-by: León Orell Valerian Liehr <liehr.exchange@gmx.net>
2020-10-05 21:27:18 +00:00
Aleksey Kladov
bff812ddfe Fix feature name 2020-10-05 20:25:11 +02:00
Robin van Dijk
81f61afa9f add docstring 2020-10-05 20:06:25 +02:00
Robin van Dijk
c3cc361294 honor content_format clientcap
This removes all markdown when the client does not support the markdown MarkupKind

Otherwise the output on the editor will have some markdown boilerplate, making it less readable
2020-10-05 19:27:29 +02:00
Wesley Norris
adb3c56ff0 Trim all trailing whitespace in onEnter
Fixes #5848
2020-10-03 14:17:21 -04:00
Igor Aleksanov
3cadba4956 Improve readability in inlay_hints.rs 2020-10-03 13:44:43 +03:00
Igor Aleksanov
91a09f50f4 Remove 'for_expr' test from inlay_hints.rs 2020-10-03 08:58:17 +03:00
Igor Aleksanov
a58441ad1b Make the tests for complete/incomplete for inlay hints work 2020-10-03 08:37:58 +03:00
Igor Aleksanov
8ca214fbfb Better inlay hints in 'for' loops 2020-10-03 08:30:25 +03:00
León Orell Valerian Liehr
32864e3b49 Correctly complete items with leading underscore 2020-10-03 03:00:09 +02:00
Kirill Bulatov
9d19e5b962 Properly name the field 2020-10-02 21:38:22 +03:00
Kirill Bulatov
cae2e859ff Add a dash test 2020-10-02 20:59:32 +03:00
Aleksey Kladov
b06259673f rename mock_analysis -> fixture 2020-10-02 17:49:44 +02:00
Aleksey Kladov
09348b2474 Get rid of MockAnalysis 2020-10-02 17:31:20 +02:00
Aleksey Kladov
8716c4cec3 Move ide::AnalysisChange -> base_db::Change
This seems like a better factoring logically; ideally, clients shouldn't touch
`set_` methods of the database directly. Additionally, I think this
should remove the unfortunate duplication in fixture code.
2020-10-02 16:45:08 +02:00
Aleksey Kladov
700c9bc019 Expectify find_references tests 2020-10-02 16:42:48 +02:00
Aleksey Kladov
763b13a74e Reduce visibiity 2020-10-02 14:26:40 +02:00
Igor Aleksanov
97f2905dec Use expect_test to make format_str_parser test more data-driven 2020-10-02 14:51:20 +03:00
Igor Aleksanov
76d0546ac7 Use lookup table instead of enum for postfix completion kinds 2020-10-02 13:33:27 +03:00
Igor Aleksanov
b7ac540f15 Use ast::String for extracting string literal contents 2020-10-02 13:23:49 +03:00
Igor Aleksanov
2557cb8518 Improve format-like completions code appearance 2020-10-02 12:49:33 +03:00
Igor Aleksanov
777ccb58f0 Add missing entry to doc-comment 2020-10-02 12:42:39 +03:00
Igor Aleksanov
cd3d654f60 Simplify is_string_literal function 2020-10-02 12:42:39 +03:00
Igor Aleksanov
e447b3a4a2 Improve checks for postfix suggestions 2020-10-02 12:42:39 +03:00
Igor Aleksanov
ea320141c6 Add postfix completion for format-like string literals 2020-10-02 12:42:39 +03:00
kjeremy
82d6cfd495 Minor clippy performance suggestions 2020-09-30 15:22:49 -04:00
Aleksey Kladov
af8063fe37 Extend **Status** command to also show dep info for the file
This should help with troubleshooting wrong project configuration
2020-09-29 22:13:23 +02:00
Aleksey Kladov
e7df0ad2fb Remove periodic gc stub 2020-09-29 21:22:48 +02:00
vsrs
cd5eeb904e Add tests 2020-09-29 15:29:20 +03:00
vsrs
1895716c88 Do not show references CodeLens for tests. 2020-09-29 15:29:20 +03:00
vsrs
06fbd69050 Make method references CodeLens lazy. 2020-09-29 15:29:20 +03:00
flw
e73ee9dfa2
Add hover config linksInHover to suppress links 2020-09-29 19:47:18 +08:00
bors[bot]
cfe987bcdf
Merge #6055
6055: Add ok postfix completion r=matklad a=mullr

Wrapping values in `Ok(...)` is so pervasive that it seems reasonable for it to
have its own postfix completion.


Co-authored-by: Russell Mull <russell.mull@gmail.com>
2020-09-25 11:55:35 +00:00
bors[bot]
163ffb8803
Merge #6072
6072: Cleanup unintended unresolved reference in syntax higlighting test r=matklad a=Nashenas88

Fixes the issue brought up here https://github.com/rust-analyzer/rust-analyzer/pull/5957#discussion_r486625707

cc @jonas-schievink 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-09-25 11:49:12 +00:00
Paul Daniel Faria
ed8968af49 Cleanup unintended unresolved reference in syntax higlighting test 2020-09-24 10:14:25 -04:00
bors[bot]
5d137f21f2
Merge #6056
6056: Add dbgr postfix completion r=matklad a=lnicola

Expanding to `dbg!(&e)`.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-09-24 14:14:01 +00:00
bors[bot]
9d3483a74d
Merge #5846
5846: Add references to fn args during completion r=matklad a=adamrk

When completing a function call, if there is an argument taken as a ref or mut ref which matches the name and type of a variable in scope, we will insert a `&` or `&mut` when filling in the function arguments. This addresses https://github.com/rust-analyzer/rust-analyzer/issues/5449.

E.g. 
```rust
fn foo(x: &i32) {}
fn main() {
  let x = 5;
  foo # completing foo here generates `foo(&x)` now instead of `foo(x)`
}
```

Co-authored-by: adamrk <ark.email@gmail.com>
2020-09-24 12:23:28 +00:00
Laurențiu Nicola
eb0e710779 Add dbgr postfix completion 2020-09-22 08:54:57 +03:00
Russell Mull
197d1e1b05 Cargo fmt 2020-09-21 17:47:20 -07:00
Russell Mull
e3b19da8c1 Add ok postfix completion 2020-09-21 17:15:20 -07:00
Jonas Schievink
603613a302 Update tests 2020-09-16 17:26:51 +02:00
oxalica
d2fced1c26
Avoid checking all ancestors and fix mis-completion 2020-09-16 01:16:06 +08:00
Benjamin Coenen
e0f0d93eda inline parameters for a function description #6002
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-09-15 18:04:34 +02:00
Benjamin Coenen
2e91159ced inline parameters for a function description #6002
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-09-15 17:15:33 +02:00
bors[bot]
d134a81037
Merge #5976
5976: Complete trait impl immediately after type/const/fn r=jonas-schievink a=oxalica

Currently, we can complete type/const/fn but only if we typed an identifier.
That is, `impl .. { fn f<|> }` has completions with all trait fn including `f`, but `impl .. { fn <|> }` doesn't provide any suggestion (even if explicit trigger it).

This PR tweak the logic of completion match to make it possible.

However, we still need to explicit trigger suggestions (`Control + Space` by default) in vscode to show. Not sure if we can make it automatically triggered after typing the space after `fn`.

Another question is that I cannot figure out why `BLOCK_EXPR` need to be checked. A block expr directly inside a impl block should be invalid, and nested items will failed to locate impl block in specific offset and skip the suggestion. Now I simply removed it and no tests are broken.
4f91478e50/crates/ide/src/completion/complete_trait_impl.rs (L109)


Co-authored-by: oxalica <oxalicc@pm.me>
2020-09-14 10:22:20 +00:00
bors[bot]
a61178d218
Merge #5985
5985: Make MergeBehaviour configurable r=jonas-schievink a=Veykril

This should make the newly implemented `MergeBehaviour` for import insertion configurable as roughly outlined in https://github.com/rust-analyzer/rust-analyzer/pull/5935#issuecomment-685834257. For the config name and the like I just picked what came to mind so that might be up for bikeshedding.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-09-14 10:12:08 +00:00
bors[bot]
0d03fe6ef5
Merge #5971
5971: Implement async blocks r=flodiebold a=oxalica

Fix #4018

@flodiebold already gave a generic guide in the issue. Here's some concern about implementation detail:
- Chalk doesn't support generator type yet.
- Adding generator type as a brand new type (ctor) can be complex and need to *re-introduced* builtin impls. (Like how we implement closures before native closure support of chalk, which is already removed in #5401 )
- The output type of async block should be known after type inference of the whole body.
  - We cannot directly get the type from source like return-positon-impl-trait. But we still need to provide trait bounds when chalk asking for `opaque_ty_data`.
  - During the inference, the output type of async block can be temporary unknown and participate the later inference.
    `let a = async { None }; let _: i32 = a.await.unwrap();`

So in this PR, the type of async blocks is inferred as an opaque type parameterized by the `Future::Output` type it should be, like what we do with closure type.
And it really works now.

Well, I still have some questions:
- The bounds `AsyncBlockImplType<T>: Future<Output = T>` is currently generated in `opaque_ty_data`. I'm not sure if we should put this code here.
- Type of async block is now rendered as `impl Future<Output = OutputType>`. Do we need to special display to hint that it's a async block? Note that closure type has its special format, instead of `impl Fn(..) -> ..` or function type.



Co-authored-by: oxalica <oxalicc@pm.me>
2020-09-13 17:28:22 +00:00
Lukas Wirth
adc4c6b9d7 Make MergeBehaviour configurable 2020-09-12 12:11:16 +02:00
oxalica
529c369c9b
Fix type walking about type of async block 2020-09-12 01:08:50 +08:00
oxalica
8ebf3596b7
Complete trait impl immediately after type/const/fn 2020-09-11 23:05:10 +08:00
bors[bot]
4f1167d8dd
Merge #5969
5969: Propose module name completion options r=jonas-schievink a=SomeoneToIgnore

<img width="539" alt="image" src="https://user-images.githubusercontent.com/2690773/92663009-cb0aec00-f308-11ea-9ef5-1faa91518031.png">

Currently traverses the whole file set every time we try to complete the module, as discussed in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/mod.3C.7C.3E.20completion

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-09-11 11:37:04 +00:00
Kirill Bulatov
ca698a0b8c Adjust the test comment 2020-09-11 14:16:15 +03:00
oxalica
251ef93ac3
Implement async blocks 2020-09-10 20:01:23 +08:00
Kirill Bulatov
492e3c40f6 One more test 2020-09-10 01:58:29 +03:00
Kirill Bulatov
9863798480 Rename the method to avoid false promises 2020-09-10 01:45:49 +03:00
Kirill Bulatov
a7d75463c7 Fix the tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
5aebf54fd4 Add tests 2020-09-10 01:42:20 +03:00
Kirill Bulatov
dbf70cd015 Properly handle mod.rs imports 2020-09-10 01:42:20 +03:00
Kirill Bulatov
9fb83211f9 Complete semicolon when needed 2020-09-10 01:42:20 +03:00
Kirill Bulatov
57a260f579 Properly reacto to keywords 2020-09-10 01:42:20 +03:00
Kirill Bulatov
cc43abcde8 Less false positive completion candidates 2020-09-10 01:42:20 +03:00
Kirill Bulatov
3fd6f45141 Properly handle nested submodules in the same file 2020-09-10 01:42:20 +03:00
Kirill Bulatov
f9c14ac720 Move most of the logic into the completion module 2020-09-10 01:42:20 +03:00
Kirill Bulatov
6ba479cd05 Finally cretae the mod completion module 2020-09-10 01:42:20 +03:00
Kirill Bulatov
b2bcc5278d Properly handle special cases (binaries, mod.rs) 2020-09-10 01:42:20 +03:00
Kirill Bulatov
486c5c3285 Exclude special files 2020-09-10 01:42:20 +03:00
Kirill Bulatov
8aa740dab4 Happy path implemented 2020-09-10 01:42:20 +03:00