Commit graph

78 commits

Author SHA1 Message Date
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
Robin Freyler
6aae0cf7fa
replace usages of algo::generate with iter::successors from std 2019-04-13 16:43:49 +02:00
Aleksey Kladov
f4a94e74bc fold ScopeWithSyntax into SourceAnalyzer 2019-04-13 10:49:01 +03:00
Aleksey Kladov
3aae223d93 hide some scopes 2019-04-13 09:31:03 +03:00
Aleksey Kladov
0fd93bc14a use really correct resolver for expressions 2019-04-13 00:44:47 +03:00
Aleksey Kladov
20013de2ab fix typo 2019-04-11 17:15:20 +03:00
Aleksey Kladov
b6809b6695 rename 2019-04-11 16:29:33 +03:00
Aleksey Kladov
10d66d63d7 introduce SourceAnalyzer 2019-04-11 16:29:33 +03:00
Marco Groppo
c5f8f3b1f4 Stylistic changes. Updated features.md with the new assists. 2019-04-09 21:12:54 +02:00
Marco Groppo
a4ba3841b4 Add explicit type assist. 2019-04-08 19:56:37 +02:00
Aleksey Kladov
f3a82c372c remove flavor 2019-04-02 12:25:24 +03:00
Aleksey Kladov
ae282d8da6 add ast::tokens 2019-04-02 10:23:29 +03:00
gfreezy
4ca51cfbcf intelligently add parens when inlining local varaibles 2019-04-01 22:53:47 +08:00
Aleksey Kladov
9e213385c9 switch to new rowan 2019-04-01 12:06:24 +03:00
Marco Groppo
7b81c088f7 Flip any binary expression except assignments. 2019-03-26 23:12:46 +01:00
Marco Groppo
12b5d4f795 Assist to flip (some) binary expressions.
This assist can flip the following operators: ==, !=, >, >=, <, <=.
2019-03-25 23:53:57 +01:00
bors[bot]
d88a96bd05 Merge #1037
1037: inline immutable local varialbe r=matklad a=gfreezy

resolved #1033 

Co-authored-by: gfreezy <gfreezy@gmail.com>
2019-03-25 14:11:18 +00:00
gfreezy
61315e4a89 use | instead of multiple match arms 2019-03-25 20:57:43 +08:00
bors[bot]
965363db15 Merge #1036
1036: Assist to flip equality (==) and negated equality (!=) operands. r=matklad a=marcogroppo

This PR adds an assist to flip the equality operands.

I hope this is the right way to do this (I'm a newbie...)

Fixes #1023.


Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-03-25 07:04:47 +00:00
gfreezy
fd1585a071 inline immutable local varialbe 2019-03-25 10:18:20 +08:00
Marco Groppo
67055c47da Target only the actual operator.
Renamed `BinExpr::op()` and `PrefixExpr::op()` to `op_kind`.
Now `op()` returns the `SyntaxNode`.
2019-03-24 22:21:22 +01:00
Marco Groppo
acac7415a6 Minor formatting changes. 2019-03-24 15:12:39 +01:00
Marco Groppo
481d3f56cf Assist to flip equality (==) and negative equality (!=) operands. 2019-03-24 14:42:11 +01:00
gfreezy
02383b91d5 Add assist for adding default methods 2019-03-23 23:13:07 +08:00
gfreezy
d99ae9ba56 Add impl members assist shold not copy docstrings, attrs and default methods. 2019-03-23 22:49:20 +08:00
Florian Diebold
8a5fbf4713 Remove the old variants replaced by Ty::Apply 2019-03-21 22:17:00 +01:00
Caio
99c45609ef Improve performance and ordering 2019-03-20 20:31:14 -03:00
Caio
ba6863754e Fill partial fields 2019-03-20 16:52:29 -03:00
bors[bot]
7c117567ab Merge #989
989: Implement naive version of fill_struct_fields assist r=matklad a=yanchith

Fixes #964

This implements the `fill_struct_fields` assist. Currently only works for named struct fields, but not for tuple structs, because we seem to be missing a `TupleStructLit` (akin to `StructLit`, but for tuple structs). I am happy to implement `TupleStructLit` parsing given some guidance (provided it's really missing) and make the assist work for tuple structs as well. Could do so either in this PR, or another one 🙂 

Sorry if I missed something important, this is my first PR for Rust Analyzer.

Btw is there any way to run the assists in emacs?

UPDATE: I just realized that parsing `TupleStructLit` would be quite difficult as it it really similar, if not identical to a function call...

Co-authored-by: yanchith <yanchi.toth@gmail.com>
2019-03-18 08:24:18 +00:00
yanchith
ca262fbab8 Only replace NamedFieldList and add test for preserving Self 2019-03-18 09:03:10 +01:00
yanchith
8d47e004b8 Remove unachievable TODO 2019-03-18 08:19:51 +01:00
yanchith
907f7307af Implement naive version of fill_struct_fields assist 2019-03-17 19:48:25 +01:00
Igor Matuszewski
30a226c725 Move the primary assist fn to the top of the file 2019-03-16 23:24:17 +01:00
Igor Matuszewski
5b0b87f8de Provide assist when cursor is immediately outside impl item block 2019-03-16 23:19:14 +01:00
Igor Matuszewski
2f36f47dab Do a cleanup/legibility pass 2019-03-16 22:41:13 +01:00
Igor Matuszewski
1df81f3d65 Take into account parent indent when filling trait members 2019-03-16 22:41:13 +01:00
Igor Matuszewski
b3742873d9 Simplify trait resolution fragment 2019-03-16 22:41:13 +01:00
Igor Matuszewski
0e47c371fd Ignore unnamed trait fns and add more tests 2019-03-16 22:41:13 +01:00
Igor Matuszewski
406343492c Simplify calculation of missing functions
Asymptotically computing a set difference is faster but in the average
case we won't have more than ~10 functions. Also prefer not using hash
sets as these may yield nondeterministic results.
2019-03-16 22:41:13 +01:00
Igor Matuszewski
713975b1c1 Properly support the case when the cursor is inside an empty block or outside 2019-03-16 22:41:13 +01:00
Igor Matuszewski
38eece97ec Redo indent calculation when adding missing impl members 2019-03-16 22:41:13 +01:00
Igor Matuszewski
2f616eea9c Implement a simple working assist 2019-03-16 22:41:13 +01:00
Igor Matuszewski
1c07c5ccf9 Calculate missing functions from impl body 2019-03-16 22:41:13 +01:00
Igor Matuszewski
fc060573f9 Add 'add_missing_impl_members' assist stub 2019-03-16 22:41:13 +01:00
Aleksey Kladov
03b2ab8e1f rename syntax_mapping as well 2019-03-02 16:56:09 +03:00
Aleksey Kladov
eaf1df26e9 rename syntax-mapping -> source-map 2019-03-02 15:40:40 +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
Ville Penttinen
14cff98cb0 Simplify test_fill_match_arm_refs test cases 2019-02-23 15:13:17 +02:00