Commit graph

2974 commits

Author SHA1 Message Date
Aleksey Kladov
81bca78349 rename 2019-02-24 13:14:14 +03:00
bors[bot]
c5e74cebdc Merge #886
886: Associated method generics r=matklad a=flodiebold

Refactor associated method resolution a bit and make it work with generics.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-24 06:45:08 +00:00
Florian Diebold
82fe7b77a3 Refactor associated method resolution a bit and make it work with generics 2019-02-23 23:00:02 +01:00
Aleksey Kladov
8cf156d85b Add a test for macro parsing 2019-02-23 17:51:23 +03:00
bors[bot]
1eef9fbefe Merge #884
884: Split ty.rs into several modules r=matklad a=flodiebold

It was just getting too big. We now have:

 - ty: the `Ty` enum and helpers
 - ty::infer: actual type inference
 - ty::lower: lowering from HIR to `Ty`
 - ty::op: helpers for binary operations, currently

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-23 14:48:54 +00:00
Florian Diebold
dcfb4ee702 Split ty.rs into several modules
It was just getting too big. We now have:

 - ty: the `Ty` enum and helpers
 - ty::infer: actual type inference
 - ty::lower: lowering from HIR to `Ty`
 - ty::op: helpers for binary operations, currently
2019-02-23 15:36:38 +01:00
Aleksey Kladov
8eac450f41 implement tt -> ast 2019-02-23 17:21:56 +03:00
Aleksey Kladov
83d6be6cec keep-text 2019-02-23 16:55:18 +03:00
Aleksey Kladov
71b8a874e7 flatten tt 2019-02-23 16:55:18 +03:00
Aleksey Kladov
10deefd371 token source scaffold 2019-02-23 16:55:18 +03:00
Aleksey Kladov
e9cafafbc2 add dependency on the parser 2019-02-23 16:55:18 +03:00
Aleksey Kladov
60373aa504 add interface 2019-02-23 16:55:18 +03:00
Aleksey Kladov
f078f7adc8 introduce tree builder 2019-02-23 16:55:01 +03:00
bors[bot]
460ceb4cf2 Merge #883
883: Fix fill_match_arms not working with references r=matklad a=vipentti

This fixes #881 

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-23 13:16:41 +00:00
Ville Penttinen
14cff98cb0 Simplify test_fill_match_arm_refs test cases 2019-02-23 15:13:17 +02:00
Aleksey Kladov
0c1cb98182 rename 2019-02-23 16:07:29 +03:00
Ville Penttinen
9dafad2402 Fix fill_match_arms not working with references 2019-02-23 15:05:26 +02:00
bors[bot]
98caeac106 Merge #882
882: emacs-lsp: Add runnables support r=matklad a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-23 12:54:36 +00:00
Florian Diebold
da8976d865 emacs-lsp: Add runnables support 2019-02-23 13:42:20 +01:00
bors[bot]
e5fb33a946 Merge #879
879: Fixes to goto definition r=vipentti a=vipentti

Previously goto definition would fail when the cursor was over the name of the definition. Now we should properly resolve to a `NavigationTarget` when on top of the name of a definition.

In addition this adds `name_range` field to `FileSymbol`, this further fixes goto_definition and symbol based navigation by allowing the `NavigationTarget` to actually have a `focus_range`, meaning instead of focusing on the start of the `full_range`, we can have the cursor focus on the name.

e.g. goto definition
```rust
fn bar() {
    fn foo() { }
  
   foo<|>();
}
```

Previously this would put the cursor at the start of the FN_DEF:
```rust
fn bar() {
   <|>fn foo() { }
  
   foo();
}
```
Now when using the symbol based resolving, we'll have a proper focus range and instead put the cursor at the start of the name.

```rust
fn bar() {
   fn <|>foo() { }
  
   foo();
}
```

This fixes #877 but doesn't contain the refactoring of the return type for `goto_definition`

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-23 12:17:53 +00:00
Ville Penttinen
40e6cb196b Remove unnecessary to_nav_target 2019-02-23 14:08:57 +02:00
bors[bot]
38add103c3 Merge #880
880: Fix resolution of associated method calls across crates r=matklad a=flodiebold

I think it'll be better to make the path resolution the number of unresolved
segments, not the first unresolved index; then this error could simply not have
happened. But I'll do that separately.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-23 12:02:06 +00:00
Florian Diebold
6a04d1f292 Fix resolution of associated method calls across crates
I think it'll be better to make the path resolution the number of unresolved
segments, not the first unresolved index; then this error could simply not have
happened. But I'll do that separately.
2019-02-23 12:37:29 +01:00
Ville Penttinen
c565ec2d6e Add name_range field to FileSymbol
This contains the syntax range of the name itself, allowing NavigationTarget to
properly set the focus_range. This should make it so that when using symbol
based navigation, we should always focus on the name, instead of the full range.
2019-02-23 13:05:45 +02:00
Ville Penttinen
7046b16275 Fix NavigationTarget debug_render container_name output 2019-02-23 12:53:53 +02:00
Ville Penttinen
2a3abe2ce3 Fix goto def not working when cursor was over the name of a def
We now allow goto_definition to return the named NavigationTarget if the cursor
is on the name of a definition.
2019-02-23 11:02:42 +02:00
bors[bot]
3d8a0982a1 Merge #866
866: Implement basic support for Associated Methods r=flodiebold a=vipentti

