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

Side by Side Diff: pkg/front_end/lib/src/fasta/compiler_context.dart

Issue 2746963002: Enable colors on-demand. (Closed)
Patch Set: Update color numbers. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/colors.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 fasta.compiler_context; 5 library fasta.compiler_context;
6 6
7 import 'dart:async' show Zone, runZoned; 7 import 'dart:async' show Zone, runZoned;
8 8
9 import 'package:kernel/ast.dart' show Source; 9 import 'package:kernel/ast.dart' show Source;
10 10
11 import 'compiler_command_line.dart' show CompilerCommandLine; 11 import 'compiler_command_line.dart' show CompilerCommandLine;
12 12
13 import 'colors.dart' show computeEnableColors;
14
13 final Object compilerContextKey = new Object(); 15 final Object compilerContextKey = new Object();
14 16
15 final CompilerContext rootContext = 17 final CompilerContext rootContext =
16 new CompilerContext(CompilerCommandLine.forRootContext()); 18 new CompilerContext(CompilerCommandLine.forRootContext());
17 19
18 class CompilerContext { 20 class CompilerContext {
19 final CompilerCommandLine options; 21 final CompilerCommandLine options;
20 22
21 final Map<String, Source> uriToSource = <String, Source>{}; 23 final Map<String, Source> uriToSource = <String, Source>{};
22 24
25 bool enableColorsCached = null;
26
23 CompilerContext(this.options); 27 CompilerContext(this.options);
24 28
25 static CompilerContext get current { 29 static CompilerContext get current {
26 return Zone.current[compilerContextKey] ?? rootContext; 30 return Zone.current[compilerContextKey] ?? rootContext;
27 } 31 }
28 32
29 /// Perform [action] in a [Zone] where [cl] will be available as 33 /// Perform [action] in a [Zone] where [cl] will be available as
30 /// `CompilerContext.current.options`. 34 /// `CompilerContext.current.options`.
31 static dynamic withGlobalOptions( 35 static dynamic withGlobalOptions(
32 CompilerCommandLine cl, dynamic action(CompilerContext c)) { 36 CompilerCommandLine cl, dynamic action(CompilerContext c)) {
33 CompilerContext c = new CompilerContext(cl); 37 CompilerContext c = new CompilerContext(cl);
34 return runZoned(() => action(c), zoneValues: {compilerContextKey: c}); 38 return runZoned(() => action(c), zoneValues: {compilerContextKey: c});
35 } 39 }
40
41 static bool get enableColors {
42 return current.enableColorsCached ??= computeEnableColors(current);
43 }
36 } 44 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/colors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698