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

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

Issue 1086273002: Fix for linked position offsets when insert directly before. (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/fix_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.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/plugin/server_plugin.dart'; 8 import 'package:analysis_server/src/plugin/server_plugin.dart';
9 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; 9 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
10 import 'package:analysis_server/src/services/correction/fix.dart'; 10 import 'package:analysis_server/src/services/correction/fix.dart';
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 } 1286 }
1287 f(String p) {} 1287 f(String p) {}
1288 '''); 1288 ''');
1289 assertHasFix(DartFixKind.CREATE_LOCAL_VARIABLE, ''' 1289 assertHasFix(DartFixKind.CREATE_LOCAL_VARIABLE, '''
1290 main() { 1290 main() {
1291 String test; 1291 String test;
1292 f(test); 1292 f(test);
1293 } 1293 }
1294 f(String p) {} 1294 f(String p) {}
1295 '''); 1295 ''');
1296 _assertLinkedGroup(change.linkedEditGroups[0], ['String test;']);
1297 _assertLinkedGroup(change.linkedEditGroups[1], ['test;', 'test);']);
1298 }
1299
1300 void test_createLocalVariable_read_typeInvocationTarget() {
1301 resolveTestUnit('''
1302 main() {
1303 test.add('hello');
1304 }
1305 ''');
1306 assertHasFix(DartFixKind.CREATE_LOCAL_VARIABLE, '''
1307 main() {
1308 var test;
1309 test.add('hello');
1310 }
1311 ''');
1312 _assertLinkedGroup(change.linkedEditGroups[0], ['test;', 'test.add(']);
1296 } 1313 }
1297 1314
1298 void test_createLocalVariable_write_assignment() { 1315 void test_createLocalVariable_write_assignment() {
1299 resolveTestUnit(''' 1316 resolveTestUnit('''
1300 main() { 1317 main() {
1301 test = 42; 1318 test = 42;
1302 } 1319 }
1303 '''); 1320 ''');
1304 assertHasFix(DartFixKind.CREATE_LOCAL_VARIABLE, ''' 1321 assertHasFix(DartFixKind.CREATE_LOCAL_VARIABLE, '''
1305 main() { 1322 main() {
(...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 3546
3530 List<Position> _findResultPositions(List<String> searchStrings) { 3547 List<Position> _findResultPositions(List<String> searchStrings) {
3531 List<Position> positions = <Position>[]; 3548 List<Position> positions = <Position>[];
3532 for (String search in searchStrings) { 3549 for (String search in searchStrings) {
3533 int offset = resultCode.indexOf(search); 3550 int offset = resultCode.indexOf(search);
3534 positions.add(new Position(testFile, offset)); 3551 positions.add(new Position(testFile, offset));
3535 } 3552 }
3536 return positions; 3553 return positions;
3537 } 3554 }
3538 } 3555 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698