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

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

Issue 1066913002: Tweaks for 'Encapsulate Field' assist. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/assist_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.assist; 5 library test.services.correction.assist;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/correction/assist.dart'; 8 import 'package:analysis_server/src/services/correction/assist.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 class A { 1335 class A {
1336 int _test = 42; 1336 int _test = 42;
1337 } 1337 }
1338 main(A a) { 1338 main(A a) {
1339 print(a._test); 1339 print(a._test);
1340 } 1340 }
1341 '''); 1341 ''');
1342 assertNoAssistAt('_test =', AssistKind.ENCAPSULATE_FIELD); 1342 assertNoAssistAt('_test =', AssistKind.ENCAPSULATE_FIELD);
1343 } 1343 }
1344 1344
1345 void test_encapsulateField_BAD_final() {
1346 resolveTestUnit('''
1347 class A {
1348 final int test = 42;
1349 }
1350 ''');
1351 assertNoAssistAt('test =', AssistKind.ENCAPSULATE_FIELD);
1352 }
1353
1345 void test_encapsulateField_BAD_multipleFields() { 1354 void test_encapsulateField_BAD_multipleFields() {
1346 resolveTestUnit(''' 1355 resolveTestUnit('''
1347 class A { 1356 class A {
1348 int aaa, bbb, ccc; 1357 int aaa, bbb, ccc;
1349 } 1358 }
1350 main(A a) { 1359 main(A a) {
1351 print(a.bbb); 1360 print(a.bbb);
1352 } 1361 }
1353 '''); 1362 ''');
1354 assertNoAssistAt('bbb, ', AssistKind.ENCAPSULATE_FIELD); 1363 assertNoAssistAt('bbb, ', AssistKind.ENCAPSULATE_FIELD);
1355 } 1364 }
1356 1365
1366 void test_encapsulateField_BAD_notOnName() {
1367 resolveTestUnit('''
1368 class A {
1369 int test = 1 + 2 + 3;
1370 }
1371 ''');
1372 assertNoAssistAt('+ 2', AssistKind.ENCAPSULATE_FIELD);
1373 }
1374
1357 void test_encapsulateField_BAD_parseError() { 1375 void test_encapsulateField_BAD_parseError() {
1358 verifyNoTestUnitErrors = false; 1376 verifyNoTestUnitErrors = false;
1359 resolveTestUnit(''' 1377 resolveTestUnit('''
1360 class A { 1378 class A {
1361 int; // marker 1379 int; // marker
1362 } 1380 }
1363 main(A a) { 1381 main(A a) {
1364 print(a.test); 1382 print(a.test);
1365 } 1383 }
1366 '''); 1384 ''');
1367 assertNoAssistAt('; // marker', AssistKind.ENCAPSULATE_FIELD); 1385 assertNoAssistAt('; // marker', AssistKind.ENCAPSULATE_FIELD);
1368 } 1386 }
1369 1387
1388 void test_encapsulateField_BAD_static() {
1389 resolveTestUnit('''
1390 class A {
1391 static int test = 42;
1392 }
1393 ''');
1394 assertNoAssistAt('test =', AssistKind.ENCAPSULATE_FIELD);
1395 }
1396
1370 void test_encapsulateField_OK_hasType() { 1397 void test_encapsulateField_OK_hasType() {
1371 resolveTestUnit(''' 1398 resolveTestUnit('''
1372 class A { 1399 class A {
1373 int test = 42; 1400 int test = 42;
1401 A(this.test);
1374 } 1402 }
1375 main(A a) { 1403 main(A a) {
1376 print(a.test); 1404 print(a.test);
1377 } 1405 }
1378 '''); 1406 ''');
1379 assertHasAssistAt('test = 42', AssistKind.ENCAPSULATE_FIELD, ''' 1407 assertHasAssistAt('test = 42', AssistKind.ENCAPSULATE_FIELD, '''
1380 class A { 1408 class A {
1381 int _test = 42; 1409 int _test = 42;
1382 1410
1383 int get test => _test; 1411 int get test => _test;
1384 1412
1385 void set test(int test) { 1413 void set test(int test) {
1386 _test = test; 1414 _test = test;
1387 } 1415 }
1416 A(this._test);
1388 } 1417 }
1389 main(A a) { 1418 main(A a) {
1390 print(a.test); 1419 print(a.test);
1391 } 1420 }
1392 '''); 1421 ''');
1393 } 1422 }
1394 1423
1395 void test_encapsulateField_OK_noType() { 1424 void test_encapsulateField_OK_noType() {
1396 resolveTestUnit(''' 1425 resolveTestUnit('''
1397 class A { 1426 class A {
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 positions.add(new Position(testFile, offset)); 3065 positions.add(new Position(testFile, offset));
3037 } 3066 }
3038 return positions; 3067 return positions;
3039 } 3068 }
3040 3069
3041 void _setStartEndSelection() { 3070 void _setStartEndSelection() {
3042 offset = findOffset('// start\n') + '// start\n'.length; 3071 offset = findOffset('// start\n') + '// start\n'.length;
3043 length = findOffset('// end') - offset; 3072 length = findOffset('// end') - offset;
3044 } 3073 }
3045 } 3074 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698