Improve "why not promoted" context message for the case of writes.

The new message phrasing should flow better, especially in the analyzer CLI.

For the motivation for this change, please see
https://github.com/dart-lang/sdk/issues/44904#issuecomment-776286501

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I595492c64b42aff25cae5a8936c32aa8a218edd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
index b372ad4..c8e1eff 100644
--- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
@@ -9665,15 +9665,13 @@
         r"""Try removing the keyword 'var', or replacing it with the name of the return type.""");
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
-const Template<
-    Message Function(
-        String
-            name)> templateVariableCouldBeNullDueToWrite = const Template<
-        Message Function(String name)>(
-    messageTemplate:
-        r"""Variable '#name' could be null due to a write occurring here.""",
-    tipTemplate: r"""Try null checking the variable after the write.""",
-    withArguments: _withArgumentsVariableCouldBeNullDueToWrite);
+const Template<Message Function(String name)>
+    templateVariableCouldBeNullDueToWrite =
+    const Template<Message Function(String name)>(
+        messageTemplate:
+            r"""Variable '#name' could be null due to an intervening write.""",
+        tipTemplate: r"""Try null checking the variable after the write.""",
+        withArguments: _withArgumentsVariableCouldBeNullDueToWrite);
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const Code<Message Function(String name)> codeVariableCouldBeNullDueToWrite =
@@ -9687,7 +9685,7 @@
   name = demangleMixinApplicationName(name);
   return new Message(codeVariableCouldBeNullDueToWrite,
       message:
-          """Variable '${name}' could be null due to a write occurring here.""",
+          """Variable '${name}' could be null due to an intervening write.""",
       tip: """Try null checking the variable after the write.""",
       arguments: {'name': name});
 }
diff --git a/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
index 65bef9a..d6204de 100644
--- a/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/type_property_resolver.dart
@@ -392,8 +392,8 @@
       String variableName, Expression writeExpression) {
     return DiagnosticMessageImpl(
         filePath: source.fullName,
-        message:
-            "Variable '$variableName' could be null due to a write occurring here.",
+        message: "Variable '$variableName' could be null due to an intervening "
+            "write.",
         offset: writeExpression.offset,
         length: writeExpression.length);
   }
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index 5d8cdd8..2ec9981 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -4589,7 +4589,7 @@
   analyzerCode: ParserErrorCode.MULTIPLE_VARIANCE_MODIFIERS
 
 VariableCouldBeNullDueToWrite:
-  template: "Variable '#name' could be null due to a write occurring here."
+  template: "Variable '#name' could be null due to an intervening write."
   tip: "Try null checking the variable after the write."
 
 FieldNotPromoted:
diff --git a/pkg/front_end/test/spell_checking_list_messages.txt b/pkg/front_end/test/spell_checking_list_messages.txt
index 04eb66f..be9adce 100644
--- a/pkg/front_end/test/spell_checking_list_messages.txt
+++ b/pkg/front_end/test/spell_checking_list_messages.txt
@@ -36,6 +36,7 @@
 h
 https
 interop
+intervening
 js_util
 libraries.json
 list.filled