| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.test.memory_compiler; | 5 library dart2js.test.memory_compiler; |
| 6 | 6 |
| 7 import 'memory_source_file_helper.dart'; | 7 import 'memory_source_file_helper.dart'; |
| 8 | 8 |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 10 show NullSink; | 10 show NullSink; |
| 11 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; | |
| 12 | 11 |
| 13 import '../../../sdk/lib/_internal/compiler/compiler.dart' | 12 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
| 14 show Diagnostic, DiagnosticHandler; | 13 show Diagnostic, DiagnosticHandler; |
| 15 | 14 |
| 16 import 'dart:async'; | 15 import 'dart:async'; |
| 17 | 16 |
| 18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirror
s.dart'; | 17 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirror
s.dart'; |
| 19 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.dart'
; | 18 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/analyze.dart'
; |
| 20 | 19 |
| 21 class DiagnosticMessage { | 20 class DiagnosticMessage { |
| 22 final Uri uri; | 21 final Uri uri; |
| 23 final int begin; | 22 final int begin; |
| 24 final int end; | 23 final int end; |
| 25 final String message; | 24 final String message; |
| 26 final Diagnostic kind; | 25 final Diagnostic kind; |
| 27 | 26 |
| 28 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind); | 27 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind); |
| 28 |
| 29 String toString() => '$uri:$begin:$end:$message:$kind'; |
| 29 } | 30 } |
| 30 | 31 |
| 31 class DiagnosticCollector { | 32 class DiagnosticCollector { |
| 32 List<DiagnosticMessage> messages = <DiagnosticMessage>[]; | 33 List<DiagnosticMessage> messages = <DiagnosticMessage>[]; |
| 33 | 34 |
| 34 void call(Uri uri, int begin, int end, String message, | 35 void call(Uri uri, int begin, int end, String message, |
| 35 Diagnostic kind) { | 36 Diagnostic kind) { |
| 36 messages.add(new DiagnosticMessage(uri, begin, end, message, kind)); | 37 messages.add(new DiagnosticMessage(uri, begin, end, message, kind)); |
| 37 } | 38 } |
| 38 | 39 |
| 39 Iterable<DiagnosticMessage> filterMessagesByKind(Diagnostic kind) { | 40 Iterable<DiagnosticMessage> filterMessagesByKind(Diagnostic kind) { |
| 40 return messages.where( | 41 return messages.where( |
| 41 (DiagnosticMessage message) => message.kind == kind); | 42 (DiagnosticMessage message) => message.kind == kind); |
| 42 } | 43 } |
| 43 | 44 |
| 44 Iterable<DiagnosticMessage> get errors { | 45 Iterable<DiagnosticMessage> get errors { |
| 45 return filterMessagesByKind(Diagnostic.ERROR); | 46 return filterMessagesByKind(Diagnostic.ERROR); |
| 46 } | 47 } |
| 47 | 48 |
| 48 Iterable<DiagnosticMessage> get warnings { | 49 Iterable<DiagnosticMessage> get warnings { |
| 49 return filterMessagesByKind(Diagnostic.WARNING); | 50 return filterMessagesByKind(Diagnostic.WARNING); |
| 50 } | 51 } |
| 51 | 52 |
| 52 Iterable<DiagnosticMessage> get hints { | 53 Iterable<DiagnosticMessage> get hints { |
| 53 return filterMessagesByKind(Diagnostic.HINT); | 54 return filterMessagesByKind(Diagnostic.HINT); |
| 54 } | 55 } |
| 56 |
| 57 Iterable<DiagnosticMessage> get infos { |
| 58 return filterMessagesByKind(Diagnostic.INFO); |
| 59 } |
| 55 } | 60 } |
| 56 | 61 |
| 57 DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler, | 62 DiagnosticHandler createDiagnosticHandler(DiagnosticHandler diagnosticHandler, |
| 58 SourceFileProvider provider, | 63 SourceFileProvider provider, |
| 59 bool showDiagnostics) { | 64 bool showDiagnostics) { |
| 60 var handler = diagnosticHandler; | 65 var handler = diagnosticHandler; |
| 61 if (showDiagnostics) { | 66 if (showDiagnostics) { |
| 62 if (diagnosticHandler == null) { | 67 if (diagnosticHandler == null) { |
| 63 handler = new FormattingDiagnosticHandler(provider); | 68 handler = new FormattingDiagnosticHandler(provider); |
| 64 } else { | 69 } else { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 171 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 167 | 172 |
| 168 List<Uri> libraries = <Uri>[]; | 173 List<Uri> libraries = <Uri>[]; |
| 169 memorySourceFiles.forEach((String path, _) { | 174 memorySourceFiles.forEach((String path, _) { |
| 170 libraries.add(new Uri(scheme: 'memory', path: path)); | 175 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 171 }); | 176 }); |
| 172 | 177 |
| 173 return analyze(libraries, libraryRoot, packageRoot, | 178 return analyze(libraries, libraryRoot, packageRoot, |
| 174 provider, handler, options); | 179 provider, handler, options); |
| 175 } | 180 } |
| OLD | NEW |