refactor: remove `pub`, use a getter instead

pull/12759/head
Nikita Revenco 2025-02-05 17:32:46 +00:00 committed by Nik Revenco
parent ec94fbdf3b
commit a07819b497
2 changed files with 6 additions and 2 deletions

View File

@ -68,7 +68,7 @@ pub fn injection_for_range(syntax: &Syntax, from: usize, to: usize) -> Option<La
let mut best_fit = None; let mut best_fit = None;
let mut min_gap = usize::MAX; let mut min_gap = usize::MAX;
for (layer_id, layer) in &syntax.layers { for (layer_id, layer) in syntax.layers() {
for ts_range in &layer.ranges { for ts_range in &layer.ranges {
let is_encompassing = ts_range.start_byte <= from && ts_range.end_byte >= to; let is_encompassing = ts_range.start_byte <= from && ts_range.end_byte >= to;
if is_encompassing { if is_encompassing {

View File

@ -1097,7 +1097,7 @@ thread_local! {
#[derive(Debug)] #[derive(Debug)]
pub struct Syntax { pub struct Syntax {
pub layers: HopSlotMap<LayerId, LanguageLayer>, layers: HopSlotMap<LayerId, LanguageLayer>,
root: LayerId, root: LayerId,
loader: Arc<ArcSwap<Loader>>, loader: Arc<ArcSwap<Loader>>,
} }
@ -1429,6 +1429,10 @@ impl Syntax {
}) })
} }
pub fn layers(&self) -> &HopSlotMap<LayerId, LanguageLayer> {
&self.layers
}
/// Get an injection layer's language configuration /// Get an injection layer's language configuration
pub fn layer_config(&self, layer_id: LayerId) -> Arc<LanguageConfiguration> { pub fn layer_config(&self, layer_id: LayerId) -> Arc<LanguageConfiguration> {
let loader = &self.loader.load(); let loader = &self.loader.load();