| OLD | NEW |
| 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.assist; | 5 library test.services.correction.assist; |
| 6 | 6 |
| 7 import 'package:analysis_server/edit/assist/assist_core.dart'; | 7 import 'package:analysis_server/edit/assist/assist_core.dart'; |
| 8 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 8 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/correction/assist.dart'; | 10 import 'package:analysis_server/src/services/correction/assist.dart'; |
| (...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 | 1332 |
| 1333 void test_convertToIsNotEmpty_wrong_notIsEmpty() { | 1333 void test_convertToIsNotEmpty_wrong_notIsEmpty() { |
| 1334 resolveTestUnit(''' | 1334 resolveTestUnit(''' |
| 1335 main(int p) { | 1335 main(int p) { |
| 1336 !p.isEven; | 1336 !p.isEven; |
| 1337 } | 1337 } |
| 1338 '''); | 1338 '''); |
| 1339 assertNoAssistAt('isEven;', DartAssistKind.CONVERT_INTO_IS_NOT_EMPTY); | 1339 assertNoAssistAt('isEven;', DartAssistKind.CONVERT_INTO_IS_NOT_EMPTY); |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 void test_convertToNormalParameter_OK_dynamic() { |
| 1343 resolveTestUnit(''' |
| 1344 class A { |
| 1345 var test; |
| 1346 A(this.test) { |
| 1347 } |
| 1348 } |
| 1349 '''); |
| 1350 assertHasAssistAt('test)', DartAssistKind.CONVERT_TO_NORMAL_PARAMETER, ''' |
| 1351 class A { |
| 1352 var test; |
| 1353 A(test) : test = test { |
| 1354 } |
| 1355 } |
| 1356 '''); |
| 1357 } |
| 1358 |
| 1359 void test_convertToNormalParameter_OK_firstInitializer() { |
| 1360 resolveTestUnit(''' |
| 1361 class A { |
| 1362 int test; |
| 1363 A(this.test) { |
| 1364 } |
| 1365 } |
| 1366 '''); |
| 1367 assertHasAssistAt('test)', DartAssistKind.CONVERT_TO_NORMAL_PARAMETER, ''' |
| 1368 class A { |
| 1369 int test; |
| 1370 A(int test) : test = test { |
| 1371 } |
| 1372 } |
| 1373 '''); |
| 1374 } |
| 1375 |
| 1376 void test_convertToNormalParameter_OK_secondInitializer() { |
| 1377 resolveTestUnit(''' |
| 1378 class A { |
| 1379 double aaa; |
| 1380 int bbb; |
| 1381 A(this.bbb) : aaa = 1.0; |
| 1382 } |
| 1383 '''); |
| 1384 assertHasAssistAt('bbb)', DartAssistKind.CONVERT_TO_NORMAL_PARAMETER, ''' |
| 1385 class A { |
| 1386 double aaa; |
| 1387 int bbb; |
| 1388 A(int bbb) : aaa = 1.0, bbb = bbb; |
| 1389 } |
| 1390 '''); |
| 1391 } |
| 1392 |
| 1342 void test_encapsulateField_BAD_alreadyPrivate() { | 1393 void test_encapsulateField_BAD_alreadyPrivate() { |
| 1343 resolveTestUnit(''' | 1394 resolveTestUnit(''' |
| 1344 class A { | 1395 class A { |
| 1345 int _test = 42; | 1396 int _test = 42; |
| 1346 } | 1397 } |
| 1347 main(A a) { | 1398 main(A a) { |
| 1348 print(a._test); | 1399 print(a._test); |
| 1349 } | 1400 } |
| 1350 '''); | 1401 '''); |
| 1351 assertNoAssistAt('_test =', DartAssistKind.ENCAPSULATE_FIELD); | 1402 assertNoAssistAt('_test =', DartAssistKind.ENCAPSULATE_FIELD); |
| (...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3082 positions.add(new Position(testFile, offset)); | 3133 positions.add(new Position(testFile, offset)); |
| 3083 } | 3134 } |
| 3084 return positions; | 3135 return positions; |
| 3085 } | 3136 } |
| 3086 | 3137 |
| 3087 void _setStartEndSelection() { | 3138 void _setStartEndSelection() { |
| 3088 offset = findOffset('// start\n') + '// start\n'.length; | 3139 offset = findOffset('// start\n') + '// start\n'.length; |
| 3089 length = findOffset('// end') - offset; | 3140 length = findOffset('// end') - offset; |
| 3090 } | 3141 } |
| 3091 } | 3142 } |
| OLD | NEW |