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

Side by Side Diff: lib/devc.dart

Issue 1067553004: Factor out reporting from rules (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Change set/get pair to field Created 5 years, 8 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/src/checker/checker.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 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Command line tool to run the checker on a Dart program. 5 /// Command line tool to run the checker on a Dart program.
6 library dev_compiler.devc; 6 library dev_compiler.devc;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ? new TypeResolver.fromMock(mockSdkSources, options) 61 ? new TypeResolver.fromMock(mockSdkSources, options)
62 : new TypeResolver.fromDir(options.dartSdkPath, options); 62 : new TypeResolver.fromDir(options.dartSdkPath, options);
63 } 63 }
64 64
65 if (reporter == null) { 65 if (reporter == null) {
66 reporter = options.dumpInfo 66 reporter = options.dumpInfo
67 ? new SummaryReporter() 67 ? new SummaryReporter()
68 : new LogReporter(options.useColors); 68 : new LogReporter(options.useColors);
69 } 69 }
70 var graph = new SourceGraph(resolver.context, reporter, options); 70 var graph = new SourceGraph(resolver.context, reporter, options);
71 var rules = new RestrictedRules(resolver.context.typeProvider, reporter, 71 var rules =
72 options: options); 72 new RestrictedRules(resolver.context.typeProvider, options: options);
73 var checker = new CodeChecker(rules, reporter, options); 73 var checker = new CodeChecker(rules, reporter, options);
74 var inputFile = options.entryPointFile; 74 var inputFile = options.entryPointFile;
75 var uri = inputFile.startsWith('dart:') || inputFile.startsWith('package:') 75 var uri = inputFile.startsWith('dart:') || inputFile.startsWith('package:')
76 ? Uri.parse(inputFile) 76 ? Uri.parse(inputFile)
77 : new Uri.file(path.absolute(inputFile)); 77 : new Uri.file(path.absolute(inputFile));
78 var entryNode = graph.nodeFromUri(uri); 78 var entryNode = graph.nodeFromUri(uri);
79 79
80 var outputDir = options.outputDir; 80 var outputDir = options.outputDir;
81 var generators = <CodeGenerator>[]; 81 var generators = <CodeGenerator>[];
82 if (options.dumpSrcDir != null) { 82 if (options.dumpSrcDir != null) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 var resolvedParts = node.parts 170 var resolvedParts = node.parts
171 .map((p) => _resolver.context.resolveCompilationUnit2(p.source, source)) 171 .map((p) => _resolver.context.resolveCompilationUnit2(p.source, source))
172 .toList(growable: false); 172 .toList(growable: false);
173 var libraryUnit = new LibraryUnit(entryUnit, resolvedParts); 173 var libraryUnit = new LibraryUnit(entryUnit, resolvedParts);
174 bool failureInLib = false; 174 bool failureInLib = false;
175 for (var unit in libraryUnit.libraryThenParts) { 175 for (var unit in libraryUnit.libraryThenParts) {
176 var unitSource = unit.element.source; 176 var unitSource = unit.element.source;
177 _reporter.enterSource(unitSource); 177 _reporter.enterSource(unitSource);
178 // TODO(sigmund): integrate analyzer errors with static-info (issue #6). 178 // TODO(sigmund): integrate analyzer errors with static-info (issue #6).
179 failureInLib = _resolver.logErrors(unitSource, _reporter) || failureInLib; 179 failureInLib = _resolver.logErrors(unitSource, _reporter) || failureInLib;
180 unit.visitChildren(_checker); 180 _checker.visitCompilationUnit(unit);
181 if (_checker.failure) failureInLib = true; 181 if (_checker.failure) failureInLib = true;
182 _reporter.leaveSource(); 182 _reporter.leaveSource();
183 } 183 }
184 if (failureInLib) { 184 if (failureInLib) {
185 _failure = true; 185 _failure = true;
186 if (!_options.forceCompile) return; 186 if (!_options.forceCompile) return;
187 } 187 }
188 188
189 for (var cg in _generators) { 189 for (var cg in _generators) {
190 var hash = cg.generateLibrary(libraryUnit, current, _reporter); 190 var hash = cg.generateLibrary(libraryUnit, current);
191 if (_hashing) node.cachingHash = hash; 191 if (_hashing) node.cachingHash = hash;
192 } 192 }
193 _reporter.leaveLibrary(); 193 _reporter.leaveLibrary();
194 } 194 }
195 195
196 CheckerResults run() { 196 CheckerResults run() {
197 var clock = new Stopwatch()..start(); 197 var clock = new Stopwatch()..start();
198 198
199 // TODO(sigmund): we are missing a couple failures here. The 199 // TODO(sigmund): we are missing a couple failures here. The
200 // dependency_graph now detects broken imports or unsupported features 200 // dependency_graph now detects broken imports or unsupported features
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // Note: the cache-control header should be enough, but this doesn't hurt 306 // Note: the cache-control header should be enough, but this doesn't hurt
307 // and can help renew the policy after it expires. 307 // and can help renew the policy after it expires.
308 headers['ETag'] = segments[1]; 308 headers['ETag'] = segments[1];
309 } 309 }
310 return response.change(headers: headers); 310 return response.change(headers: headers);
311 }; 311 };
312 } 312 }
313 313
314 final _log = new Logger('dev_compiler'); 314 final _log = new Logger('dev_compiler');
315 final _earlyErrorResult = new CheckerResults(const [], null, true); 315 final _earlyErrorResult = new CheckerResults(const [], null, true);
OLDNEW
« no previous file with comments | « no previous file | lib/src/checker/checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698