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

Side by Side Diff: bin/edit_files.dart

Issue 1266483003: format with dart_style 0.2.0-rc.3 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | lib/runtime/messages_widget.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 devc.dart passing the arguments 8 /// running devc.dart passing the arguments
9 /// --dump-info --dump-info-file info.json 9 /// --dump-info --dump-info-file info.json
10 10
(...skipping 27 matching lines...) Expand all
38 ..addOption('exclude-pattern', 38 ..addOption('exclude-pattern',
39 help: 'regular expression of file names to exclude', defaultsTo: null) 39 help: 'regular expression of file names to exclude', defaultsTo: null)
40 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null) 40 ..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null)
41 ..addOption('package-root', 41 ..addOption('package-root',
42 abbr: 'p', 42 abbr: 'p',
43 help: 'Package root to resolve "package:" imports', 43 help: 'Package root to resolve "package:" imports',
44 defaultsTo: 'packages/') 44 defaultsTo: 'packages/')
45 ..addFlag('use-multi-package', 45 ..addFlag('use-multi-package',
46 help: 'Whether to use the multi-package resolver for "package:" imports', 46 help: 'Whether to use the multi-package resolver for "package:" imports',
47 defaultsTo: false) 47 defaultsTo: false)
48 ..addOption('package-paths', help: 'if using the multi-package resolver, ' 48 ..addOption('package-paths',
49 'the list of directories where to look for packages.', defaultsTo: '') 49 help: 'if using the multi-package resolver, '
50 'the list of directories where to look for packages.',
51 defaultsTo: '')
50 ..addFlag('help', abbr: 'h', help: 'Display this message'); 52 ..addFlag('help', abbr: 'h', help: 'Display this message');
51 53
52 void _showUsageAndExit() { 54 void _showUsageAndExit() {
53 print('usage: edit_files [<options>] <summary.json>\n'); 55 print('usage: edit_files [<options>] <summary.json>\n');
54 print('<summary.json> GlobalSummary serialized as json.\n'); 56 print('<summary.json> GlobalSummary serialized as json.\n');
55 print('<options> include:\n'); 57 print('<options> include:\n');
56 print(argParser.usage); 58 print(argParser.usage);
57 exit(1); 59 exit(1);
58 } 60 }
59 61
60 class EditFileSummaryVisitor extends RecursiveSummaryVisitor { 62 class EditFileSummaryVisitor extends RecursiveSummaryVisitor {
61 var _files = new Map<String, TextEditTransaction>(); 63 var _files = new Map<String, TextEditTransaction>();
62 AnalysisContext context; 64 AnalysisContext context;
63 String level; 65 String level;
64 String checkoutFilesExecutable; 66 String checkoutFilesExecutable;
65 String checkoutFilesArg; 67 String checkoutFilesArg;
66 RegExp includePattern; 68 RegExp includePattern;
67 RegExp excludePattern; 69 RegExp excludePattern;
68 70
69 final Map<Uri, Source> _sources = <Uri, Source>{}; 71 final Map<Uri, Source> _sources = <Uri, Source>{};
70 72
71 EditFileSummaryVisitor(this.context, this.level, this.checkoutFilesExecutable, 73 EditFileSummaryVisitor(this.context, this.level, this.checkoutFilesExecutable,
72 this.checkoutFilesArg, this.includePattern, this.excludePattern); 74 this.checkoutFilesArg, this.includePattern, this.excludePattern);
73 75
74 TextEditTransaction getEdits(String name) => _files.putIfAbsent(name, () { 76 TextEditTransaction getEdits(String name) => _files.putIfAbsent(name, () {
75 var fileContents = new File(name).readAsStringSync(); 77 var fileContents = new File(name).readAsStringSync();
76 return new TextEditTransaction(fileContents, new SourceFile(fileContents)); 78 return new TextEditTransaction(
77 }); 79 fileContents, new SourceFile(fileContents));
80 });
78 81
79 /// Find the corresponding [Source] for [uri]. 82 /// Find the corresponding [Source] for [uri].
80 Source findSource(Uri uri) { 83 Source findSource(Uri uri) {
81 var source = _sources[uri]; 84 var source = _sources[uri];
82 if (source != null) return source; 85 if (source != null) return source;
83 return _sources[uri] = context.sourceFactory.forUri('$uri'); 86 return _sources[uri] = context.sourceFactory.forUri('$uri');
84 } 87 }
85 88
86 @override 89 @override
87 void visitMessage(MessageSummary message) { 90 void visitMessage(MessageSummary message) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 var summary = GlobalSummary.parse(json); 149 var summary = GlobalSummary.parse(json);
147 var excludePattern = (args['exclude-pattern'] != null) 150 var excludePattern = (args['exclude-pattern'] != null)
148 ? new RegExp(args['exclude-pattern']) 151 ? new RegExp(args['exclude-pattern'])
149 : null; 152 : null;
150 var includePattern = (args['include-pattern'] != null) 153 var includePattern = (args['include-pattern'] != null)
151 ? new RegExp(args['include-pattern']) 154 ? new RegExp(args['include-pattern'])
152 : null; 155 : null;
153 156
154 var context = 157 var context =
155 createAnalysisContextWithSources(new StrongModeOptions(), options); 158 createAnalysisContextWithSources(new StrongModeOptions(), options);
156 var visitor = new EditFileSummaryVisitor(context, args['level'], 159 var visitor = new EditFileSummaryVisitor(
157 args['checkout-files-executable'], args['checkout-files-arg'], 160 context,
158 includePattern, excludePattern); 161 args['level'],
162 args['checkout-files-executable'],
163 args['checkout-files-arg'],
164 includePattern,
165 excludePattern);
159 summary.accept(visitor); 166 summary.accept(visitor);
160 visitor.build(); 167 visitor.build();
161 } 168 }
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/messages_widget.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698