about summary refs log tree commit diff
path: root/crates/syntax/src
AgeCommit message (Collapse)AuthorLines
2021-07-10Respect coercions in `inline_call`Lukas Wirth-4/+13
2021-07-09fix: Adding async keyword when await is present in generate_function assistvi_mi-2/+5
2021-07-05Update `inline_call` assist doc exampleLukas Wirth-6/+8
2021-07-05Merge #9474bors[bot]-0/+21
9474: fix: Inline parameters in `inline_call` if possible r=Veykril a=Veykril Fixes #9491 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-05Fixup emitted whitespace in most casesLukas Wirth-0/+6
2021-07-04minor: untangle complex conditionAleksey Kladov-10/+9
2021-07-04minor: better error messageAleksey Kladov-1/+1
2021-07-03Merge #9476bors[bot]-16/+1143
9476: internal: overhaul codegen r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-07-03internal: overhaul code generationAleksey Kladov-16/+1143
* Keep codegen adjacent to the relevant crates. * Remove codgen deps from xtask, speeding-up from-source installation. This regresses the release process a bit, as it now needs to run the tests (and, by extension, compile the code).
2021-07-03Inline parameters in `inline_call` if possibleLukas Wirth-0/+15
2021-07-03Merge the inline function/method assists into `inline_call`Lukas Wirth-2/+1
2021-07-03feat: Implement `inline_method` assistLukas Wirth-11/+17
2021-07-02`replace_match_with_if_let` works on more binary matchesLukas Wirth-0/+4
2021-07-01Merge #9458bors[bot]-3/+10
9458: minor: Remove make::match_arm_with_guard r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-02Remove make::match_arm_with_guardLukas Wirth-3/+10
2021-07-01Merge #9455bors[bot]-0/+13
9455: feat: Handle not let if expressions in replace_if_let_with_match r=Veykril a=Veykril Transforms bare `if cond {}` into `_ if cond` guard patterns in the match as long as at least one `if let` is in the if chain, otherwise the assist wont be applicable. bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-07-02Handle not let if expressions in replace_if_let_with_matchLukas Wirth-0/+13
2021-06-30Don't classify NameRef paths inside attribute TokenTreesLukas Wirth-0/+8
2021-06-28Fix `NameRef::classify` path resolution inside attributesLukas Wirth-5/+21
2021-06-27Deduplicate ast expression walking logicLukas Wirth-1/+51
2021-06-22Merge #9367bors[bot]-0/+9
9367: Document perf characteristic of to_node r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-06-22Document perf characteristic of to_nodeAleksey Kladov-0/+9
2021-06-21feature: massively improve performance for large filesAleksey Kladov-1/+1
This story begins in #8384, where we added a smart test for our syntax highting, which run the algorithm on synthetic files of varying length in order to guesstimate if the complexity is O(N^2) or O(N)-ish. The test turned out to be pretty effective, and flagged #9031 as a change that makes syntax highlighting accidentally quadratic. There was much rejoicing, for the time being. Then, lnicola asked an ominous question[1]: "Are we sure that the time is linear right now?" Of course it turned out that our sophisticated non-linearity detector *was* broken, and that our syntax highlighting *was* quadratic. Investigating that, many brave hearts dug deeper and deeper into the guts of rust-analyzer, only to get lost in a maze of traits delegating to traits delegating to macros. Eventually, matklad managed to peel off all layers of abstraction one by one, until almost nothing was left. In fact, the issue was discovered in the very foundation of the rust-analyzer -- in the syntax trees. Worse, it was not a new problem, but rather a well-know, well-understood and event (almost) well-fixed (!) performance bug. The problem lies within `SyntaxNodePtr` type -- a light-weight "address" of a node in a syntax tree [3]. Such pointers are used by rust-analyzer all other the place to record relationships between IR nodes and the original syntax. Internally, the pointer to a syntax node is represented by node's range. To "dereference" the pointer, you traverse the syntax tree from the root, looking for the node with the right range. The inner loop of this search is finding a node's child whose range contains the specified range. This inner loop was implemented by naive linear search over all the children. For wide trees, dereferencing a single `SyntaxNodePtr` was linear. The problem with wide trees though is that they contain a lot of nodes! And dereferencing pointers to all the nodes is quadratic in the size of the file! The solution to this problem is to speed up the children search -- rather than doing a linear lookup, we can use binary search to locate the child with the desired interval. Doing this optimization was one of the motivations (or rather, side effects) of #6857. That's why `rowan` grew the useful `child_or_token_at_range` method which does exactly this binary search. But looks like we've never actually switch to this method? Oups. Lesson learned: do not leave broken windows in the fundamental infra. Otherwise, you'll have to repeatedly re-investigate the issue, by digging from the top of the Everest down to the foundation! [1]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/.60syntax_highlighting_not_quadratic.60.20failure/near/240811501 [2]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Syntax.20highlighting.20is.20quadratic [3]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Syntax.20highlighting.20is.20quadratic/near/243412392
2021-06-18Don't insert imports outside of cfg attributed itemsLukas Wirth-1/+7
2021-06-18Allow to disable import insertion on single path glob importsLukas Wirth-0/+9
2021-06-17Create modules in correct directory for nested modules in move_module assistLukas Wirth-0/+8
2021-06-15Highlight unsafe trait refs as unsafe only in impl blocks and definitionsLukas Wirth-0/+9
2021-06-13clippy::manual_str_repeatMaan2003-1/+1
2021-06-13clippy::redudant_borrowMaan2003-10/+10
2021-06-11Update ungrammarJonas Schievink-7/+43
2021-06-08Fix edge case for ImportGranularity guessingLukas Wirth-1/+4
2021-06-03Apply more clippy suggestions and update generatedClemens Wasser-5/+5
2021-06-02Account for generics in extract_struct_from_enum_variantLukas Wirth-3/+2
2021-05-31minor: remove debug printAleksey Kladov-1/+0
2021-05-27Attribute completion is context awareLukas Wirth-0/+7
2021-05-24generate match arms with todo!() as placeholder bodyDomantas Jadenkus-6/+15
2021-05-22Add more docsAleksey Kladov-4/+15
2021-05-22internal: replace AstTransformer with mutable syntax treesAleksey Kladov-54/+19
2021-05-20Don't compare ast::Visibility by stringifyingLukas Tobias Wirth-0/+23
2021-05-17fix: don't add extra whitespace around fieldsAleksey Kladov-0/+4
closes #8785
2021-05-16internal: use mutable syntax trees when filling fieldsAleksey Kladov-98/+42
2021-05-16internal: use mutable trees when filling match armsAleksey Kladov-126/+69
2021-05-16Merge #8813bors[bot]-20/+61
8813: Get some more array lengths! r=lf- a=lf- This is built on #8799 and thus contains its changes. I'll rebase it onto master when that one gets merged. It adds support for r-a understanding the length of: * `let a: [u8; 2] = ...` * `let a = b"aaa"` * `let a = [0u8; 4]` I have added support for getting the values of byte strings, which was not previously there. I am least confident in the correctness of this part and it probably needs some more tests, as we currently have only one test that exercised that part (!). Fixes #2922. Co-authored-by: Jade <software@lfcode.ca>
2021-05-15Attach comments to ast::ImplLukas Wirth-2/+2
2021-05-14internal: use more mutable APIsAleksey Kladov-35/+17
2021-05-14internal: rewrite assoc item manipulaion to use mutable treesAleksey Kladov-153/+72
2021-05-14internal: remove SyntaxRewriterAleksey Kladov-153/+4
2021-05-14internal: remove more of the SyntaxRewriterAleksey Kladov-29/+31
2021-05-14internal: remove one more immutable treeAleksey Kladov-39/+12
2021-05-13Cleanup importsAleksey Kladov-4/+3