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

Side by Side Diff: pkg/analyzer/lib/src/task/dart_work_manager.dart

Issue 1160873004: Only units with 'part of' and no other directives are parts. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/context/context_test.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 library analyzer.src.task.dart_work_manager; 5 library analyzer.src.task.dart_work_manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/cache.dart'; 9 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 librarySourceQueue.add(target); 256 librarySourceQueue.add(target);
257 } 257 }
258 } 258 }
259 } 259 }
260 // Update parts in libraries. 260 // Update parts in libraries.
261 if (_isDartSource(target)) { 261 if (_isDartSource(target)) {
262 Source library = target; 262 Source library = target;
263 List<Source> includedParts = outputs[INCLUDED_PARTS]; 263 List<Source> includedParts = outputs[INCLUDED_PARTS];
264 if (includedParts != null) { 264 if (includedParts != null) {
265 libraryPartsMap[library] = includedParts; 265 libraryPartsMap[library] = includedParts;
266 // update contanining libraries
267 for (Source part in includedParts) { 266 for (Source part in includedParts) {
268 List<Source> libraries = 267 List<Source> libraries =
269 partLibrariesMap.putIfAbsent(part, () => <Source>[]); 268 partLibrariesMap.putIfAbsent(part, () => <Source>[]);
270 if (!libraries.contains(library)) { 269 if (!libraries.contains(library)) {
271 libraries.add(library); 270 libraries.add(library);
272 } 271 _invalidateContainingLibraries(part);
273 }
274 // all of the "includedParts" are not libraries anymore
275 for (Source part in includedParts) {
276 unknownSourceQueue.remove(part);
277 librarySourceQueue.remove(part);
278 analysisCache.remove(new LibrarySpecificUnit(part, part));
279 CacheEntry partEntry = analysisCache.get(part);
280 if (partEntry != null) {
281 partEntry.setValue(SOURCE_KIND, SourceKind.PART, <TargetedResult>[
282 new TargetedResult(part, CONTENT),
283 new TargetedResult(target, CONTENT)
284 ]);
285 } 272 }
286 } 273 }
287 } 274 }
288 } 275 }
289 // Update notice. 276 // Update notice.
290 if (_isDartSource(target)) { 277 if (_isDartSource(target)) {
291 bool shouldSetErrors = false; 278 bool shouldSetErrors = false;
292 outputs.forEach((ResultDescriptor descriptor, value) { 279 outputs.forEach((ResultDescriptor descriptor, value) {
293 if (descriptor == PARSED_UNIT && value != null) { 280 if (descriptor == PARSED_UNIT && value != null) {
294 context.getNotice(target).parsedDartUnit = value; 281 context.getNotice(target).parsedDartUnit = value;
(...skipping 22 matching lines...) Expand all
317 context.getNotice(source).setErrors(info.errors, info.lineInfo); 304 context.getNotice(source).setErrors(info.errors, info.lineInfo);
318 } 305 }
319 } 306 }
320 } 307 }
321 308
322 void unitIncrementallyResolved(Source librarySource, Source unitSource) { 309 void unitIncrementallyResolved(Source librarySource, Source unitSource) {
323 librarySourceQueue.add(librarySource); 310 librarySourceQueue.add(librarySource);
324 } 311 }
325 312
326 /** 313 /**
314 * Invalidate [CONTAINING_LIBRARIES] for the given [source].
315 * [CONTAINING_LIBRARIES] does not have dependencies, so we manage it here.
316 * The [source] may be a part, or a library whose contents is updated so
317 * will be a part.
318 */
319 void _invalidateContainingLibraries(Source source) {
320 CacheEntry entry = analysisCache.get(source);
321 if (entry != null) {
322 entry.setState(CONTAINING_LIBRARIES, CacheState.INVALID);
323 }
324 }
325
326 /**
327 * Returns `true` if the given [result] of the given [target] needs 327 * Returns `true` if the given [result] of the given [target] needs
328 * computing, i.e. it is not in the valid and not in the error state. 328 * computing, i.e. it is not in the valid and not in the error state.
329 */ 329 */
330 bool _needsComputing(AnalysisTarget target, ResultDescriptor result) { 330 bool _needsComputing(AnalysisTarget target, ResultDescriptor result) {
331 CacheState state = analysisCache.getState(target, result); 331 CacheState state = analysisCache.getState(target, result);
332 return state != CacheState.VALID && state != CacheState.ERROR; 332 return state != CacheState.VALID && state != CacheState.ERROR;
333 } 333 }
334 334
335 /** 335 /**
336 * The given [library] source was changed or removed. 336 * The given [library] source was changed or removed.
337 * Update [libraryPartsMap] and [partLibrariesMap]. 337 * Update [libraryPartsMap] and [partLibrariesMap].
338 */ 338 */
339 void _onLibrarySourceChangedOrRemoved(Source library) { 339 void _onLibrarySourceChangedOrRemoved(Source library) {
340 List<Source> parts = libraryPartsMap.remove(library); 340 List<Source> parts = libraryPartsMap.remove(library);
341 if (parts != null) { 341 if (parts != null) {
342 for (Source part in parts) { 342 for (Source part in parts) {
343 List<Source> libraries = partLibrariesMap[part]; 343 List<Source> libraries = partLibrariesMap[part];
344 if (libraries != null) { 344 if (libraries != null) {
345 libraries.remove(library); 345 libraries.remove(library);
346 _invalidateContainingLibraries(part);
Brian Wilkerson 2015/06/04 20:45:56 I think this does too much. If a file 'part.dart'
scheglov 2015/06/04 20:50:27 Yes, we will lose it in the cache. So, ContainingL
346 } 347 }
347 } 348 }
348 } 349 }
350 _invalidateContainingLibraries(library);
349 } 351 }
350 352
351 static bool _isDartSource(AnalysisTarget target) { 353 static bool _isDartSource(AnalysisTarget target) {
352 return target is Source && AnalysisEngine.isDartFileName(target.fullName); 354 return target is Source && AnalysisEngine.isDartFileName(target.fullName);
353 } 355 }
354 } 356 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698