| 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 /// Summarizes the information produced by the checker. | 5 /// Summarizes the information produced by the checker. |
| 6 library ddc.src.report; | 6 library dev_compiler.src.report; |
| 7 | 7 |
| 8 import 'dart:math' show max; | 8 import 'dart:math' show max; |
| 9 | 9 |
| 10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
| 11 import 'package:source_span/source_span.dart'; | 11 import 'package:source_span/source_span.dart'; |
| 12 import 'package:analyzer/src/generated/ast.dart'; | 12 import 'package:analyzer/src/generated/ast.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart' show Source; | 13 import 'package:analyzer/src/generated/source.dart' show Source; |
| 14 import 'package:logging/logging.dart'; | 14 import 'package:logging/logging.dart'; |
| 15 | 15 |
| 16 import 'info.dart'; | 16 import 'info.dart'; |
| 17 import 'utils.dart'; | 17 import 'utils.dart'; |
| 18 | 18 |
| 19 // Interface used to report error messages from the checker. | 19 // Interface used to report error messages from the checker. |
| 20 abstract class CheckerReporter { | 20 abstract class CheckerReporter { |
| 21 /// Called when starting to process a library. | 21 /// Called when starting to process a library. |
| 22 void enterLibrary(LibraryInfo info); | 22 void enterLibrary(LibraryInfo info); |
| 23 void leaveLibrary(); | 23 void leaveLibrary(); |
| 24 | 24 |
| 25 /// Called when starting to process a source. All subsequent log entries must | 25 /// Called when starting to process a source. All subsequent log entries must |
| 26 /// belong to this source until the next call to enterSource. | 26 /// belong to this source until the next call to enterSource. |
| 27 void enterSource(Source source); | 27 void enterSource(Source source); |
| 28 void leaveSource(); | 28 void leaveSource(); |
| 29 | 29 |
| 30 void log(StaticInfo info); | 30 void log(StaticInfo info); |
| 31 | 31 |
| 32 // TODO(sigmund): merge this and [log] | 32 // TODO(sigmund): merge this and [log] |
| 33 void logAnalyzerError(String message, Level level, int begin, int end); | 33 void logAnalyzerError(String message, Level level, int begin, int end); |
| 34 } | 34 } |
| 35 | 35 |
| 36 final _checkerLogger = new Logger('ddc.checker'); | 36 final _checkerLogger = new Logger('dev_compiler.checker'); |
| 37 | 37 |
| 38 /// Simple reporter that logs checker messages as they are seen. | 38 /// Simple reporter that logs checker messages as they are seen. |
| 39 class LogReporter implements CheckerReporter { | 39 class LogReporter implements CheckerReporter { |
| 40 final bool useColors; | 40 final bool useColors; |
| 41 SourceFile _file; | 41 SourceFile _file; |
| 42 Source _current; | 42 Source _current; |
| 43 | 43 |
| 44 LogReporter([this.useColors = false]); | 44 LogReporter([this.useColors = false]); |
| 45 | 45 |
| 46 void enterLibrary(LibraryInfo info) {} | 46 void enterLibrary(LibraryInfo info) {} |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 /// Returns a [SourceSpan] in [file] for the offsets of [node]. | 491 /// Returns a [SourceSpan] in [file] for the offsets of [node]. |
| 492 SourceSpan _spanForNode(SourceFile file, AstNode node) { | 492 SourceSpan _spanForNode(SourceFile file, AstNode node) { |
| 493 final begin = node is AnnotatedNode | 493 final begin = node is AnnotatedNode |
| 494 ? node.firstTokenAfterCommentAndMetadata.offset | 494 ? node.firstTokenAfterCommentAndMetadata.offset |
| 495 : node.offset; | 495 : node.offset; |
| 496 return file.span(begin, node.end); | 496 return file.span(begin, node.end); |
| 497 } | 497 } |
| OLD | NEW |