Aleksey Kladov
d847d53e36
Start simplifying editing API
2019-09-26 22:22:08 +03:00
uHOOCCOOHu
2ecb126f5c
Support $crate
in item and expr place.
2019-09-27 02:05:06 +08:00
Aleksey Kladov
1a4b424005
move diff to ra_syntax
2019-09-26 15:56:52 +03:00
Aleksey Kladov
183a38fb50
keep ast creation API simple
2019-09-26 15:29:28 +03:00
Aleksey Kladov
a525e830a6
add new editing API, suitable for modifying several nodes at once
2019-09-25 17:57:12 +03:00
bors[bot]
a452e50e0e
Merge #1911
...
1911: fewer monomorphisations r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-09-25 14:19:46 +00:00
Aleksey Kladov
b7422bd1ab
fewer monomorphisations
2019-09-25 17:19:16 +03:00
Aleksey Kladov
efeae82f52
clean up naming
2019-09-25 15:58:40 +03:00
Aleksey Kladov
32843ae6f7
shorten AstBuilder names
2019-09-25 15:28:26 +03:00
Aleksey Kladov
546f031e4e
minor builder cleanups
2019-09-25 15:26:05 +03:00
Aleksey Kladov
25fca04753
cleaned up record field builder
2019-09-25 15:09:03 +03:00
Aleksey Kladov
69689625ce
move ast builder to a separate file
2019-09-25 14:35:26 +03:00
Aleksey Kladov
f32081fa18
move assists to subdir
2019-09-25 14:29:41 +03:00
Shotaro Yamada
9c45a9e586
Remove redundant clone()
2019-09-25 10:32:01 +09:00
Jeremy Kolb
13d7fc1620
Revert Self
2019-09-23 14:38:05 -04:00
kjeremy
1808175f98
Drive by lints
2019-09-23 14:31:30 -04:00
kjeremy
6da645d858
Suspicious line endings
2019-09-20 11:55:59 -04:00
Geobert Quach
ce4d843656
feat(assists): Apply comments
2019-09-19 22:12:28 +01:00
Geobert Quach
a3ab80b332
feat(assists): Rename escape_quote
to escape_double_quote
2019-09-19 22:12:28 +01:00
Geobert Quach
889f1f0a7c
feature(assists): Fix regression
2019-09-19 22:12:28 +01:00
Geobert Quach
016c997243
feat(assists): manage "
when removing hash and make_usual_string
2019-09-19 22:12:28 +01:00
Geobert Quach
b6d55290a1
feat(assists): raw string <-> usual string manipulation
...
Fixes #1730
2019-09-19 22:12:28 +01:00
uHOOCCOOHu
de9670fe45
Move store TypeRef of type based path in PathKind
2019-09-15 19:48:24 +08:00
uHOOCCOOHu
4926bed426
Support path starting with a type
2019-09-15 19:40:32 +08:00
Aleksey Kladov
114a1b878e
rename AdtDef -> Adt
2019-09-13 00:34:52 +03:00
Nelson Chen
14585468e2
Minor typo fix for ra_assists code doc
2019-09-08 02:10:53 -07:00
Ekaterina Babshukova
acb89d2be1
add assist to move type bounds to where clause
2019-09-05 13:29:13 +03:00
Aleksey Kladov
e94587e315
fix assists
2019-09-02 21:52:06 +03:00
Aleksey Kladov
5e3f291195
fix hir for new block syntax
2019-09-02 21:23:19 +03:00
Aleksey Kladov
4b6bccb58c
⬆️ once_cell
2019-09-01 23:18:15 +03:00
Aleksey Kladov
5b18a4eef9
rename struct -> record, pos -> tuple
2019-08-23 16:59:50 +03:00
Aleksey Kladov
bbcca4f735
make ast object safe
2019-08-23 15:06:47 +03:00
Ekaterina Babshukova
e84f93cb5b
refactor fill_match_arms assist
2019-08-23 00:43:12 +03:00
Aleksey Kladov
4753409f86
refactor TryConvWith similar to ConvWith
2019-08-20 19:53:05 +03:00
Aleksey Kladov
3bec812258
remove ast::*Kind enums from assists
2019-08-19 14:11:09 +03:00
Florian Diebold
22724f37f3
Lower fully qualified associated type paths
...
I.e. `<T as Trait>::Foo`.
2019-08-12 21:43:00 +02:00
Evgenii P
06c3de310e
rustfmt
2019-07-30 21:02:29 +07:00
Evgenii P
e7cdbe795a
Fix flip comma assist
2019-07-30 20:33:58 +07:00
Phil Ellison
e6113c0998
Add merge_match_arm assist, bump rowan to 0.6.1
2019-07-29 21:59:52 +01:00
Aleksey Kladov
61739b0c17
Document AssistBuilder
...
closes #1603
2019-07-29 15:43:34 +03:00
Aleksey Kladov
d52ee59a71
streamline API
2019-07-21 13:28:58 +03:00
Aleksey Kladov
c9cfd57eea
switch to upstream rowan's API
2019-07-20 20:12:06 +03:00
Aleksey Kladov
f6bcc2d745
align SyntaxText API with upstream
2019-07-20 16:52:11 +03:00
Aleksey Kladov
f3bdbec1b6
rename range -> text_range
2019-07-20 12:58:27 +03:00
Aleksey Kladov
0025299370
sane indexing in text
2019-07-19 20:55:32 +03:00
Aleksey Kladov
191a6ba330
convenience api
2019-07-19 19:05:34 +03:00
Aleksey Kladov
0343c4a815
migrate ra_assists to the new AST
2019-07-19 13:16:25 +03:00
Aleksey Kladov
deab4caa7b
make Parse fields private
...
this is in preparation for the new rowan API
2019-07-12 19:41:13 +03:00
Ekaterina Babshukova
895597d567
move whitespace manipulation inside AstEditor
2019-07-10 22:03:00 +03:00
Jeremy Kolb
98d769a799
readability
2019-07-05 10:18:01 -04:00
Jeremy Kolb
6b4ec73b7e
Clippy changes
2019-07-04 23:00:00 -04:00
Jeremy Kolb
4ad9e986ad
Some clippy fixes for 1.36
2019-07-04 17:43:00 -04:00
Aleksey Kladov
1834bae5b8
allow rustfmt to reorder imports
...
This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
2019-07-04 23:09:09 +03:00
Ekaterina Babshukova
e0e42095db
extend add_impl_members to constants and types
2019-07-03 16:17:18 +03:00
Changyu Li
3a2a13756f
Review 1
2019-06-25 13:26:12 -07:00
ironyman
888157b52e
fill_match_arm works with trivial arm
2019-06-23 21:05:50 -07:00
Florian Diebold
9c5e7dd849
Implement autoderef using the Deref trait
...
- add support for other lang item targets, since we need the Deref lang item
2019-06-15 18:21:23 +02:00
Aleksey Kladov
c4512fadb1
remove inherent source impls
2019-06-11 18:28:51 +03:00
Aleksey Kladov
178d8e96b5
use Source for StructField
2019-06-11 18:28:51 +03:00
Aleksey Kladov
f411c2988d
use Source for Trait
2019-06-11 18:28:51 +03:00
Alan Du
964edd9943
Fix clippy::while_let_loop
2019-06-04 18:05:07 -04:00
Alan Du
b28ca32db2
Fix clippy::or_fun_call
2019-06-04 18:05:07 -04:00
Alan Du
ed3d93b875
Fix clippy::single_char_pattern
2019-06-04 18:05:07 -04:00
Aleksey Kladov
61e1474ab3
fix typos in mbe tests
2019-05-28 18:46:11 +03:00
bors[bot]
67d5927b16
Merge #1281
...
1281: Move arm cond to match guard r=matklad a=unrealhoang
I did split the rename to another commit, yet Github UI still show entirely new file change. Please review using commits.
Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
2019-05-22 07:39:54 +00:00
Unreal Hoang
08e954f0fd
add assist to move arm condition to match guard
2019-05-21 23:31:51 +09:00
Unreal Hoang
99ad6143cd
rename
2019-05-16 12:53:52 +09:00
Sergey Parilin
993abedd77
apply T! macro where it is possible
2019-05-15 15:35:47 +03:00
Aleksey Kladov
1667b5cf52
switch to once_cell from lazy_static
2019-05-07 20:54:33 +03:00
Sergey Parilin
12f8472d28
removed duplicating fill_struct_fields assist
2019-05-06 17:26:09 +03:00
Sergey Parilin
26ed925685
fill struct fields diagnostic
2019-05-06 17:16:11 +03:00
Jeremy Kolb
293cc81bf1
Remove collect
2019-05-05 13:28:22 -04:00
Unreal Hoang
d1c21b85cf
add complex match case and documentation
2019-05-02 01:41:02 +09:00
Unreal Hoang
f83e452b1e
move guard to arm body assist.
2019-05-02 00:42:00 +09:00
bors[bot]
c416caeda2
Merge #1194
...
1194: Pr 1190 r=matklad a=matklad
Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 13:19:47 +00:00
Aleksey Kladov
e01052d1f0
move auto-imoprter into IDE
...
auto-import is purely an IDE concern, so it should be done outside of
HIR
2019-04-22 15:56:28 +03:00
Aleksey Kladov
b73a978b95
drop useless test
2019-04-22 13:05:01 +03:00
Aleksey Kladov
268e739c94
move add_missing_members to structured editing API
...
Currently, this is more code, and we also loose auto-indenting of
bodies, but, long-term, this is the right approach
2019-04-22 13:01:33 +03:00
Aleksey Kladov
5b2fd86d25
more type safety
2019-04-22 10:11:06 +03:00
Andrea Pretto
9144214958
complete_import: add new import resolver infrastructure with some hardcoded importable name.
...
Changes complete_scope to support that.
2019-04-22 00:14:58 +02:00
Andrea Pretto
cf0eff2e33
auto_import: better no anchor management
2019-04-22 00:13:00 +02:00
Andrea Pretto
766813898f
auto_import: make auto import working with target as a list of SmolStr instead of ast::Path
2019-04-22 00:13:00 +02:00
Andrea Pretto
0e0ae47b47
auto_import: use TextEditBuilder instead of AssistBuilder to make it more reusable
2019-04-22 00:13:00 +02:00
Aleksey Kladov
97f41d7343
test short structs
2019-04-22 00:52:21 +03:00
Aleksey Kladov
f313ac45af
use structured editing API for fill struct assist
2019-04-21 22:13:52 +03:00
Aleksey Kladov
7cc845e88d
start structured editing API
2019-04-21 20:51:20 +03:00
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
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
Andrea Pretto
6d8832359e
auto_import: Removed Empty in favor of Partial(0)
...
auto_import: Removed unecessary lifetimes
2019-02-09 11:30:09 +01:00
Andrea Pretto
5580cf239d
auto_import assist
2019-02-09 11:29:59 +01:00
bors[bot]
34398a8756
Merge #766
...
766: Formatting code into ra_fmt r=matklad a=eulerdisk
As discussed https://github.com/rust-analyzer/rust-analyzer/pull/762#discussion_r254905885
I did only move the code without other improvements.
Co-authored-by: Andrea Pretto <eulerdisk@gmail.com>
2019-02-09 09:56:54 +00:00
robojumper
4fdeb54bb5
Improve sorting delegate
2019-02-09 01:57:08 +01:00
robojumper
a70589712a
Remove unused import
2019-02-09 00:54:07 +01:00
robojumper
3be98f2ac9
Add tests for action target ranges
2019-02-09 00:34:26 +01:00
robojumper
a3622eb629
Add some assist ranges
2019-02-08 22:43:13 +01:00
Andrea Pretto
02dd0cfd8c
Refactor formatting code out of ra_ida_api_light into ra_fmt.
2019-02-08 18:58:27 +01:00
Aleksey Kladov
12e3b4c70b
reformat the world
2019-02-08 14:49:43 +03:00
Ville Penttinen
be7c5eecc4
Remove unnecessary dbg! calls
2019-02-07 20:42:00 +02:00
Ville Penttinen
6cbf83c946
Add new assist to remove dbg!() calls
...
This fixes #758 .
Currently we try to maintain the cursor position relative to the statement under
cursor, if the cursor is inside the dbg! macro call.
Meaning:
let foo = dbg!(some.complex<|>().expression());
Should turn into:
let foo = some.complex<|>().expression();
With the cursor staying in place.
2019-02-07 20:34:33 +02:00
kjeremy
6753051a45
Some clippy cleanups
2019-02-06 15:50:26 -05:00
kjeremy
bcbee10b89
assists: compute edit
2019-02-06 11:15:18 -05:00
Aleksey Kladov
0c5fd8f7cb
move assists to a separate crate
2019-02-06 17:00:00 +03:00