Commit Graph

3605 Commits

Author SHA1 Message Date
Edwin Cheng
c0f19d7005 Add expr, pat, ty and macro_stmts 2019-04-19 03:49:56 +08:00
Edwin Cheng
3ff5440a50 Add MacroItems and MacroStmts in grammer.ron 2019-04-19 02:47:29 +08:00
bors[bot]
d55f1136d6 Merge #1164
1164: Fix missing last token in mbe $repeat parsing r=matklad a=edwin0cheng

The `mbe parser` incorrectly eat one more token in $repeat parsing, described in #1141.

Remove incorrect token eating, and add related test.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-18 18:13:09 +00:00
Edwin Cheng
e8ddeb869d Fix missing last token in mbe $repeat parsing 2019-04-18 23:33:54 +08:00
bors[bot]
403cd78bae Merge #1161
1161: Add mbe 'item' matcher r=matklad a=edwin0cheng

Add `item` matcher in `ra_mbe` , and added corresponding `item()` parser in `ra_syntax`. 
This PR also help PR #1148 for `Items` parsing.

And hopefully fix #1149 ?!




Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-18 12:00:16 +00:00
Edwin Cheng
e944fd059d Add item matcher in mbe 2019-04-18 10:21:36 +08:00
bors[bot]
112fd0ec7d Merge #1160
1160: better formatting when adding trait members r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-17 11:11:31 +00:00
Aleksey Kladov
a27fc96aa1 better formatting when adding trait members
* it's conventional not to use one-liners
* new placement is more predictable, b/c it does not depend on
  header's length
2019-04-17 14:05:02 +03:00
bors[bot]
4c8e6e89aa Merge #1145
1145: Fix #1099, plug self type type parameters in infer_path_expr r=flodiebold a=edwin0cheng

As discussed in #1099, this PR try to "plug" a `self type` type parameters in `infer_path_expr`.
All the cases in 1099 was fixed and tested.
And luckily, this PR fixed bug #1030 again and make the test output correct.





Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-17 11:03:34 +00:00
bors[bot]
feaa30cf67 Merge #1159
1159: ⬆️ vfs r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-17 09:34:51 +00:00
Aleksey Kladov
16256ee2c6 ⬆️ vfs 2019-04-17 12:34:25 +03:00
bors[bot]
645a7b77b6 Merge #1158
1158: cleanup cancellation r=matklad a=matklad

Now that we explicitelly exit the reading loop on exit notification,
we can assume that the sender is always alive

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-17 08:56:36 +00:00
Aleksey Kladov
f75feb6724 cleanup cancellation
Now that we explicitelly exit the reading loop on exit notification,
we can assume that the sender is always alive
2019-04-17 11:47:38 +03:00
bors[bot]
d3afb1b378 Merge #1153
1153: "Restart server" command r=jrvidal a=jrvidal

The only tricky aspect is that fact that once the `exit` command has been received, we no longer need to join on the reader thread. 

Also, I think `terminateProcesses.sh` was not working properly. In fact, the very same script from the vscode language server implementation is not working either! It's because of that I noticed the reader thread issue 😮 

Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2019-04-17 05:51:12 +00:00
bors[bot]
0e35603069 Merge #1157
1157: Add mbe stmt matcher r=matklad a=edwin0cheng

Add `stmt` matcher in `ra_mbe` , and added corresponding `stmt()` parser in `ra_syntax`. 
This PR also help PR #1148 for `MarcoKind::Items` parsing.

Note: 
* According [the book](https://doc.rust-lang.org/reference/macros-by-example.html), mbe `stmt` matcher will only match statement without the trailing semicolon 
* `item` is a valid statement.





Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-17 05:10:29 +00:00
Edwin Cheng
57e4122b89 Add mbe stmt matcher 2019-04-17 12:34:43 +08:00
Edwin Cheng
8747c903a2 Refactoring 2019-04-17 09:35:03 +08:00
Edwin Cheng
039ab2e820 Simpliy code 2019-04-17 09:31:53 +08:00
Edwin Cheng
0edb5ce97a Bug fix and add more comments 2019-04-17 09:31:52 +08:00
Edwin Cheng
180655077a Fix 1099 2019-04-17 09:31:52 +08:00
Roberto Vidal
8d569d49d2 Breaks read loop on 'exit' 2019-04-17 00:38:56 +02:00
Roberto Vidal
13d92b3f11 Fixes doctest 2019-04-16 22:25:17 +02:00
Roberto Vidal
145ee9c3e9 Prettier 2019-04-16 22:11:50 +02:00
Roberto Vidal
3bdd6973d1 Fixes unrelated process termination quirk 2019-04-16 22:07:33 +02:00
Roberto Vidal
12f28f6276 Adds "restart server" command 2019-04-16 22:07:33 +02:00
bors[bot]
546d9be2a7 Merge #1146
1146: Moar profiling r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-14 22:21:12 +00:00
Aleksey Kladov
247ac265f1 fix test 2019-04-15 01:17:26 +03:00
Aleksey Kladov
c4a5aa45dc add a couple of profiling points 2019-04-15 01:10:07 +03:00
Aleksey Kladov
06615bd331 more intuitive name 2019-04-15 01:10:07 +03:00
Aleksey Kladov
5b7012318c filter by time 2019-04-15 01:10:07 +03:00
Aleksey Kladov
b228947b68 cleanup syntax 2019-04-15 01:10:07 +03:00
Aleksey Kladov
e6f32c6d3a fast path for disabled profiler 2019-04-15 01:10:07 +03:00
Aleksey Kladov
30a4099ea7 switch to modern paths 2019-04-15 01:10:07 +03:00
bors[bot]
e1a2649aff Merge #1144
1144: Refactor method candidate generation a bit r=flodiebold a=flodiebold

This fixes the order in which candidates are chosen a bit (not completely though, as the ignored test demonstrates), and makes autoderef work with trait methods.
As a side effect, this also makes completion of trait methods work :)

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-04-14 19:55:18 +00:00
Florian Diebold
4f8a49f43c Refactor method candidate generation a bit
This fixes the order in which candidates are chosen a bit (not completely
though, as the ignored test demonstrates), and makes autoderef work with trait
methods. As a side effect, this also makes completion of trait methods work :)
2019-04-14 21:53:35 +02:00
bors[bot]
88be6f3217 Merge #1137
1137: Adds support for multiple editor workspaces on initialization r=matklad a=jrvidal

OK, so this "simple hack" turned out to be way more contrived than I expected 😂

### What works
This patch only handles multi-folder editor workspaces _on initialization_.
  * I've found that modifying the layout of a workspace in VSCode just reloads the extension, so this hack should be enough for now.
  * Not sure about how emacs-lsp behaves, but we fallback gracefully to the mono-folder workspace, so it should be fine.

### What doesn't work
* [x] `cargo watch` can only watch a single root folder with a `Cargo.toml`. I've left this part untouched but we could either warn that it's not supported or launch _multiple_ `cargo-watch` processes.
* [x] The `rust-analyzer/runnables` command is not functional, since we don't send the correct `cwd`.
* [x] Should we add some happy path test to `heavy_tests`?
* [ ] Going from a single `root` to multiple `roots` leaves us with a couple of `n * m` loops that smell a bit. The number of folders in the editor workspace is probably low though.

Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2019-04-14 17:26:07 +00:00
bors[bot]
5d35f284f5 Merge #1138
1138: Add L_DOLLAR and R_DOLLAR r=matklad a=edwin0cheng

As discussion in issue https://github.com/rust-analyzer/rust-analyzer/issues/1132 and PR #1125 , this PR add 2 `Syntax::Kind` : `L_DOLLAR` and `R_DOLLAR` for representing `Delimiter::None` in mbe and proc_marco. By design, It should not affect the final syntax tree, and will be discard in `TreeSink`.

My original idea is handling these 2 tokens case by case, but i found that they will appear in every place in the parser (imagine `tt` matcher). So this PR only handle it in `Parser::do_bump` and `Parser::start`, although It will not fix the `expr` matcher executing order problem in original idea.


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-14 14:16:42 +00:00
bors[bot]
fcbd026954 Merge #1120
1120: More trait infrastructure r=matklad a=flodiebold

This adds enough trait infrastructure to be able to make some deductions about type variables when resolving trait methods, while at the same time doing as little as possible that will be later replaced by Chalk 😄 

E.g. (as the tests show) if we have
```rust
trait Trait<T> { fn method(self) -> T }
impl Trait<u32> for S {}
...
S.method()
```
we can infer that the return type is `u32`. On the other hand the unification logic is so primitive that we can't handle e.g. `impl<T> Trait<T> for S<T>`.

It's all quite hacky, I plan to refactor the parts that will stay, while hopefully the other parts will be replaced soon 🙂 In particular, we need to handle 'containers' (impls and trait defs) more cleanly, and I need to reorganize the method resolution / type inference code...

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-04-14 14:06:48 +00:00
Florian Diebold
8bcbcc454c Extract generic_params method to a HasGenericParams trait 2019-04-14 13:07:45 +02:00
Florian Diebold
4497e1d3ea Add Container enum to handle both kinds of container (impl/trait) 2019-04-14 11:28:53 +02:00
Florian Diebold
7650a44640 Make callable signature handling a bit nicer 2019-04-14 11:28:53 +02:00
Florian Diebold
9339241b78 Some cleanup 2019-04-14 11:28:53 +02:00
Florian Diebold
a1ed53a4f1 More trait infrastructure
- make it possible to get parent trait from method
 - add 'obligation' machinery for checking that a type implements a
   trait (and inferring facts about type variables from that)
 - handle type parameters of traits (to a certain degree)
 - improve the hacky implements check to cover enough cases to exercise the
   handling of traits with type parameters
 - basic canonicalization (will probably also be done by Chalk)
2019-04-14 11:28:53 +02:00
Florian Diebold
413c87f155 Get substs for trait refs in impl blocks 2019-04-14 11:28:53 +02:00
Roberto Vidal
c2dfc8a229 Modifies runnables test to use multi-workspace root 2019-04-14 10:04:38 +02:00
Roberto Vidal
7c7cfc5f04 Sends cwd info for runnables and code lenses 2019-04-14 10:04:38 +02:00
Roberto Vidal
3507bcb97a Adds support for multiple editor workspaces on initialization
This is a quick, partial fix for #1104
2019-04-14 10:04:38 +02:00
Edwin Cheng
6646d49f23 Fix bug and add expr , pat , ty matcher 2019-04-14 11:42:20 +08:00
bors[bot]
23b876bc3b Merge #1143
1143: replace usages of `algo::generate` with `iter::successors` from std r=matklad a=Robbepop

Implements #1136

Co-authored-by: Robin Freyler <robin.freyler@gmail.com>
2019-04-13 15:25:17 +00:00
Robin Freyler
6aae0cf7fa
replace usages of algo::generate with iter::successors from std 2019-04-13 16:43:49 +02:00