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

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

Issue 1051733003: Fix removing type annotations for const/final variables. (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 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 int v = 1; 2317 int v = 1;
2318 } 2318 }
2319 '''); 2319 ''');
2320 assertHasAssistAt('v = ', AssistKind.REMOVE_TYPE_ANNOTATION, ''' 2320 assertHasAssistAt('v = ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2321 class A { 2321 class A {
2322 var v = 1; 2322 var v = 1;
2323 } 2323 }
2324 '''); 2324 ''');
2325 } 2325 }
2326 2326
2327 void test_removeTypeAnnotation_classField_OK_final() {
2328 resolveTestUnit('''
2329 class A {
2330 final int v = 1;
2331 }
2332 ''');
2333 assertHasAssistAt('v = ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2334 class A {
2335 final v = 1;
2336 }
2337 ''');
2338 }
2339
2327 void test_removeTypeAnnotation_localVariable_OK() { 2340 void test_removeTypeAnnotation_localVariable_OK() {
2328 resolveTestUnit(''' 2341 resolveTestUnit('''
2329 main() { 2342 main() {
2330 int a = 1, b = 2; 2343 int a = 1, b = 2;
2331 } 2344 }
2332 '''); 2345 ''');
2333 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, ''' 2346 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2334 main() { 2347 main() {
2335 var a = 1, b = 2; 2348 var a = 1, b = 2;
2336 } 2349 }
2337 '''); 2350 ''');
2338 } 2351 }
2339 2352
2353 void test_removeTypeAnnotation_localVariable_OK_const() {
2354 resolveTestUnit('''
2355 main() {
2356 const int v = 1;
2357 }
2358 ''');
2359 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2360 main() {
2361 const v = 1;
2362 }
2363 ''');
2364 }
2365
2366 void test_removeTypeAnnotation_localVariable_OK_final() {
2367 resolveTestUnit('''
2368 main() {
2369 final int v = 1;
2370 }
2371 ''');
2372 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2373 main() {
2374 final v = 1;
2375 }
2376 ''');
2377 }
2378
2340 void test_removeTypeAnnotation_topLevelVariable_OK() { 2379 void test_removeTypeAnnotation_topLevelVariable_OK() {
2341 resolveTestUnit(''' 2380 resolveTestUnit('''
2342 int V = 1; 2381 int V = 1;
2343 '''); 2382 ''');
2344 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, ''' 2383 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2345 var V = 1; 2384 var V = 1;
2346 '''); 2385 ''');
2347 } 2386 }
2348 2387
2388 void test_removeTypeAnnotation_topLevelVariable_OK_final() {
2389 resolveTestUnit('''
2390 final int V = 1;
2391 ''');
2392 assertHasAssistAt('int ', AssistKind.REMOVE_TYPE_ANNOTATION, '''
2393 final V = 1;
2394 ''');
2395 }
2396
2349 void test_replaceConditionalWithIfElse_OK_assignment() { 2397 void test_replaceConditionalWithIfElse_OK_assignment() {
2350 resolveTestUnit(''' 2398 resolveTestUnit('''
2351 main() { 2399 main() {
2352 var v; 2400 var v;
2353 v = true ? 111 : 222; 2401 v = true ? 111 : 222;
2354 } 2402 }
2355 '''); 2403 ''');
2356 // on conditional 2404 // on conditional
2357 assertHasAssistAt('11 :', AssistKind.REPLACE_CONDITIONAL_WITH_IF_ELSE, ''' 2405 assertHasAssistAt('11 :', AssistKind.REPLACE_CONDITIONAL_WITH_IF_ELSE, '''
2358 main() { 2406 main() {
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 positions.add(new Position(testFile, offset)); 2939 positions.add(new Position(testFile, offset));
2892 } 2940 }
2893 return positions; 2941 return positions;
2894 } 2942 }
2895 2943
2896 void _setStartEndSelection() { 2944 void _setStartEndSelection() {
2897 offset = findOffset('// start\n') + '// start\n'.length; 2945 offset = findOffset('// start\n') + '// start\n'.length;
2898 length = findOffset('// end') - offset; 2946 length = findOffset('// end') - offset;
2899 } 2947 }
2900 } 2948 }
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