Commit Graph

2109 Commits

Author SHA1 Message Date
kjeremy
d0efa77e0e Update hover message since we do support globs 2019-02-28 14:48:21 -05:00
Ville Penttinen
da26820ebd Enable markup for hover on expressions which resolve using type_of
This adds highlighting when hovering over items which are resolved using
`type_of`.
2019-02-28 09:33:06 +02:00
bors[bot]
84e47113e0 Merge #906
906: Add support for goto definition and hover for struct fields r=matklad a=vipentti

This works partially towards fixing #512

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-27 15:59:56 +00:00
Ville Penttinen
c879f43186 Enable hover support for NamedFieldDefs
Additionally add type ascription for const and statics as well.
2019-02-27 17:52:37 +02:00
Ville Penttinen
bb4521be1c Allow goto-definition to work for named fields in struct initializer
Now goto definition should work when done on a named field in a struct
initializer.
2019-02-27 17:51:59 +02:00
kjeremy
7463f5debb Fix the build 2019-02-27 09:35:04 -05:00
bors[bot]
2e2a6dd2fb Merge #900
900: Add new trait ast::TypeAscriptionOwner r=vipentti a=vipentti

This trait should be implemented for nodes which have an ascribed type,
e.g. thing : Type. Such as let, const, static, param, named struct fields.

In addition, we update some places where previously we used node + node.type_ref() with `TypeAscriptionOwner` in the trait bounds.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-27 12:18:55 +00:00
Ville Penttinen
d3ce69aee3 Remove TypeRef from item opts which implement TypeAscriptionOwner 2019-02-27 14:08:09 +02:00
bors[bot]
1927eb088a Merge #901
901: Add basic support for showing fn signature when hovering r=matklad a=vipentti

This adds basic support for displaying function signature when hovering over a usage of a function. 

Additionally refactored `hover` to return `HoverResult` to ease with testing and in general to be more robust.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-27 11:50:38 +00:00
Ville Penttinen
6eb45c1c2b Remove RawResponse::empty() 2019-02-27 12:57:59 +02:00
Ville Penttinen
33cebe1724 Work around for issue in vscode reporting a failure in request
vscode would report "A request has failed" when it got "Content modified"
message and this would cause a pop-up to appear. This works around the issue by
returning an "empty" response that vscode can ignore.
2019-02-27 12:49:04 +02:00
Ville Penttinen
e3525527e3 Add support for hovering over the name of an item 2019-02-27 09:49:22 +02:00
Ville Penttinen
79114c67b1 Replace visit_fn with crate::completion::function_label 2019-02-26 21:30:46 +02:00
Dale Wijnand
ffca2c1fe4
Fix a typo 2019-02-26 17:59:32 +00:00
Ville Penttinen
6f5fd6c9de Add new type HoverResult to contain the results of hovering
This makes testing hovers easier as well as allows us to do more things with the
results if needed.
2019-02-26 19:30:17 +02:00
Ville Penttinen
3ec2584148 Add support for showing fn signature when hovering 2019-02-26 18:55:08 +02:00
Ville Penttinen
52054e1140 Use TypeAscriptionOwner
This replaces places where we would use node + node.type_ref() with things that
have an ascribed type, with using the TypeAscriptionOwner as the trait bound so
we can simply pass the node.
2019-02-26 11:47:13 +02:00
Ville Penttinen
6eb070d661 Add new trait TypeAscriptionOwner
This trait should be implemented for nodes which have an ascribed type,
e.g. thing : Type. Such as let, const, static, param, named struct fields.
2019-02-26 11:35:57 +02:00
bors[bot]
7c9acf2f83 Merge #897
897: Add basic const/static type inference r=flodiebold a=vipentti

This adds basic const/static type inference discussed in #887.

