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

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

Issue 1375043004: Issue 24459. Fix for 'Create Method' QF in different unit. (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 unified diff | Download patch
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/edit/fix/fix_core.dart'; 7 import 'package:analysis_server/edit/fix/fix_core.dart';
8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
9 import 'package:analysis_server/src/services/correction/fix.dart'; 9 import 'package:analysis_server/src/services/correction/fix.dart';
10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; 10 import 'package:analysis_server/src/services/correction/fix_internal.dart';
(...skipping 4155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 void myUndefinedMethod() { 4166 void myUndefinedMethod() {
4167 } 4167 }
4168 } 4168 }
4169 main() { 4169 main() {
4170 var a = new A(); 4170 var a = new A();
4171 a.myUndefinedMethod(); 4171 a.myUndefinedMethod();
4172 } 4172 }
4173 '''); 4173 ''');
4174 } 4174 }
4175 4175
4176 void test_undefinedMethod_parameterType_differentPrefixInTargetUnit() {
4177 String code2 = r'''
4178 library test2;
4179 import 'test3.dart' as bbb;
4180 export 'test3.dart';
4181 class D {
4182 }
4183 ''';
4184 addSource('/test2.dart', code2);
4185 addSource(
4186 '/test3.dart',
4187 r'''
4188 library test3;
4189 class E {}
4190 ''');
4191 resolveTestUnit('''
4192 library test;
4193 import 'test2.dart' as aaa;
4194 main(aaa.D d, aaa.E e) {
4195 d.foo(e);
4196 }
4197 ''');
4198 AnalysisError error = _findErrorToFix();
4199 fix = _assertHasFix(DartFixKind.CREATE_METHOD, error);
4200 change = fix.change;
4201 // apply to "test2.dart"
4202 List<SourceFileEdit> fileEdits = change.edits;
4203 expect(fileEdits, hasLength(1));
4204 SourceFileEdit fileEdit = change.edits[0];
4205 expect(fileEdit.file, '/test2.dart');
4206 expect(
4207 SourceEdit.applySequence(code2, fileEdit.edits),
4208 r'''
4209 library test2;
4210 import 'test3.dart' as bbb;
4211 export 'test3.dart';
4212 class D {
4213 void foo(bbb.E e) {
4214 }
4215 }
4216 ''');
4217 }
4218
4219 void test_undefinedMethod_parameterType_inTargetUnit() {
4220 String code2 = r'''
4221 library test2;
4222 class D {
4223 }
4224 class E {}
4225 ''';
4226 addSource('/test2.dart', code2);
4227 resolveTestUnit('''
4228 library test;
4229 import 'test2.dart' as test2;
4230 main(test2.D d, test2.E e) {
4231 d.foo(e);
4232 }
4233 ''');
4234 AnalysisError error = _findErrorToFix();
4235 fix = _assertHasFix(DartFixKind.CREATE_METHOD, error);
4236 change = fix.change;
4237 // apply to "test2.dart"
4238 List<SourceFileEdit> fileEdits = change.edits;
4239 expect(fileEdits, hasLength(1));
4240 SourceFileEdit fileEdit = change.edits[0];
4241 expect(fileEdit.file, '/test2.dart');
4242 expect(
4243 SourceEdit.applySequence(code2, fileEdit.edits),
4244 r'''
4245 library test2;
4246 class D {
4247 void foo(E e) {
4248 }
4249 }
4250 class E {}
4251 ''');
4252 }
4253
4176 void test_undefinedMethod_useSimilar_ignoreOperators() { 4254 void test_undefinedMethod_useSimilar_ignoreOperators() {
4177 resolveTestUnit(''' 4255 resolveTestUnit('''
4178 main(Object object) { 4256 main(Object object) {
4179 object.then(); 4257 object.then();
4180 } 4258 }
4181 '''); 4259 ''');
4182 assertNoFix(DartFixKind.CHANGE_TO); 4260 assertNoFix(DartFixKind.CHANGE_TO);
4183 } 4261 }
4184 4262
4185 void test_undefinedMethod_useSimilar_qualified() { 4263 void test_undefinedMethod_useSimilar_qualified() {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
4435 int offset = resultCode.indexOf(search); 4513 int offset = resultCode.indexOf(search);
4436 positions.add(new Position(testFile, offset)); 4514 positions.add(new Position(testFile, offset));
4437 } 4515 }
4438 return positions; 4516 return positions;
4439 } 4517 }
4440 4518
4441 void _performAnalysis() { 4519 void _performAnalysis() {
4442 while (context.performAnalysisTask().hasMoreWork); 4520 while (context.performAnalysisTask().hasMoreWork);
4443 } 4521 }
4444 } 4522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698