pub struct JavaScriptAdapter;Expand description
Language adapter for JavaScript source files.
Parses .js and .mjs files with the tree-sitter-javascript grammar
and extracts:
importsfromimportstatementsexportsfromexportstatements at module scopesignaturesfrom function and method declarationspattern_hintsfor the patterns stage
§Examples
use sdivi_lang_javascript::JavaScriptAdapter;
use sdivi_parsing::adapter::LanguageAdapter;
let adapter = JavaScriptAdapter;
assert_eq!(adapter.language_name(), "javascript");
assert!(adapter.file_extensions().contains(&".js"));Trait Implementations§
Source§impl LanguageAdapter for JavaScriptAdapter
impl LanguageAdapter for JavaScriptAdapter
Source§fn parse_file(&self, path: &Path, content: String) -> FeatureRecord
fn parse_file(&self, path: &Path, content: String) -> FeatureRecord
Parses content and returns a FeatureRecord.
The tree-sitter CST is created, traversed, and dropped before this method returns. No tree-sitter type escapes into the returned record.
Source§fn language_name(&self) -> &'static str
fn language_name(&self) -> &'static str
Returns the canonical lower-case language name (e.g.
"rust").Source§fn file_extensions(&self) -> &[&'static str]
fn file_extensions(&self) -> &[&'static str]
Returns the file extensions handled by this adapter (e.g.
&[".rs"]). Read moreAuto Trait Implementations§
impl Freeze for JavaScriptAdapter
impl RefUnwindSafe for JavaScriptAdapter
impl Send for JavaScriptAdapter
impl Sync for JavaScriptAdapter
impl Unpin for JavaScriptAdapter
impl UnsafeUnpin for JavaScriptAdapter
impl UnwindSafe for JavaScriptAdapter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more