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

Unified Diff: pkg/front_end/lib/src/fasta/compiler_command_line.dart

Issue 2980033004: Throw if there is no compiler context available (Closed)
Patch Set: cl comments, handle validate and deprecated_InputError Created 3 years, 5 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
Index: pkg/front_end/lib/src/fasta/compiler_command_line.dart
diff --git a/pkg/front_end/lib/src/fasta/compiler_command_line.dart b/pkg/front_end/lib/src/fasta/compiler_command_line.dart
index 345a304d3c6269edfe2ed6908cb37ca74161310f..36709b7b672bfbfecc6c42d659bb57be04f699b0 100644
--- a/pkg/front_end/lib/src/fasta/compiler_command_line.dart
+++ b/pkg/front_end/lib/src/fasta/compiler_command_line.dart
@@ -6,12 +6,14 @@ library fasta.compiler_command_line;
import 'dart:io' show exit;
+import 'dart:async' show runZoned;
+
import 'package:kernel/target/targets.dart'
show Target, getTarget, TargetFlags, targets;
import 'command_line.dart' show CommandLine, deprecated_argumentError;
-import 'compiler_context.dart' show CompilerContext;
+import 'compiler_context.dart' show CompilerContext, compilerContextKey;
import 'command_line_reporting.dart' as command_line_reporting;
@@ -153,12 +155,23 @@ class CompilerCommandLine extends CommandLine {
static dynamic withGlobalOptions(String programName, List<String> arguments,
dynamic f(CompilerContext context)) {
- return CompilerContext.withGlobalOptions(
- new CompilerCommandLine(programName, arguments), f);
+ CompilerCommandLine cl = deprecated_withDefaultOptions(
+ () => new CompilerCommandLine(programName, arguments));
+ return CompilerContext.withGlobalOptions(cl, f);
}
- static CompilerCommandLine forRootContext() {
- return new CompilerCommandLine("", [""]);
+ // TODO(sigmund, ahe): delete. We use this to wrap places where we require a
+ // context but we shoudln't. Right now this includes:
+ // - constructor calls to CompilerCommandLine (because it is calling
+ // [validate] which may report errors). This should be fixed by doing
+ // validation after creating these objects.
+ // - top-level try-catch in command-line tools that capture
+ // deprecated_InputError, and then report errors using fasta's error
+ // reporting mechanism. Those should be unnecessary once we get rid of all
+ // deprecated_InputErrors.
+ static dynamic deprecated_withDefaultOptions(dynamic f()) {
+ var defaultContext = new CompilerContext(new CompilerCommandLine("", [""]));
+ return runZoned(f, zoneValues: {compilerContextKey: defaultContext});
}
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/compile_platform.dart ('k') | pkg/front_end/lib/src/fasta/compiler_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698