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

Side by Side Diff: pkg/front_end/tool/_fasta/analyzer_compile.dart

Issue 2977013002: Report messages instead of just printing. (Closed)
Patch Set: Update expectations. 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 unified diff | Download patch
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.analyzer_compile; 5 library fasta.analyzer_compile;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show exitCode; 9 import 'dart:io' show exitCode;
10 10
11 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget; 11 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget;
12 12
13 import 'package:front_end/src/fasta/compiler_command_line.dart' 13 import 'package:front_end/src/fasta/compiler_command_line.dart'
14 show CompilerCommandLine; 14 show CompilerCommandLine;
15 15
16 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; 16 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
17 17
18 import 'package:front_end/src/fasta/ticker.dart' show Ticker; 18 import 'package:front_end/src/fasta/ticker.dart' show Ticker;
19 19
20 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; 20 import 'package:front_end/src/fasta/fasta.dart' show CompileTask;
21 21
22 import 'package:front_end/src/fasta/deprecated_problems.dart' 22 import 'package:front_end/src/fasta/deprecated_problems.dart'
23 show deprecated_InputError; 23 show deprecated_InputError;
24 24
25 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; 25 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
26 26
27 import 'package:front_end/src/fasta/severity.dart' show Severity;
28
27 import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator; 29 import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator;
28 30
29 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); 31 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
30 32
31 Future<Uri> compile(List<String> arguments) async { 33 Future<Uri> compile(List<String> arguments) async {
32 try { 34 try {
33 return await CompilerCommandLine.withGlobalOptions("kompile", arguments, 35 return await CompilerCommandLine.withGlobalOptions("kompile", arguments,
34 (CompilerContext c) async { 36 (CompilerContext c) async {
35 if (c.options.verbose) { 37 if (c.options.verbose) {
36 print("Compiling via analyzer: ${arguments.join(' ')}"); 38 print("Compiling via analyzer: ${arguments.join(' ')}");
37 } 39 }
38 AnalyzerCompileTask task = 40 AnalyzerCompileTask task =
39 new AnalyzerCompileTask(c, new Ticker(isVerbose: c.options.verbose)); 41 new AnalyzerCompileTask(c, new Ticker(isVerbose: c.options.verbose));
40 return await task.compile(); 42 return await task.compile();
41 }); 43 });
42 } on deprecated_InputError catch (e) { 44 } on deprecated_InputError catch (e) {
45 CompilerContext.current
46 .report(deprecated_InputError.toMessage(e), Severity.error);
43 exitCode = 1; 47 exitCode = 1;
44 print(e.deprecated_format());
45 return null; 48 return null;
46 } 49 }
47 } 50 }
48 51
49 class AnalyzerCompileTask extends CompileTask { 52 class AnalyzerCompileTask extends CompileTask {
50 AnalyzerCompileTask(CompilerContext c, Ticker ticker) : super(c, ticker); 53 AnalyzerCompileTask(CompilerContext c, Ticker ticker) : super(c, ticker);
51 54
52 @override 55 @override
53 AnalyzerTarget createKernelTarget( 56 AnalyzerTarget createKernelTarget(
54 DillTarget dillTarget, UriTranslator uriTranslator, bool strongMode) { 57 DillTarget dillTarget, UriTranslator uriTranslator, bool strongMode) {
55 return new AnalyzerTarget( 58 return new AnalyzerTarget(
56 dillTarget, uriTranslator, strongMode, c.uriToSource); 59 dillTarget, uriTranslator, strongMode, c.uriToSource);
57 } 60 }
58 } 61 }
59 62
60 main(List<String> arguments) async { 63 main(List<String> arguments) async {
61 for (int i = 0; i < iterations; i++) { 64 for (int i = 0; i < iterations; i++) {
62 if (i > 0) { 65 if (i > 0) {
63 print("\n"); 66 print("\n");
64 } 67 }
65 await compile(arguments); 68 await compile(arguments);
66 } 69 }
67 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698