D.Source = Diag::DiagSource::Clangd;
D.File = AST.tuPath();
D.InsideMainFile = true;
- D.Severity = DiagnosticsEngine::Warning;
+ // We avoid the "warning" severity here in favor of LSP's "information".
+ //
+ // Users treat most warnings on code being edited as high-priority.
+ // They don't think of include cleanups the same way: they want to edit
+ // lines with existing violations without fixing them.
+ // Diagnostics at the same level tend to be visually indistinguishable,
+ // and a few missing includes can cause many diagnostics.
+ // Marking these as "information" leaves them visible, but less intrusive.
+ //
+ // (These concerns don't apply to unused #include warnings: these are fewer,
+ // they appear on infrequently-edited lines with few other warnings, and
+ // the 'Unneccesary' tag often result in a different rendering)
+ //
+ // Usually clang's "note" severity usually has special semantics, being
+ // translated into LSP RelatedInformation of a parent diagnostic.
+ // But not here: these aren't processed by clangd's DiagnosticConsumer.
+ D.Severity = DiagnosticsEngine::Note;
D.Range = clangd::Range{
offsetToPosition(Code,
SymbolWithMissingInclude.SymRefRange.beginOffset()),
# CHECK-NEXT: "line": 2
# CHECK-NEXT: }
# CHECK-NEXT: },
-# CHECK-NEXT: "severity": 2,
+# CHECK-NEXT: "severity": 3,
# CHECK-NEXT: "source": "clangd"
# CHECK-NEXT: },
# CHECK-NEXT: {
# CHECK-NEXT: "line": 2
# CHECK-NEXT: }
# CHECK-NEXT: },
-# CHECK-NEXT: "severity": 2,
+# CHECK-NEXT: "severity": 3,
# CHECK-NEXT: "source": "clangd"
# CHECK-NEXT: },
# CHECK-NEXT: {
# CHECK-NEXT: "version": 0
# CHECK-NEXT: }
---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///simple.cpp"},"range":{"start":{"line":2,"character":1},"end":{"line":2,"character":4}},"context":{"diagnostics":[{"range":{"start": {"line": 2, "character": 1}, "end": {"line": 2, "character": 4}},"severity":2,"message":"No header providing \"Foo\" is directly included (fixes available)", "code": "missing-includes", "source": "clangd"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///simple.cpp"},"range":{"start":{"line":2,"character":1},"end":{"line":2,"character":4}},"context":{"diagnostics":[{"range":{"start": {"line": 2, "character": 1}, "end": {"line": 2, "character": 4}},"severity":3,"message":"No header providing \"Foo\" is directly included (fixes available)", "code": "missing-includes", "source": "clangd"}]}}}
# CHECK: "id": 2,
# CHECK-NEXT: "jsonrpc": "2.0",
# CHECK-NEXT: "result": [