You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the API to modify source file is based on text edits: the user of the API should specify which text ranges should be replaced with which text.
We are primarily dealing with syntax trees, so having APIs which work directly on syntax trees should be useful. Specifically, we need three kinds of "well-typed" API for every ast node:
a factory/builder API to create node from components
a "setter" API which allows to change an existing node in arbitrary ways
a high-level DWIM API for semantic modification (ie, add a new field to a struct, and figure out appropriate placing and spacing automatically)
Note that the precise shape of the API is not trivial: because tree contains parent pointers, just mutating node in place probably will not work. I think we should have a functional-style with_* APIs which return a copy of the node with None parent.
A possibly interesting first target for the API would be "merge import" action, which replaces use foo::bar; use foo::baz; with use foo::{bar, baz};. I imagine a nice structural editing API should allow to write this in "merge two imports, repeat" style, without computing a single global edit.
The text was updated successfully, but these errors were encountered:
Currently, the API to modify source file is based on text edits: the user of the API should specify which text ranges should be replaced with which text.
We are primarily dealing with syntax trees, so having APIs which work directly on syntax trees should be useful. Specifically, we need three kinds of "well-typed" API for every ast node:
A good inspiration is, as usual, Swift.
Note that the precise shape of the API is not trivial: because tree contains parent pointers, just mutating node in place probably will not work. I think we should have a functional-style
with_*
APIs which return a copy of the node withNone
parent.A possibly interesting first target for the API would be "merge import" action, which replaces
use foo::bar; use foo::baz;
withuse foo::{bar, baz};
. I imagine a nice structural editing API should allow to write this in "merge two imports, repeat" style, without computing a single global edit.The text was updated successfully, but these errors were encountered: