OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /// Command line tool to write checker errors as inline comments in the source | 6 /// Command line tool to write checker errors as inline comments in the source |
7 /// code of the program. This tool requires the info.json file created by | 7 /// code of the program. This tool requires the info.json file created by |
8 /// running dartdevc.dart passing the arguments | 8 /// running dartdevc.dart passing the arguments |
9 /// --dump-info --dump-info-file info.json | 9 /// --dump-info --dump-info-file info.json |
10 | 10 |
11 library dev_compiler.bin.edit_files; | 11 library dev_compiler.bin.edit_files; |
12 | 12 |
13 import 'dart:io'; | 13 import 'dart:io'; |
14 import 'dart:convert'; | 14 import 'dart:convert'; |
15 | 15 |
16 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 16 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
17 import 'package:analyzer/src/generated/source.dart' show Source; | 17 import 'package:analyzer/src/generated/source.dart' show Source; |
18 import 'package:args/args.dart'; | 18 import 'package:args/args.dart'; |
19 import 'package:cli_util/cli_util.dart' show getSdkDir; | 19 import 'package:cli_util/cli_util.dart' show getSdkDir; |
20 import 'package:source_maps/refactor.dart'; | 20 import 'package:source_maps/refactor.dart'; |
21 import 'package:source_span/source_span.dart'; | 21 import 'package:source_span/source_span.dart'; |
22 | 22 |
23 import 'package:dev_compiler/src/analysis_context.dart'; | 23 import 'package:dev_compiler/src/analysis_context.dart'; |
24 import 'package:dev_compiler/src/options.dart'; | 24 import 'package:dev_compiler/src/options.dart'; |
25 import 'package:dev_compiler/src/summary.dart'; | 25 import 'package:dev_compiler/src/summary.dart'; |
26 import 'package:dev_compiler/strong_mode.dart'; | |
27 | 26 |
28 final ArgParser argParser = new ArgParser() | 27 final ArgParser argParser = new ArgParser() |
29 ..addOption('level', help: 'Minimum error level', defaultsTo: "info") | 28 ..addOption('level', help: 'Minimum error level', defaultsTo: "info") |
30 ..addOption('checkout-files-executable', | 29 ..addOption('checkout-files-executable', |
31 help: 'Executable to check out files from source control (e.g. svn)', | 30 help: 'Executable to check out files from source control (e.g. svn)', |
32 defaultsTo: null) | 31 defaultsTo: null) |
33 ..addOption('checkout-files-arg', | 32 ..addOption('checkout-files-arg', |
34 help: 'Arg to check out files from source control (e.g. checkout)', | 33 help: 'Arg to check out files from source control (e.g. checkout)', |
35 defaultsTo: null) | 34 defaultsTo: null) |
36 ..addOption('include-pattern', | 35 ..addOption('include-pattern', |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 146 |
148 Map json = JSON.decode(new File(filename).readAsStringSync()); | 147 Map json = JSON.decode(new File(filename).readAsStringSync()); |
149 var summary = GlobalSummary.parse(json); | 148 var summary = GlobalSummary.parse(json); |
150 var excludePattern = (args['exclude-pattern'] != null) | 149 var excludePattern = (args['exclude-pattern'] != null) |
151 ? new RegExp(args['exclude-pattern']) | 150 ? new RegExp(args['exclude-pattern']) |
152 : null; | 151 : null; |
153 var includePattern = (args['include-pattern'] != null) | 152 var includePattern = (args['include-pattern'] != null) |
154 ? new RegExp(args['include-pattern']) | 153 ? new RegExp(args['include-pattern']) |
155 : null; | 154 : null; |
156 | 155 |
157 var context = | 156 var context = createAnalysisContextWithSources(options); |
158 createAnalysisContextWithSources(new StrongModeOptions(), options); | |
159 var visitor = new EditFileSummaryVisitor( | 157 var visitor = new EditFileSummaryVisitor( |
160 context, | 158 context, |
161 args['level'], | 159 args['level'], |
162 args['checkout-files-executable'], | 160 args['checkout-files-executable'], |
163 args['checkout-files-arg'], | 161 args['checkout-files-arg'], |
164 includePattern, | 162 includePattern, |
165 excludePattern); | 163 excludePattern); |
166 summary.accept(visitor); | 164 summary.accept(visitor); |
167 visitor.build(); | 165 visitor.build(); |
168 } | 166 } |
OLD | NEW |