| 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 library dev_compiler.src.testing; | 5 library dev_compiler.src.testing; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Uri _current; | 142 Uri _current; |
| 143 | 143 |
| 144 void enterLibrary(Uri uri) { | 144 void enterLibrary(Uri uri) { |
| 145 super.enterLibrary(uri); | 145 super.enterLibrary(uri); |
| 146 infoMap[uri] = {}; | 146 infoMap[uri] = {}; |
| 147 _current = uri; | 147 _current = uri; |
| 148 } | 148 } |
| 149 | 149 |
| 150 void log(Message info) { | 150 void log(Message info) { |
| 151 super.log(info); | 151 super.log(info); |
| 152 if (info is! StaticInfo) return; | 152 if (info is StaticInfo) { |
| 153 infoMap[_current].putIfAbsent(info.node, () => []).add(info); | 153 infoMap[_current].putIfAbsent(info.node, () => []).add(info); |
| 154 } |
| 154 } | 155 } |
| 155 } | 156 } |
| 156 | 157 |
| 157 /// Create an error explanation for errors that were not expected, but that the | 158 /// Create an error explanation for errors that were not expected, but that the |
| 158 /// checker produced. | 159 /// checker produced. |
| 159 String _unexpectedErrors(AstNode node, List errors) { | 160 String _unexpectedErrors(AstNode node, List errors) { |
| 160 final span = _spanFor(node); | 161 final span = _spanFor(node); |
| 161 return errors.map((e) { | 162 return errors.map((e) { |
| 162 var level = e.level.name.toLowerCase(); | 163 var level = e.level.name.toLowerCase(); |
| 163 return '$level: ${span.message(e.message, color: colorOf(level))}'; | 164 return '$level: ${span.message(e.message, color: colorOf(level))}'; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 336 |
| 336 SourceSpan spanFor(AstNode node) { | 337 SourceSpan spanFor(AstNode node) { |
| 337 final begin = node is AnnotatedNode | 338 final begin = node is AnnotatedNode |
| 338 ? node.firstTokenAfterCommentAndMetadata.offset | 339 ? node.firstTokenAfterCommentAndMetadata.offset |
| 339 : node.offset; | 340 : node.offset; |
| 340 return _file.span(begin, node.end); | 341 return _file.span(begin, node.end); |
| 341 } | 342 } |
| 342 | 343 |
| 343 String toString() => '[$runtimeType: $uri]'; | 344 String toString() => '[$runtimeType: $uri]'; |
| 344 } | 345 } |
| OLD | NEW |