Say I have two SyntaxTree A and B ,
where B was created by modifying A.
I would like the following information:
- Syntax Nodes and tokens removed from A to create B
- Syntax Nodes and Tokens Added to A to Create B
Is there an API for this?
If not, how can this be effectively calculated?
This information must be available to Roslyn.
since immutable GreenNode are shared between trees.
One solution I can think of is using SyntaxTree.GetChangedSpans()
and then find the intersecting tokens.
However, this seems like a hack, and I'm not sure if it is always accurate. A small change to the text can greatly affect SyntaxTree :
(for example, replacing * with + in an expression can change the order / priority)
source share