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

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

Issue 1492843003: Don't attempt to create a file for non-Dart imports. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« 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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 // validate change 1486 // validate change
1487 List<SourceFileEdit> fileEdits = change.edits; 1487 List<SourceFileEdit> fileEdits = change.edits;
1488 expect(fileEdits, hasLength(1)); 1488 expect(fileEdits, hasLength(1));
1489 SourceFileEdit fileEdit = change.edits[0]; 1489 SourceFileEdit fileEdit = change.edits[0];
1490 expect(fileEdit.file, '/my/project/bin/my_file.dart'); 1490 expect(fileEdit.file, '/my/project/bin/my_file.dart');
1491 expect(fileEdit.fileStamp, -1); 1491 expect(fileEdit.fileStamp, -1);
1492 expect(fileEdit.edits, hasLength(1)); 1492 expect(fileEdit.edits, hasLength(1));
1493 expect(fileEdit.edits[0].replacement, contains('library my_file;')); 1493 expect(fileEdit.edits[0].replacement, contains('library my_file;'));
1494 } 1494 }
1495 1495
1496 test_createFile_forImport_BAD_inPackage_lib_justLib() async {
1497 provider.newFile('/projects/my_package/pubspec.yaml', 'name: my_package');
1498 testFile = '/projects/my_package/test.dart';
1499 resolveTestUnit('''
1500 import 'lib';
1501 ''');
1502 await assertNoFix(DartFixKind.CREATE_FILE);
1503 }
1504
1505 test_createFile_forImport_BAD_notDart() async {
1506 testFile = '/my/project/bin/test.dart';
1507 resolveTestUnit('''
1508 import 'my_file.txt';
1509 ''');
1510 await assertNoFix(DartFixKind.CREATE_FILE);
1511 }
1512
1496 test_createFile_forImport_inPackage_lib() async { 1513 test_createFile_forImport_inPackage_lib() async {
1497 provider.newFile('/projects/my_package/pubspec.yaml', 'name: my_package'); 1514 provider.newFile('/projects/my_package/pubspec.yaml', 'name: my_package');
1498 testFile = '/projects/my_package/lib/test.dart'; 1515 testFile = '/projects/my_package/lib/test.dart';
1499 provider.newFolder('/projects/my_package/lib'); 1516 provider.newFolder('/projects/my_package/lib');
1500 resolveTestUnit(''' 1517 resolveTestUnit('''
1501 import 'a/bb/c_cc/my_lib.dart'; 1518 import 'a/bb/c_cc/my_lib.dart';
1502 '''); 1519 ''');
1503 AnalysisError error = _findErrorToFix(); 1520 AnalysisError error = _findErrorToFix();
1504 fix = await _assertHasFix(DartFixKind.CREATE_FILE, error); 1521 fix = await _assertHasFix(DartFixKind.CREATE_FILE, error);
1505 change = fix.change; 1522 change = fix.change;
(...skipping 3200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4706 int offset = resultCode.indexOf(search); 4723 int offset = resultCode.indexOf(search);
4707 positions.add(new Position(testFile, offset)); 4724 positions.add(new Position(testFile, offset));
4708 } 4725 }
4709 return positions; 4726 return positions;
4710 } 4727 }
4711 4728
4712 void _performAnalysis() { 4729 void _performAnalysis() {
4713 while (context.performAnalysisTask().hasMoreWork); 4730 while (context.performAnalysisTask().hasMoreWork);
4714 } 4731 }
4715 } 4732 }
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