| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 engine; | 5 library engine; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
| 10 | 10 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 * Apply the given [delta] to change the level of analysis that will be | 445 * Apply the given [delta] to change the level of analysis that will be |
| 446 * performed for the sources known to this context. | 446 * performed for the sources known to this context. |
| 447 */ | 447 */ |
| 448 void applyAnalysisDelta(AnalysisDelta delta); | 448 void applyAnalysisDelta(AnalysisDelta delta); |
| 449 | 449 |
| 450 /** | 450 /** |
| 451 * Apply the changes specified by the given [changeSet] to this context. Any | 451 * Apply the changes specified by the given [changeSet] to this context. Any |
| 452 * analysis results that have been invalidated by these changes will be | 452 * analysis results that have been invalidated by these changes will be |
| 453 * removed. | 453 * removed. |
| 454 */ | 454 */ |
| 455 void applyChanges(ChangeSet changeSet); | 455 ApplyChangesStatus applyChanges(ChangeSet changeSet); |
| 456 | 456 |
| 457 /** | 457 /** |
| 458 * Return the documentation comment for the given [element] as it appears in | 458 * Return the documentation comment for the given [element] as it appears in |
| 459 * the original source (complete with the beginning and ending delimiters) for | 459 * the original source (complete with the beginning and ending delimiters) for |
| 460 * block documentation comments, or lines starting with `"///"` and separated | 460 * block documentation comments, or lines starting with `"///"` and separated |
| 461 * with `"\n"` characters for end-of-line documentation comments, or `null` if | 461 * with `"\n"` characters for end-of-line documentation comments, or `null` if |
| 462 * the element does not have a documentation comment associated with it. This | 462 * the element does not have a documentation comment associated with it. This |
| 463 * can be a long-running operation if the information needed to access the | 463 * can be a long-running operation if the information needed to access the |
| 464 * comment is not cached. | 464 * comment is not cached. |
| 465 * | 465 * |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 if (level == AnalysisLevel.NONE) { | 1609 if (level == AnalysisLevel.NONE) { |
| 1610 changeSet.removedSource(source); | 1610 changeSet.removedSource(source); |
| 1611 } else { | 1611 } else { |
| 1612 changeSet.addedSource(source); | 1612 changeSet.addedSource(source); |
| 1613 } | 1613 } |
| 1614 }); | 1614 }); |
| 1615 applyChanges(changeSet); | 1615 applyChanges(changeSet); |
| 1616 } | 1616 } |
| 1617 | 1617 |
| 1618 @override | 1618 @override |
| 1619 void applyChanges(ChangeSet changeSet) { | 1619 ApplyChangesStatus applyChanges(ChangeSet changeSet) { |
| 1620 if (changeSet.isEmpty) { | 1620 if (changeSet.isEmpty) { |
| 1621 return; | 1621 return new ApplyChangesStatus(false); |
| 1622 } | 1622 } |
| 1623 // | 1623 // |
| 1624 // First, compute the list of sources that have been removed. | 1624 // First, compute the list of sources that have been removed. |
| 1625 // | 1625 // |
| 1626 List<Source> removedSources = | 1626 List<Source> removedSources = |
| 1627 new List<Source>.from(changeSet.removedSources); | 1627 new List<Source>.from(changeSet.removedSources); |
| 1628 for (SourceContainer container in changeSet.removedContainers) { | 1628 for (SourceContainer container in changeSet.removedContainers) { |
| 1629 _addSourcesInContainer(removedSources, container); | 1629 _addSourcesInContainer(removedSources, container); |
| 1630 } | 1630 } |
| 1631 // | 1631 // |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1651 _contentRangeChanged(source, change.contents, change.offset, | 1651 _contentRangeChanged(source, change.contents, change.offset, |
| 1652 change.oldLength, change.newLength); | 1652 change.oldLength, change.newLength); |
| 1653 }); | 1653 }); |
| 1654 for (Source source in changeSet.deletedSources) { | 1654 for (Source source in changeSet.deletedSources) { |
| 1655 _sourceDeleted(source); | 1655 _sourceDeleted(source); |
| 1656 } | 1656 } |
| 1657 for (Source source in removedSources) { | 1657 for (Source source in removedSources) { |
| 1658 _sourceRemoved(source); | 1658 _sourceRemoved(source); |
| 1659 } | 1659 } |
| 1660 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); | 1660 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); |
| 1661 return new ApplyChangesStatus(true); |
| 1661 } | 1662 } |
| 1662 | 1663 |
| 1663 @override | 1664 @override |
| 1664 String computeDocumentationComment(Element element) { | 1665 String computeDocumentationComment(Element element) { |
| 1665 if (element == null) { | 1666 if (element == null) { |
| 1666 return null; | 1667 return null; |
| 1667 } | 1668 } |
| 1668 Source source = element.source; | 1669 Source source = element.source; |
| 1669 if (source == null) { | 1670 if (source == null) { |
| 1670 return null; | 1671 return null; |
| (...skipping 5124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6795 E visitResolveHtmlTask(ResolveHtmlTask task); | 6796 E visitResolveHtmlTask(ResolveHtmlTask task); |
| 6796 | 6797 |
| 6797 /** | 6798 /** |
| 6798 * Visit the given [task], returning the result of the visit. This method will | 6799 * Visit the given [task], returning the result of the visit. This method will |
| 6799 * throw an AnalysisException if the visitor throws an exception. | 6800 * throw an AnalysisException if the visitor throws an exception. |
| 6800 */ | 6801 */ |
| 6801 E visitScanDartTask(ScanDartTask task); | 6802 E visitScanDartTask(ScanDartTask task); |
| 6802 } | 6803 } |
| 6803 | 6804 |
| 6804 /** | 6805 /** |
| 6806 * The result of applying a [ChangeSet] to a [AnalysisContext]. |
| 6807 */ |
| 6808 class ApplyChangesStatus { |
| 6809 /** |
| 6810 * Is `true` if the given [ChangeSet] caused any changes in the context. |
| 6811 */ |
| 6812 final bool hasChanges; |
| 6813 |
| 6814 ApplyChangesStatus(this.hasChanges); |
| 6815 } |
| 6816 |
| 6817 /** |
| 6805 * A `CachedResult` is a single analysis result that is stored in a | 6818 * A `CachedResult` is a single analysis result that is stored in a |
| 6806 * [SourceEntry]. | 6819 * [SourceEntry]. |
| 6807 */ | 6820 */ |
| 6808 class CachedResult<E> { | 6821 class CachedResult<E> { |
| 6809 /** | 6822 /** |
| 6810 * The state of the cached value. | 6823 * The state of the cached value. |
| 6811 */ | 6824 */ |
| 6812 CacheState state; | 6825 CacheState state; |
| 6813 | 6826 |
| 6814 /** | 6827 /** |
| (...skipping 5298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12113 PendingFuture pendingFuture = | 12126 PendingFuture pendingFuture = |
| 12114 new PendingFuture<T>(_context, source, computeValue); | 12127 new PendingFuture<T>(_context, source, computeValue); |
| 12115 if (!pendingFuture.evaluate(sourceEntry)) { | 12128 if (!pendingFuture.evaluate(sourceEntry)) { |
| 12116 _context._pendingFutureSources | 12129 _context._pendingFutureSources |
| 12117 .putIfAbsent(source, () => <PendingFuture>[]) | 12130 .putIfAbsent(source, () => <PendingFuture>[]) |
| 12118 .add(pendingFuture); | 12131 .add(pendingFuture); |
| 12119 } | 12132 } |
| 12120 return pendingFuture.future; | 12133 return pendingFuture.future; |
| 12121 } | 12134 } |
| 12122 } | 12135 } |
| OLD | NEW |