use crate::base::FileId;
use crate::hir::{SymbolIndex, SymbolKind};
#[derive(Debug, Clone)]
pub struct FoldingRange {
pub start_line: u32,
pub start_col: u32,
pub end_line: u32,
pub end_col: u32,
pub is_comment: bool,
}
pub fn folding_ranges(index: &SymbolIndex, file: FileId) -> Vec<FoldingRange> {
let mut ranges: Vec<FoldingRange> = index
.symbols_in_file(file)
.into_iter()
.filter(|sym| sym.end_line > sym.start_line) .map(|sym| FoldingRange {
start_line: sym.start_line,
start_col: sym.start_col,
end_line: sym.end_line,
end_col: sym.end_col,
is_comment: sym.kind == SymbolKind::Comment,
})
.collect();
ranges.sort_by_key(|r| r.start_line);
ranges
}