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

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

Issue 1013543002: Quick Fix for creating a missing part file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/src/protocol.dart' hide AnalysisError; 7 import 'package:analysis_server/src/protocol.dart' hide AnalysisError;
8 import 'package:analysis_server/src/services/correction/fix.dart'; 8 import 'package:analysis_server/src/services/correction/fix.dart';
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 change = fix.change; 852 change = fix.change;
853 // validate change 853 // validate change
854 List<SourceFileEdit> fileEdits = change.edits; 854 List<SourceFileEdit> fileEdits = change.edits;
855 expect(fileEdits, hasLength(1)); 855 expect(fileEdits, hasLength(1));
856 SourceFileEdit fileEdit = change.edits[0]; 856 SourceFileEdit fileEdit = change.edits[0];
857 expect(fileEdit.file, '/my/project/bin/my_file.dart'); 857 expect(fileEdit.file, '/my/project/bin/my_file.dart');
858 expect(fileEdit.fileStamp, -1); 858 expect(fileEdit.fileStamp, -1);
859 expect(fileEdit.edits[0].replacement, contains('library my.file;')); 859 expect(fileEdit.edits[0].replacement, contains('library my.file;'));
860 } 860 }
861 861
862 void test_createFile_forPart() {
863 testFile = '/my/project/bin/test.dart';
864 resolveTestUnit('''
865 library my.lib;
866 part 'my_part.dart';
867 ''');
868 AnalysisError error = _findErrorToFix();
869 fix = _assertHasFix(FixKind.CREATE_FILE, error);
870 change = fix.change;
871 // validate change
872 List<SourceFileEdit> fileEdits = change.edits;
873 expect(fileEdits, hasLength(1));
874 SourceFileEdit fileEdit = change.edits[0];
875 expect(fileEdit.file, '/my/project/bin/my_part.dart');
876 expect(fileEdit.fileStamp, -1);
877 expect(fileEdit.edits[0].replacement, contains('part of my.lib;'));
878 }
879
862 void test_createGetter_BAD_inSDK() { 880 void test_createGetter_BAD_inSDK() {
863 resolveTestUnit(''' 881 resolveTestUnit('''
864 main(List p) { 882 main(List p) {
865 int v = p.foo; 883 int v = p.foo;
866 } 884 }
867 '''); 885 ''');
868 assertNoFix(FixKind.CREATE_GETTER); 886 assertNoFix(FixKind.CREATE_GETTER);
869 } 887 }
870 888
871 void test_createGetter_multiLevel() { 889 void test_createGetter_multiLevel() {
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after
3222 3240
3223 List<Position> _findResultPositions(List<String> searchStrings) { 3241 List<Position> _findResultPositions(List<String> searchStrings) {
3224 List<Position> positions = <Position>[]; 3242 List<Position> positions = <Position>[];
3225 for (String search in searchStrings) { 3243 for (String search in searchStrings) {
3226 int offset = resultCode.indexOf(search); 3244 int offset = resultCode.indexOf(search);
3227 positions.add(new Position(testFile, offset)); 3245 positions.add(new Position(testFile, offset));
3228 } 3246 }
3229 return positions; 3247 return positions;
3230 } 3248 }
3231 } 3249 }
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