| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('mock_compiler'); | 5 #library('mock_compiler'); |
| 6 | 6 |
| 7 #import("dart:uri"); | 7 #import("dart:uri"); |
| 8 | 8 |
| 9 #import("../../../lib/compiler/implementation/elements/elements.dart"); | 9 #import("../../../lib/compiler/implementation/elements/elements.dart"); |
| 10 #import("../../../lib/compiler/implementation/leg.dart"); | 10 #import("../../../lib/compiler/implementation/leg.dart"); |
| 11 #import('../../../lib/compiler/implementation/source_file.dart'); | 11 #import('../../../lib/compiler/implementation/source_file.dart'); |
| 12 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 12 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
| 13 #import("../../../lib/compiler/implementation/util/util.dart"); | 13 #import("../../../lib/compiler/implementation/util/util.dart"); |
| 14 #import('../../../lib/compiler/compiler.dart', prefix: 'api'); |
| 14 #import("parser_helper.dart"); | 15 #import("parser_helper.dart"); |
| 15 | 16 |
| 16 class WarningMessage { | 17 class WarningMessage { |
| 17 Node node; | 18 Node node; |
| 18 Message message; | 19 Message message; |
| 19 WarningMessage(this.node, this.message); | 20 WarningMessage(this.node, this.message); |
| 20 | 21 |
| 21 toString() => message.toString(); | 22 toString() => message.toString(); |
| 22 } | 23 } |
| 23 | 24 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 99 } |
| 99 | 100 |
| 100 void reportError(Node node, var message) { | 101 void reportError(Node node, var message) { |
| 101 if (message is String && message.startsWith("no #library tag found in")) { | 102 if (message is String && message.startsWith("no #library tag found in")) { |
| 102 // TODO(ahe): Fix the MockCompiler to not have this problem. | 103 // TODO(ahe): Fix the MockCompiler to not have this problem. |
| 103 return; | 104 return; |
| 104 } | 105 } |
| 105 errors.add(new WarningMessage(node, message.message)); | 106 errors.add(new WarningMessage(node, message.message)); |
| 106 } | 107 } |
| 107 | 108 |
| 109 void reportMessage(SourceSpan span, var message, api.Diagnostic kind) { |
| 110 var diagnostic = new WarningMessage(null, message.message); |
| 111 if (kind === api.Diagnostic.ERROR) { |
| 112 errors.add(diagnostic); |
| 113 } else { |
| 114 warnings.add(diagnostic); |
| 115 } |
| 116 } |
| 117 |
| 108 void reportDiagnostic(SourceSpan span, String message, var kind) { | 118 void reportDiagnostic(SourceSpan span, String message, var kind) { |
| 109 print(message); | 119 print(message); |
| 110 } | 120 } |
| 111 | 121 |
| 112 void clearWarnings() { | 122 void clearWarnings() { |
| 113 warnings = []; | 123 warnings = []; |
| 114 } | 124 } |
| 115 | 125 |
| 116 void clearErrors() { | 126 void clearErrors() { |
| 117 errors = []; | 127 errors = []; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 }); | 207 }); |
| 198 } | 208 } |
| 199 } | 209 } |
| 200 | 210 |
| 201 LibraryElement mockLibrary(Compiler compiler, String source) { | 211 LibraryElement mockLibrary(Compiler compiler, String source) { |
| 202 Uri uri = new Uri.fromComponents(scheme: "source"); | 212 Uri uri = new Uri.fromComponents(scheme: "source"); |
| 203 var library = new LibraryElement(new Script(uri, new MockFile(source))); | 213 var library = new LibraryElement(new Script(uri, new MockFile(source))); |
| 204 importLibrary(library, compiler.coreLibrary, compiler); | 214 importLibrary(library, compiler.coreLibrary, compiler); |
| 205 return library; | 215 return library; |
| 206 } | 216 } |
| OLD | NEW |