diff --git a/rust/contracts/rust-core-api.md b/rust/contracts/rust-core-api.md index 3ea41cd3..93f0acd6 100644 --- a/rust/contracts/rust-core-api.md +++ b/rust/contracts/rust-core-api.md @@ -671,7 +671,7 @@ or removing a command fails until the table changes in the same commit. | `lsp.builtinNavigation` | Return lightweight current-file definition/reference locations | | `lsp.mergeCompletions` | Choose which candidates survive when several prioritized providers complete at one position | | `lsp.activationPolicy` | Decide whether a language server may start automatically after failures, using a platform monotonic clock | -| `lsp.problems.query` | Filter, order, and group Problems tool-window diagnostics and count them by severity | +| `lsp.problems.query` | Filter, order, and group Problems tool-window diagnostics, count them by severity, and lay the tree rows out | | `lsp.references.query` | Group Find Usages locations by file and lay out the References tool window's visible rows, selection, and previous/next usages | | `lsp.references.lines` | Show the lines of References tool-window usages with highlighted usage ranges, as search results show theirs | | `lsp.startServer` | Start one Rust-owned process/session and begin initialization | @@ -2979,8 +2979,24 @@ stable `key`, `indices` into the submitted list, and per-severity `counts`), `files` (file summaries in file order regardless of `groupBy`), `visibleCounts`, and `totalCounts`. `fileKey` is the platform's native file identity; `displayPath` is the workspace-relative path and orders files with -the Project view's natural file-name order. Severity is the LSP number; -missing or out-of-range values are unknown (`0`) and rank last. Cases: +the Project view's natural file-name order; file groups also carry `name` +(its last segment) and `folder` (the rest, empty at the root). Severity is the +LSP number; missing or out-of-range values are unknown (`0`) and rank last. +The request also carries the platform-held tree state: `collapsed` (the keys +of closed group nodes; unknown keys are ignored) and the `selected` row key. +The response lays the tree out the way IntelliJ IDEA's Problems window does: +`rows` are the rows that show from top to bottom, each with `key`, `kind` +(`group`, `diagnostic`), `depth`, `expanded` (group nodes only), `group`, and +`shows` (the diagnostic the row previews and opens: itself, or the first under +a node). Group nodes (`file:`, `severity:`) head their diagnostics +at depth 1; with `groupBy` `none` there are no nodes and the diagnostics sit at +depth 0. A diagnostic's key is `diagnostic::::`, +where `ordinal` counts the earlier submitted diagnostics at the same file and +position, so a selection stays on a diagnostic the server republishes at +another index. `selected` and `selectedRow` name the selected row: an absent +or unknown key selects nothing, a diagnostic a closed node hides moves the +selection to that node, and a diagnostic that is gone moves it to its file's +node when the list is grouped by file and the file still shows. Cases: `rust/fixtures/lsp/problems-query-v1.json`. `lsp.references.query` accepts the Find Usages answer as diff --git a/rust/crates/core/src/protocol/command.rs b/rust/crates/core/src/protocol/command.rs index 1fb18f64..1ea63032 100644 --- a/rust/crates/core/src/protocol/command.rs +++ b/rust/crates/core/src/protocol/command.rs @@ -645,7 +645,8 @@ pub enum LspCommand { MergeCompletions, /// Decides whether a language server may start automatically (`lsp.activationPolicy`). ActivationPolicy, - /// Filters, orders, and groups Problems tool-window diagnostics (`lsp.problems.query`). + /// Filters, orders, and groups Problems tool-window diagnostics and lays the tree rows out + /// (`lsp.problems.query`). ProblemsQuery, /// Groups Find Usages locations by file and lays out the References tool /// window's rows (`lsp.references.query`). diff --git a/rust/crates/core/src/tests/lsp_policy.rs b/rust/crates/core/src/tests/lsp_policy.rs index b5a5996c..04a0dca2 100644 --- a/rust/crates/core/src/tests/lsp_policy.rs +++ b/rust/crates/core/src/tests/lsp_policy.rs @@ -144,6 +144,10 @@ fn malformed_requests_fail_with_invalid_request() { "lsp.problems.query", json!({"diagnostics": [], "groupBy": "type"}), ), + ( + "lsp.problems.query", + json!({"diagnostics": [], "collapsed": "file:a"}), + ), ( "lsp.references.query", json!({"locations": [{"fileKey": "a"}]}), diff --git a/rust/crates/lsp-policy/src/problems.rs b/rust/crates/lsp-policy/src/problems.rs index d0854c1b..1ea32d9e 100644 --- a/rust/crates/lsp-policy/src/problems.rs +++ b/rust/crates/lsp-policy/src/problems.rs @@ -1,17 +1,26 @@ -//! Problems tool-window filtering, ordering, and grouping (`lsp.problems.query`). +//! Problems tool-window filtering, ordering, grouping, and tree rows +//! (`lsp.problems.query`). //! //! Platforms submit the diagnostics they display together with the active //! view options. Core returns indices into the submitted list, so the large //! message payload never crosses the boundary a second time. File paths are //! compared with the IDEA natural file-name order that the Project view uses, //! which keeps `File2` before `File10` on both platforms. +//! +//! The tool window shows the groups the way IntelliJ IDEA's Problems window +//! does: a node per file (or severity) over its diagnostics. Platforms keep +//! which nodes are collapsed and which row is selected, and ask Core again +//! after a change; Core returns the rows that show and moves a selection that +//! a collapsed node hides to that node. A diagnostic's row key names its file, +//! position, and place among the diagnostics at that position rather than its +//! index, so the selection stays on it when the server republishes the list. use lithe_core_rules::file_names::FileNameKey; use lithe_protocol::{CoreError, ErrorCode}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::cmp::Ordering; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; /// LSP severities in display order; unknown (`0`) ranks after hints. const SEVERITY_RANKS: [u8; 5] = [1, 2, 3, 4, 0]; @@ -26,6 +35,12 @@ struct Request { sort_by: SortBy, #[serde(default)] filter: Filter, + /// The keys of the group nodes the user closed; unknown keys are ignored. + #[serde(default)] + collapsed: Vec, + /// The key of the selected row; absent or unknown selects nothing. + #[serde(default)] + selected: Option, } /// One displayed diagnostic. Only the fields that affect filtering and order @@ -142,6 +157,13 @@ struct Group { file_key: Option, #[serde(skip_serializing_if = "Option::is_none")] display_path: Option, + /// The last segment of a file group's `displayPath`. + #[serde(skip_serializing_if = "Option::is_none")] + name: Option, + /// A file group's `displayPath` without its last segment; empty at the + /// workspace root. + #[serde(skip_serializing_if = "Option::is_none")] + folder: Option, #[serde(skip_serializing_if = "Option::is_none")] severity: Option, /// Indices into the submitted `diagnostics`, in display order. @@ -149,6 +171,34 @@ struct Group { counts: SeverityCounts, } +#[derive(Serialize, Clone, Copy, PartialEq, Eq)] +#[serde(rename_all = "camelCase")] +enum RowKind { + Group, + Diagnostic, +} + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +struct Row { + /// The group's key, or `diagnostic::::` + /// where `ordinal` counts the earlier submitted diagnostics at the same + /// file and position; stable while nodes open and close. + key: String, + kind: RowKind, + /// 0 for a group node and for a diagnostic of the ungrouped list, 1 for a + /// diagnostic under a node. + depth: u8, + /// Whether a node's diagnostics show; absent on a diagnostic. + #[serde(skip_serializing_if = "Option::is_none")] + expanded: Option, + /// The row's group. + group: usize, + /// The diagnostic the row previews and opens: itself, or the first + /// diagnostic under a node. + shows: usize, +} + #[derive(Serialize)] #[serde(rename_all = "camelCase")] struct FileSummary { @@ -167,6 +217,15 @@ struct Response { files: Vec, visible_counts: SeverityCounts, total_counts: SeverityCounts, + /// The rows that show, top to bottom; empty when nothing is visible. + rows: Vec, + /// The key of the selected row, always one of `rows`; absent when nothing + /// is selected. + #[serde(skip_serializing_if = "Option::is_none")] + selected: Option, + /// The position of the selected row in `rows`. + #[serde(skip_serializing_if = "Option::is_none")] + selected_row: Option, } struct Entry<'a> { @@ -273,14 +332,23 @@ fn query(request: &Request) -> Response { let groups = match request.group_by { GroupBy::File => files .iter() - .map(|file| Group { - key: format!("file:{}", file.facts.file_key), - kind: "file", - file_key: Some(file.facts.file_key.clone()), - display_path: Some(file.facts.display_path.clone()), - severity: None, - indices: file.indices.clone(), - counts: file.counts, + .map(|file| { + let path = file.facts.display_path.as_str(); + let (folder, name) = match path.rfind('/') { + Some(at) => (&path[..at], &path[at + 1..]), + None => ("", path), + }; + Group { + key: file_group_key(&file.facts.file_key), + kind: "file", + file_key: Some(file.facts.file_key.clone()), + display_path: Some(path.to_string()), + name: Some(name.to_string()), + folder: Some(folder.to_string()), + severity: None, + indices: file.indices.clone(), + counts: file.counts, + } }) .collect(), GroupBy::Severity => SEVERITY_RANKS @@ -299,6 +367,8 @@ fn query(request: &Request) -> Response { kind: "severity", file_key: None, display_path: None, + name: None, + folder: None, severity: Some(severity), indices, counts, @@ -312,6 +382,8 @@ fn query(request: &Request) -> Response { kind: "all", file_key: None, display_path: None, + name: None, + folder: None, severity: None, indices: visible.iter().map(|entry| entry.index).collect(), counts: visible_counts, @@ -327,14 +399,120 @@ fn query(request: &Request) -> Response { counts: file.counts, }) .collect(); + let keys = diagnostic_keys(&request.diagnostics); + let (rows, selected) = tree(request, &groups, &keys); + let selected_row = selected + .as_ref() + .and_then(|key| rows.iter().position(|row| &row.key == key)); Response { groups, files, visible_counts, total_counts, + rows, + selected, + selected_row, } } +/// The rows that show and the key of the selected one. Group nodes head +/// their diagnostics except in the ungrouped list, whose diagnostics sit at +/// the top level. A selected diagnostic that a closed node hides moves to +/// that node; one that is gone moves to its file's node when the list is +/// grouped by file and the file still shows, and is dropped otherwise. +fn tree(request: &Request, groups: &[Group], keys: &[String]) -> (Vec, Option) { + let headed = request.group_by != GroupBy::None; + let collapsed: BTreeSet<&str> = request.collapsed.iter().map(String::as_str).collect(); + let expanded: Vec = groups + .iter() + .map(|group| !headed || !collapsed.contains(group.key.as_str())) + .collect(); + let mut rows = Vec::new(); + for (slot, group) in groups.iter().enumerate() { + if headed { + rows.push(Row { + key: group.key.clone(), + kind: RowKind::Group, + depth: 0, + expanded: Some(expanded[slot]), + group: slot, + shows: group.indices[0], + }); + } + if !expanded[slot] { + continue; + } + for index in &group.indices { + rows.push(Row { + key: keys[*index].clone(), + kind: RowKind::Diagnostic, + depth: u8::from(headed), + expanded: None, + group: slot, + shows: *index, + }); + } + } + + let Some(wanted) = request.selected.as_deref() else { + return (rows, None); + }; + if headed && groups.iter().any(|group| group.key == wanted) { + return (rows, Some(wanted.to_string())); + } + if let Some(index) = keys.iter().position(|key| key == wanted) { + if let Some(slot) = groups + .iter() + .position(|group| group.indices.contains(&index)) + { + let shown = if expanded[slot] { + wanted.to_string() + } else { + groups[slot].key.clone() + }; + return (rows, Some(shown)); + } + } + let file = (request.group_by == GroupBy::File) + .then(|| diagnostic_file(wanted)) + .flatten() + .map(file_group_key) + .filter(|key| groups.iter().any(|group| &group.key == key)); + (rows, file) +} + +/// Each submitted diagnostic's row key, in submission order. +fn diagnostic_keys(diagnostics: &[DiagnosticFacts]) -> Vec { + let mut seen = BTreeMap::<(&str, u64, u64), usize>::new(); + diagnostics + .iter() + .map(|facts| { + let ordinal = seen + .entry((facts.file_key.as_str(), facts.line, facts.column)) + .or_insert(0); + let key = format!( + "diagnostic:{}:{}:{}:{}", + facts.line, facts.column, ordinal, facts.file_key + ); + *ordinal += 1; + key + }) + .collect() +} + +/// The `fileKey` a diagnostic row key names, or `None` for another key. +fn diagnostic_file(key: &str) -> Option<&str> { + let mut parts = key.strip_prefix("diagnostic:")?.splitn(4, ':'); + for _ in 0..3 { + parts.next()?.parse::().ok()?; + } + parts.next() +} + +fn file_group_key(file_key: &str) -> String { + format!("file:{file_key}") +} + struct FileGroup<'a> { /// The first visible diagnostic of the file names the group. facts: &'a DiagnosticFacts, diff --git a/rust/fixtures/lsp/problems-query-v1.json b/rust/fixtures/lsp/problems-query-v1.json index 3f2f5edb..e92f9a00 100644 --- a/rust/fixtures/lsp/problems-query-v1.json +++ b/rust/fixtures/lsp/problems-query-v1.json @@ -1,5 +1,5 @@ { - "description": "lsp.problems.query filters, orders, and groups Problems tool-window diagnostics. Responses return indices into the submitted diagnostics.", + "description": "lsp.problems.query filters, orders, and groups Problems tool-window diagnostics and lays the tree rows out. Responses return indices into the submitted diagnostics.", "cases": [ { "name": "default groups files in natural path order and sorts by severity inside each file", @@ -70,6 +70,8 @@ "kind": "file", "fileKey": "/w/README.md", "displayPath": "README.md", + "name": "README.md", + "folder": "", "indices": [ 3 ], @@ -86,6 +88,8 @@ "kind": "file", "fileKey": "/w/src/File2.java", "displayPath": "src/File2.java", + "name": "File2.java", + "folder": "src", "indices": [ 1, 2, @@ -104,6 +108,8 @@ "kind": "file", "fileKey": "/w/src/File10.java", "displayPath": "src/File10.java", + "name": "File10.java", + "folder": "src", "indices": [ 0, 4 @@ -171,7 +177,75 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "file:/w/README.md", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 3 + }, + { + "key": "diagnostic:0:0:0:/w/README.md", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 3 + }, + { + "key": "file:/w/src/File2.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 1, + "shows": 1 + }, + { + "key": "diagnostic:9:0:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 1 + }, + { + "key": "diagnostic:1:5:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 2 + }, + { + "key": "diagnostic:1:5:1:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 5 + }, + { + "key": "file:/w/src/File10.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 2, + "shows": 0 + }, + { + "key": "diagnostic:4:2:0:/w/src/File10.java", + "kind": "diagnostic", + "depth": 1, + "group": 2, + "shows": 0 + }, + { + "key": "diagnostic:4:2:1:/w/src/File10.java", + "kind": "diagnostic", + "depth": 1, + "group": 2, + "shows": 4 + } + ] } }, { @@ -371,7 +445,91 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "severity:1", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 1 + }, + { + "key": "diagnostic:9:0:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 1 + }, + { + "key": "severity:2", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:4:2:0:/w/src/File10.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:4:2:1:/w/src/File10.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 4 + }, + { + "key": "severity:3", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 2, + "shows": 2 + }, + { + "key": "diagnostic:1:5:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 2, + "shows": 2 + }, + { + "key": "severity:4", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 3, + "shows": 5 + }, + { + "key": "diagnostic:1:5:1:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 3, + "shows": 5 + }, + { + "key": "severity:0", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 4, + "shows": 3 + }, + { + "key": "diagnostic:0:0:0:/w/README.md", + "kind": "diagnostic", + "depth": 1, + "group": 4, + "shows": 3 + } + ] } }, { @@ -514,7 +672,51 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "diagnostic:0:0:0:/w/README.md", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 3 + }, + { + "key": "diagnostic:1:5:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 2 + }, + { + "key": "diagnostic:1:5:1:/w/src/File2.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 5 + }, + { + "key": "diagnostic:4:2:0:/w/src/File10.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 0 + }, + { + "key": "diagnostic:4:2:1:/w/src/File10.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 4 + }, + { + "key": "diagnostic:9:0:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 1 + } + ] } }, { @@ -592,6 +794,8 @@ "kind": "file", "fileKey": "/w/src/File2.java", "displayPath": "src/File2.java", + "name": "File2.java", + "folder": "src", "indices": [ 1 ], @@ -608,6 +812,8 @@ "kind": "file", "fileKey": "/w/src/File10.java", "displayPath": "src/File10.java", + "name": "File10.java", + "folder": "src", "indices": [ 0, 4 @@ -662,7 +868,46 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "file:/w/src/File2.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 1 + }, + { + "key": "diagnostic:9:0:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 1 + }, + { + "key": "file:/w/src/File10.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:4:2:0:/w/src/File10.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:4:2:1:/w/src/File10.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 4 + } + ] } }, { @@ -739,6 +984,8 @@ "kind": "file", "fileKey": "/w/README.md", "displayPath": "README.md", + "name": "README.md", + "folder": "", "indices": [ 3 ], @@ -779,7 +1026,24 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "file:/w/README.md", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 3 + }, + { + "key": "diagnostic:0:0:0:/w/README.md", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 3 + } + ] } }, { @@ -855,6 +1119,8 @@ "kind": "file", "fileKey": "/w/src/File2.java", "displayPath": "src/File2.java", + "name": "File2.java", + "folder": "src", "indices": [ 1, 2, @@ -897,7 +1163,38 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "file:/w/src/File2.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 1 + }, + { + "key": "diagnostic:9:0:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 1 + }, + { + "key": "diagnostic:1:5:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 2 + }, + { + "key": "diagnostic:1:5:1:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 5 + } + ] } }, { @@ -972,6 +1269,8 @@ "kind": "file", "fileKey": "/w/src/File2.java", "displayPath": "src/File2.java", + "name": "File2.java", + "folder": "src", "indices": [ 1 ], @@ -1012,7 +1311,24 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "file:/w/src/File2.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 1 + }, + { + "key": "diagnostic:9:0:0:/w/src/File2.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 1 + } + ] } }, { @@ -1128,81 +1444,134 @@ "information": 1, "hint": 1, "unknown": 1 - } + }, + "rows": [ + { + "key": "diagnostic:4:2:0:/w/src/File10.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 0 + }, + { + "key": "diagnostic:4:2:1:/w/src/File10.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 4 + } + ] } }, { - "name": "no visible diagnostics produce no groups", + "name": "a closed file node hides its diagnostics and takes their selection", "request": { "diagnostics": [ { - "fileKey": "/w/src/File10.java", - "displayPath": "src/File10.java", - "line": 4, - "column": 2, - "severity": 2, - "message": "Unused import", - "source": "java", - "code": "268435844" - }, - { - "fileKey": "/w/src/File2.java", - "displayPath": "src/File2.java", - "line": 9, + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, "column": 0, "severity": 1, - "message": "Type mismatch", - "source": "java", - "code": "16777233" - }, - { - "fileKey": "/w/src/File2.java", - "displayPath": "src/File2.java", - "line": 1, - "column": 5, - "severity": 3, - "message": "Consider final", + "message": "Missing return", "source": "java" }, { - "fileKey": "/w/README.md", - "displayPath": "README.md", - "line": 0, + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, "column": 0, - "severity": null, - "message": "Spelling", - "source": "cspell" - }, - { - "fileKey": "/w/src/File10.java", - "displayPath": "src/File10.java", - "line": 4, - "column": 2, "severity": 2, - "message": "Duplicate at the same position", + "message": "Unused variable", "source": "java" }, { - "fileKey": "/w/src/File2.java", - "displayPath": "src/File2.java", - "line": 1, - "column": 5, - "severity": 4, - "message": "Hint here", - "source": "Java" + "fileKey": "/w/B.java", + "displayPath": "B.java", + "line": 0, + "column": 4, + "severity": 2, + "message": "Raw type", + "source": "java" } ], - "groupBy": "none", - "filter": { - "query": "absent" - } + "collapsed": [ + "file:/w/src/A.java", + "file:/w/unknown.java" + ], + "selected": "diagnostic:3:0:1:/w/src/A.java" }, "response": { - "groups": [], - "files": [], + "groups": [ + { + "key": "file:/w/B.java", + "kind": "file", + "fileKey": "/w/B.java", + "displayPath": "B.java", + "name": "B.java", + "folder": "", + "indices": [ + 2 + ], + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "key": "file:/w/src/A.java", + "kind": "file", + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "name": "A.java", + "folder": "src", + "indices": [ + 0, + 1 + ], + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "files": [ + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "count": 1, + "highestSeverity": 2, + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "count": 2, + "highestSeverity": 1, + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], "visibleCounts": { - "error": 0, - "warning": 0, + "error": 1, + "warning": 2, "information": 0, "hint": 0, "unknown": 0 @@ -1210,34 +1579,903 @@ "totalCounts": { "error": 1, "warning": 2, - "information": 1, - "hint": 1, - "unknown": 1 - } - } - }, - { - "name": "empty input", - "request": { - "diagnostics": [] - }, - "response": { - "groups": [], - "files": [], - "visibleCounts": { - "error": 0, - "warning": 0, "information": 0, "hint": 0, "unknown": 0 }, - "totalCounts": { - "error": 0, - "warning": 0, - "information": 0, - "hint": 0, - "unknown": 0 - } + "rows": [ + { + "key": "file:/w/B.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 2 + }, + { + "key": "diagnostic:0:4:0:/w/B.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 2 + }, + { + "key": "file:/w/src/A.java", + "kind": "group", + "depth": 0, + "expanded": false, + "group": 1, + "shows": 0 + } + ], + "selected": "file:/w/src/A.java", + "selectedRow": 2 + } + }, + { + "name": "the selection follows a diagnostic the server republished at another index", + "request": { + "diagnostics": [ + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 1, + "column": 0, + "severity": 1, + "message": "New error", + "source": "java" + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 1, + "message": "Missing return", + "source": "java" + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 2, + "message": "Unused variable", + "source": "java" + }, + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "line": 0, + "column": 4, + "severity": 2, + "message": "Raw type", + "source": "java" + } + ], + "selected": "diagnostic:3:0:1:/w/src/A.java" + }, + "response": { + "groups": [ + { + "key": "file:/w/B.java", + "kind": "file", + "fileKey": "/w/B.java", + "displayPath": "B.java", + "name": "B.java", + "folder": "", + "indices": [ + 3 + ], + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "key": "file:/w/src/A.java", + "kind": "file", + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "name": "A.java", + "folder": "src", + "indices": [ + 0, + 1, + 2 + ], + "counts": { + "error": 2, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "files": [ + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "count": 1, + "highestSeverity": 2, + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "count": 3, + "highestSeverity": 1, + "counts": { + "error": 2, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "visibleCounts": { + "error": 2, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 2, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "rows": [ + { + "key": "file:/w/B.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 3 + }, + { + "key": "diagnostic:0:4:0:/w/B.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 3 + }, + { + "key": "file:/w/src/A.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:1:0:0:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:3:0:0:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 1 + }, + { + "key": "diagnostic:3:0:1:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 2 + } + ], + "selected": "diagnostic:3:0:1:/w/src/A.java", + "selectedRow": 5 + } + }, + { + "name": "a gone diagnostic selects its file node when the list is grouped by file", + "request": { + "diagnostics": [ + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 1, + "message": "Missing return", + "source": "java" + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 2, + "message": "Unused variable", + "source": "java" + }, + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "line": 0, + "column": 4, + "severity": 2, + "message": "Raw type", + "source": "java" + } + ], + "selected": "diagnostic:7:2:0:/w/src/A.java" + }, + "response": { + "groups": [ + { + "key": "file:/w/B.java", + "kind": "file", + "fileKey": "/w/B.java", + "displayPath": "B.java", + "name": "B.java", + "folder": "", + "indices": [ + 2 + ], + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "key": "file:/w/src/A.java", + "kind": "file", + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "name": "A.java", + "folder": "src", + "indices": [ + 0, + 1 + ], + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "files": [ + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "count": 1, + "highestSeverity": 2, + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "count": 2, + "highestSeverity": 1, + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "visibleCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "rows": [ + { + "key": "file:/w/B.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 2 + }, + { + "key": "diagnostic:0:4:0:/w/B.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 2 + }, + { + "key": "file:/w/src/A.java", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:3:0:0:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 0 + }, + { + "key": "diagnostic:3:0:1:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 1 + } + ], + "selected": "file:/w/src/A.java", + "selectedRow": 2 + } + }, + { + "name": "a gone diagnostic selects nothing when the list is grouped by severity", + "request": { + "diagnostics": [ + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 1, + "message": "Missing return", + "source": "java" + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 2, + "message": "Unused variable", + "source": "java" + }, + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "line": 0, + "column": 4, + "severity": 2, + "message": "Raw type", + "source": "java" + } + ], + "groupBy": "severity", + "selected": "diagnostic:7:2:0:/w/src/A.java" + }, + "response": { + "groups": [ + { + "key": "severity:1", + "kind": "severity", + "severity": 1, + "indices": [ + 0 + ], + "counts": { + "error": 1, + "warning": 0, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "key": "severity:2", + "kind": "severity", + "severity": 2, + "indices": [ + 2, + 1 + ], + "counts": { + "error": 0, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "files": [ + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "count": 1, + "highestSeverity": 2, + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "count": 2, + "highestSeverity": 1, + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "visibleCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "rows": [ + { + "key": "severity:1", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 0 + }, + { + "key": "diagnostic:3:0:0:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 0 + }, + { + "key": "severity:2", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 1, + "shows": 2 + }, + { + "key": "diagnostic:0:4:0:/w/B.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 2 + }, + { + "key": "diagnostic:3:0:1:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 1, + "shows": 1 + } + ] + } + }, + { + "name": "severity nodes close by key and keep a node selection", + "request": { + "diagnostics": [ + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 1, + "message": "Missing return", + "source": "java" + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 2, + "message": "Unused variable", + "source": "java" + }, + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "line": 0, + "column": 4, + "severity": 2, + "message": "Raw type", + "source": "java" + } + ], + "groupBy": "severity", + "collapsed": [ + "severity:2" + ], + "selected": "severity:2" + }, + "response": { + "groups": [ + { + "key": "severity:1", + "kind": "severity", + "severity": 1, + "indices": [ + 0 + ], + "counts": { + "error": 1, + "warning": 0, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "key": "severity:2", + "kind": "severity", + "severity": 2, + "indices": [ + 2, + 1 + ], + "counts": { + "error": 0, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "files": [ + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "count": 1, + "highestSeverity": 2, + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "count": 2, + "highestSeverity": 1, + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "visibleCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "rows": [ + { + "key": "severity:1", + "kind": "group", + "depth": 0, + "expanded": true, + "group": 0, + "shows": 0 + }, + { + "key": "diagnostic:3:0:0:/w/src/A.java", + "kind": "diagnostic", + "depth": 1, + "group": 0, + "shows": 0 + }, + { + "key": "severity:2", + "kind": "group", + "depth": 0, + "expanded": false, + "group": 1, + "shows": 2 + } + ], + "selected": "severity:2", + "selectedRow": 2 + } + }, + { + "name": "the ungrouped list ignores closed keys and selects only its diagnostics", + "request": { + "diagnostics": [ + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 1, + "message": "Missing return", + "source": "java" + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "line": 3, + "column": 0, + "severity": 2, + "message": "Unused variable", + "source": "java" + }, + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "line": 0, + "column": 4, + "severity": 2, + "message": "Raw type", + "source": "java" + } + ], + "groupBy": "none", + "collapsed": [ + "all", + "file:/w/src/A.java" + ], + "selected": "all" + }, + "response": { + "groups": [ + { + "key": "all", + "kind": "all", + "indices": [ + 0, + 2, + 1 + ], + "counts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "files": [ + { + "fileKey": "/w/B.java", + "displayPath": "B.java", + "count": 1, + "highestSeverity": 2, + "counts": { + "error": 0, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + }, + { + "fileKey": "/w/src/A.java", + "displayPath": "src/A.java", + "count": 2, + "highestSeverity": 1, + "counts": { + "error": 1, + "warning": 1, + "information": 0, + "hint": 0, + "unknown": 0 + } + } + ], + "visibleCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 1, + "warning": 2, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "rows": [ + { + "key": "diagnostic:3:0:0:/w/src/A.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 0 + }, + { + "key": "diagnostic:0:4:0:/w/B.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 2 + }, + { + "key": "diagnostic:3:0:1:/w/src/A.java", + "kind": "diagnostic", + "depth": 0, + "group": 0, + "shows": 1 + } + ] + } + }, + { + "name": "no visible diagnostics produce no groups", + "request": { + "diagnostics": [ + { + "fileKey": "/w/src/File10.java", + "displayPath": "src/File10.java", + "line": 4, + "column": 2, + "severity": 2, + "message": "Unused import", + "source": "java", + "code": "268435844" + }, + { + "fileKey": "/w/src/File2.java", + "displayPath": "src/File2.java", + "line": 9, + "column": 0, + "severity": 1, + "message": "Type mismatch", + "source": "java", + "code": "16777233" + }, + { + "fileKey": "/w/src/File2.java", + "displayPath": "src/File2.java", + "line": 1, + "column": 5, + "severity": 3, + "message": "Consider final", + "source": "java" + }, + { + "fileKey": "/w/README.md", + "displayPath": "README.md", + "line": 0, + "column": 0, + "severity": null, + "message": "Spelling", + "source": "cspell" + }, + { + "fileKey": "/w/src/File10.java", + "displayPath": "src/File10.java", + "line": 4, + "column": 2, + "severity": 2, + "message": "Duplicate at the same position", + "source": "java" + }, + { + "fileKey": "/w/src/File2.java", + "displayPath": "src/File2.java", + "line": 1, + "column": 5, + "severity": 4, + "message": "Hint here", + "source": "Java" + } + ], + "groupBy": "none", + "filter": { + "query": "absent" + } + }, + "response": { + "groups": [], + "files": [], + "visibleCounts": { + "error": 0, + "warning": 0, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 1, + "warning": 2, + "information": 1, + "hint": 1, + "unknown": 1 + }, + "rows": [] + } + }, + { + "name": "empty input", + "request": { + "diagnostics": [] + }, + "response": { + "groups": [], + "files": [], + "visibleCounts": { + "error": 0, + "warning": 0, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "totalCounts": { + "error": 0, + "warning": 0, + "information": 0, + "hint": 0, + "unknown": 0 + }, + "rows": [] } } ]