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

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

Issue 1147543002: [WEB-16445] When create a missing imported library/part, add the edit once. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/protocol.dart' hide AnalysisError; 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
9 import 'package:analysis_server/src/services/correction/fix.dart'; 9 import 'package:analysis_server/src/services/correction/fix.dart';
10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; 10 import 'package:analysis_server/src/services/correction/fix_internal.dart';
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 '''); 1048 ''');
1049 AnalysisError error = _findErrorToFix(); 1049 AnalysisError error = _findErrorToFix();
1050 fix = _assertHasFix(DartFixKind.CREATE_FILE, error); 1050 fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
1051 change = fix.change; 1051 change = fix.change;
1052 // validate change 1052 // validate change
1053 List<SourceFileEdit> fileEdits = change.edits; 1053 List<SourceFileEdit> fileEdits = change.edits;
1054 expect(fileEdits, hasLength(1)); 1054 expect(fileEdits, hasLength(1));
1055 SourceFileEdit fileEdit = change.edits[0]; 1055 SourceFileEdit fileEdit = change.edits[0];
1056 expect(fileEdit.file, '/my/project/bin/my_file.dart'); 1056 expect(fileEdit.file, '/my/project/bin/my_file.dart');
1057 expect(fileEdit.fileStamp, -1); 1057 expect(fileEdit.fileStamp, -1);
1058 expect(fileEdit.edits, hasLength(1));
1058 expect(fileEdit.edits[0].replacement, contains('library my.file;')); 1059 expect(fileEdit.edits[0].replacement, contains('library my.file;'));
1059 } 1060 }
1060 1061
1061 void test_createFile_forPart() { 1062 void test_createFile_forPart() {
1062 testFile = '/my/project/bin/test.dart'; 1063 testFile = '/my/project/bin/test.dart';
1063 resolveTestUnit(''' 1064 resolveTestUnit('''
1064 library my.lib; 1065 library my.lib;
1065 part 'my_part.dart'; 1066 part 'my_part.dart';
1066 '''); 1067 ''');
1067 AnalysisError error = _findErrorToFix(); 1068 AnalysisError error = _findErrorToFix();
1068 fix = _assertHasFix(DartFixKind.CREATE_FILE, error); 1069 fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
1069 change = fix.change; 1070 change = fix.change;
1070 // validate change 1071 // validate change
1071 List<SourceFileEdit> fileEdits = change.edits; 1072 List<SourceFileEdit> fileEdits = change.edits;
1072 expect(fileEdits, hasLength(1)); 1073 expect(fileEdits, hasLength(1));
1073 SourceFileEdit fileEdit = change.edits[0]; 1074 SourceFileEdit fileEdit = change.edits[0];
1074 expect(fileEdit.file, '/my/project/bin/my_part.dart'); 1075 expect(fileEdit.file, '/my/project/bin/my_part.dart');
1075 expect(fileEdit.fileStamp, -1); 1076 expect(fileEdit.fileStamp, -1);
1077 expect(fileEdit.edits, hasLength(1));
1076 expect(fileEdit.edits[0].replacement, contains('part of my.lib;')); 1078 expect(fileEdit.edits[0].replacement, contains('part of my.lib;'));
1077 } 1079 }
1078 1080
1079 void test_createGetter_BAD_inSDK() { 1081 void test_createGetter_BAD_inSDK() {
1080 resolveTestUnit(''' 1082 resolveTestUnit('''
1081 main(List p) { 1083 main(List p) {
1082 int v = p.foo; 1084 int v = p.foo;
1083 } 1085 }
1084 '''); 1086 ''');
1085 assertNoFix(DartFixKind.CREATE_GETTER); 1087 assertNoFix(DartFixKind.CREATE_GETTER);
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 3645
3644 List<Position> _findResultPositions(List<String> searchStrings) { 3646 List<Position> _findResultPositions(List<String> searchStrings) {
3645 List<Position> positions = <Position>[]; 3647 List<Position> positions = <Position>[];
3646 for (String search in searchStrings) { 3648 for (String search in searchStrings) {
3647 int offset = resultCode.indexOf(search); 3649 int offset = resultCode.indexOf(search);
3648 positions.add(new Position(testFile, offset)); 3650 positions.add(new Position(testFile, offset));
3649 } 3651 }
3650 return positions; 3652 return positions;
3651 } 3653 }
3652 } 3654 }
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