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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2453693002: Analyze priority files first. (Closed)
Patch Set: Created 4 years, 1 month 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 | no next file » | 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) 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 */ 101 */
102 final AnalysisOptions _analysisOptions; 102 final AnalysisOptions _analysisOptions;
103 103
104 /** 104 /**
105 * The combined unlinked and linked package for the SDK, extracted from 105 * The combined unlinked and linked package for the SDK, extracted from
106 * the given [_sourceFactory]. 106 * the given [_sourceFactory].
107 */ 107 */
108 PackageBundle _sdkBundle; 108 PackageBundle _sdkBundle;
109 109
110 /** 110 /**
111 * The set of explicitly analyzed files.
112 */
113 final _explicitFiles = new LinkedHashSet<String>();
114
115 /**
116 * The set of priority files, that should be analyzed sooner.
117 */
118 final _priorityFiles = new LinkedHashSet<String>();
119
120 /**
111 * The mapping from the files for which analysis was requested using 121 * The mapping from the files for which analysis was requested using
112 * [getResult] to the [Completer]s to report the result. 122 * [getResult] to the [Completer]s to report the result.
113 */ 123 */
114 final _requestedFiles = <String, List<Completer<AnalysisResult>>>{}; 124 final _requestedFiles = <String, List<Completer<AnalysisResult>>>{};
115 125
116 /** 126 /**
117 * The set of explicitly analyzed files.
118 */
119 final _explicitFiles = new LinkedHashSet<String>();
120
121 /**
122 * The set of files were reported as changed through [changeFile] and not 127 * The set of files were reported as changed through [changeFile] and not
123 * checked for actual changes yet. 128 * checked for actual changes yet.
124 */ 129 */
125 final _changedFiles = new LinkedHashSet<String>(); 130 final _changedFiles = new LinkedHashSet<String>();
126 131
127 /** 132 /**
128 * The set of files that are currently scheduled for analysis. 133 * The set of files that are currently scheduled for analysis.
129 */ 134 */
130 final _filesToAnalyze = new LinkedHashSet<String>(); 135 final _filesToAnalyze = new LinkedHashSet<String>();
131 136
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 /** 174 /**
170 * Set the list of files that the driver should try to analyze sooner. 175 * Set the list of files that the driver should try to analyze sooner.
171 * 176 *
172 * Every path in the list must be absolute and normalized. 177 * Every path in the list must be absolute and normalized.
173 * 178 *
174 * The driver will produce the results through the [results] stream. The 179 * The driver will produce the results through the [results] stream. The
175 * exact order in which results are produced is not defined, neither 180 * exact order in which results are produced is not defined, neither
176 * between priority files, nor between priority and non-priority files. 181 * between priority files, nor between priority and non-priority files.
177 */ 182 */
178 void set priorityFiles(List<String> priorityPaths) { 183 void set priorityFiles(List<String> priorityPaths) {
179 // TODO(scheglov) implement 184 _priorityFiles.clear();
185 _priorityFiles.addAll(priorityPaths);
186 _hasWork.notify();
180 } 187 }
181 188
182 /** 189 /**
183 * Return the [Stream] that produces [AnalysisResult]s for added files. 190 * Return the [Stream] that produces [AnalysisResult]s for added files.
184 * 191 *
185 * Analysis starts when the client starts listening to the stream, and stops 192 * Analysis starts when the client starts listening to the stream, and stops
186 * when the client cancels the subscription. 193 * when the client cancels the subscription.
187 * 194 *
188 * When the client starts listening, the analysis state transitions to 195 * When the client starts listening, the analysis state transitions to
189 * "analyzing" and an analysis result is produced for every added file prior 196 * "analyzing" and an analysis result is produced for every added file prior
(...skipping 23 matching lines...) Expand all
213 220
214 // Verify all changed files one at a time. 221 // Verify all changed files one at a time.
215 if (_changedFiles.isNotEmpty) { 222 if (_changedFiles.isNotEmpty) {
216 String path = _removeFirst(_changedFiles); 223 String path = _removeFirst(_changedFiles);
217 _verifyApiSignatureOfChangedFile(path); 224 _verifyApiSignatureOfChangedFile(path);
218 // Repeat the processing loop. 225 // Repeat the processing loop.
219 _hasWork.notify(); 226 _hasWork.notify();
220 continue; 227 continue;
221 } 228 }
222 229
223 // Analyze the first file in the general queue. 230 // TODO(scheglov) analyze requested files
231
232 // Analyze a priority file.
233 if (_priorityFiles.isNotEmpty) {
234 bool analyzed = false;
235 for (String path in _priorityFiles) {
236 if (_filesToAnalyze.remove(path)) {
237 _File file = _fileForPath(path);
238 AnalysisResult result = _computeAnalysisResult(file);
239 yield result;
240 break;
Paul Berry 2016/10/31 16:51:40 Do need to set `analyzed = true` here? Otherwise
scheglov 2016/10/31 17:38:52 Yes, you are right, we need to set `analyzed = tru
241 }
242 }
243 // Repeat the processing loop.
244 if (analyzed) {
245 _hasWork.notify();
246 continue;
247 }
248 }
249
250 // Analyze a general file.
224 if (_filesToAnalyze.isNotEmpty) { 251 if (_filesToAnalyze.isNotEmpty) {
225 String path = _removeFirst(_filesToAnalyze); 252 String path = _removeFirst(_filesToAnalyze);
226 _File file = _fileForPath(path); 253 _File file = _fileForPath(path);
227 AnalysisResult result = _computeAnalysisResult(file); 254 AnalysisResult result = _computeAnalysisResult(file);
228 yield result; 255 yield result;
229 // Repeat the processing loop. 256 // Repeat the processing loop.
230 _hasWork.notify(); 257 _hasWork.notify();
231 continue; 258 continue;
232 } 259 }
233 260
234 // There is nothing to do. 261 // There is nothing to do.
235 analysisSection.exit(); 262 analysisSection.exit();
236 analysisSection = null; 263 analysisSection = null;
237 } 264 }
238 // TODO(scheglov) implement
239 } finally { 265 } finally {
240 print('The stream was cancelled.'); 266 print('The stream was cancelled.');
241 } 267 }
242 } 268 }
243 269
244 /** 270 /**
245 * Add the file with the given [path] to the set of files to analyze. 271 * Add the file with the given [path] to the set of files to analyze.
246 * 272 *
247 * The [path] must be absolute and normalized. 273 * The [path] must be absolute and normalized.
248 * 274 *
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 } 1018 }
993 } 1019 }
994 for (UnlinkedExportPublic export in unit.publicNamespace.exports) { 1020 for (UnlinkedExportPublic export in unit.publicNamespace.exports) {
995 referenced.exported.add(export.uri); 1021 referenced.exported.add(export.uri);
996 } 1022 }
997 return referenced; 1023 return referenced;
998 } 1024 }
999 1025
1000 _ReferencedUris._(); 1026 _ReferencedUris._();
1001 } 1027 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698