pub struct TypeScriptAdapter;Expand description
Language adapter for TypeScript source files (.ts and .tsx).
Parses .ts and .tsx files with the tree-sitter-typescript grammar and
extracts:
importsfromimportstatementsexportsfromexportstatements at module scopesignaturesfrom function and method declarationspattern_hintsfor the patterns stage
§Examples
use sdivi_lang_typescript::TypeScriptAdapter;
use sdivi_parsing::adapter::LanguageAdapter;
let adapter = TypeScriptAdapter;
assert_eq!(adapter.language_name(), "typescript");
assert!(adapter.file_extensions().contains(&".ts"));
assert!(adapter.file_extensions().contains(&".tsx"));Trait Implementations§
Source§impl LanguageAdapter for TypeScriptAdapter
impl LanguageAdapter for TypeScriptAdapter
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 TypeScriptAdapter
impl RefUnwindSafe for TypeScriptAdapter
impl Send for TypeScriptAdapter
impl Sync for TypeScriptAdapter
impl Unpin for TypeScriptAdapter
impl UnsafeUnpin for TypeScriptAdapter
impl UnwindSafe for TypeScriptAdapter
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