Commit Graph

3605 Commits

Author SHA1 Message Date
bors[bot]
cc284dad30 Merge #1122
1122: Add explicit type assist. r=matklad a=marcogroppo

This assist can be used to specify the explicit type in let statements. For example `let num = 1;` becomes `let num: i32 = 1;`. 

The assist is applicable only if the inferred type is fully known.


Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-04-09 19:16:28 +00:00
Marco Groppo
c5f8f3b1f4 Stylistic changes. Updated features.md with the new assists. 2019-04-09 21:12:54 +02:00
bors[bot]
2fc2d4373b Merge #1110
1110: Introduce display module and implement new FunctionSignature for CallInfo's r=matklad a=vipentti

This introduces a new module `display` in `ra_ide_api` that contains UI-related things, in addition this refactors CallInfo's function signatures into a new `FunctionSignature` type, which implements `Display` and can be converted into `lsp_types::SignatureInformation` in the `conv` layer. 

Currently only `CallInfo` uses the `FunctionSignature` directly, but `function_label` now uses the same signature and returns it as a string, using the `Display` implementation.

This also fixes #960 

I think this similar structure could be applied to other UI-displayable items, so instead of the `ra_ide_api` returning `Strings` we could return some intermediate structures that can be converted into a UI-displayable `String` easily, but that could also provide some additional information.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-04-09 17:55:44 +00:00
Ville Penttinen
45a2b92524 Fix doc comment 2019-04-09 16:08:24 +03:00
Ville Penttinen
07f0069f34 Move display related things from hover to display 2019-04-09 14:45:05 +03:00
Ville Penttinen
fead60aa27 Move FunctionSignature to display/function_signature 2019-04-09 14:45:05 +03:00
Ville Penttinen
bd6ddfcdde Make display modules private 2019-04-09 14:45:05 +03:00
Ville Penttinen
7821c56be7 Move structure to display/structure 2019-04-09 14:45:05 +03:00
Ville Penttinen
027d4d229d Move navigation_target to display/navigation_target 2019-04-09 14:45:05 +03:00
Ville Penttinen
946b5789d1 Move completion label functions to display 2019-04-09 14:45:05 +03:00
Ville Penttinen
dfaebd76ab Add FunctionSignature::from_hir 2019-04-09 14:45:05 +03:00
Ville Penttinen
2fe075f56e Normalize line-endings in display.rs
This changes from CRLF to LF
2019-04-09 14:45:05 +03:00
Ville Penttinen
f4aa15c16b Move FunctionSignature creation to display 2019-04-09 14:45:05 +03:00
Ville Penttinen
ed65e2619a Add no parameter test to call_info 2019-04-09 14:45:05 +03:00
Ville Penttinen
7ba22f1c19 Move FunctionSignature to display, remove write_joined
write_joined is replaced with `join_to_string::join` which provides the
necessary functionality.
2019-04-09 14:45:05 +03:00
Ville Penttinen
84fde47d00 Move test specific things 2019-04-09 14:45:04 +03:00
Ville Penttinen
751b454442 Update test snapshots 2019-04-09 14:45:04 +03:00
Ville Penttinen
0e49abb7fb Refactor CallInfo function signatures to new FunctionSignature type
This is used by CallInfo to create a pretty printed function signature that can
be used with completions and other places as well.
2019-04-09 14:45:04 +03:00
bors[bot]
5f700179fc Merge #1123
1123: migrate to untyped rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-09 07:29:06 +00:00
Aleksey Kladov
faf526e021 migrate to untyped rowan 2019-04-09 10:26:51 +03:00
Marco Groppo
a4ba3841b4 Add explicit type assist. 2019-04-08 19:56:37 +02:00
bors[bot]
ac6ab07587 Merge #1105
1105: [WIP] Implement ra_mbe meta variables support  r=matklad a=edwin0cheng

