Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 1423993005: Quick Fix for CAN_BE_NULL_AFTER_NULL_AWARE. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/services/correction/fix_test.dart
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index 14f2fc8811e317029f828a76b90c4914250ce2df..3a8c20cd20fb7e5665a0270dec991f9403ad2ecb 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -398,6 +398,51 @@ main() {
''');
}
+ void test_canBeNullAfterNullAware_chain() {
+ resolveTestUnit('''
+main(x) {
+ x?.a.b.c;
+}
+''');
+ assertHasFix(
+ DartFixKind.REPLACE_WITH_NULL_AWARE,
+ '''
+main(x) {
+ x?.a?.b?.c;
+}
+''');
+ }
+
+ void test_canBeNullAfterNullAware_methodInvocation() {
+ resolveTestUnit('''
+main(x) {
+ x?.a.b();
+}
+''');
+ assertHasFix(
+ DartFixKind.REPLACE_WITH_NULL_AWARE,
+ '''
+main(x) {
+ x?.a?.b();
+}
+''');
+ }
+
+ void test_canBeNullAfterNullAware_propertyAccess() {
+ resolveTestUnit('''
+main(x) {
+ x?.a().b;
+}
+''');
+ assertHasFix(
+ DartFixKind.REPLACE_WITH_NULL_AWARE,
+ '''
+main(x) {
+ x?.a()?.b;
+}
+''');
+ }
+
void test_changeToStaticAccess_method() {
resolveTestUnit('''
class A {

Powered by Google App Engine
This is Rietveld 408576698