OLD | NEW |
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 /// Defines static information collected by the type checker and used later by | 5 /// Defines static information collected by the type checker and used later by |
6 /// emitters to generate code. | 6 /// emitters to generate code. |
7 library dev_compiler.src.info; | 7 library dev_compiler.src.info; |
8 | 8 |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 | 10 |
11 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
12 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
| 13 import 'package:analyzer/src/generated/error.dart' as analyzer; |
13 import 'package:analyzer/src/generated/scanner.dart' | 14 import 'package:analyzer/src/generated/scanner.dart' |
14 show Token, TokenType, SyntheticStringToken; | 15 show Token, TokenType, SyntheticStringToken; |
15 import 'package:logging/logging.dart' show Level; | 16 import 'package:logging/logging.dart' show Level; |
16 | 17 |
17 import 'package:dev_compiler/src/checker/rules.dart'; | 18 import 'package:dev_compiler/src/checker/rules.dart'; |
18 import 'package:dev_compiler/src/utils.dart' as utils; | 19 import 'package:dev_compiler/src/utils.dart' as utils; |
19 | 20 |
20 import 'report.dart' show Message; | 21 import 'report.dart' show Message; |
21 | 22 |
22 /// Represents a summary of the results collected by running the program | 23 /// Represents a summary of the results collected by running the program |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 for (var cls in declarations.where((d) => d is ClassMirror)) { | 724 for (var cls in declarations.where((d) => d is ClassMirror)) { |
724 if (cls.isSubtypeOf(infoMirror)) { | 725 if (cls.isSubtypeOf(infoMirror)) { |
725 allTypes.add(cls); | 726 allTypes.add(cls); |
726 baseTypes.add(cls.superclass); | 727 baseTypes.add(cls.superclass); |
727 } | 728 } |
728 } | 729 } |
729 allTypes.removeAll(baseTypes); | 730 allTypes.removeAll(baseTypes); |
730 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) | 731 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) |
731 ..sort((t1, t2) => '$t1'.compareTo('$t2')); | 732 ..sort((t1, t2) => '$t1'.compareTo('$t2')); |
732 }(); | 733 }(); |
| 734 |
| 735 class AnalyzerError extends Message { |
| 736 factory AnalyzerError.from(analyzer.AnalysisError error) { |
| 737 var severity = error.errorCode.type.severity; |
| 738 var isError = severity == analyzer.ErrorSeverity.ERROR; |
| 739 var level = isError ? Level.SEVERE : Level.WARNING; |
| 740 int begin = error.offset; |
| 741 int end = begin + error.length; |
| 742 return new AnalyzerError(error.message, level, begin, end); |
| 743 } |
| 744 |
| 745 const AnalyzerError(String message, Level level, int begin, int end) |
| 746 : super('[from analyzer]: $message', level, begin, end); |
| 747 } |
OLD | NEW |