This PR implements the following meta variable support in `ra_mba` crate (issue  #720):

- [x] `path`
- [ ] `expr`
- [ ] `ty`
- [ ]  `pat`
- [ ] `stmt`
- [ ]  `block`
- [ ]  `meta`
- [ ] `item`

*Implementation Details*

In the macro expanding lhs phase, if we see a meta variable type, we try to create a `tt:TokenTree` from the remaining input. And then we use a special set of `ra_parser` to parse it to `SyntaxNode`. 


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-08 14:18:57 +00:00
bors[bot]
1ca7a744eb Merge #1121
1121: Avoid two-phase borrow conflict r=matklad a=lnicola

See https://github.com/rust-lang/rust/issues/59159.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2019-04-08 14:11:48 +00:00
Laurențiu Nicola
61c09edb4a Avoid two-phase borrow conflict 2019-04-08 16:47:28 +03:00
Edwin Cheng
8ed7104578 Refactoring and add some docs 2019-04-08 20:32:21 +08:00
Edwin Cheng
c785c7312d Fixed infintite loop bug 2019-04-08 19:21:07 +08:00
Edwin Cheng
184e9ea230 Fixed empty node bug 2019-04-08 18:21:48 +08:00
Edwin Cheng
2697ecaa64 Use SubtreeWalker instread of flatten TtToken 2019-04-08 15:58:02 +08:00
Edwin Cheng
a7254201df Combine all tokensource to one and refactoring 2019-04-08 00:12:07 +08:00
Edwin Cheng
7f1e93a3c9 Refactoring subtree_source 2019-04-07 21:42:53 +08:00
bors[bot]
1e2178eb8e Merge #1103
1103: Array inference r=flodiebold a=Lapz

Fixes the final item in #394. The only problem is that infering the repeat cause some types to be infered twices.
i.e 
```rust
fn test() {
    let y = unknown;
    [y, &y];
}
```

results in the following diff:

```diff
[11; 48) '{     ...&y]; }': ()
[21; 22) 'y': &{unknown}
[25; 32) 'unknown': &{unknown}
-[38; 45) '[y, &y]': [&&{unknown}]
+[38; 45) '[y, &y]': [&&{unknown};usize]
[39; 40) 'y': &{unknown}
+[39; 40) 'y': &{unknown}
[42; 44) '&y': &&{unknown}
[43; 44) 'y': &{unknown}
```

Should the code produce two inference results for 'y' and if not could any tell me what needs to change.

Co-authored-by: Lenard Pratt <l3np27@gmail.com>
2019-04-07 13:22:18 +00:00
Lenard Pratt
b27fa33a9f updated snapshots 2019-04-07 13:23:18 +01:00
Lenard Pratt
e175921932 Added ArrayExprKind,
changed the  display for fixed array types,
Added Array Enum to ra_hir/expr
2019-04-07 13:23:14 +01:00
Lenard Pratt
2d73c909fe Added inference of array length 2019-04-07 13:23:12 +01:00
bors[bot]
36f5d99756 Merge #1119
1119: Add warning when open file outside workspace r=matklad a=edwin0cheng

When file is not found in `ra_vfs` but exist, use `LspError` for warning instead of `error_fmt` to bail out error, 

Temporarily fix #967 .

edit: typo

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-07 10:48:49 +00:00
Edwin Cheng
ce3d78335d Remove checking file exists 2019-04-07 18:26:02 +08:00
Edwin Cheng
e92740c28b fix formatting 2019-04-07 12:46:45 +08:00
Edwin Cheng
333feb3869 Add warning when open file outside workspace 2019-04-07 01:20:33 +08:00
Edwin Cheng
aac9dfa464 Add TtCursorTokenSource and TtCursorTokenSink 2019-04-06 20:14:28 +08:00
Edwin Cheng
1d7735fbc6 Add path test and empty eat_path handling 2019-04-06 12:12:32 +08:00
bors[bot]
990e74ba7c Merge #1117
1117: [WIP] Tuple struct index inference r=matklad a=robojumper

The first commit adds a helper struct `ast::FieldKind` to facilitate inference.

The second commit adds a slightly modified test from #1109 while mentioning that there is a problem with how we're handling tuple indexing / floats.

cc #1109 

Co-authored-by: robojumper <robojumper@gmail.com>
2019-04-05 23:24:11 +00:00
robojumper
2caa690ef6 Rudimentarily autocomplete tuple struct field access 2019-04-06 01:10:48 +02:00
robojumper
ca40ca93a5 Parse and infer tuple indices 2019-04-06 01:07:35 +02:00
bors[bot]
9d39b7bc42 Merge #1118
1118: Updated the gitignore r=flodiebold a=Lapz

Updated the gitignore to ignore *.rs.pending-snap

Co-authored-by: Lenard Pratt <l3np27@gmail.com>
2019-04-05 21:20:24 +00:00
Lenard Pratt
5b82ca2fdd Updated the gitignore 2019-04-05 22:06:15 +01:00
bors[bot]
0372eca5b2 Merge #1115
1115: Add .gitattributes for fix Windows Line-ending problem in `generated_grammar_is_fresh` r=matklad a=edwin0cheng

Although https://github.com/rust-analyzer/rust-analyzer/issues/937 is marked as `Closed` . But it should work without setting `core.autocrlf` to `false` by this PR.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-05 17:21:48 +00:00
Edwin Cheng
7ca0a1012a add .gitattributes 2019-04-05 23:31:58 +08:00
bors[bot]
9d795a6784 Merge #1114
1114: Crate updates r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-04-05 15:01:36 +00:00
bors[bot]
a52e86f9a9 Merge #1112
1112: Fix literal support in token tree to ast item list r=matklad a=edwin0cheng

This PR implements following things :

1. Expose `next_token` from `ra_parse`
2. Fix the literal conversion in `token_tree_to_ast_item_list`
3. Add test for the conversion

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-04-05 14:17:07 +00:00
kjeremy
1af7ae506a Update deps 2019-04-05 10:14:02 -04:00