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

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

Issue 1253103007: WEB-17598. Name new libraries according to the Dart Style Guide. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 AnalysisError error = _findErrorToFix(); 1398 AnalysisError error = _findErrorToFix();
1399 fix = _assertHasFix(DartFixKind.CREATE_FILE, error); 1399 fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
1400 change = fix.change; 1400 change = fix.change;
1401 // validate change 1401 // validate change
1402 List<SourceFileEdit> fileEdits = change.edits; 1402 List<SourceFileEdit> fileEdits = change.edits;
1403 expect(fileEdits, hasLength(1)); 1403 expect(fileEdits, hasLength(1));
1404 SourceFileEdit fileEdit = change.edits[0]; 1404 SourceFileEdit fileEdit = change.edits[0];
1405 expect(fileEdit.file, '/my/project/bin/my_file.dart'); 1405 expect(fileEdit.file, '/my/project/bin/my_file.dart');
1406 expect(fileEdit.fileStamp, -1); 1406 expect(fileEdit.fileStamp, -1);
1407 expect(fileEdit.edits, hasLength(1)); 1407 expect(fileEdit.edits, hasLength(1));
1408 expect(fileEdit.edits[0].replacement, contains('library my.file;')); 1408 expect(fileEdit.edits[0].replacement, contains('library my_file;'));
1409 }
1410
1411 void test_createFile_forImport_inPackage_lib() {
1412 provider.newFile('/projects/my_package/pubspec.yaml', 'name: my_package');
1413 testFile = '/projects/my_package/lib/test.dart';
1414 provider.newFolder('/projects/my_package/lib');
1415 resolveTestUnit('''
1416 import 'a/bb/c_cc/my_lib.dart';
1417 ''');
1418 AnalysisError error = _findErrorToFix();
1419 fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
1420 change = fix.change;
1421 // validate change
1422 List<SourceFileEdit> fileEdits = change.edits;
1423 expect(fileEdits, hasLength(1));
1424 SourceFileEdit fileEdit = change.edits[0];
1425 expect(fileEdit.file, '/projects/my_package/lib/a/bb/c_cc/my_lib.dart');
1426 expect(fileEdit.fileStamp, -1);
1427 expect(fileEdit.edits, hasLength(1));
1428 expect(fileEdit.edits[0].replacement,
1429 contains('library my_package.a.bb.c_cc.my_lib;'));
1430 }
1431
1432 void test_createFile_forImport_inPackage_test() {
1433 provider.newFile('/projects/my_package/pubspec.yaml', 'name: my_package');
1434 testFile = '/projects/my_package/test/misc/test_all.dart';
1435 resolveTestUnit('''
1436 import 'a/bb/my_lib.dart';
1437 ''');
1438 AnalysisError error = _findErrorToFix();
1439 fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
1440 change = fix.change;
1441 // validate change
1442 List<SourceFileEdit> fileEdits = change.edits;
1443 expect(fileEdits, hasLength(1));
1444 SourceFileEdit fileEdit = change.edits[0];
1445 expect(fileEdit.file, '/projects/my_package/test/misc/a/bb/my_lib.dart');
1446 expect(fileEdit.fileStamp, -1);
1447 expect(fileEdit.edits, hasLength(1));
1448 expect(fileEdit.edits[0].replacement,
1449 contains('library my_package.test.misc.a.bb.my_lib;'));
1409 } 1450 }
1410 1451
1411 void test_createFile_forPart() { 1452 void test_createFile_forPart() {
1412 testFile = '/my/project/bin/test.dart'; 1453 testFile = '/my/project/bin/test.dart';
1413 resolveTestUnit(''' 1454 resolveTestUnit('''
1414 library my.lib; 1455 library my.lib;
1415 part 'my_part.dart'; 1456 part 'my_part.dart';
1416 '''); 1457 ''');
1417 AnalysisError error = _findErrorToFix(); 1458 AnalysisError error = _findErrorToFix();
1418 fix = _assertHasFix(DartFixKind.CREATE_FILE, error); 1459 fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
(...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after
4341 expect(group.positions, unorderedEquals(expectedPositions)); 4382 expect(group.positions, unorderedEquals(expectedPositions));
4342 if (expectedSuggestions != null) { 4383 if (expectedSuggestions != null) {
4343 expect(group.suggestions, unorderedEquals(expectedSuggestions)); 4384 expect(group.suggestions, unorderedEquals(expectedSuggestions));
4344 } 4385 }
4345 } 4386 }
4346 4387
4347 /** 4388 /**
4348 * Computes fixes for the given [error] in [testUnit]. 4389 * Computes fixes for the given [error] in [testUnit].
4349 */ 4390 */
4350 List<Fix> _computeFixes(AnalysisError error) { 4391 List<Fix> _computeFixes(AnalysisError error) {
4351 FixProcessor processor = new FixProcessor(testUnit, error); 4392 FixProcessor processor = new FixProcessor(provider, testUnit, error);
4352 return processor.compute(); 4393 return processor.compute();
4353 } 4394 }
4354 4395
4355 /** 4396 /**
4356 * Configures the [SourceFactory] to have the `my_pkg` package in 4397 * Configures the [SourceFactory] to have the `my_pkg` package in
4357 * `/packages/my_pkg/lib` folder. 4398 * `/packages/my_pkg/lib` folder.
4358 */ 4399 */
4359 void _configureMyPkg(String myLibCode) { 4400 void _configureMyPkg(String myLibCode) {
4360 provider.newFile('/packages/my_pkg/lib/my_lib.dart', myLibCode); 4401 provider.newFile('/packages/my_pkg/lib/my_lib.dart', myLibCode);
4361 // configure SourceFactory 4402 // configure SourceFactory
(...skipping 22 matching lines...) Expand all
4384 int offset = resultCode.indexOf(search); 4425 int offset = resultCode.indexOf(search);
4385 positions.add(new Position(testFile, offset)); 4426 positions.add(new Position(testFile, offset));
4386 } 4427 }
4387 return positions; 4428 return positions;
4388 } 4429 }
4389 4430
4390 void _performAnalysis() { 4431 void _performAnalysis() {
4391 while (context.performAnalysisTask().hasMoreWork); 4432 while (context.performAnalysisTask().hasMoreWork);
4392 } 4433 }
4393 } 4434 }
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