I don’t think foldable means what you think it means. You pass it the start/end of a line and it will see if the registered fold services provide a foldable range for that line. If you know which range you want to fold, you should not be calling foldable, and definitely not with the extent of a syntax node, which probably does not precisely cover a line.
I’d like to fold all objects - that is, “a” and “b” in this example - after loading this text. “a” and “b” could have arbitrary depth and also arbitrary other child objects.
A folow-up question would be if I can pass additional metadata into SyntaxNodes to map them back to javascript objects - a goal would be that when a user clicks on a button related to “a”, I can focus the right line where “a” starts.