Currently the inference does not work for const/static declared inside a block. In addition the inference does not work inside the bodies of const/static.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-25 12:03:57 +00:00
Aleksey Kladov
4f67df9042 kill accidently commited file 2019-02-25 15:02:12 +03:00
Aleksey Kladov
78f10fcdc4 rename type to type_alias in the AST as well 2019-02-25 13:49:32 +03:00
Ville Penttinen
cff9a7dfad Move ConstSignature creation to a single method 2019-02-25 10:55:39 +02:00
Ville Penttinen
29f93a7906 Add static type inference 2019-02-25 10:55:23 +02:00
Ville Penttinen
18b0bd9bff Add const type inference 2019-02-25 10:51:46 +02:00
Aleksey Kladov
330ce2e26b complete patterns 2019-02-24 23:50:02 +03:00
Florian Diebold
bd8ed644e4 Rename Type => TypeAlias 2019-02-24 21:36:49 +01:00
Florian Diebold
c3c0979561 Add test for recursive type aliases 2019-02-24 20:54:04 +01:00
Florian Diebold
5d72b96988 Implement support for type aliases 2019-02-24 20:54:04 +01:00
Aleksey Kladov
d5f6a5f5e2 move testing functions 2019-02-24 21:54:13 +03:00
Aleksey Kladov
98510ec5d3 move the rest of presentation to presentation 2019-02-24 21:46:04 +03:00
Aleksey Kladov
b7a7872910 move more code to presentation 2019-02-24 21:34:38 +03:00
Aleksey Kladov
a650a93bf5 move res completion to presentation 2019-02-24 21:21:31 +03:00
Aleksey Kladov
2369af8c82 simplify 2019-02-24 20:59:12 +03:00
Aleksey Kladov
5887c0e574 move enum-variants to presentation 2019-02-24 20:56:53 +03:00
Aleksey Kladov
9af525dbd6 simplify 2019-02-24 20:49:55 +03:00
Aleksey Kladov
3c7c5a7354 move presentaion completion to presentation 2019-02-24 19:37:22 +03:00
Aleksey Kladov
b04cadc02c move function rendering to presentation 2019-02-24 19:34:27 +03:00
Aleksey Kladov
d0a261468e introduce completion presentation
This module should remove completion rendering boilerplate from the
"brains" of completion engine.
2019-02-24 18:51:38 +03:00
bors[bot]
67528c4b39 Merge #891
891: Field completion r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-24 14:39:38 +00:00
Aleksey Kladov
6285fcc39b complete fields in struct literals 2019-02-24 17:39:08 +03:00
Florian Diebold
c71740e956 Clean up imports a bit 2019-02-24 15:17:20 +01:00
Aleksey Kladov
65a2be4953 complete struct literals 2019-02-24 17:01:56 +03:00
Aleksey Kladov
666303faf3 support upcastig in AST enum 2019-02-24 16:57:05 +03:00
Aleksey Kladov
c110e72a11 add marks to assists 2019-02-24 15:46:06 +03:00
Aleksey Kladov
b3cc7c057d dont show introduce variable everywhere 2019-02-24 14:18:10 +03:00
Aleksey Kladov
ef442b8682 Assign IDs to assists 2019-02-24 14:00:00 +03:00
bors[bot]
f6f160391d Merge #885
885: Parse token trees directy r=matklad a=matklad

This takes advantage of the recent macro refactoring to directly parse token stream into a syntax tree.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-24 10:15:43 +00:00
Aleksey Kladov
81bca78349 rename 2019-02-24 13:14:14 +03: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
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
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]
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
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
kjeremy
56f48ac42a Update lsp-types and backtrace 2019-02-21 10:07:14 -05:00
Aleksey Kladov
4fe07a2b61 add API guide to ra_syntax 2019-02-21 17:35:45 +03: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
Aleksey Kladov
6225e1ab70 Ignore lockfile in fuzz
It's too much trouble maintaining it
2019-02-21 15:44:38 +03: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
Aleksey Kladov
46179230a0 fix the test 2019-02-21 13:45:10 +03:00
Aleksey Kladov
c47f9e2d37 fix compilation 2019-02-21 13:37:32 +03:00
Aleksey Kladov
d334b5a1db move parser to a separate crate 2019-02-21 13:27:45 +03:00
Ville Penttinen
816971ebc9 Implement basic support for Associated Methods and Constants
This is done in `infer_path_expr`. When `Resolver::resolve_path` returns
`PartiallyResolved`, we use the returned `Resolution` together with the given
`segment_index` to check if we can find something matching the segment at
segment_index in the impls for that particular type.
2019-02-21 12:25:55 +02:00
Aleksey Kladov
cd0d2866fc make grammar independent of syntax tree 2019-02-21 12:12:04 +03:00
Aleksey Kladov
1b2e70df99 minor 2019-02-21 12:05:52 +03:00
Aleksey Kladov
79ce0fa8d7 move whitespace handling to tree builder 2019-02-21 12:03:42 +03:00
Florian Diebold
72712b8a42 Fix handling of generics in tuple variants and refactor a bit
Also make them display a tiny bit nicer.

