Revert "fix: Stale diagnostics with rust-project.json and rustc JSON"
This reverts commit 2cefe47e6d55c186b68687bf677bf0d5eb65a922.
This commit is contained in:
parent
ca35562cd3
commit
a9cc42e576
1 changed files with 33 additions and 54 deletions
|
|
@ -741,63 +741,42 @@ impl FlycheckActor {
|
||||||
flycheck_id = self.id,
|
flycheck_id = self.id,
|
||||||
message = diagnostic.message,
|
message = diagnostic.message,
|
||||||
package_id = package_id.as_ref().map(|it| it.as_str()),
|
package_id = package_id.as_ref().map(|it| it.as_str()),
|
||||||
scope = ?self.scope,
|
|
||||||
"diagnostic received"
|
"diagnostic received"
|
||||||
);
|
);
|
||||||
|
if self.diagnostics_received == DiagnosticsReceived::NotYet {
|
||||||
match &self.scope {
|
self.diagnostics_received = DiagnosticsReceived::AtLeastOne;
|
||||||
FlycheckScope::Workspace => {
|
|
||||||
if self.diagnostics_received == DiagnosticsReceived::NotYet {
|
|
||||||
self.send(FlycheckMessage::ClearDiagnostics {
|
|
||||||
id: self.id,
|
|
||||||
kind: ClearDiagnosticsKind::All(ClearScope::Workspace),
|
|
||||||
});
|
|
||||||
|
|
||||||
self.diagnostics_received =
|
|
||||||
DiagnosticsReceived::AtLeastOneAndClearedWorkspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.send(FlycheckMessage::AddDiagnostic {
|
|
||||||
id: self.id,
|
|
||||||
generation: self.generation,
|
|
||||||
package_id: None,
|
|
||||||
workspace_root: self.root.clone(),
|
|
||||||
diagnostic,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
FlycheckScope::Package { package: flycheck_package, .. } => {
|
|
||||||
if self.diagnostics_received == DiagnosticsReceived::NotYet {
|
|
||||||
self.diagnostics_received = DiagnosticsReceived::AtLeastOne;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the package has been set in the diagnostic JSON, respect that. Otherwise, use the
|
|
||||||
// package that the current flycheck is scoped to. This is useful when a project is
|
|
||||||
// directly using rustc for its checks (e.g. custom check commands in rust-project.json).
|
|
||||||
let package_id = package_id.unwrap_or(flycheck_package.clone());
|
|
||||||
|
|
||||||
if self.diagnostics_cleared_for.insert(package_id.clone()) {
|
|
||||||
tracing::trace!(
|
|
||||||
flycheck_id = self.id,
|
|
||||||
package_id = package_id.as_str(),
|
|
||||||
"clearing diagnostics"
|
|
||||||
);
|
|
||||||
self.send(FlycheckMessage::ClearDiagnostics {
|
|
||||||
id: self.id,
|
|
||||||
kind: ClearDiagnosticsKind::All(ClearScope::Package(
|
|
||||||
package_id.clone(),
|
|
||||||
)),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
self.send(FlycheckMessage::AddDiagnostic {
|
|
||||||
id: self.id,
|
|
||||||
generation: self.generation,
|
|
||||||
package_id: Some(package_id),
|
|
||||||
workspace_root: self.root.clone(),
|
|
||||||
diagnostic,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if let Some(package_id) = &package_id {
|
||||||
|
if self.diagnostics_cleared_for.insert(package_id.clone()) {
|
||||||
|
tracing::trace!(
|
||||||
|
flycheck_id = self.id,
|
||||||
|
package_id = package_id.as_str(),
|
||||||
|
"clearing diagnostics"
|
||||||
|
);
|
||||||
|
self.send(FlycheckMessage::ClearDiagnostics {
|
||||||
|
id: self.id,
|
||||||
|
kind: ClearDiagnosticsKind::All(ClearScope::Package(
|
||||||
|
package_id.clone(),
|
||||||
|
)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if self.diagnostics_received
|
||||||
|
!= DiagnosticsReceived::AtLeastOneAndClearedWorkspace
|
||||||
|
{
|
||||||
|
self.diagnostics_received =
|
||||||
|
DiagnosticsReceived::AtLeastOneAndClearedWorkspace;
|
||||||
|
self.send(FlycheckMessage::ClearDiagnostics {
|
||||||
|
id: self.id,
|
||||||
|
kind: ClearDiagnosticsKind::All(ClearScope::Workspace),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
self.send(FlycheckMessage::AddDiagnostic {
|
||||||
|
id: self.id,
|
||||||
|
generation: self.generation,
|
||||||
|
package_id,
|
||||||
|
workspace_root: self.root.clone(),
|
||||||
|
diagnostic,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue