Extract entities from a source file. Automatically selects the right parser based on the file extension. Returns an empty list if the language is not supported.
(&mut self, file_path: &str, source: &str)
| 287 | /// Automatically selects the right parser based on the file extension. |
| 288 | /// Returns an empty list if the language is not supported. |
| 289 | pub fn extract(&mut self, file_path: &str, source: &str) -> Vec<Entity> { |
| 290 | let language = match Language::detect(file_path) { |
| 291 | Some(l) => l, |
| 292 | None => return Vec::new(), |
| 293 | }; |
| 294 | |
| 295 | match self.parsers.get_mut(&language) { |
| 296 | Some(parser) => parser.extract(source, file_path), |
| 297 | None => Vec::new(), |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /// Extract references from a source file. |
| 302 | /// |