Finish getting multiple diagnostics sources building and running
This commit is contained in:
parent
bb4de47b15
commit
6156dbced0
8 changed files with 34 additions and 23 deletions
|
@ -620,7 +620,7 @@ mod tests {
|
|||
}],
|
||||
&snapshot,
|
||||
);
|
||||
buffer.update_diagnostics(set, cx);
|
||||
buffer.update_diagnostics(0, set, cx);
|
||||
});
|
||||
|
||||
// Hover pops diagnostic immediately
|
||||
|
|
|
@ -2800,7 +2800,7 @@ impl MultiBufferSnapshot {
|
|||
) -> impl Iterator<Item = DiagnosticEntry<O>> + 'a
|
||||
where
|
||||
T: 'a + ToOffset,
|
||||
O: 'a + text::FromAnchor,
|
||||
O: 'a + text::FromAnchor + Ord,
|
||||
{
|
||||
self.as_singleton()
|
||||
.into_iter()
|
||||
|
|
|
@ -1588,7 +1588,7 @@ mod tests {
|
|||
..Default::default()
|
||||
},
|
||||
tree_sitter_javascript::language(),
|
||||
None,
|
||||
vec![],
|
||||
|_| Default::default(),
|
||||
);
|
||||
|
||||
|
|
|
@ -250,10 +250,6 @@ impl LanguageServer {
|
|||
log::trace!("incoming message:{}", String::from_utf8_lossy(&buffer));
|
||||
|
||||
if let Ok(msg) = serde_json::from_slice::<AnyNotification>(&buffer) {
|
||||
dbg!(
|
||||
msg.method,
|
||||
notification_handlers.lock().keys().collect::<Vec<_>>()
|
||||
);
|
||||
if let Some(handler) = notification_handlers.lock().get_mut(msg.method) {
|
||||
handler(msg.id, msg.params.get(), cx.clone());
|
||||
} else {
|
||||
|
|
|
@ -1547,12 +1547,13 @@ impl Project {
|
|||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<()>> {
|
||||
let worktree_task = self.find_or_create_local_worktree(&abs_path, true, cx);
|
||||
let old_path =
|
||||
File::from_dyn(buffer.read(cx).file()).and_then(|f| Some(f.as_local()?.abs_path(cx)));
|
||||
let old_file = File::from_dyn(buffer.read(cx).file())
|
||||
.filter(|f| f.is_local())
|
||||
.cloned();
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
if let Some(old_path) = old_path {
|
||||
if let Some(old_file) = &old_file {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.unregister_buffer_from_language_servers(&buffer, old_path, cx);
|
||||
this.unregister_buffer_from_language_servers(&buffer, old_file, cx);
|
||||
});
|
||||
}
|
||||
let (worktree, path) = worktree_task.await?;
|
||||
|
@ -1740,11 +1741,24 @@ impl Project {
|
|||
fn unregister_buffer_from_language_servers(
|
||||
&mut self,
|
||||
buffer: &ModelHandle<Buffer>,
|
||||
old_path: PathBuf,
|
||||
old_file: &File,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
let old_path = match old_file.as_local() {
|
||||
Some(local) => local.abs_path(cx),
|
||||
None => return,
|
||||
};
|
||||
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.update_diagnostics(Default::default(), cx);
|
||||
let worktree_id = old_file.worktree_id(cx);
|
||||
let ids = &self.language_server_ids;
|
||||
|
||||
let language = buffer.language().cloned();
|
||||
let adapters = language.iter().flat_map(|language| language.lsp_adapters());
|
||||
for &server_id in adapters.flat_map(|a| ids.get(&(worktree_id, a.name.clone()))) {
|
||||
buffer.update_diagnostics(server_id, Default::default(), cx);
|
||||
}
|
||||
|
||||
self.buffer_snapshots.remove(&buffer.remote_id());
|
||||
let file_url = lsp::Url::from_file_path(old_path).unwrap();
|
||||
for (_, language_server) in self.language_servers_for_buffer(buffer, cx) {
|
||||
|
@ -4501,8 +4515,10 @@ impl Project {
|
|||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
let snapshot = worktree_handle.read(cx).snapshot();
|
||||
|
||||
let mut buffers_to_delete = Vec::new();
|
||||
let mut renamed_buffers = Vec::new();
|
||||
|
||||
for (buffer_id, buffer) in &self.opened_buffers {
|
||||
if let Some(buffer) = buffer.upgrade(cx) {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
|
@ -4545,7 +4561,7 @@ impl Project {
|
|||
|
||||
let old_path = old_file.abs_path(cx);
|
||||
if new_file.abs_path(cx) != old_path {
|
||||
renamed_buffers.push((cx.handle(), old_path));
|
||||
renamed_buffers.push((cx.handle(), old_file.clone()));
|
||||
}
|
||||
|
||||
if new_file != *old_file {
|
||||
|
@ -4572,8 +4588,8 @@ impl Project {
|
|||
self.opened_buffers.remove(&buffer_id);
|
||||
}
|
||||
|
||||
for (buffer, old_path) in renamed_buffers {
|
||||
self.unregister_buffer_from_language_servers(&buffer, old_path, cx);
|
||||
for (buffer, old_file) in renamed_buffers {
|
||||
self.unregister_buffer_from_language_servers(&buffer, &old_file, cx);
|
||||
self.detect_language_for_buffer(&buffer, cx);
|
||||
self.register_buffer_with_language_servers(&buffer, cx);
|
||||
}
|
||||
|
|
|
@ -303,6 +303,7 @@ async fn test_managing_language_servers(
|
|||
|
||||
rust_buffer2.update(cx, |buffer, cx| {
|
||||
buffer.update_diagnostics(
|
||||
0,
|
||||
DiagnosticSet::from_sorted_entries(
|
||||
vec![DiagnosticEntry {
|
||||
diagnostic: Default::default(),
|
||||
|
@ -1402,6 +1403,8 @@ async fn test_empty_diagnostic_ranges(cx: &mut gpui::TestAppContext) {
|
|||
project
|
||||
.update_buffer_diagnostics(
|
||||
&buffer,
|
||||
0,
|
||||
None,
|
||||
vec![
|
||||
DiagnosticEntry {
|
||||
range: Unclipped(PointUtf16::new(0, 10))..Unclipped(PointUtf16::new(0, 10)),
|
||||
|
@ -1420,8 +1423,6 @@ async fn test_empty_diagnostic_ranges(cx: &mut gpui::TestAppContext) {
|
|||
},
|
||||
},
|
||||
],
|
||||
0,
|
||||
None,
|
||||
cx,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -90,7 +90,7 @@ pub fn init(
|
|||
"tsx",
|
||||
tree_sitter_typescript::language_tsx(),
|
||||
vec![
|
||||
// adapter_arc(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
|
||||
adapter_arc(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
|
||||
adapter_arc(typescript::EsLintLspAdapter::new(node_runtime.clone())),
|
||||
],
|
||||
),
|
||||
|
@ -98,7 +98,7 @@ pub fn init(
|
|||
"typescript",
|
||||
tree_sitter_typescript::language_typescript(),
|
||||
vec![
|
||||
// adapter_arc(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
|
||||
adapter_arc(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
|
||||
adapter_arc(typescript::EsLintLspAdapter::new(node_runtime.clone())),
|
||||
],
|
||||
),
|
||||
|
@ -106,7 +106,7 @@ pub fn init(
|
|||
"javascript",
|
||||
tree_sitter_typescript::language_tsx(),
|
||||
vec![
|
||||
// adapter_arc(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
|
||||
adapter_arc(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
|
||||
adapter_arc(typescript::EsLintLspAdapter::new(node_runtime.clone())),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -73,7 +73,6 @@ impl LspAdapter for TypeScriptLspAdapter {
|
|||
_: Arc<dyn HttpClient>,
|
||||
container_dir: PathBuf,
|
||||
) -> Result<LanguageServerBinary> {
|
||||
dbg!();
|
||||
let versions = versions.downcast::<TypeScriptVersions>().unwrap();
|
||||
let server_path = container_dir.join(Self::NEW_SERVER_PATH);
|
||||
|
||||
|
@ -99,7 +98,6 @@ impl LspAdapter for TypeScriptLspAdapter {
|
|||
}
|
||||
|
||||
async fn cached_server_binary(&self, container_dir: PathBuf) -> Option<LanguageServerBinary> {
|
||||
dbg!();
|
||||
(|| async move {
|
||||
let old_server_path = container_dir.join(Self::OLD_SERVER_PATH);
|
||||
let new_server_path = container_dir.join(Self::NEW_SERVER_PATH);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue