Skip to main content

sem_core/parser/
plugin.rs

1use crate::model::entity::SemanticEntity;
2
3pub trait SemanticParserPlugin: Send + Sync {
4    fn id(&self) -> &str;
5    fn extensions(&self) -> &[&str];
6    fn extract_entities(&self, content: &str, file_path: &str) -> Vec<SemanticEntity>;
7    /// Extract entities and optionally return the tree-sitter Tree for reuse.
8    /// Default returns None for the tree (non-code plugins).
9    fn extract_entities_with_tree(
10        &self,
11        content: &str,
12        file_path: &str,
13    ) -> (Vec<SemanticEntity>, Option<tree_sitter::Tree>) {
14        (self.extract_entities(content, file_path), None)
15    }
16    fn compute_similarity(&self, a: &SemanticEntity, b: &SemanticEntity) -> f64 {
17        crate::model::identity::default_similarity(a, b)
18    }
19}