| 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 "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:uri'; | 9 import 'dart:uri'; |
| 10 | 10 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 var script = new Script(uri, new MockFile(source)); | 229 var script = new Script(uri, new MockFile(source)); |
| 230 var library = new LibraryElementX(script); | 230 var library = new LibraryElementX(script); |
| 231 parseScript(source, library); | 231 parseScript(source, library); |
| 232 library.setExports(library.localScope.values.toList()); | 232 library.setExports(library.localScope.values.toList()); |
| 233 registerSource(uri, source); | 233 registerSource(uri, source); |
| 234 libraries.putIfAbsent(uri.toString(), () => library); | 234 libraries.putIfAbsent(uri.toString(), () => library); |
| 235 return library; | 235 return library; |
| 236 } | 236 } |
| 237 | 237 |
| 238 void reportWarning(Node node, var message) { | 238 void reportWarning(Node node, var message) { |
| 239 warnings.add(new WarningMessage(node, message.message)); | 239 if (message is! Message) message = message.message; |
| 240 warnings.add(new WarningMessage(node, message)); |
| 240 } | 241 } |
| 241 | 242 |
| 242 void reportError(Node node, var message) { | 243 void reportError(Node node, var message) { |
| 243 if (message is String && message.startsWith("no library name found in")) { | 244 if (message is String && message.startsWith("no library name found in")) { |
| 244 // TODO(ahe): Fix the MockCompiler to not have this problem. | 245 // TODO(ahe): Fix the MockCompiler to not have this problem. |
| 245 return; | 246 return; |
| 246 } | 247 } |
| 247 errors.add(new WarningMessage(node, message.message)); | 248 if (message is! Message) message = message.message; |
| 249 errors.add(new WarningMessage(node, message)); |
| 248 } | 250 } |
| 249 | 251 |
| 250 void reportMessage(SourceSpan span, var message, api.Diagnostic kind) { | 252 void reportMessage(SourceSpan span, var message, api.Diagnostic kind) { |
| 251 var diagnostic = new WarningMessage(null, message.message); | 253 var diagnostic = new WarningMessage(null, message.message); |
| 252 if (kind == api.Diagnostic.ERROR) { | 254 if (kind == api.Diagnostic.ERROR) { |
| 253 errors.add(diagnostic); | 255 errors.add(diagnostic); |
| 254 } else { | 256 } else { |
| 255 warnings.add(diagnostic); | 257 warnings.add(diagnostic); |
| 256 } | 258 } |
| 257 } | 259 } |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 390 } |
| 389 } | 391 } |
| 390 | 392 |
| 391 class MockDeferredLoadTask extends DeferredLoadTask { | 393 class MockDeferredLoadTask extends DeferredLoadTask { |
| 392 MockDeferredLoadTask(Compiler compiler) : super(compiler); | 394 MockDeferredLoadTask(Compiler compiler) : super(compiler); |
| 393 | 395 |
| 394 void registerMainApp(LibraryElement mainApp) { | 396 void registerMainApp(LibraryElement mainApp) { |
| 395 // Do nothing. | 397 // Do nothing. |
| 396 } | 398 } |
| 397 } | 399 } |
| OLD | NEW |