kotlinx / ast

Generic AST parsing library for kotlin multiplatform
Apache License 2.0
316 stars 22 forks source link

AST Node Tree Refactoring / Insertion / Removal #105

Open sdfgsdfgd opened 6 months ago

sdfgsdfgd commented 6 months ago

inserting an element, removing an element, refactoring an existing element within a Node tree thats parsed from a Kotlin file for example... I'm interested in these use cases

  1. Is it possible to grab the exact same tree, copy it, with a node inserted, or removed, or copy()d right ?
  2. Are we able to unwrap() (just like in python's AST module) the AST tree to original kotlin code, and then back ? Are we able to modify the AST node tree in this way, as I described in 1 ? This is a very valuable capability.
  3. If it's not possible with this library, would it be possible to do with ANTLR-kotlin ?

Looking forward to any ideas