| 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 leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import '../compiler_new.dart' as api; | 10 import '../compiler_new.dart' as api; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 String lookupPatchPath(String dartLibraryName) { | 189 String lookupPatchPath(String dartLibraryName) { |
| 190 LibraryInfo info = lookupLibraryInfo(dartLibraryName); | 190 LibraryInfo info = lookupLibraryInfo(dartLibraryName); |
| 191 if (info == null) return null; | 191 if (info == null) return null; |
| 192 if (!info.isDart2jsLibrary) return null; | 192 if (!info.isDart2jsLibrary) return null; |
| 193 String path = info.dart2jsPatchPath; | 193 String path = info.dart2jsPatchPath; |
| 194 if (path == null) return null; | 194 if (path == null) return null; |
| 195 return "lib/$path"; | 195 return "lib/$path"; |
| 196 } | 196 } |
| 197 | 197 |
| 198 void log(message) { | 198 void log(message) { |
| 199 callUserHandler(null, null, null, message, api.Diagnostic.VERBOSE_INFO); | 199 callUserHandler( |
| 200 null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); |
| 200 } | 201 } |
| 201 | 202 |
| 202 /// See [leg.Compiler.translateResolvedUri]. | 203 /// See [leg.Compiler.translateResolvedUri]. |
| 203 Uri translateResolvedUri(elements.LibraryElement importingLibrary, | 204 Uri translateResolvedUri(elements.LibraryElement importingLibrary, |
| 204 Uri resolvedUri, tree.Node node) { | 205 Uri resolvedUri, tree.Node node) { |
| 205 if (resolvedUri.scheme == 'dart') { | 206 if (resolvedUri.scheme == 'dart') { |
| 206 return translateDartUri(importingLibrary, resolvedUri, node); | 207 return translateDartUri(importingLibrary, resolvedUri, node); |
| 207 } | 208 } |
| 208 return resolvedUri; | 209 return resolvedUri; |
| 209 } | 210 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 api.Diagnostic kind) { | 421 api.Diagnostic kind) { |
| 421 leg.SourceSpan span = spanFromSpannable(node); | 422 leg.SourceSpan span = spanFromSpannable(node); |
| 422 if (identical(kind, api.Diagnostic.ERROR) | 423 if (identical(kind, api.Diagnostic.ERROR) |
| 423 || identical(kind, api.Diagnostic.CRASH) | 424 || identical(kind, api.Diagnostic.CRASH) |
| 424 || (fatalWarnings && identical(kind, api.Diagnostic.WARNING))) { | 425 || (fatalWarnings && identical(kind, api.Diagnostic.WARNING))) { |
| 425 compilationFailed = true; | 426 compilationFailed = true; |
| 426 } | 427 } |
| 427 // [:span.uri:] might be [:null:] in case of a [Script] with no [uri]. For | 428 // [:span.uri:] might be [:null:] in case of a [Script] with no [uri]. For |
| 428 // instance in the [Types] constructor in typechecker.dart. | 429 // instance in the [Types] constructor in typechecker.dart. |
| 429 if (span == null || span.uri == null) { | 430 if (span == null || span.uri == null) { |
| 430 callUserHandler(null, null, null, '$message', kind); | 431 callUserHandler(message, null, null, null, '$message', kind); |
| 431 } else { | 432 } else { |
| 432 callUserHandler(span.uri, span.begin, span.end, '$message', kind); | 433 callUserHandler( |
| 434 message, span.uri, span.begin, span.end, '$message', kind); |
| 433 } | 435 } |
| 434 } | 436 } |
| 435 | 437 |
| 436 bool get isMockCompilation { | 438 bool get isMockCompilation { |
| 437 return mockableLibraryUsed | 439 return mockableLibraryUsed |
| 438 && (options.indexOf('--allow-mock-compilation') != -1); | 440 && (options.indexOf('--allow-mock-compilation') != -1); |
| 439 } | 441 } |
| 440 | 442 |
| 441 void callUserHandler(Uri uri, int begin, int end, | 443 void callUserHandler(leg.Message message, Uri uri, int begin, int end, |
| 442 String message, api.Diagnostic kind) { | 444 String text, api.Diagnostic kind) { |
| 443 try { | 445 try { |
| 444 userHandlerTask.measure(() { | 446 userHandlerTask.measure(() { |
| 445 handler.report(uri, begin, end, message, kind); | 447 handler.report(message, uri, begin, end, text, kind); |
| 446 }); | 448 }); |
| 447 } catch (ex, s) { | 449 } catch (ex, s) { |
| 448 diagnoseCrashInUserCode( | 450 diagnoseCrashInUserCode( |
| 449 'Uncaught exception in diagnostic handler', ex, s); | 451 'Uncaught exception in diagnostic handler', ex, s); |
| 450 rethrow; | 452 rethrow; |
| 451 } | 453 } |
| 452 } | 454 } |
| 453 | 455 |
| 454 Future callUserProvider(Uri uri) { | 456 Future callUserProvider(Uri uri) { |
| 455 try { | 457 try { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 475 print('$message: ${tryToString(exception)}'); | 477 print('$message: ${tryToString(exception)}'); |
| 476 print(tryToString(stackTrace)); | 478 print(tryToString(stackTrace)); |
| 477 } | 479 } |
| 478 | 480 |
| 479 fromEnvironment(String name) => environment[name]; | 481 fromEnvironment(String name) => environment[name]; |
| 480 | 482 |
| 481 LibraryInfo lookupLibraryInfo(String libraryName) { | 483 LibraryInfo lookupLibraryInfo(String libraryName) { |
| 482 return library_info.LIBRARIES[libraryName]; | 484 return library_info.LIBRARIES[libraryName]; |
| 483 } | 485 } |
| 484 } | 486 } |
| OLD | NEW |