[analysis_server] Always show TODOs via LSP if configured as warning/error

See https://github.com/dart-lang/sdk/issues/49061.

Change-Id: I6113acf9712502669b199ab1269f39ea7a1d2df4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245543
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
index 5f2e759..7164122 100644
--- a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
+++ b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
@@ -1019,9 +1019,18 @@
   }
 
   bool _shouldSendError(protocol.AnalysisError error) {
+    // Non-TODOs are always shown.
     if (error.type.name != ErrorType.TODO.name) {
       return true;
     }
+
+    // TODOs that are upgraded from INFO are always shown.
+    if (error.severity.name != ErrorSeverity.INFO.name) {
+      return true;
+    }
+
+    // Otherwise, show TODOs based on client configuration (either showing all,
+    // or specific types of TODOs).
     if (analysisServer.clientConfiguration.global.showAllTodos) {
       return true;
     }
diff --git a/pkg/analysis_server/test/lsp/diagnostic_test.dart b/pkg/analysis_server/test/lsp/diagnostic_test.dart
index a825b00..994943f 100644
--- a/pkg/analysis_server/test/lsp/diagnostic_test.dart
+++ b/pkg/analysis_server/test/lsp/diagnostic_test.dart
@@ -444,6 +444,31 @@
     await verifyDiagnostics('final dynamicbar;');
   }
 
+  Future<void> test_todos_asWarnings() async {
+    newFile(analysisOptionsPath, '''
+analyzer:
+  errors:
+    # Increase the severity of TODOs.
+    todo: warning
+    fixme: warning
+''');
+
+    const contents = '''
+    // TODO: This
+    // FIXME: This
+    String a = "";
+    ''';
+    newFile(mainFilePath, contents);
+
+    final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
+    // Don't set showTodos in config, because they should show even without this
+    // setting if they are upgraded to warnings/errors.
+    await initialize();
+    final initialDiagnostics = await firstDiagnosticsUpdate;
+    expect(initialDiagnostics, hasLength(2));
+    expect(initialDiagnostics!.map((d) => d.code).toSet(), {'todo', 'fixme'});
+  }
+
   Future<void> test_todos_boolean() async {
     // TODOs only show up if there's also some code in the file.
     const contents = '''