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

Side by Side Diff: pkg/analysis_services/test/correction/fix_test.dart

Issue 414273002: New 'use similar' fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library test.services.correction.fix; 8 library test.services.correction.fix;
9 9
10 import 'package:analysis_services/correction/change.dart'; 10 import 'package:analysis_services/correction/change.dart';
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 assertHasFix(FixKind.CREATE_FUNCTION, ''' 1182 assertHasFix(FixKind.CREATE_FUNCTION, '''
1183 main() { 1183 main() {
1184 myUndefinedFunction(); 1184 myUndefinedFunction();
1185 } 1185 }
1186 1186
1187 void myUndefinedFunction() { 1187 void myUndefinedFunction() {
1188 } 1188 }
1189 '''); 1189 ''');
1190 } 1190 }
1191 1191
1192 void test_undefinedFunction_useSimilar_fromImport() {
1193 _indexTestUnit('''
1194 main() {
1195 pritn(0);
1196 }
1197 ''');
1198 assertHasFix(FixKind.CHANGE_TO, '''
1199 main() {
1200 print(0);
1201 }
1202 ''');
1203 }
1204
1205 void test_undefinedFunction_useSimilar_thisLibrary() {
1206 _indexTestUnit('''
1207 myFunction() {}
1208 main() {
1209 myFuntcion();
1210 }
1211 ''');
1212 assertHasFix(FixKind.CHANGE_TO, '''
1213 myFunction() {}
1214 main() {
1215 myFunction();
1216 }
1217 ''');
1218 }
1219
1192 void test_undefinedMethod_createQualified_fromClass() { 1220 void test_undefinedMethod_createQualified_fromClass() {
1193 _indexTestUnit(''' 1221 _indexTestUnit('''
1194 class A { 1222 class A {
1195 } 1223 }
1196 main() { 1224 main() {
1197 A.myUndefinedMethod(); 1225 A.myUndefinedMethod();
1198 } 1226 }
1199 '''); 1227 ''');
1200 assertHasFix(FixKind.CREATE_METHOD, ''' 1228 assertHasFix(FixKind.CREATE_METHOD, '''
1201 class A { 1229 class A {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 void myUndefinedMethod() { 1408 void myUndefinedMethod() {
1381 } 1409 }
1382 } 1410 }
1383 main() { 1411 main() {
1384 var a = new A(); 1412 var a = new A();
1385 a.myUndefinedMethod(); 1413 a.myUndefinedMethod();
1386 } 1414 }
1387 '''); 1415 ''');
1388 } 1416 }
1389 1417
1418 void test_undefinedMethod_useSimilar_ignoreOperators() {
1419 _indexTestUnit('''
1420 main(Object object) {
1421 object.then();
1422 }
1423 ''');
1424 assertNoFix(FixKind.CHANGE_TO);
1425 }
1426
1427 void test_undefinedMethod_useSimilar_qualified() {
1428 _indexTestUnit('''
1429 class A {
1430 myMethod() {}
1431 }
1432 main() {
1433 A a = new A();
1434 a.myMehtod();
1435 }
1436 ''');
1437 assertHasFix(FixKind.CHANGE_TO, '''
1438 class A {
1439 myMethod() {}
1440 }
1441 main() {
1442 A a = new A();
1443 a.myMethod();
1444 }
1445 ''');
1446 }
1447
1448 void test_undefinedClass_useSimilar_fromThisLibrary() {
1449 _indexTestUnit('''
1450 class MyClass {}
1451 main() {
1452 MyCalss v = null;
1453 }
1454 ''');
1455 assertHasFix(FixKind.CHANGE_TO, '''
1456 class MyClass {}
1457 main() {
1458 MyClass v = null;
1459 }
1460 ''');
1461 }
1462
1463 void test_undefinedClass_useSimilar_fromImport() {
1464 _indexTestUnit('''
1465 main() {
1466 Stirng s = 'abc';
1467 }
1468 ''');
1469 assertHasFix(FixKind.CHANGE_TO, '''
1470 main() {
1471 String s = 'abc';
1472 }
1473 ''');
1474 }
1475
1476 void test_undefinedMethod_useSimilar_unqualified_superClass() {
1477 _indexTestUnit('''
1478 class A {
1479 myMethod() {}
1480 }
1481 class B extends A {
1482 main() {
1483 myMehtod();
1484 }
1485 }
1486 ''');
1487 assertHasFix(FixKind.CHANGE_TO, '''
1488 class A {
1489 myMethod() {}
1490 }
1491 class B extends A {
1492 main() {
1493 myMethod();
1494 }
1495 }
1496 ''');
1497 }
1498
1499 void test_undefinedMethod_useSimilar_unqualified_thisClass() {
1500 _indexTestUnit('''
1501 class A {
1502 myMethod() {}
1503 main() {
1504 myMehtod();
1505 }
1506 }
1507 ''');
1508 assertHasFix(FixKind.CHANGE_TO, '''
1509 class A {
1510 myMethod() {}
1511 main() {
1512 myMethod();
1513 }
1514 }
1515 ''');
1516 }
1517
1390 void test_useEffectiveIntegerDivision() { 1518 void test_useEffectiveIntegerDivision() {
1391 _indexTestUnit(''' 1519 _indexTestUnit('''
1392 main() { 1520 main() {
1393 var a = 5; 1521 var a = 5;
1394 var b = 2; 1522 var b = 2;
1395 print((a / b).toInt()); 1523 print((a / b).toInt());
1396 } 1524 }
1397 '''); 1525 ''');
1398 assertHasFix(FixKind.USE_EFFECTIVE_INTEGER_DIVISION, ''' 1526 assertHasFix(FixKind.USE_EFFECTIVE_INTEGER_DIVISION, '''
1399 main() { 1527 main() {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 positions.add(new Position(testFile, offset, length)); 1597 positions.add(new Position(testFile, offset, length));
1470 } 1598 }
1471 return positions; 1599 return positions;
1472 } 1600 }
1473 1601
1474 void _indexTestUnit(String code) { 1602 void _indexTestUnit(String code) {
1475 resolveTestUnit(code); 1603 resolveTestUnit(code);
1476 index.indexUnit(context, testUnit); 1604 index.indexUnit(context, testUnit);
1477 } 1605 }
1478 } 1606 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698