aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge #7777bors[bot]2021-03-022-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 <[email protected]>
| * Implement line<->block comment assistJohn Renner2021-02-252-5/+9
| |
* | Add tests for apply_demorganLukas Wirth2021-02-241-2/+5
|/
* Fix incorrect missing field diagnostic with box patternsLaurențiu Nicola2021-02-201-4/+13
|
* Revert "Replace usage of ast::NameOrNameRef with ast::NameLike"Lukas Wirth2021-02-172-18/+23
| | | | This reverts commit e1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979.
* Replace usage of ast::NameOrNameRef with ast::NameLikeLukas Wirth2021-02-172-23/+18
|
* Implement ast::AstNode for NameLike and move it to node_extLukas Wirth2021-02-162-1/+47
|
* Merge #7620bors[bot]2021-02-161-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 <[email protected]>
| * allow try expr? when extacting functionVladyslav Katasonov2021-02-131-0/+3
| |
| * handle return, break and continue when extracting functionVladyslav Katasonov2021-02-131-9/+47
| |
* | Don't rename field record patterns directlyLukas Wirth2021-02-131-3/+2
|/
* Refactor reference searching to work with the astLukas Wirth2021-02-121-4/+26
|
* Add parsing benchmarkAleksey Kladov2021-02-091-3/+25
|
* AdtDef -> AdtAleksey Kladov2021-02-071-19/+19
|
* allow modifications of vars from outer scope inside extracted functionVladyslav Katasonov2021-02-031-1/+1
| | | | | It currently allows only directly setting variable. No `&mut` references or methods.
* Fix ast::String::value not properly escaping in some casesLukas Wirth2021-01-301-2/+19
|
* Add validation for mutable const itemsLukas Wirth2021-01-241-1/+15
|
* :arrow_up: rowanAleksey Kladov2021-01-204-8/+7
| | | | It now stores text inline with tokens
* .Aleksey Kladov2021-01-195-17/+17
|
* :arrow_up: rowanAleksey Kladov2021-01-192-4/+5
|
* Add `MacroType` syntaxJonas Schievink2021-01-181-2/+31
|
* Merge #7291bors[bot]2021-01-182-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 <[email protected]>
| * Wrap remaining self/super/crate in Name{Ref}Lukas Wirth2021-01-152-15/+25
| |
* | Add Unmerge Use assistunexge2021-01-151-2/+6
|/
* Merge #7288bors[bot]2021-01-154-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 <[email protected]>
| * Handle self/super/crate in PathSegment as NameRefLukas Wirth2021-01-154-9/+23
| |
* | Merge #7286bors[bot]2021-01-152-8/+3
|\ \ | |/ |/| | | | | | | | | | | | | 7286: Remove useless wrapper r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
| * Remove useless wrapperAleksey Kladov2021-01-152-8/+3
| |
* | Add support for yiled keywordDaiki Ihara2021-01-151-1/+33
|/
* Introduce more appropriate assertion mechanismAleksey Kladov2021-01-141-1/+1
| | | | | | | rust-analyzer is a long-running program, so we *should* handle assertion failures. See also https://www.sqlite.org/assert.html.
* Merge #7218bors[bot]2021-01-104-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 <[email protected]>
| * Fixed typos in local bindingsVincent Esche2021-01-091-2/+2
| |
| * Fixed typos in code assertsVincent Esche2021-01-091-1/+1
| |
| * Fixed typos in code commentsVincent Esche2021-01-092-5/+5
| |
* | Merge #7239bors[bot]2021-01-101-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 <[email protected]>
| * | Replace SyntaxKind usage with T! macro where applicableLukas Wirth2021-01-101-1/+1
| |/
* / Fix typo, parentheses is pluralLaurențiu Nicola2021-01-101-2/+2
|/
* Change <|> to $0 - RebaseKevaundray Wedderburn2021-01-072-29/+29
|
* Rename expr -> tail_exprAleksey Kladov2021-01-052-2/+2
|
* parser,syntax: Add separate parser for stmt with optional semicolonMarijn Suijten2021-01-031-1/+1
| | | | | Adjusting `grammar::fragments::stmt` to Optional or Yes will break original functionality and tests.
* syntax,ssr: Implement statement parsingMarijn Suijten2021-01-032-0/+16
|
* Fix warnings on rust-nightlycynecx2021-01-021-2/+2
|
* indentationAdnoC2020-12-301-3/+3
|
* Smarter bracketed use diagnosticAdnoC2020-12-301-0/+8
|
* Implement const block inferenceLukas Wirth2020-12-231-0/+4
|
* Merge #7010bors[bot]2020-12-231-1/+32
|\ | | | | | | | | | | | | | | | | | | | | | | 7010: Update ungrammar for const block patterns r=matklad a=Veykril Fixes #6848 Adds const blocks and const block patterns to the AST and parses them. Blocked on https://github.com/rust-analyzer/ungrammar/pull/17/, will merge that PR there once this one gets the OK so I can remove the local ungrammar dependency path and fix the Cargo.lock. Co-authored-by: Lukas Wirth <[email protected]>
| * Update ungrammar for const block patternsLukas Wirth2020-12-231-1/+32
| |
* | Document `make` module designAleksey Kladov2020-12-231-1/+7
|/
* Merge #6934bors[bot]2020-12-181-0/+7
|\ | | | | | | | | | | | | | | 6934: Implement `cfg_attr` handling r=jonas-schievink a=jonas-schievink Part of https://github.com/rust-analyzer/rust-analyzer/issues/5548 Co-authored-by: Jonas Schievink <[email protected]>
| * Implement `RawAttr::filter`Jonas Schievink2020-12-181-0/+7
| |