Function biome_js_parser::parse_js_with_cache
source · pub fn parse_js_with_cache(
text: &str,
source_type: JsFileSource,
options: JsParserOptions,
cache: &mut NodeCache
) -> Parse<AnyJsRoot>Expand description
Parses the provided string as a EcmaScript program using the provided syntax features and node cache.
§Examples
use biome_js_parser::{JsParserOptions, parse_js_with_cache};
use biome_js_syntax::JsFileSource;
use biome_rowan::NodeCache;
let source_type = JsFileSource::js_module();
let mut cache = NodeCache::default();
let mut source = "function f() { return 2 }";
let parsed = parse_js_with_cache(source, source_type, JsParserOptions::default(), &mut cache);
assert_eq!(parsed.diagnostics().len(), 0);
source = "function bar() { return 3 }";
let parsed = parse_js_with_cache(source, source_type, JsParserOptions::default(), &mut cache);
assert_eq!(parsed.diagnostics().len(), 0);