pit-of-successify tree editor

This commit is contained in:
Aleksey Kladov 2021-03-16 22:59:57 +03:00
parent 34555593ca
commit 186a430853
2 changed files with 17 additions and 14 deletions

View file

@ -102,17 +102,17 @@ impl GenericParamsOwnerEdit for ast::Enum {
fn create_where_clause(position: Position) {
let where_clause: SyntaxElement =
make::where_clause(empty()).clone_for_update().syntax().clone().into();
ted::insert_ws(position, where_clause);
ted::insert(position, where_clause);
}
impl ast::WhereClause {
pub fn add_predicate(&self, predicate: ast::WherePred) {
if let Some(pred) = self.predicates().last() {
if !pred.syntax().siblings_with_tokens(Direction::Next).any(|it| it.kind() == T![,]) {
ted::append_child(self.syntax().clone(), make::token(T![,]));
ted::append_child_raw(self.syntax().clone(), make::token(T![,]));
}
}
ted::append_child_ws(self.syntax().clone(), predicate.syntax().clone())
ted::append_child(self.syntax().clone(), predicate.syntax().clone())
}
}