This is my attempt at learning to understand how the type inference works by adding basic support for associated methods. Currently it does not resolve associated types or constants. 

The basic idea is that `Resolver::resolve_path` returns a new `PathResult` type, which has two variants, `FullyResolved` and `PartiallyResolved`, fully resolved matches the previous behavior, where as `PartiallyResolved` contains the `PerNs<Resolution` in addition to a `segment_index` which contains the index of the segment which we failed to resolve. This index can then be used to continue inference in `infer_path_expr` using the `Type` we managed to resolve.

This changes some of the previous apis, so looking for feedback and suggestions.

This should enable fixing #832

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-22 19:58:22 +00:00
Ville Penttinen
247d1c17b3 Change resolve_path to return the fully resolved path or PerNs::none
This also adds new pub(crate) resolve_path_segments which returns the
PathResult, which may or may not be fully resolved. PathResult is also now
pub(crate) since it is an implementation detail.
2019-02-22 10:15:23 +02:00
Ville Penttinen
39679d499f Ignore failing test for now 2019-02-22 00:27:22 +02:00
Ville Penttinen
a34eb98a78 Make nameres::ResolvePathResult private and refactor 2019-02-22 00:11:21 +02:00
Ville Penttinen
2e7bc905be Remove Const inference for now, refactor PathResult 2019-02-21 23:57:07 +02:00
bors[bot]
bb665a7062 Merge #864
864: Fix handling of generics in tuple variants and refactor a bit r=matklad a=flodiebold

(The problem was that we created separate substitutions for the return value, so we lost the connection between the type arguments in the constructor call and the type arguments of the result.)

Also make them display a tiny bit nicer.

Fixes #860.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2019-02-21 20:47:50 +00:00
Florian Diebold
db9a5a9ac0 Add an assert (and fix the other) 2019-02-21 21:25:27 +01:00
bors[bot]
5100aeac42 Merge #876
876: Fix join_lines not adding a comma after join_single_expr_block with match arm r=matklad a=vipentti

Fixes #868 

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-21 16:55:26 +00:00
Ville Penttinen
82173c8de4 Move non_trivia_sibling to ra_syntax::algo 2019-02-21 18:49:03 +02:00
Ville Penttinen
3c22c64725 Simplify adding a comma after match arm 2019-02-21 18:26:27 +02:00
Ville Penttinen
40add5de9a Fix join_lines not adding a comma after join_single_expr_block in match arm
We will also remove optional whitespace between the expression and the comma.

e.g.

```rust
fn foo() {
    let x = (<|>{
       4
    }   ,); // NOTE: whitespace
}
```

becomes

```rust
fn foo() {
    let x = (<|>4,);
}
```
2019-02-21 17:55:14 +02:00
bors[bot]
55da8e786d Merge #874
874: Update lsp-types and backtrace r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-02-21 15:28:16 +00:00
kjeremy
56f48ac42a Update lsp-types and backtrace 2019-02-21 10:07:14 -05:00
bors[bot]
368bc56ac1 Merge #873
873: add API guide to ra_syntax r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-21 14:36:08 +00:00
Aleksey Kladov
4fe07a2b61 add API guide to ra_syntax 2019-02-21 17:35:45 +03:00
bors[bot]
5cacdfcb3c Merge #872
872: simplify trait bounds r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-21 13:13:45 +00:00
Aleksey Kladov
7060a39d5c simplify trait bounds 2019-02-21 16:12:15 +03:00
Aleksey Kladov
b51b71bf25 rearrange methods 2019-02-21 16:04:03 +03:00
Aleksey Kladov
f7f99af0a6 kill utils module 2019-02-21 15:57:40 +03:00
bors[bot]
9be7426aae Merge #871
871: Ignore lockfile in fuzz r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-21 12:45:31 +00:00
Aleksey Kladov
6225e1ab70 Ignore lockfile in fuzz
It's too much trouble maintaining it
2019-02-21 15:44:38 +03:00
bors[bot]
782cb43c14 Merge #870
870: docs r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-21 12:25:32 +00:00
Aleksey Kladov
412ac63ff5 docs 2019-02-21 15:24:42 +03:00
Aleksey Kladov
2fa2805887 add failing test 2019-02-21 14:06:21 +03:00