| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine; | 8 library engine; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 */ | 921 */ |
| 922 HashSet<Source> _neededForResolution = null; | 922 HashSet<Source> _neededForResolution = null; |
| 923 | 923 |
| 924 /** | 924 /** |
| 925 * A table mapping sources to the change notices that are waiting to be return
ed related to that | 925 * A table mapping sources to the change notices that are waiting to be return
ed related to that |
| 926 * source. | 926 * source. |
| 927 */ | 927 */ |
| 928 HashMap<Source, ChangeNoticeImpl> _pendingNotices = new HashMap<Source, Change
NoticeImpl>(); | 928 HashMap<Source, ChangeNoticeImpl> _pendingNotices = new HashMap<Source, Change
NoticeImpl>(); |
| 929 | 929 |
| 930 /** | 930 /** |
| 931 * A set containing information about the tasks that have been performed since
the last change | |
| 932 * notification. Used to detect infinite loops in [performAnalysisTask]. | |
| 933 */ | |
| 934 LinkedHashSet<String> _recentTasks = new LinkedHashSet<String>(); | |
| 935 | |
| 936 /** | |
| 937 * A flag indicating whether we have already reported an infinite loop in | |
| 938 * [performAnalysisTask]. | |
| 939 */ | |
| 940 bool _reportedLoop = false; | |
| 941 | |
| 942 /** | |
| 943 * The object used to synchronize access to all of the caches. The rules relat
ed to the use of | 931 * The object used to synchronize access to all of the caches. The rules relat
ed to the use of |
| 944 * this lock object are | 932 * this lock object are |
| 945 * * no analysis work is done while holding the lock, and | 933 * * no analysis work is done while holding the lock, and |
| 946 * * no analysis results can be recorded unless we have obtained the lock and
validated that the | 934 * * no analysis results can be recorded unless we have obtained the lock and
validated that the |
| 947 * results are for the same version (modification time) of the source as our c
urrent cache | 935 * results are for the same version (modification time) of the source as our c
urrent cache |
| 948 * content. | 936 * content. |
| 949 */ | 937 */ |
| 950 static Object _cacheLock = new Object(); | 938 static Object _cacheLock = new Object(); |
| 951 | 939 |
| 952 /** | 940 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 } | 1009 } |
| 1022 } | 1010 } |
| 1023 applyChanges(changeSet); | 1011 applyChanges(changeSet); |
| 1024 } | 1012 } |
| 1025 | 1013 |
| 1026 @override | 1014 @override |
| 1027 void applyChanges(ChangeSet changeSet) { | 1015 void applyChanges(ChangeSet changeSet) { |
| 1028 if (changeSet.isEmpty) { | 1016 if (changeSet.isEmpty) { |
| 1029 return; | 1017 return; |
| 1030 } | 1018 } |
| 1031 _recentTasks.clear(); | |
| 1032 _reportedLoop = false; | |
| 1033 // | 1019 // |
| 1034 // First, compute the list of sources that have been removed. | 1020 // First, compute the list of sources that have been removed. |
| 1035 // | 1021 // |
| 1036 List<Source> removedSources = new List<Source>.from(changeSet.removedSources
); | 1022 List<Source> removedSources = new List<Source>.from(changeSet.removedSources
); |
| 1037 for (SourceContainer container in changeSet.removedContainers) { | 1023 for (SourceContainer container in changeSet.removedContainers) { |
| 1038 _addSourcesInContainer(removedSources, container); | 1024 _addSourcesInContainer(removedSources, container); |
| 1039 } | 1025 } |
| 1040 // | 1026 // |
| 1041 // Then determine which cached results are no longer valid. | 1027 // Then determine which cached results are no longer valid. |
| 1042 // | 1028 // |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 int getStart = JavaSystem.currentTimeMillis(); | 1708 int getStart = JavaSystem.currentTimeMillis(); |
| 1723 AnalysisTask task = nextAnalysisTask; | 1709 AnalysisTask task = nextAnalysisTask; |
| 1724 int getEnd = JavaSystem.currentTimeMillis(); | 1710 int getEnd = JavaSystem.currentTimeMillis(); |
| 1725 if (task == null && _validateCacheConsistency()) { | 1711 if (task == null && _validateCacheConsistency()) { |
| 1726 task = nextAnalysisTask; | 1712 task = nextAnalysisTask; |
| 1727 } | 1713 } |
| 1728 if (task == null) { | 1714 if (task == null) { |
| 1729 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); | 1715 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); |
| 1730 } | 1716 } |
| 1731 String taskDescription = task.toString(); | 1717 String taskDescription = task.toString(); |
| 1732 // if (!reportedLoop && !recentTasks.add(taskDescription)) { | |
| 1733 // reportedLoop = true; | |
| 1734 // @SuppressWarnings("resource") | |
| 1735 // PrintStringWriter writer = new PrintStringWriter(); | |
| 1736 // writer.print("Performing repeated task: "); | |
| 1737 // writer.println(taskDescription); | |
| 1738 // for (String description : recentTasks) { | |
| 1739 // writer.print(" "); | |
| 1740 // writer.println(description); | |
| 1741 // } | |
| 1742 // logInformation(writer.toString()); | |
| 1743 // } | |
| 1744 _notifyAboutToPerformTask(taskDescription); | 1718 _notifyAboutToPerformTask(taskDescription); |
| 1745 if (_TRACE_PERFORM_TASK) { | 1719 if (_TRACE_PERFORM_TASK) { |
| 1746 print(taskDescription); | 1720 print(taskDescription); |
| 1747 } | 1721 } |
| 1748 int performStart = JavaSystem.currentTimeMillis(); | 1722 int performStart = JavaSystem.currentTimeMillis(); |
| 1749 try { | 1723 try { |
| 1750 task.perform(_resultRecorder); | 1724 task.perform(_resultRecorder); |
| 1751 } on ObsoleteSourceAnalysisException catch (exception) { | 1725 } on ObsoleteSourceAnalysisException catch (exception) { |
| 1752 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescription}", exception); | 1726 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescription}", exception); |
| 1753 } on AnalysisException catch (exception) { | 1727 } on AnalysisException catch (exception) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 int count = Math.min(sources.length, _options.cacheSize - _PRIORITY_ORDER_
SIZE_DELTA); | 1860 int count = Math.min(sources.length, _options.cacheSize - _PRIORITY_ORDER_
SIZE_DELTA); |
| 1887 _priorityOrder = new List<Source>(count); | 1861 _priorityOrder = new List<Source>(count); |
| 1888 for (int i = 0; i < count; i++) { | 1862 for (int i = 0; i < count; i++) { |
| 1889 _priorityOrder[i] = sources[i]; | 1863 _priorityOrder[i] = sources[i]; |
| 1890 } | 1864 } |
| 1891 } | 1865 } |
| 1892 } | 1866 } |
| 1893 | 1867 |
| 1894 @override | 1868 @override |
| 1895 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { | 1869 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { |
| 1896 _recentTasks.clear(); | |
| 1897 _reportedLoop = false; | |
| 1898 String originalContents = _contentCache.setContents(source, contents); | 1870 String originalContents = _contentCache.setContents(source, contents); |
| 1899 if (contents != null) { | 1871 if (contents != null) { |
| 1900 if (contents != originalContents) { | 1872 if (contents != originalContents) { |
| 1901 if (_options.incremental) { | 1873 if (_options.incremental) { |
| 1902 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment
alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt
h, _getReadableSourceEntry(source)); | 1874 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment
alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt
h, _getReadableSourceEntry(source)); |
| 1903 } | 1875 } |
| 1904 _sourceChanged(source); | 1876 _sourceChanged(source); |
| 1905 SourceEntryImpl sourceEntry = _cache.get(source); | 1877 SourceEntryImpl sourceEntry = _cache.get(source); |
| 1906 if (sourceEntry != null) { | 1878 if (sourceEntry != null) { |
| 1907 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour
ce); | 1879 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour
ce); |
| 1908 sourceEntry.setValue(SourceEntry.CONTENT, contents); | 1880 sourceEntry.setValue(SourceEntry.CONTENT, contents); |
| 1909 } | 1881 } |
| 1910 } | 1882 } |
| 1911 } else if (originalContents != null) { | 1883 } else if (originalContents != null) { |
| 1912 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); | 1884 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); |
| 1913 _sourceChanged(source); | 1885 _sourceChanged(source); |
| 1914 } | 1886 } |
| 1915 } | 1887 } |
| 1916 | 1888 |
| 1917 @override | 1889 @override |
| 1918 void setContents(Source source, String contents) { | 1890 void setContents(Source source, String contents) { |
| 1919 _recentTasks.clear(); | |
| 1920 _reportedLoop = false; | |
| 1921 String originalContents = _contentCache.setContents(source, contents); | 1891 String originalContents = _contentCache.setContents(source, contents); |
| 1922 if (contents != null) { | 1892 if (contents != null) { |
| 1923 if (contents != originalContents) { | 1893 if (contents != originalContents) { |
| 1924 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); | 1894 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); |
| 1925 _sourceChanged(source); | 1895 _sourceChanged(source); |
| 1926 SourceEntryImpl sourceEntry = _cache.get(source); | 1896 SourceEntryImpl sourceEntry = _cache.get(source); |
| 1927 if (sourceEntry != null) { | 1897 if (sourceEntry != null) { |
| 1928 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour
ce); | 1898 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour
ce); |
| 1929 sourceEntry.setValue(SourceEntry.CONTENT, contents); | 1899 sourceEntry.setValue(SourceEntry.CONTENT, contents); |
| 1930 } | 1900 } |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3680 _workManager.add(source, SourcePriority.HTML); | 3650 _workManager.add(source, SourcePriority.HTML); |
| 3681 } else if (sourceEntry is DartEntry) { | 3651 } else if (sourceEntry is DartEntry) { |
| 3682 DartEntryImpl dartEntry = sourceEntry; | 3652 DartEntryImpl dartEntry = sourceEntry; |
| 3683 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); | 3653 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
| 3684 dartEntry.invalidateAllResolutionInformation(invalidateUris); | 3654 dartEntry.invalidateAllResolutionInformation(invalidateUris); |
| 3685 iterator.value = dartEntry; | 3655 iterator.value = dartEntry; |
| 3686 _workManager.add(source, _computePriority(dartEntry)); | 3656 _workManager.add(source, _computePriority(dartEntry)); |
| 3687 } | 3657 } |
| 3688 } | 3658 } |
| 3689 _removeFromPartsUsingMap(oldPartMap); | 3659 _removeFromPartsUsingMap(oldPartMap); |
| 3690 _recentTasks.clear(); | |
| 3691 _reportedLoop = false; | |
| 3692 } | 3660 } |
| 3693 | 3661 |
| 3694 /** | 3662 /** |
| 3695 * In response to a change to Angular entry point [HtmlElement], invalidate an
y results that | 3663 * In response to a change to Angular entry point [HtmlElement], invalidate an
y results that |
| 3696 * depend on it. | 3664 * depend on it. |
| 3697 * | 3665 * |
| 3698 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3666 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3699 * | 3667 * |
| 3700 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be | 3668 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
| 3701 * re-accessed after this method returns. | 3669 * re-accessed after this method returns. |
| (...skipping 11537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15239 void _advance() { | 15207 void _advance() { |
| 15240 _index++; | 15208 _index++; |
| 15241 if (_index >= _manager._workQueues[_queueIndex].length) { | 15209 if (_index >= _manager._workQueues[_queueIndex].length) { |
| 15242 _index = 0; | 15210 _index = 0; |
| 15243 _queueIndex++; | 15211 _queueIndex++; |
| 15244 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_
queueIndex].isEmpty) { | 15212 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_
queueIndex].isEmpty) { |
| 15245 _queueIndex++; | 15213 _queueIndex++; |
| 15246 } | 15214 } |
| 15247 } | 15215 } |
| 15248 } | 15216 } |
| 15249 } | 15217 } |
| OLD | NEW |