rust/crates
bors[bot] 38c0a1e333 Merge #1184
1184: Start structured editing API r=matklad a=matklad

I think I finally understand how to provide nice, mutable structured editing API on top of red-green trees.

The problem I am trying to solve is that any modification to a particular `SyntaxNode` returns an independent new file. So, if you are editing a struct literal, and add a field, you get back a SourceFile, and you have to find the struct literal inside it yourself! This happens because our trees are immutable, but have parent pointers. 

The main idea here is to introduce `AstEditor<T>` type, which abstracts away that API. So, you create an `AstEditor` for node you want to edit and call various `&mut` taking methods on it. Internally, `AstEditor` stores both the original node and the current node. All edits are applied to the current node, which is replaced by the corresponding node in the new file. In the end, `AstEditor` computes a text edit between old and new nodes.

Note that this also should sole a problem when you create an anchor pointing to a subnode and mutate the parent node, invalidating anchor. Because mutation needs `&mut`, all anchors must be killed before modification. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-04-22 10:08:18 +00:00
..
gen_lsp_server switch to official extend selection API 2019-04-21 12:13:48 +03:00
ra_arena
ra_assists drop useless test 2019-04-22 13:05:01 +03:00
ra_batch migrate to salsas interning 2019-04-09 22:51:22 +03:00
ra_cli Merge #1068 2019-04-03 09:09:11 +00:00
ra_db drop old interning infra 2019-04-09 22:52:06 +03:00
ra_fmt replace usages of algo::generate with iter::successors from std 2019-04-13 16:43:49 +02:00
ra_hir Change macro stack monitor test to func ptr based 2019-04-22 17:15:22 +08:00
ra_ide_api fix postfix match indent 2019-04-22 10:38:39 +03:00
ra_lsp_server ⬆️ lsp 2019-04-21 15:17:22 +03:00
ra_mbe Add mbe expand limit and poision macro set 2019-04-22 15:33:55 +08:00
ra_parser Add vis matcher 2019-04-19 21:38:26 +08:00
ra_prof fix test 2019-04-15 01:17:26 +03:00
ra_project_model Sends cwd info for runnables and code lenses 2019-04-14 10:04:38 +02:00
ra_syntax move add_missing_members to structured editing API 2019-04-22 13:01:33 +03:00
ra_text_edit
ra_tt Use map, sum in Subtree::coount instead of fold 2019-04-22 17:37:27 +08:00
test_utils
thread_worker
tools Use EXE extension for pre-commit hook on Window 2019-03-27 07:52:59 +01:00