Fixes #860.
2019-02-20 22:48:55 +01:00
Aleksey Kladov
882c47f187 move syntax error to parser 2019-02-20 23:17:07 +03:00
Aleksey Kladov
61992dc1cd simplify 2019-02-20 23:05:59 +03:00
Aleksey Kladov
4c1f9b8d4e remove TokenPos 2019-02-20 23:02:24 +03:00
Aleksey Kladov
cce23fddba flattern module structure 2019-02-20 22:52:32 +03:00
Aleksey Kladov
2acb21e8f7 merge parse_impl and parser_api 2019-02-20 22:44:06 +03:00
Aleksey Kladov
e72ad0a2fa fix off by one error 2019-02-20 22:27:49 +03:00
Aleksey Kladov
2b5e336ce7 move abstract traits to top 2019-02-20 22:19:12 +03:00
Aleksey Kladov
d2bce118ae switch to dynamic dispatch for TokenSource
Benchmarks show no difference. This is probably because we are
bottlenecked on memory allocations, and we should fix that, but we are
not optimizing for performance just yet.

changes. Lines starting # with '#' will be ignored, and an empty
message aborts the commit. # # On branch token-source # Changes to be
committed: # modified: crates/ra_syntax/src/parsing/parser_api.rs #
modified: crates/ra_syntax/src/parsing/parser_impl.rs #
2019-02-20 22:02:03 +03:00
Aleksey Kladov
0c81b9deee route parsing via TokenSource trait 2019-02-20 21:50:07 +03:00
Aleksey Kladov
3517c175ac rename Sink -> TreeSink 2019-02-20 21:08:59 +03:00
Aleksey Kladov
86a67dce25 fix tests 2019-02-20 16:48:06 +03:00
Aleksey Kladov
45fc91cc47 rearrange modules in a suggestd reading order 2019-02-20 16:24:39 +03:00
Aleksey Kladov
a4a1e08ab8 flatten modules 2019-02-20 16:16:14 +03:00
Aleksey Kladov
9f6883fbf1 move reparsers to grammar 2019-02-20 16:02:06 +03:00
Aleksey Kladov
5a6eda528c tighten visibility 2019-02-20 15:57:26 +03:00
Aleksey Kladov
5222b8aba3 move all parsing related bits to a separate module 2019-02-20 15:47:32 +03:00
Aleksey Kladov
9d0cda4bc8 slightly better name 2019-02-20 15:03:31 +03:00
Aleksey Kladov
df6efe62c5 make stuff private 2019-02-20 14:53:19 +03:00
Aleksey Kladov
9738fb48a6 remove ignored macro tests
we need to significantly reengineer macros, so the tests as they exist
are useless
2019-02-19 20:06:53 +03:00
Aleksey Kladov
a6897a837c remove local-vfs 2019-02-18 16:43:48 +03:00
Aleksey Kladov
1bdd935e91 switch to crates.io vfs 2019-02-18 16:43:16 +03:00
Aleksey Kladov
d93097a493 better comments 2019-02-18 16:20:12 +03:00
Aleksey Kladov
def7bc0ec5 drop dependency on thread_worker 2019-02-18 15:30:58 +03:00
Aleksey Kladov
9da3705191 drop unused extern crate 2019-02-18 14:39:18 +03:00
Aleksey Kladov
c5a65466e2 hide TaskResult from the public API 2019-02-18 14:29:54 +03:00
Aleksey Kladov
062aa97235 move public API to top of the file 2019-02-18 14:29:39 +03:00
Aleksey Kladov
74288ae272 remove depedency on ra_arena 2019-02-18 14:20:54 +03:00
Aleksey Kladov
4c154c289e remove arena from Roots
we want to move ra_vfs to a new repo, so having fewer deps is useful.
Arena is a thin layer of sugar on top of Vec anyway.
2019-02-18 14:13:13 +03:00
Aleksey Kladov
d151b2a655 remove useless Arc 2019-02-18 14:05:08 +03:00
Aleksey Kladov
5823d3d042 drop unused deps 2019-02-18 12:46:08 +03:00
bors[bot]
16c7ebbb27 Merge #854
854: more compact edits in insta r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-18 09:26:24 +00:00
Aleksey Kladov
a92db7c848 more compact edits in insta 2019-02-18 12:24:25 +03:00
Aleksey Kladov
92aa0f9c87 Don't use additional_text_edits API internally 2019-02-18 12:24:20 +03:00
bors[bot]
564ab84b78 Merge #852
852: Handle != r=flodiebold a=matklad

