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

Unified Diff: pkg/dev_compiler/web/main.dart

Issue 2713773004: Extend the API exposed to JS to include a method that resolves urls against the summaryDataStore fi… (Closed)
Patch Set: Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/compiler.dart ('k') | pkg/dev_compiler/web/web_command.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/web/main.dart
diff --git a/pkg/dev_compiler/web/main.dart b/pkg/dev_compiler/web/main.dart
index 70f84402fa591f260ad3291585f91f47830541ce..22b7e08e110b34b9c569dd01c074ed812a416407 100755
--- a/pkg/dev_compiler/web/main.dart
+++ b/pkg/dev_compiler/web/main.dart
@@ -16,40 +16,47 @@ import 'web_command.dart';
@JS(r'$setUpDartDevCompilerInBrowser')
external set setUpCompilerInBrowser(Function function);
-Future main() async {
+Future<Function> _setUpCompilerInBrowser;
+main() {
var args = ['compile', '--repl-compile'];
+
+ // Avoid race condition when users try to call $setUpDartDevCompilerInBrowser
+ // before it is ready by installing the method immediately and making the body
+ // of the method async.
+ setUpCompilerInBrowser = allowInterop((String summaryRoot, String sdkUrl,
+ List<String> summaryUrls,
+ Function onCompileReady,
+ Function onError) async {
+ (await _setUpCompilerInBrowser)(
+ summaryRoot, sdkUrl, summaryUrls, onCompileReady, onError);
+ });
_runCommand(args);
}
/// Runs a single compile command, and returns an exit code.
-Future<int> _runCommand(List<String> args,
- {MessageHandler messageHandler}) async {
+_runCommand(List<String> args, {MessageHandler messageHandler}) {
try {
// TODO: Remove CommandRunner and args if possible. May run into issues
// with ArgResults or ArgParsers.
var runner = new CommandRunner('dartdevc', 'Dart Development Compiler');
runner.addCommand(new WebCompileCommand(messageHandler: messageHandler));
- setUpCompilerInBrowser = allowInterop((await runner.run(args)) as Function);
+ _setUpCompilerInBrowser = runner.run(args) as Future<Function>;
} catch (e, s) {
- return _handleError(e, s, args, messageHandler: messageHandler);
+ _handleError(e, s, args, messageHandler: messageHandler);
}
- return 1;
}
-/// Handles [error] in a uniform fashion. Returns the proper exit code and calls
-/// [messageHandler] with messages.
-int _handleError(dynamic error, dynamic stackTrace, List<String> args,
+/// Handles [error] in a uniform fashion. Calls [messageHandler] with messages.
+_handleError(dynamic error, dynamic stackTrace, List<String> args,
{MessageHandler messageHandler}) {
messageHandler ??= print;
if (error is UsageException) {
// Incorrect usage, input file not found, etc.
messageHandler(error);
- return 64;
} else if (error is CompileErrorException) {
// Code has error(s) and failed to compile.
messageHandler(error);
- return 1;
} else {
// Anything else is likely a compiler bug.
//
@@ -74,6 +81,5 @@ int _handleError(dynamic error, dynamic stackTrace, List<String> args,
messageHandler(error);
messageHandler(stackTrace);
messageHandler("```");
- return 70;
}
}
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/compiler.dart ('k') | pkg/dev_compiler/web/web_command.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698