Commit graph

64 commits

Author SHA1 Message Date
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
Ville Penttinen
9dafad2402 Fix fill_match_arms not working with references 2019-02-23 15:05:26 +02:00
Ville Penttinen
82173c8de4 Move non_trivia_sibling to ra_syntax::algo 2019-02-21 18:49:03 +02:00
Andrea Pretto
e8f3c1650a auto_import: fix bug when the common path was shorter than both the current use and target path.
Shorter test names.
2019-02-14 21:58:36 +01:00
Andrea Pretto
6518fb2bf8 auto_import: import in enclosing module instead of file 2019-02-12 21:18:55 +01:00
Andrea Pretto
468e1d4c5e auto_import: more tests and some refactorings 2019-02-12 21:18:42 +01:00
Pascal Hertleif
4fd3613434 Fix some typos 2019-02-12 15:02:57 +01:00
Andrea Pretto
5c9c0d3ae2 ra_assists: assist "providers" can produce multiple assists 2019-02-11 18:07:21 +01:00
Ville Penttinen
710975ecd8 Fix typo in Cargo.toml authors
Fixes typo introduced in #782
2019-02-11 10:20:04 +02:00
Ville Penttinen
ab3d231b1d Update authors field in Cargo.tomls to "rust-analyzer developers"
This closes #777
2019-02-11 08:55:35 +02:00
bors[bot]
b952c270ee Merge #762
762: "Dumb" auto import assist r=matklad a=eulerdisk

This adds a new assist to "add xxx::yyy to the current file" when the cursor is on a PATH. It manages correctly nested imports,`self` keyword and creates new nested imports if necessary. [See the tests]
It doesn't use name resolution so in that sense is 'dumb', but I have plans to do that. That in the future will be useful to auto import trait names in autocompletion for example.

It can easily be extended to provide multiple actions to select in which scope to import. That's another thing I plan to do.

@matklad I copied some indentation code from `ide_light`, I don't know at the moment if/how you want to refactor that code. This assist was meant to be in `ide_light`.

Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-02-10 19:00:36 +00:00
Ville Penttinen
7b9aefc29d Fix introduce var duplicating newlines
This fixes #713.

If the block before the statement we want to use introduce var on, had empty
lines these empty lines would also be added between the let-statement and
the current line where the new variable is used.

This fixes that by trimming excess newlines from the start of the indent chunk
and simply adding a single newline (when the chunk had newlines) between the
let-statement and the current statement. If there were no newlines this
matches the previous behaviour.
2019-02-09 13:52:01 +02:00
Andrea Pretto
1a4faaffd7 auto_import: use ra_fmt 2019-02-09 11:47:23 +01:00
Andrea Pretto
ee9b0c89e6 auto_import: struct variants for ImportAction 2019-02-09 11:30:09 +01:00
Andrea Pretto
1866fb2dda auto_import: remove PathSegmentsMatch 2019-02-09 11:30:09 +01:00