This commit is contained in:
Max Brunsfeld 2021-12-13 17:44:20 -08:00
parent 0b1c27956b
commit 4efdc53d9f
6 changed files with 68 additions and 9 deletions

View file

@ -7,7 +7,10 @@ edition = "2021"
path = "src/diagnostics.rs"
[dependencies]
anyhow = "1.0"
collections = { path = "../collections" }
editor = { path = "../editor" }
language = { path = "../language" }
gpui = { path = "../gpui" }
project = { path = "../project" }
workspace = { path = "../workspace" }

View file

@ -1,5 +1,7 @@
use editor::{Editor, MultiBuffer};
use collections::HashMap;
use editor::{Editor, ExcerptProperties, MultiBuffer};
use gpui::{elements::*, Entity, ModelHandle, RenderContext, View, ViewContext, ViewHandle};
use language::Point;
use postage::watch;
use project::Project;
@ -14,10 +16,52 @@ impl ProjectDiagnostics {
settings: watch::Receiver<workspace::Settings>,
cx: &mut ViewContext<Self>,
) -> Self {
let mut buffer = cx.add_model(|cx| MultiBuffer::new(project.read(cx).replica_id(cx)));
for (project_path, diagnostic_summary) in project.read(cx).diagnostic_summaries(cx) {
//
}
let buffer = cx.add_model(|cx| MultiBuffer::new(project.read(cx).replica_id(cx)));
let project_paths = project
.read(cx)
.diagnostic_summaries(cx)
.map(|e| e.0)
.collect::<Vec<_>>();
cx.spawn(|this, mut cx| {
let project = project.clone();
async move {
let mut excerpts = Vec::new();
for project_path in project_paths {
let buffer = project
.update(&mut cx, |project, cx| project.open_buffer(project_path, cx))
.await?;
let snapshot = buffer.read_with(&cx, |b, _| b.snapshot());
let mut grouped_diagnostics = HashMap::default();
for entry in snapshot.all_diagnostics() {
let mut group = grouped_diagnostics
.entry(entry.diagnostic.group_id)
.or_insert((Point::zero(), Vec::new()));
if entry.diagnostic.is_primary {
group.0 = entry.range.start;
}
group.1.push(entry);
}
let mut sorted_diagnostic_groups =
grouped_diagnostics.into_values().collect::<Vec<_>>();
sorted_diagnostic_groups.sort_by_key(|group| group.0);
let mut prev_end_row = None;
let mut pending_excerpt = None;
for diagnostic in snapshot.all_diagnostics::<Point>() {
excerpts.push(ExcerptProperties {
buffer: &buffer,
range: todo!(),
header_height: todo!(),
});
}
}
Result::Ok::<_, anyhow::Error>(())
}
})
.detach();
Self {
editor: cx.add_view(|cx| {