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

Side by Side Diff: tests/compiler/dart2js/memory_compiler.dart

Issue 1415463022: Use DiagnosticMessage in MockCompiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:compiler/compiler.dart' show 9 import 'package:compiler/compiler.dart' show
10 DiagnosticHandler; 10 DiagnosticHandler;
(...skipping 10 matching lines...) Expand all
21 import 'package:compiler/src/null_compiler_output.dart' show 21 import 'package:compiler/src/null_compiler_output.dart' show
22 NullCompilerOutput; 22 NullCompilerOutput;
23 import 'package:compiler/src/library_loader.dart' show 23 import 'package:compiler/src/library_loader.dart' show
24 LoadedLibraries; 24 LoadedLibraries;
25 25
26 import 'memory_source_file_helper.dart'; 26 import 'memory_source_file_helper.dart';
27 27
28 export 'output_collector.dart'; 28 export 'output_collector.dart';
29 export 'package:compiler/compiler_new.dart' show 29 export 'package:compiler/compiler_new.dart' show
30 CompilationResult; 30 CompilationResult;
31 31 export 'diagnostic_helper.dart';
32 class DiagnosticMessage {
33 final Message message;
34 final Uri uri;
35 final int begin;
36 final int end;
37 final String text;
38 final Diagnostic kind;
39
40 DiagnosticMessage(
41 this.message, this.uri, this.begin, this.end, this.text, this.kind);
42
43 String toString() => '$uri:$begin:$end:$text:$kind';
44 }
45
46 class DiagnosticCollector implements CompilerDiagnostics {
47 List<DiagnosticMessage> messages = <DiagnosticMessage>[];
48
49 void call(Uri uri, int begin, int end, String message, Diagnostic kind) {
50 report(null, uri, begin, end, message, kind);
51 }
52
53 @override
54 void report(Message message,
55 Uri uri, int begin, int end, String text, Diagnostic kind) {
56 messages.add(new DiagnosticMessage(message, uri, begin, end, text, kind));
57 }
58
59 Iterable<DiagnosticMessage> filterMessagesByKinds(List<Diagnostic> kinds) {
60 return messages.where(
61 (DiagnosticMessage message) => kinds.contains(message.kind));
62 }
63
64 Iterable<DiagnosticMessage> get errors {
65 return filterMessagesByKinds([Diagnostic.ERROR]);
66 }
67
68 Iterable<DiagnosticMessage> get warnings {
69 return filterMessagesByKinds([Diagnostic.WARNING]);
70 }
71
72 Iterable<DiagnosticMessage> get hints {
73 return filterMessagesByKinds([Diagnostic.HINT]);
74 }
75
76 Iterable<DiagnosticMessage> get infos {
77 return filterMessagesByKinds([Diagnostic.INFO]);
78 }
79
80 /// `true` if non-verbose messages has been collected.
81 bool get hasRegularMessages {
82 return messages.any((m) => m.kind != Diagnostic.VERBOSE_INFO);
83 }
84
85 void clear() {
86 messages.clear();
87 }
88 }
89 32
90 class MultiDiagnostics implements CompilerDiagnostics { 33 class MultiDiagnostics implements CompilerDiagnostics {
91 final List<CompilerDiagnostics> diagnosticsList; 34 final List<CompilerDiagnostics> diagnosticsList;
92 35
93 const MultiDiagnostics([this.diagnosticsList = const []]); 36 const MultiDiagnostics([this.diagnosticsList = const []]);
94 37
95 @override 38 @override
96 void report(Message message, Uri uri, int begin, int end, 39 void report(Message message, Uri uri, int begin, int end,
97 String text, Diagnostic kind) { 40 String text, Diagnostic kind) {
98 for (CompilerDiagnostics diagnostics in diagnosticsList) { 41 for (CompilerDiagnostics diagnostics in diagnosticsList) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); 273 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics);
331 274
332 List<Uri> libraries = <Uri>[]; 275 List<Uri> libraries = <Uri>[];
333 memorySourceFiles.forEach((String path, _) { 276 memorySourceFiles.forEach((String path, _) {
334 libraries.add(new Uri(scheme: 'memory', path: path)); 277 libraries.add(new Uri(scheme: 'memory', path: path));
335 }); 278 });
336 279
337 return analyze(libraries, libraryRoot, packageRoot, 280 return analyze(libraries, libraryRoot, packageRoot,
338 provider, handler, options); 281 provider, handler, options);
339 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698