Summarize the contents of a file using the embedding query

This commit is contained in:
Antonio Scandurra 2023-10-02 14:32:13 +02:00
parent 53c25690f9
commit 64a55681e6
4 changed files with 264 additions and 235 deletions

View file

@ -8,8 +8,8 @@ use crate::{
language_settings::{language_settings, LanguageSettings},
outline::OutlineItem,
syntax_map::{
SyntaxLayerInfo, SyntaxMap, SyntaxMapCapture, SyntaxMapCaptures, SyntaxSnapshot,
ToTreeSitterPoint,
SyntaxLayerInfo, SyntaxMap, SyntaxMapCapture, SyntaxMapCaptures, SyntaxMapMatches,
SyntaxSnapshot, ToTreeSitterPoint,
},
CodeLabel, LanguageScope, Outline,
};
@ -2467,6 +2467,14 @@ impl BufferSnapshot {
Some(items)
}
pub fn matches(
&self,
range: Range<usize>,
query: fn(&Grammar) -> Option<&tree_sitter::Query>,
) -> SyntaxMapMatches {
self.syntax.matches(range, self, query)
}
/// Returns bracket range pairs overlapping or adjacent to `range`
pub fn bracket_ranges<'a, T: ToOffset>(
&'a self,