pub struct PythonAdapter;Expand description
Language adapter for Python source files.
Parses .py files with the tree-sitter-python grammar and extracts:
importsfromimportandfrom … importstatementsexportsfrom top-level non-underscore definitionssignaturesfrom function and class definitionspattern_hintsfor the patterns stage
§Examples
use sdivi_lang_python::PythonAdapter;
use sdivi_parsing::adapter::LanguageAdapter;
let adapter = PythonAdapter;
assert_eq!(adapter.language_name(), "python");
assert!(adapter.file_extensions().contains(&".py"));Trait Implementations§
Source§impl LanguageAdapter for PythonAdapter
impl LanguageAdapter for PythonAdapter
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 PythonAdapter
impl RefUnwindSafe for PythonAdapter
impl Send for PythonAdapter
impl Sync for PythonAdapter
impl Unpin for PythonAdapter
impl UnsafeUnpin for PythonAdapter
impl UnwindSafe for PythonAdapter
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