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

Unified Diff: pkg/front_end/lib/src/fasta/compiler_context.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
« no previous file with comments | « pkg/front_end/lib/src/fasta/compiler_command_line.dart ('k') | pkg/front_end/lib/src/fasta/fasta.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/compiler_context.dart
diff --git a/pkg/front_end/lib/src/fasta/compiler_context.dart b/pkg/front_end/lib/src/fasta/compiler_context.dart
index 2f427eaeb826a07ac60960659e58b074187f1cf1..466ecdf1b92149954a012193721704abaa5220bb 100644
--- a/pkg/front_end/lib/src/fasta/compiler_context.dart
+++ b/pkg/front_end/lib/src/fasta/compiler_context.dart
@@ -8,6 +8,7 @@ import 'dart:async' show Zone, runZoned;
import 'package:front_end/file_system.dart';
import 'package:front_end/physical_file_system.dart';
+import 'package:front_end/src/fasta/fasta_codes.dart';
import 'package:kernel/ast.dart' show Source;
import 'compiler_command_line.dart' show CompilerCommandLine;
@@ -20,9 +21,6 @@ import 'severity.dart' show Severity;
final Object compilerContextKey = new Object();
-final CompilerContext rootContext =
- new CompilerContext(CompilerCommandLine.forRootContext());
-
class CompilerContext {
final FileSystem fileSystem = PhysicalFileSystem.instance;
@@ -59,7 +57,15 @@ class CompilerContext {
}
static CompilerContext get current {
- return Zone.current[compilerContextKey] ?? rootContext;
+ var context = Zone.current[compilerContextKey];
+ if (context == null) {
+ // Note: we throw directly and don't use internalProblem, because
+ // internalProblem depends on having a compiler context available.
+ var message = messageInternalProblemMissingContext.message;
+ var tip = messageInternalProblemMissingContext.tip;
+ throw "Internal problem: $message\nTip: $tip";
+ }
+ return context;
}
/// Perform [action] in a [Zone] where [cl] will be available as
« no previous file with comments | « pkg/front_end/lib/src/fasta/compiler_command_line.dart ('k') | pkg/front_end/lib/src/fasta/fasta.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698