Deliver diagnostics for a single file. Called from the background diagnostic worker after debouncing. Phase 1 (instant, both modes):** Run fast collectors (syntax errors, deprecated, unused imports), merge with *cached* slow and PHPStan results, and push via `publishDiagnostics`. The editor shows strikethrough and dimming within milliseconds. Phase 2 (background, mode-dependent): - **Pull mod
(&self, uri_str: &str, content: &str)
| 654 | /// push the full set (fast + fresh slow + cached PHPStan), |
| 655 | /// replacing the Phase 1 snapshot. |
| 656 | pub(crate) async fn publish_diagnostics_for_file(&self, uri_str: &str, content: &str) { |
| 657 | if self.should_skip_diagnostics(uri_str) { |
| 658 | return; |
| 659 | } |
| 660 | |
| 661 | // ── Phase 1: collect and cache fast diagnostics ───────────── |
| 662 | let mut fast_diagnostics = Vec::new(); |
| 663 | { |
| 664 | let vc_handle = self.blade_virtual_content.read(); |
| 665 | let effective_content = vc_handle |
| 666 | .get(uri_str) |
| 667 | .map(|s| s.as_str()) |
| 668 | .unwrap_or(content); |
| 669 | |
| 670 | self.collect_fast_diagnostics(uri_str, effective_content, &mut fast_diagnostics); |
| 671 | } |
| 672 | |
| 673 | { |
| 674 | let mut cache = self.diag_last_fast.lock(); |
| 675 | cache.insert(uri_str.to_string(), fast_diagnostics.clone()); |
| 676 | } |
| 677 | |
| 678 | // Push assembled diagnostics immediately so the editor sees |
| 679 | // fast results (strikethrough, dimming) merged with whatever |
| 680 | // slow / external results are already cached. |
| 681 | self.assemble_and_push(uri_str).await; |
| 682 | |
| 683 | // ── Phase 2: compute and cache slow diagnostics ───────────── |
| 684 | // The resolved-class cache guard must not cross an `.await` |
| 685 | // point (it contains a raw pointer and is !Send). Scope it |
| 686 | // tightly around the synchronous diagnostic collection. |
| 687 | let mut slow_diagnostics = Vec::new(); |
| 688 | { |
| 689 | let _cache_guard = crate::virtual_members::with_active_resolved_class_cache( |
| 690 | &self.resolved_class_cache, |
| 691 | ); |
| 692 | |
| 693 | let vc_handle = self.blade_virtual_content.read(); |
| 694 | let effective_content = vc_handle |
| 695 | .get(uri_str) |
| 696 | .map(|s| s.as_str()) |
| 697 | .unwrap_or(content); |
| 698 | |
| 699 | self.collect_slow_diagnostics(uri_str, effective_content, &mut slow_diagnostics); |
| 700 | } |
| 701 | |
| 702 | { |
| 703 | let mut cache = self.diag_last_slow.lock(); |
| 704 | cache.insert(uri_str.to_string(), slow_diagnostics); |
| 705 | } |
| 706 | |
| 707 | // Push again with fresh slow results merged in. |
| 708 | self.assemble_and_push(uri_str).await; |
| 709 | } |
| 710 | |
| 711 | /// Assemble diagnostics from all per-source caches for a URI and |
| 712 | /// deliver them to the editor. |
no test coverage detected