OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.messages; | 5 library fasta.messages; |
6 | 6 |
7 import 'dart:io' show exitCode; | 7 import 'dart:io' show exitCode; |
8 | 8 |
9 import 'package:kernel/ast.dart' show Library, Location, Program, TreeNode; | 9 import 'package:kernel/ast.dart' show Library, Location, Program, TreeNode; |
10 | 10 |
11 import 'util/relativize.dart' show relativizeUri; | 11 import 'util/relativize.dart' show relativizeUri; |
12 | 12 |
13 import 'compiler_context.dart' show CompilerContext; | 13 import 'compiler_context.dart' show CompilerContext; |
14 | 14 |
15 import 'deprecated_problems.dart' show deprecated_InputError; | 15 import 'deprecated_problems.dart' |
| 16 show deprecated_InputError, temporaryUntilPrintsRemovedEnablePrinting; |
16 | 17 |
17 import 'colors.dart' show cyan, magenta; | 18 import 'colors.dart' show cyan, magenta; |
18 | 19 |
19 import 'fasta_codes.dart' show Message; | 20 import 'fasta_codes.dart' show Message; |
20 | 21 |
21 export 'fasta_codes.dart'; | 22 export 'fasta_codes.dart'; |
22 | 23 |
23 const bool hideWarnings = false; | 24 const bool hideWarnings = false; |
24 | 25 |
25 bool get errorsAreFatal => CompilerContext.current.options.errorsAreFatal; | 26 bool get errorsAreFatal => CompilerContext.current.options.errorsAreFatal; |
26 | 27 |
27 bool get nitsAreFatal => CompilerContext.current.options.nitsAreFatal; | 28 bool get nitsAreFatal => CompilerContext.current.options.nitsAreFatal; |
28 | 29 |
29 bool get warningsAreFatal => CompilerContext.current.options.warningsAreFatal; | 30 bool get warningsAreFatal => CompilerContext.current.options.warningsAreFatal; |
30 | 31 |
31 bool get isVerbose => CompilerContext.current.options.verbose; | 32 bool get isVerbose => CompilerContext.current.options.verbose; |
32 | 33 |
33 bool get hideNits => !isVerbose; | 34 bool get hideNits => !isVerbose; |
34 | 35 |
35 bool get setExitCodeOnProblem { | 36 bool get setExitCodeOnProblem { |
36 return CompilerContext.current.options.setExitCodeOnProblem; | 37 return CompilerContext.current.options.setExitCodeOnProblem; |
37 } | 38 } |
38 | 39 |
39 void warning(Message message, int charOffset, Uri uri) { | 40 void warning(Message message, int charOffset, Uri uri) { |
40 if (hideWarnings) return; | 41 if (hideWarnings) return; |
41 print(deprecated_format( | 42 if (temporaryUntilPrintsRemovedEnablePrinting) { |
42 uri, charOffset, colorWarning("Warning: ${message.message}"))); | 43 print(deprecated_format( |
| 44 uri, charOffset, colorWarning("Warning: ${message.message}"))); |
| 45 } |
43 if (warningsAreFatal) { | 46 if (warningsAreFatal) { |
44 if (isVerbose) print(StackTrace.current); | 47 if (isVerbose) print(StackTrace.current); |
45 throw new deprecated_InputError( | 48 throw new deprecated_InputError( |
46 uri, charOffset, "Compilation aborted due to fatal warnings."); | 49 uri, charOffset, "Compilation aborted due to fatal warnings."); |
47 } | 50 } |
48 } | 51 } |
49 | 52 |
50 void nit(Message message, int charOffset, Uri uri) { | 53 void nit(Message message, int charOffset, Uri uri) { |
51 if (hideNits) return; | 54 if (hideNits) return; |
52 print( | 55 print( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 program.libraries.clear(); | 126 program.libraries.clear(); |
124 parent.parent = null; | 127 parent.parent = null; |
125 return result; | 128 return result; |
126 } else { | 129 } else { |
127 return null; | 130 return null; |
128 } | 131 } |
129 } else { | 132 } else { |
130 return node.location; | 133 return node.location; |
131 } | 134 } |
132 } | 135 } |
OLD | NEW |