r? @flodiebold

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-18 09:13:51 +00:00
Aleksey Kladov
79f35cc699 More orthogonal method naming 2019-02-18 12:07:47 +03:00
Aleksey Kladov
864fd5ee25 More compact debug representation for completion 2019-02-18 10:31:00 +03:00
Aleksey Kladov
4e8a3f565b handle != operator 2019-02-18 10:09:44 +03:00
bors[bot]
8b95c0e0c2 Merge #850
850: Handle tuple structs / enum variants properly in type inference r=matklad a=flodiebold



Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-02-18 06:22:07 +00:00
Ville Penttinen
58d14bcaf7 Enable parsing attributes for generic lifetimes and type parameters 2019-02-17 23:32:10 +02:00
Florian Diebold
b82db68400 Handle tuple structs / enum variants properly in type inference 2019-02-17 20:53:13 +01:00
bors[bot]
a725dd4f7a Merge #849
849: Don't render `()` in calls to assoc functions r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-17 18:47:09 +00:00
bors[bot]
646b53ace3 Merge #846
846: WIP: Enable parsing of attributes inside a match block r=matklad a=vipentti

We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.

Instead we run validation on `MatchArmList` to allow better reporting of errors.

This fixes #845 and works towards #759 



Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-02-17 18:39:26 +00:00
Ville Penttinen
bb25958705 Remove match_armlist validator 2019-02-17 20:32:10 +02:00
Aleksey Kladov
e503ffe9ff Don't render () in calls to assoc functions 2019-02-17 21:30:46 +03:00
bors[bot]
3dcde0b2ab Merge #847
847: Refactor vfs r=matklad a=matklad

Some slight refctorings of VFS, in preparation for moving it to a separate repo

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-02-17 18:19:27 +00:00
Aleksey Kladov
aea986001f marginally better names 2019-02-17 21:10:40 +03:00
Aleksey Kladov
bb393e2d11 fix-tests 2019-02-17 21:05:33 +03:00
Aleksey Kladov
143e5b628e remove overlay removes overlay 2019-02-17 20:58:28 +03:00
Aleksey Kladov
e8bc29f122 simplify overlay handling 2019-02-17 20:54:11 +03:00
Ville Penttinen
96e3ac389f Parse only outer_attributes for match arms for now 2019-02-17 19:48:08 +02:00
Aleksey Kladov
b719a6cc07 simplify 2019-02-17 20:34:01 +03:00
Ville Penttinen
1c97c1ac11 Enable parsing of attributes inside a match block
We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.

Instead we run validation on `MatchArmList` to allow better reporting of errors.
2019-02-17 19:26:57 +02:00
Aleksey Kladov
7187fc5c2a rename method 2019-02-17 20:25:52 +03:00
Aleksey Kladov
e95fb7c9f9 remove duplicated method 2019-02-17 20:25:35 +03:00
Aleksey Kladov
162dea51bf hide root config 2019-02-17 20:22:46 +03:00
Aleksey Kladov
6b5d90972a move roots to a module 2019-02-17 19:46:55 +03:00