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

Side by Side Diff: pkg/analyzer/test/src/task/strong/strong_test_helper.dart

Issue 1497253002: Align strong-mode error codes with analyzer conv. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: doc_fix_cont 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/analyzer/test/src/task/strong/inferred_type_test.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 library test.src.task.strong.strong_test_helper; 7 library test.src.task.strong.strong_test_helper;
8 8
9 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 var source = unit.source; 91 var source = unit.source;
92 if (source.uri.scheme == 'dart') continue; 92 if (source.uri.scheme == 'dart') continue;
93 93
94 var librarySource = context.getLibrariesContaining(source).single; 94 var librarySource = context.getLibrariesContaining(source).single;
95 var resolved = context.resolveCompilationUnit2(source, librarySource); 95 var resolved = context.resolveCompilationUnit2(source, librarySource);
96 var analyzerErrors = context 96 var analyzerErrors = context
97 .getErrors(source) 97 .getErrors(source)
98 .errors 98 .errors
99 .where((error) => 99 .where((error) =>
100 error.errorCode.name.startsWith('dev_compiler.InferredType')) 100 error.errorCode.name.startsWith('STRONG_MODE_INFERRED_TYPE'))
101 .toList(); 101 .toList();
102 errors.addAll(analyzerErrors); 102 errors.addAll(analyzerErrors);
103 checker.visitCompilationUnit(resolved); 103 checker.visitCompilationUnit(resolved);
104 104
105 new _ExpectedErrorVisitor(errors).validate(resolved); 105 new _ExpectedErrorVisitor(errors).validate(resolved);
106 } 106 }
107 } 107 }
108 }); 108 });
109 } 109 }
110 110
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 results.add(lib); 476 results.add(lib);
477 lib.importedLibraries.forEach(find); 477 lib.importedLibraries.forEach(find);
478 lib.exportedLibraries.forEach(find); 478 lib.exportedLibraries.forEach(find);
479 } 479 }
480 find(start); 480 find(start);
481 return results; 481 return results;
482 } 482 }
483 483
484 String errorCodeName(ErrorCode errorCode) { 484 String errorCodeName(ErrorCode errorCode) {
485 var name = errorCode.name; 485 var name = errorCode.name;
486 final prefix = 'dev_compiler.'; 486 final prefix = 'STRONG_MODE_';
487 if (name.startsWith(prefix)) { 487 if (name.startsWith(prefix)) {
488 return name.substring(prefix.length); 488 return name.substring(prefix.length);
489 } else { 489 } else {
490 // TODO(jmesserly): this is for backwards compat, but not sure it's very 490 // TODO(jmesserly): this is for backwards compat, but not sure it's very
491 // useful to log this. 491 // useful to log this.
492 return 'AnalyzerMessage'; 492 return 'AnalyzerMessage';
493 } 493 }
494 } 494 }
495 495
496 /// Returns an ANSII color escape sequence corresponding to [levelName]. Colors 496 /// Returns an ANSII color escape sequence corresponding to [levelName]. Colors
497 /// are defined for: severe, error, warning, or info. Returns null if the level 497 /// are defined for: severe, error, warning, or info. Returns null if the level
498 /// name is not recognized. 498 /// name is not recognized.
499 String colorOf(String levelName) { 499 String colorOf(String levelName) {
500 levelName = levelName.toLowerCase(); 500 levelName = levelName.toLowerCase();
501 if (levelName == 'shout' || levelName == 'severe' || levelName == 'error') { 501 if (levelName == 'shout' || levelName == 'severe' || levelName == 'error') {
502 return _RED_COLOR; 502 return _RED_COLOR;
503 } 503 }
504 if (levelName == 'warning') return _MAGENTA_COLOR; 504 if (levelName == 'warning') return _MAGENTA_COLOR;
505 if (levelName == 'info') return _CYAN_COLOR; 505 if (levelName == 'info') return _CYAN_COLOR;
506 return null; 506 return null;
507 } 507 }
508 508
509 const String _RED_COLOR = '\u001b[31m'; 509 const String _RED_COLOR = '\u001b[31m';
510 const String _MAGENTA_COLOR = '\u001b[35m'; 510 const String _MAGENTA_COLOR = '\u001b[35m';
511 const String _CYAN_COLOR = '\u001b[36m'; 511 const String _CYAN_COLOR = '\u001b[36m';
512 const String GREEN_COLOR = '\u001b[32m'; 512 const String GREEN_COLOR = '\u001b[32m';
513 const String NO_COLOR = '\u001b[0m'; 513 const String NO_COLOR = '\u001b[0m';
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/strong/inferred_type_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698