pub struct ParserRegistry {
pub custom_test_dirs: Vec<String>,
/* private fields */
}Fields§
§custom_test_dirs: Vec<String>Implementations§
Source§impl ParserRegistry
impl ParserRegistry
pub fn new() -> Self
pub fn register(&mut self, plugin: Box<dyn SemanticParserPlugin>)
pub fn get_plugin(&self, file_path: &str) -> Option<&dyn SemanticParserPlugin>
pub fn get_explicit_plugin( &self, file_path: &str, ) -> Option<&dyn SemanticParserPlugin>
pub fn detect_plugin_from_content( &self, content: &str, ) -> Option<&dyn SemanticParserPlugin>
Sourcepub fn get_plugin_with_content(
&self,
file_path: &str,
content: &str,
) -> Option<&dyn SemanticParserPlugin>
pub fn get_plugin_with_content( &self, file_path: &str, content: &str, ) -> Option<&dyn SemanticParserPlugin>
Try to detect language from shebang line when extension-based lookup fails. Call this as a fallback when file content is available.
pub fn get_plugin_by_id(&self, id: &str) -> Option<&dyn SemanticParserPlugin>
Sourcepub fn add_extension_mapping(&mut self, ext: &str, language: &str) -> bool
pub fn add_extension_mapping(&mut self, ext: &str, language: &str) -> bool
Register a custom extension mapping from a .semrc file. Maps an extension (e.g. “.inc”) to an existing plugin by language name.
Sourcepub fn load_semrc(&mut self, root: &Path)
pub fn load_semrc(&mut self, root: &Path)
Load extension mappings from a .semrc file at the given root directory.
File format (one mapping per line): .ext = language
Example:
.inc = php
.j = json
.xyz = cpp
Sourcepub fn load_gitattributes(&mut self, root: &Path)
pub fn load_gitattributes(&mut self, root: &Path)
Load extension mappings from .gitattributes at the given root directory.
Parses *.ext diff=language and *.ext linguist-language=Language patterns.
Only processes *.ext glob patterns (not path-based patterns).
Sourcepub fn resolve_file_path(&self, file_path: &str) -> Option<String>
pub fn resolve_file_path(&self, file_path: &str) -> Option<String>
Resolve custom extension mappings in a file path.
E.g. if .mypy is mapped to python (canonical .py),
"utils.mypy" becomes "utils.py".
Sourcepub fn extract_entities(
&self,
file_path: &str,
content: &str,
) -> Vec<SemanticEntity>
pub fn extract_entities( &self, file_path: &str, content: &str, ) -> Vec<SemanticEntity>
Extract entities, transparently handling custom extension mappings. Uses the resolved path for language detection but restores the original file path in entity metadata (file_path, id, parent_id).
Sourcepub fn extract_entities_with_tree(
&self,
file_path: &str,
content: &str,
) -> Option<(Vec<SemanticEntity>, Option<Tree>)>
pub fn extract_entities_with_tree( &self, file_path: &str, content: &str, ) -> Option<(Vec<SemanticEntity>, Option<Tree>)>
Extract entities with tree, transparently handling custom extension mappings.
Sourcepub fn extract_all_entities(
&self,
root: &Path,
file_paths: &[String],
) -> Vec<SemanticEntity>
pub fn extract_all_entities( &self, root: &Path, file_paths: &[String], ) -> Vec<SemanticEntity>
Extract entities from multiple files in parallel.
Auto Trait Implementations§
impl !RefUnwindSafe for ParserRegistry
impl !UnwindSafe for ParserRegistry
impl Freeze for ParserRegistry
impl Send for ParserRegistry
impl Sync for ParserRegistry
impl Unpin for ParserRegistry
impl UnsafeUnpin for ParserRegistry
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
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>
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>
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