public static Location GetLocation(this SourceNode node) { // TODO remove this after SourceNode has this method itself //return new SourceLocation(node); // we don't have tree ref here var tree = SourceTree.CreateForRoot(node.AncestorsAndSelf().Last()); return(new SourceLocation(tree, node.GetSpan())); }
public static TextSpan GetSpan(this SourceNode node) { // TODO remove this after SourceNode has this method itself var pos = node.AncestorsAndSelf().Select(item => { if (item.Parent is null) { return(0); } var precedingSiblingWidth = item.Parent.Children().Take(item.IndexInParent).Sum(x => x.GetWidth()); return(precedingSiblingWidth); }).Sum(); return(new TextSpan(pos, node.GetWidth())); }