printToFile method
"Prints" a given element to a given file path. Like print, this function
can convert any SyntaxElement into its JSON string representation. However,
instead of returning the string, this function will write the resulting JSON
into a file, returning a Future that can be used to await the completion
of the operation.
Implementation
Future<void> printToFile(SyntaxElement element, String path) {
var file = File(path);
var contents = print(element);
return file.writeAsString(contents);
}