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

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 1018433002: Quick Fix for adding field formal parameters of not initialized final fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
8 import 'package:analysis_server/src/services/correction/fix.dart'; 8 import 'package:analysis_server/src/services/correction/fix.dart';
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return values.map((value) { 90 return values.map((value) {
91 return new LinkedEditSuggestion(value, kind); 91 return new LinkedEditSuggestion(value, kind);
92 }).toList(); 92 }).toList();
93 } 93 }
94 94
95 void setUp() { 95 void setUp() {
96 super.setUp(); 96 super.setUp();
97 verifyNoTestUnitErrors = false; 97 verifyNoTestUnitErrors = false;
98 } 98 }
99 99
100 void test_addFieldFormalParameters_hasRequiredParameter() {
101 resolveTestUnit('''
102 class Test {
103 final int a;
104 final int b;
105 final int c;
106 Test(this.a);
107 }
108 ''');
109 assertHasFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, '''
110 class Test {
111 final int a;
112 final int b;
113 final int c;
114 Test(this.a, this.b, this.c);
115 }
116 ''');
117 }
118
119 void test_addFieldFormalParameters_noParameters() {
120 resolveTestUnit('''
121 class Test {
122 final int a;
123 final int b;
124 final int c;
125 Test();
126 }
127 ''');
128 assertHasFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, '''
129 class Test {
130 final int a;
131 final int b;
132 final int c;
133 Test(this.a, this.b, this.c);
134 }
135 ''');
136 }
137
138 void test_addFieldFormalParameters_noRequiredParameter() {
139 resolveTestUnit('''
140 class Test {
141 final int a;
142 final int b;
143 final int c;
144 Test([this.c]);
145 }
146 ''');
147 assertHasFix(FixKind.ADD_FIELD_FORMAL_PARAMETERS, '''
148 class Test {
149 final int a;
150 final int b;
151 final int c;
152 Test(this.a, this.b, [this.c]);
153 }
154 ''');
155 }
156
100 void test_addSync_blockFunctionBody() { 157 void test_addSync_blockFunctionBody() {
101 resolveTestUnit(''' 158 resolveTestUnit('''
102 foo() {} 159 foo() {}
103 main() { 160 main() {
104 await foo(); 161 await foo();
105 } 162 }
106 '''); 163 ''');
107 List<AnalysisError> errors = context.computeErrors(testSource); 164 List<AnalysisError> errors = context.computeErrors(testSource);
108 expect(errors, hasLength(2)); 165 expect(errors, hasLength(2));
109 // ParserError: Expected to find ';' 166 // ParserError: Expected to find ';'
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 3321
3265 List<Position> _findResultPositions(List<String> searchStrings) { 3322 List<Position> _findResultPositions(List<String> searchStrings) {
3266 List<Position> positions = <Position>[]; 3323 List<Position> positions = <Position>[];
3267 for (String search in searchStrings) { 3324 for (String search in searchStrings) {
3268 int offset = resultCode.indexOf(search); 3325 int offset = resultCode.indexOf(search);
3269 positions.add(new Position(testFile, offset)); 3326 positions.add(new Position(testFile, offset));
3270 } 3327 }
3271 return positions; 3328 return positions;
3272 } 3329 }
3273 } 3330 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698