tree-sitter-graph
tree-sitter-graph copied to clipboard
Allow optional globals be omitted
When defining an optional global, currently the library still requires that it be set in the ExecutionConfig::globals
passed to File::execute
, or it fails with an ExecutionError(MissingGlobalVariable("MY_GLOBAL"))
. This change allows the global to be omitted:
constant MY_GLOBAL?
let globals = Variables::new(); // Empty; `MY_GLOBAL` does not need to be set
let config = ExecutionConfig::new(&functions, &globals);
let graph = file.execute(tree, source, &config, &NoCancellation)?;