| OLD | NEW |
| 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.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/instrumentation/instrumentation.dart'; | 10 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 this._options.dart2jsHint = options.dart2jsHint; | 247 this._options.dart2jsHint = options.dart2jsHint; |
| 248 this._options.enableNullAwareOperators = options.enableNullAwareOperators; | 248 this._options.enableNullAwareOperators = options.enableNullAwareOperators; |
| 249 this._options.enableStrictCallChecks = options.enableStrictCallChecks; | 249 this._options.enableStrictCallChecks = options.enableStrictCallChecks; |
| 250 this._options.hint = options.hint; | 250 this._options.hint = options.hint; |
| 251 this._options.incremental = options.incremental; | 251 this._options.incremental = options.incremental; |
| 252 this._options.incrementalApi = options.incrementalApi; | 252 this._options.incrementalApi = options.incrementalApi; |
| 253 this._options.incrementalValidation = options.incrementalValidation; | 253 this._options.incrementalValidation = options.incrementalValidation; |
| 254 this._options.lint = options.lint; | 254 this._options.lint = options.lint; |
| 255 this._options.preserveComments = options.preserveComments; | 255 this._options.preserveComments = options.preserveComments; |
| 256 if (needsRecompute) { | 256 if (needsRecompute) { |
| 257 _invalidateAllLocalResolutionInformation(false); | 257 dartWorkManager.onAnalysisOptionsChanged(); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 @override | 261 @override |
| 262 void set analysisPriorityOrder(List<Source> sources) { | 262 void set analysisPriorityOrder(List<Source> sources) { |
| 263 if (sources == null || sources.isEmpty) { | 263 if (sources == null || sources.isEmpty) { |
| 264 _priorityOrder = Source.EMPTY_LIST; | 264 _priorityOrder = Source.EMPTY_LIST; |
| 265 } else { | 265 } else { |
| 266 while (sources.remove(null)) { | 266 while (sources.remove(null)) { |
| 267 // Nothing else to do. | 267 // Nothing else to do. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } else if (factory.context != null) { | 359 } else if (factory.context != null) { |
| 360 throw new IllegalStateException( | 360 throw new IllegalStateException( |
| 361 "Source factories cannot be shared between contexts"); | 361 "Source factories cannot be shared between contexts"); |
| 362 } | 362 } |
| 363 if (_sourceFactory != null) { | 363 if (_sourceFactory != null) { |
| 364 _sourceFactory.context = null; | 364 _sourceFactory.context = null; |
| 365 } | 365 } |
| 366 factory.context = this; | 366 factory.context = this; |
| 367 _sourceFactory = factory; | 367 _sourceFactory = factory; |
| 368 _cache = createCacheFromSourceFactory(factory); | 368 _cache = createCacheFromSourceFactory(factory); |
| 369 _invalidateAllLocalResolutionInformation(true); | 369 dartWorkManager.onSourceFactoryChanged(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 @override | 372 @override |
| 373 List<Source> get sources { | 373 List<Source> get sources { |
| 374 return _cache.sources.toList(); | 374 return _cache.sources.toList(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 /** | 377 /** |
| 378 * Return a list of the sources that would be processed by | 378 * Return a list of the sources that would be processed by |
| 379 * [performAnalysisTask]. This method duplicates, and must therefore be kept | 379 * [performAnalysisTask]. This method duplicates, and must therefore be kept |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 // entry.getState(HtmlEntry.RESOLVED_UNIT); | 1536 // entry.getState(HtmlEntry.RESOLVED_UNIT); |
| 1537 // if (resolvedUnitState == CacheState.INVALID || | 1537 // if (resolvedUnitState == CacheState.INVALID || |
| 1538 // (isPriority && resolvedUnitState == CacheState.FLUSHED)) { | 1538 // (isPriority && resolvedUnitState == CacheState.FLUSHED)) { |
| 1539 // sources.add(source); | 1539 // sources.add(source); |
| 1540 // return; | 1540 // return; |
| 1541 // } | 1541 // } |
| 1542 } | 1542 } |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 /** | 1545 /** |
| 1546 * Invalidate all of the resolution results computed by this context. The flag | |
| 1547 * [invalidateUris] should be `true` if the cached results of converting URIs | |
| 1548 * to source files should also be invalidated. | |
| 1549 */ | |
| 1550 void _invalidateAllLocalResolutionInformation(bool invalidateUris) { | |
| 1551 HashMap<Source, List<Source>> oldPartMap = | |
| 1552 new HashMap<Source, List<Source>>(); | |
| 1553 // TODO(brianwilkerson) Implement this | |
| 1554 // MapIterator<AnalysisTarget, cache.CacheEntry> iterator = | |
| 1555 // _privatePartition.iterator(); | |
| 1556 // while (iterator.moveNext()) { | |
| 1557 // AnalysisTarget target = iterator.key; | |
| 1558 // cache.CacheEntry entry = iterator.value; | |
| 1559 // if (entry is HtmlEntry) { | |
| 1560 // HtmlEntry htmlEntry = entry; | |
| 1561 // htmlEntry.invalidateAllResolutionInformation(invalidateUris); | |
| 1562 // iterator.value = htmlEntry; | |
| 1563 // _workManager.add(target, SourcePriority.HTML); | |
| 1564 // } else if (entry is DartEntry) { | |
| 1565 // DartEntry dartEntry = entry; | |
| 1566 // oldPartMap[target] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); | |
| 1567 // dartEntry.invalidateAllResolutionInformation(invalidateUris); | |
| 1568 // iterator.value = dartEntry; | |
| 1569 // _workManager.add(target, _computePriority(dartEntry)); | |
| 1570 // } | |
| 1571 // } | |
| 1572 _removeFromPartsUsingMap(oldPartMap); | |
| 1573 } | |
| 1574 | |
| 1575 /** | |
| 1576 * Log the given debugging [message]. | 1546 * Log the given debugging [message]. |
| 1577 */ | 1547 */ |
| 1578 void _logInformation(String message) { | 1548 void _logInformation(String message) { |
| 1579 AnalysisEngine.instance.logger.logInformation(message); | 1549 AnalysisEngine.instance.logger.logInformation(message); |
| 1580 } | 1550 } |
| 1581 | 1551 |
| 1582 /** | 1552 /** |
| 1583 * Notify all of the analysis listeners that the errors associated with the | 1553 * Notify all of the analysis listeners that the errors associated with the |
| 1584 * given [source] has been updated to the given [errors]. | 1554 * given [source] has been updated to the given [errors]. |
| 1585 */ | 1555 */ |
| 1586 void _notifyErrors( | 1556 void _notifyErrors( |
| 1587 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 1557 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
| 1588 int count = _listeners.length; | 1558 int count = _listeners.length; |
| 1589 for (int i = 0; i < count; i++) { | 1559 for (int i = 0; i < count; i++) { |
| 1590 _listeners[i].computedErrors(this, source, errors, lineInfo); | 1560 _listeners[i].computedErrors(this, source, errors, lineInfo); |
| 1591 } | 1561 } |
| 1592 } | 1562 } |
| 1593 | 1563 |
| 1594 /** | 1564 @override |
| 1595 * Remove the given libraries that are keys in the given map from the list of | 1565 CachePartition get privateAnalysisCachePartition => _privatePartition; |
| 1596 * containing libraries for each of the parts in the corresponding value. | |
| 1597 */ | |
| 1598 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { | |
| 1599 // TODO(brianwilkerson) Figure out whether we still need this. | |
| 1600 // oldPartMap.forEach((Source librarySource, List<Source> oldParts) { | |
| 1601 // for (int i = 0; i < oldParts.length; i++) { | |
| 1602 // Source partSource = oldParts[i]; | |
| 1603 // if (partSource != librarySource) { | |
| 1604 // DartEntry partEntry = _getReadableDartEntry(partSource); | |
| 1605 // if (partEntry != null) { | |
| 1606 // partEntry.removeContainingLibrary(librarySource); | |
| 1607 // if (partEntry.containingLibraries.length == 0 && | |
| 1608 // !exists(partSource)) { | |
| 1609 // _cache.remove(partSource); | |
| 1610 // } | |
| 1611 // } | |
| 1612 // } | |
| 1613 // } | |
| 1614 // }); | |
| 1615 } | |
| 1616 | 1566 |
| 1617 /** | 1567 /** |
| 1618 * Remove the given [source] from the priority order if it is in the list. | 1568 * Remove the given [source] from the priority order if it is in the list. |
| 1619 */ | 1569 */ |
| 1620 void _removeFromPriorityOrder(Source source) { | 1570 void _removeFromPriorityOrder(Source source) { |
| 1621 int count = _priorityOrder.length; | 1571 int count = _priorityOrder.length; |
| 1622 List<Source> newOrder = <Source>[]; | 1572 List<Source> newOrder = <Source>[]; |
| 1623 for (int i = 0; i < count; i++) { | 1573 for (int i = 0; i < count; i++) { |
| 1624 if (_priorityOrder[i] != source) { | 1574 if (_priorityOrder[i] != source) { |
| 1625 newOrder.add(_priorityOrder[i]); | 1575 newOrder.add(_priorityOrder[i]); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 PendingFuture pendingFuture = | 1970 PendingFuture pendingFuture = |
| 2021 new PendingFuture<T>(_context, target, computeValue); | 1971 new PendingFuture<T>(_context, target, computeValue); |
| 2022 if (!pendingFuture.evaluate(entry)) { | 1972 if (!pendingFuture.evaluate(entry)) { |
| 2023 _context._pendingFutureTargets | 1973 _context._pendingFutureTargets |
| 2024 .putIfAbsent(target, () => <PendingFuture>[]) | 1974 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2025 .add(pendingFuture); | 1975 .add(pendingFuture); |
| 2026 } | 1976 } |
| 2027 return pendingFuture.future; | 1977 return pendingFuture.future; |
| 2028 } | 1978 } |
| 2029 } | 1979 } |
| OLD | NEW |