Commit graph

8955 commits

Author SHA1 Message Date
Aleksey Kladov
adbcedde18 Remove the second code-path for completing names in patterns 2020-04-03 21:00:15 +02:00
bors[bot]
6a2dd7bafc
Merge #3836
3836: Macro patterns are not confused with expressions. r=matklad a=matklad

We treat macro calls as expressions (there's appropriate Into impl),
which causes problem if there's expresison and non-expression macro in
the same node (like in the match arm).

We fix this problem by nesting macor patterns into another node (the
same way we nest path into PathExpr or PathPat). Ideally, we probably
should add a similar nesting for macro expressions, but that needs
some careful thinking about macros in blocks: `{ am_i_expression!() }`.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-03 14:13:15 +00:00
Aleksey Kladov
da8eb29a2f Macro patterns are not confused with expressions.
We treat macro calls as expressions (there's appropriate Into impl),
which causes problem if there's expresison and non-expression macro in
the same node (like in the match arm).

We fix this problem by nesting macor patterns into another node (the
same way we nest path into PathExpr or PathPat). Ideally, we probably
should add a similar nesting for macro expressions, but that needs
some careful thinking about macros in blocks: `{ am_i_expression!() }`.
2020-04-03 16:12:38 +02:00
Aleksey Kladov
0e46ed8420 Cleanups 2020-04-03 15:44:06 +02:00
bors[bot]
795b8cf9c5
Merge #3834
3834: Set semantic tokens supertypes r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-03 12:16:40 +00:00
Aleksey Kladov
2a968d4554 Set semantic tokens supertypes 2020-04-03 14:09:12 +02:00
bors[bot]
1a8779bce0
Merge #3800
3800: Introduce ra_proc_macro_srv r=matklad a=edwin0cheng

This PR add preliminary for server side of proc macro : 

1. Add crate setup
2. IO for server side


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-03 12:06:04 +00:00
Edwin Cheng
9a2114b0dd Add doc comment on main.rs 2020-04-03 19:16:54 +08:00
Edwin Cheng
84fb9b44c3 Introduce ra_proc_macro_srv 2020-04-03 19:01:44 +08:00
Aleksey Kladov
ac91de1525
Merge pull request #3833 from edwin0cheng/remove-deny-c
Remove deny_c in CI
2020-04-03 12:46:29 +02:00
Edwin Cheng
3277079412 Remove deny_c in CI 2020-04-03 18:11:28 +08:00
bors[bot]
77462bba62
Merge #3746
3746: Add create_function assist r=flodiebold a=TimoFreiberg

The function part of #3639, creating methods will come later

- [X] Function arguments
     - [X] Function call arguments
     - [x] Method call arguments
     - [x] Literal arguments
     - [x] Variable reference arguments
- [X] Migrate to `ast::make` API
    Done, but there are some ugly spots.

Issues to handle in another PR:
- function reference arguments: Their type isn't printed properly right now.
    The "insert explicit type" assist has the same issue and this is probably a relatively rare usecase.

- generating proper names for all kinds of argument expressions (if, loop, ...?)
    Without this, it's totally possible for the assist to generate invalid argument names.
    I think the assist it's already helpful enough to be shipped as it is, at least for me the main usecase involves passing in named references.
    Besides, the Rust tooling ecosystem is immature enough that some janky behaviour in a new assist probably won't scare anyone off.

- select the generated placeholder body so it's a bit easier to overwrite it

- create method (`self.foo<|>(..)` or `some_foo.foo<|>(..)`) instead of create_function.
    The main difference would be finding (or creating) the impl block and inserting the `self` argument correctly

- more specific default arg names for literals.
    So far, every generated argument whose name can't be taken from the call site is called `arg` (with a number suffix if necessary).

- creating functions in another module of the same crate.
    E.g. when typing `some_mod::foo<|>(...)` when in `lib.rs`, I'd want to have `foo` generated in `some_mod.rs` and jump there.
    Issues: the mod could exist in `some_mod.rs`, in `lib.rs` as `mod some_mod`, or inside another mod but be imported via `use other_mod::some_mod`.

- refer to arguments of the generated function with a qualified path if the types aren't imported yet
    (alternative: run autoimport. i think starting with a qualified path is cleaner and there's already an assist to replace a qualified path with an import and an unqualified path)

- add type arguments of the arguments to the generated function

- Autocomplete functions with information from unresolved calls (see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605281323)
    Issues: see https://github.com/rust-analyzer/rust-analyzer/pull/3746#issuecomment-605282542. The unresolved call could be anywhere. But just offering this autocompletion for unresolved calls in the same module would already be cool.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-04-03 08:23:44 +00:00
bors[bot]
2cee8531c5
Merge #3814
3814: Add impl From for enum variant assist r=flodiebold a=mattyhall

Basically adds a From impl for tuple enum variants with one field. It was recommended to me on the zulip to maybe try using the trait solver, but I had trouble with that as, although it could resolve the trait impl, it couldn't resolve the variable unambiguously in real use. I'm also unsure of how it would work if there were already multiple From impls to resolve - I can't see a way we could get more than one solution to my query.

Fixes #3766

Co-authored-by: Matthew Hall <matthew@quickbeam.me.uk>
2020-04-03 07:46:46 +00:00
bors[bot]
642f3f4bd6
Merge #3798
3798: Simplify r=Veetaha a=Veetaha

bear with me

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-02 18:13:38 +00:00
veetaha
c0cf60dca2 Apply cargo xtask format 2020-04-02 21:12:28 +03:00
veetaha
6190caeeae Migrate to privacy as per review commets 2020-04-02 21:09:03 +03:00
veetaha
bef899aa78 Less mutability 2020-04-02 21:07:05 +03:00
veetaha
a90401aeed Migrate to iters some more 2020-04-02 21:07:05 +03:00
veetaha
987fb26a5b Migrate to iterators 2020-04-02 21:07:05 +03:00
veetaha
b7d5172f69 Simpify workspace handling 2020-04-02 21:07:05 +03:00
veetaha
4b2bf9cf66 Don't clone where you can copy 2020-04-02 21:07:05 +03:00
Matthew Hall
6a2127be28 Cleanup checking for existing impls in impl From assist
Use the trait solver to check if there's an existing implementation of
From<type_in_enum_variant> for the enum.
2020-04-02 18:42:30 +01:00
bors[bot]
09b8ee30ba
Merge #3828
3828: Bumps vsce to 1.75 r=kjeremy a=kjeremy

Fixes a security vulnerability

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-04-02 16:04:31 +00:00
kjeremy
db102c4766 Bumps vsce to 1.75
Fixes a security vulnerability
2020-04-02 12:03:30 -04:00
bors[bot]
23c4ef5aef
Merge #3811
3811: Add inference for literal and range patterns r=kjeremy a=flodiebold

(cc @JoshMcguigan )

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-04-02 15:14:44 +00:00
bors[bot]
bda471a636
Merge #3827
3827: Fix semantic coloring r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-02 13:52:54 +00:00
Aleksey Kladov
9ca69994af Fix semantic coloring 2020-04-02 15:52:25 +02:00
bors[bot]
47a48505a5
Merge #3825
3825: Allow fully overriding check and fmt commands r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-02 12:40:05 +00:00
Aleksey Kladov
407ab946ab better wording 2020-04-02 14:39:37 +02:00
Aleksey Kladov
8a788c764f Allow fully overriding check and fmt commands 2020-04-02 14:35:51 +02:00
bors[bot]
3c9e9d3f3e
Merge #3824
3824: New config names r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-02 12:05:46 +00:00
Aleksey Kladov
7a4ebd2c8d Remove vscode_lldb setting 2020-04-02 12:56:14 +02:00
Aleksey Kladov
e21bf1b2b9 Siplify 2020-04-02 12:50:34 +02:00
Aleksey Kladov
48c58309cc Lean onto default implementation of configs 2020-04-02 12:47:58 +02:00
Aleksey Kladov
e4cf40a152 New config in package.json 2020-04-02 12:27:09 +02:00
Aleksey Kladov
0dde0f92de Reorder fields 2020-04-02 11:33:49 +02:00
bors[bot]
9ee96dcf4a
Merge #3816
3816: vscode: add goto ast node definition from rust source code r=Veetaha a=Veetaha

By holding the `Ctrl` key you can now goto-definition of the appropriate syntax token in the syntax tree read-only editor. But actually going to the definition is not very convenient, since it opens the new editor, you'd rather just hold the `Ctrl` and look at the syntax tree because it is automatically scrolled to the proper node and the node itself is enclosed with text selection.

Unfortunately, the algorithm is very simple (because we don't do any elaborate parsing of the syntax tree text received from the server), but it is enough to debug not very large source files.
I tested the performance and in a bad case (rust source file with 5K lines of code) it takes `1.3` seconds to build the `rust -> ast` mapping index (lazily once on the first goto definition request) and each lookup in this worst-case is approx `20-120` ms. I think this is good enough. In the simple case where the file is < 100 lines of code, it is instant.

One peculiarity that I've noticed is that vscode doesn't trigger the goto-definition provider when the user triggers it on some punctuation characters (i.e. it doesn't underline them and invoke te goto-definition provider), but if you explicitly click `Ctrl+LMB` it will only then invoke the provider and navigate to the definition in a new editor. I think this is fine ;D

![rust2ast](https://user-images.githubusercontent.com/36276403/78198718-24d1d500-7492-11ea-91f6-2687cedf26ee.gif)


Related: #3682 

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-02 08:34:03 +00:00
veetaha
dd5e4d4870 vscode: move docks about syntax tree to dev/README.md 2020-04-02 11:23:56 +03:00
veetaha
036a8aee2a vscode: postrefactor 2020-04-02 11:13:38 +03:00
veetaha
e4c69443e7 vscode: add docs about goto-definition for rust syntax tree 2020-04-02 11:13:38 +03:00
veetaha
e763b279a8 vscode: postrefactor variable names 2020-04-02 11:13:38 +03:00
veetaha
d453281bb2 vscode: add goto definition from rust file to syntax tree editor 2020-04-02 11:13:16 +03:00
bors[bot]
98f7842e40
Merge #3820
3820: Remove old syntax highlighting r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-02 07:55:11 +00:00
Aleksey Kladov
309fc70155 Remove old syntax highlighting 2020-04-02 09:52:27 +02:00
bors[bot]
2883b299a7
Merge #3819
3819: Unique package by name and version. r=matklad a=o0Ignition0o

This commit is a fixup of #3781 I introduced a bug by using a PackageId to refer to a crate when its name conflicts with a dependency.
It turns out the package id currently is `name version path` while cargo expects `name:version` as argument eg:
Cargo command with a `PackageId`:
```
> Executing task: cargo test --package 'config 0.1.0 (path+file:///Users/ignition/Projects/oss/config)' --test default -- test_with_name --exact --nocapture <
```
Cargo command with `name:version`:
```
> Executing task: cargo test --package 'config:0.1.0' --test default -- test_with_name --exact --nocapture <
```

Co-authored-by: o0Ignition0o <jeremy.lempereur@gmail.com>
2020-04-02 07:39:46 +00:00
bors[bot]
f0ba01cd43
Merge #3817
3817: vscode: highlight syntax tree ro editor r=matklad a=Veetaha

Small textmate grammar declaration to make rust-analyzer syntax tree more easily inspectable:
Btw, if we change the file extension of our `ra_syntax/test_data/**` files to `.rast` they should be highlighted in vscode too.

The colors of the tokens are actually going to be color-theme dependent, or you can customize them via:
```jsonc
{
    "editor.tokenColorCustomizations": {
        "textMateRules": [ { "scope": "name", "settings": { /* */ } } ] 
    }
}
```
![image](https://user-images.githubusercontent.com/36276403/78204947-99f9d600-74a3-11ea-8315-cb1c87810c7c.png)

Related: #3682

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-02 07:32:14 +00:00
bors[bot]
93f21ac624
Merge #3815
3815: vscode: add support for light themes in "Show Syntax Tree" command r=matklad a=Veetaha

Fixes: #3810

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-04-02 07:25:03 +00:00
o0Ignition0o
f643b4b5f5 Unique package by name and version.
This commit is a fixup of a bug I introduced by using a PackageId to refer to a crate when its name conflicts with a dependency.
It turns out the package id currently is `name version path` while cargo expects `name:version` as argument.
2020-04-02 09:00:44 +02:00
veetaha
62ed01a107 vscode: add highlighting of syntax tree 2020-04-02 05:38:52 +03:00
veetaha
f4f79383b1 vscode: add support for light themes and color customization for syntax tree highlights 2020-04-02 01:20:08 +03:00