about summary refs log tree commit diff
path: root/crates/syntax/src
AgeCommit message (Collapse)AuthorLines
2021-03-16Replace trait object boxing with extra AttrsOwnerNodeLukas Wirth-1/+1
2021-03-16Upgrade rowanAleksey Kladov-25/+225
Notably, new rowan comes with support for mutable syntax trees.
2021-03-16Fix macro expansion for statements w/o semicolonEdwin Cheng-2/+8
2021-03-14Attach trivia to ast::Union nodesLukas Wirth-2/+2
2021-03-09feat: add expr_for_loop to make in syntaxLuiz Carlos Mourão Paes de Carvalho-0/+3
2021-03-08Better strip turbofishesKirill Bulatov-0/+48
2021-03-08Use upstream cov-markLaurențiu Nicola-14/+12
2021-03-08Use the same name in xtask and test utilsAleksey Kladov-3/+3
2021-03-02Merge #7777bors[bot]-5/+9
7777: Implement line<->block comment assist r=Veykril a=djrenren Fixes: https://github.com/rust-analyzer/rust-analyzer/issues/6515 Co-authored-by: John Renner <john@jrenner.net>
2021-02-24Implement line<->block comment assistJohn Renner-5/+9
2021-02-24Add tests for apply_demorganLukas Wirth-2/+5
2021-02-20Fix incorrect missing field diagnostic with box patternsLaurențiu Nicola-4/+13
2021-02-17Revert "Replace usage of ast::NameOrNameRef with ast::NameLike"Lukas Wirth-18/+23
This reverts commit e1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979.
2021-02-17Replace usage of ast::NameOrNameRef with ast::NameLikeLukas Wirth-23/+18
2021-02-16Implement ast::AstNode for NameLike and move it to node_extLukas Wirth-1/+47
2021-02-16Merge #7620bors[bot]-9/+50
7620: Support control flow in `extract_function` assist r=matklad a=cpud36 Support `return`ing from outer function, `break`ing and `continue`ing outer loops when extracting function. # Example Transforms ```rust fn foo() -> i32 { let items = [1,2,3]; let mut sum = 0; for &item in items { <|>if item == 42 { break; }<|> sum += item; } sum } ``` Into ```rust fn foo() -> i32 { let items = [1,2,3]; let mut sum = 0; for &item in items { if fun_name(item) { break; } sum += item; } sum } fn fun_name(item: i32) -> bool { if item == 42 { return true; } false } ``` ![add_explicit_type_infer_type](https://user-images.githubusercontent.com/4218373/107544222-0fadf280-6bdb-11eb-9625-ed6194ba92c0.gif) # Features Supported variants - break and function does not return => uses `bool` and plain if - break and function does return => uses `Option<T>` and matches on it - break with value and function does not return => uses `Option<T>` and if let - break with value and function does return => uses `Result<T, U>` and matches on t - same for `return` and `continue`(but we can't continue with value) Assist does handle nested loops and nested items(like functions, modules, impls) Try `expr?` operator is allowed together with `return Err(_)` and `return None`. `return expr` is not allowed. # Not supported ## Mixing `return` with `break` or `continue` If we have e.g. a `return` and a `break` in the selected code, it is unclear what the produced code should look like. We can try `Result<T, Option<U>>` or something like that, but it isn't idiomatic, nor it is established. Otherwise, implementation is relatively simple. ## `break` with label Not sure how to handle different labels for multiple `break`s. [edit] implemented try `expr?` Co-authored-by: Vladyslav Katasonov <cpud47@gmail.com>
2021-02-13Don't rename field record patterns directlyLukas Wirth-3/+2
2021-02-13allow try expr? when extacting functionVladyslav Katasonov-0/+3
2021-02-13handle return, break and continue when extracting functionVladyslav Katasonov-9/+47
2021-02-12Refactor reference searching to work with the astLukas Wirth-4/+26
2021-02-09Add parsing benchmarkAleksey Kladov-3/+25
2021-02-07AdtDef -> AdtAleksey Kladov-19/+19
2021-02-03allow modifications of vars from outer scope inside extracted functionVladyslav Katasonov-1/+1
It currently allows only directly setting variable. No `&mut` references or methods.
2021-01-30Fix ast::String::value not properly escaping in some casesLukas Wirth-2/+19
2021-01-24Add validation for mutable const itemsLukas Wirth-1/+15
2021-01-20:arrow_up: rowanAleksey Kladov-8/+7
It now stores text inline with tokens
2021-01-20.Aleksey Kladov-17/+17
2021-01-19:arrow_up: rowanAleksey Kladov-4/+5
2021-01-18Add `MacroType` syntaxJonas Schievink-2/+31
2021-01-18Merge #7291bors[bot]-15/+25
7291: Wrap remaining self/super/crate in Name{Ref} r=matklad a=Veykril That should be the remaining special casing for `self` 🎉 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-15Wrap remaining self/super/crate in Name{Ref}Lukas Wirth-15/+25
2021-01-15Add Unmerge Use assistunexge-2/+6
2021-01-15Merge #7288bors[bot]-9/+23
7288: Handle self/super/crate in PathSegment as NameRef r=matklad a=Veykril Wrapping self/super/crate in NameRef as per https://github.com/rust-analyzer/rust-analyzer/pull/7261#issuecomment-760023172 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-15Handle self/super/crate in PathSegment as NameRefLukas Wirth-9/+23
2021-01-15Merge #7286bors[bot]-8/+3
7286: Remove useless wrapper r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-01-15Remove useless wrapperAleksey Kladov-8/+3
2021-01-15Add support for yiled keywordDaiki Ihara-1/+33
2021-01-14Introduce more appropriate assertion mechanismAleksey Kladov-1/+1
rust-analyzer is a long-running program, so we *should* handle assertion failures. See also https://www.sqlite.org/assert.html.
2021-01-10Merge #7218bors[bot]-8/+8
7218: Fix typos r=Veykril a=regexident Apart from the very last commit on this PR (which fixes a public type's name) all changes are non-breaking. Co-authored-by: Vincent Esche <regexident@gmail.com>
2021-01-10Merge #7239bors[bot]-1/+1
7239: Replace SyntaxKind usage with T! macro where applicable r=lnicola a=Veykril https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/style.md#token-names Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-10Replace SyntaxKind usage with T! macro where applicableLukas Wirth-1/+1
2021-01-10Fix typo, parentheses is pluralLaurențiu Nicola-2/+2
2021-01-09Fixed typos in local bindingsVincent Esche-2/+2
2021-01-09Fixed typos in code assertsVincent Esche-1/+1
2021-01-09Fixed typos in code commentsVincent Esche-5/+5
2021-01-07Change <|> to $0 - RebaseKevaundray Wedderburn-29/+29
2021-01-05Rename expr -> tail_exprAleksey Kladov-2/+2
2021-01-03parser,syntax: Add separate parser for stmt with optional semicolonMarijn Suijten-1/+1
Adjusting `grammar::fragments::stmt` to Optional or Yes will break original functionality and tests.
2021-01-03syntax,ssr: Implement statement parsingMarijn Suijten-0/+16
2021-01-02Fix warnings on rust-nightlycynecx-2/+2