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/src/cancelable_future.dart'; | 10 import 'package:analyzer/src/cancelable_future.dart'; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 this._options.lint = options.lint; | 226 this._options.lint = options.lint; |
227 this._options.preserveComments = options.preserveComments; | 227 this._options.preserveComments = options.preserveComments; |
228 if (needsRecompute) { | 228 if (needsRecompute) { |
229 _invalidateAllLocalResolutionInformation(false); | 229 _invalidateAllLocalResolutionInformation(false); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 @override | 233 @override |
234 void set analysisPriorityOrder(List<Source> sources) { | 234 void set analysisPriorityOrder(List<Source> sources) { |
235 if (sources == null || sources.isEmpty) { | 235 if (sources == null || sources.isEmpty) { |
236 _priorityOrder = Source.EMPTY_ARRAY; | 236 _priorityOrder = Source.EMPTY_LIST; |
237 } else { | 237 } else { |
238 while (sources.remove(null)) { | 238 while (sources.remove(null)) { |
239 // Nothing else to do. | 239 // Nothing else to do. |
240 } | 240 } |
241 if (sources.isEmpty) { | 241 if (sources.isEmpty) { |
242 _priorityOrder = Source.EMPTY_ARRAY; | 242 _priorityOrder = Source.EMPTY_LIST; |
243 } else { | 243 } else { |
244 _priorityOrder = sources; | 244 _priorityOrder = sources; |
245 } | 245 } |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 @override | 249 @override |
250 set contentCache(ContentCache value) { | 250 set contentCache(ContentCache value) { |
251 _contentCache = value; | 251 _contentCache = value; |
252 } | 252 } |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 // if (sourceEntry is HtmlEntry) { | 769 // if (sourceEntry is HtmlEntry) { |
770 // return sourceEntry.getValue(HtmlEntry.ELEMENT); | 770 // return sourceEntry.getValue(HtmlEntry.ELEMENT); |
771 // } | 771 // } |
772 return null; | 772 return null; |
773 } | 773 } |
774 | 774 |
775 @override | 775 @override |
776 List<Source> getHtmlFilesReferencing(Source source) { | 776 List<Source> getHtmlFilesReferencing(Source source) { |
777 SourceKind sourceKind = getKindOf(source); | 777 SourceKind sourceKind = getKindOf(source); |
778 if (sourceKind == null) { | 778 if (sourceKind == null) { |
779 return Source.EMPTY_ARRAY; | 779 return Source.EMPTY_LIST; |
780 } | 780 } |
781 List<Source> htmlSources = new List<Source>(); | 781 List<Source> htmlSources = new List<Source>(); |
782 while (true) { | 782 while (true) { |
783 if (sourceKind == SourceKind.PART) { | 783 if (sourceKind == SourceKind.PART) { |
784 List<Source> librarySources = getLibrariesContaining(source); | 784 List<Source> librarySources = getLibrariesContaining(source); |
785 MapIterator<AnalysisTarget, cache.CacheEntry> iterator = | 785 MapIterator<AnalysisTarget, cache.CacheEntry> iterator = |
786 _cache.iterator(); | 786 _cache.iterator(); |
787 while (iterator.moveNext()) { | 787 while (iterator.moveNext()) { |
788 cache.CacheEntry entry = iterator.value; | 788 cache.CacheEntry entry = iterator.value; |
789 if (entry.getValue(SOURCE_KIND) == SourceKind.HTML) { | 789 if (entry.getValue(SOURCE_KIND) == SourceKind.HTML) { |
(...skipping 14 matching lines...) Expand all Loading... |
804 (entry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARIES); | 804 (entry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARIES); |
805 if (_contains(referencedLibraries, source)) { | 805 if (_contains(referencedLibraries, source)) { |
806 htmlSources.add(iterator.key); | 806 htmlSources.add(iterator.key); |
807 } | 807 } |
808 } | 808 } |
809 } | 809 } |
810 } | 810 } |
811 break; | 811 break; |
812 } | 812 } |
813 if (htmlSources.isEmpty) { | 813 if (htmlSources.isEmpty) { |
814 return Source.EMPTY_ARRAY; | 814 return Source.EMPTY_LIST; |
815 } | 815 } |
816 return htmlSources; | 816 return htmlSources; |
817 } | 817 } |
818 | 818 |
819 @override | 819 @override |
820 SourceKind getKindOf(Source source) => _getResult(source, SOURCE_KIND); | 820 SourceKind getKindOf(Source source) => _getResult(source, SOURCE_KIND); |
821 | 821 |
822 @override | 822 @override |
823 List<Source> getLibrariesContaining(Source source) { | 823 List<Source> getLibrariesContaining(Source source) { |
824 // TODO(brianwilkerson) Implement this. | 824 // TODO(brianwilkerson) Implement this. |
825 // cache.CacheEntry sourceEntry = _cache.get(source); | 825 // cache.CacheEntry sourceEntry = _cache.get(source); |
826 // if (sourceEntry is DartEntry) { | 826 // if (sourceEntry is DartEntry) { |
827 // return sourceEntry.containingLibraries; | 827 // return sourceEntry.containingLibraries; |
828 // } | 828 // } |
829 return Source.EMPTY_ARRAY; | 829 return Source.EMPTY_LIST; |
830 } | 830 } |
831 | 831 |
832 @override | 832 @override |
833 List<Source> getLibrariesDependingOn(Source librarySource) { | 833 List<Source> getLibrariesDependingOn(Source librarySource) { |
834 List<Source> dependentLibraries = new List<Source>(); | 834 List<Source> dependentLibraries = new List<Source>(); |
835 MapIterator<AnalysisTarget, cache.CacheEntry> iterator = _cache.iterator(); | 835 MapIterator<AnalysisTarget, cache.CacheEntry> iterator = _cache.iterator(); |
836 while (iterator.moveNext()) { | 836 while (iterator.moveNext()) { |
837 cache.CacheEntry entry = iterator.value; | 837 cache.CacheEntry entry = iterator.value; |
838 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY) { | 838 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY) { |
839 if (_contains(entry.getValue(EXPORTED_LIBRARIES), librarySource)) { | 839 if (_contains(entry.getValue(EXPORTED_LIBRARIES), librarySource)) { |
840 dependentLibraries.add(iterator.key); | 840 dependentLibraries.add(iterator.key); |
841 } | 841 } |
842 if (_contains(entry.getValue(IMPORTED_LIBRARIES), librarySource)) { | 842 if (_contains(entry.getValue(IMPORTED_LIBRARIES), librarySource)) { |
843 dependentLibraries.add(iterator.key); | 843 dependentLibraries.add(iterator.key); |
844 } | 844 } |
845 } | 845 } |
846 } | 846 } |
847 if (dependentLibraries.isEmpty) { | 847 if (dependentLibraries.isEmpty) { |
848 return Source.EMPTY_ARRAY; | 848 return Source.EMPTY_LIST; |
849 } | 849 } |
850 return dependentLibraries; | 850 return dependentLibraries; |
851 } | 851 } |
852 | 852 |
853 @override | 853 @override |
854 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { | 854 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { |
855 // TODO(brianwilkerson) Implement this. | 855 // TODO(brianwilkerson) Implement this. |
856 // cache.CacheEntry entry = getReadableSourceEntryOrNull(htmlSource); | 856 // cache.CacheEntry entry = getReadableSourceEntryOrNull(htmlSource); |
857 // if (entry is HtmlEntry) { | 857 // if (entry is HtmlEntry) { |
858 // HtmlEntry htmlEntry = entry; | 858 // HtmlEntry htmlEntry = entry; |
859 // return htmlEntry.getValue(HtmlEntry.REFERENCED_LIBRARIES); | 859 // return htmlEntry.getValue(HtmlEntry.REFERENCED_LIBRARIES); |
860 // } | 860 // } |
861 return Source.EMPTY_ARRAY; | 861 return Source.EMPTY_LIST; |
862 } | 862 } |
863 | 863 |
864 @override | 864 @override |
865 LibraryElement getLibraryElement(Source source) => | 865 LibraryElement getLibraryElement(Source source) => |
866 _getResult(source, LIBRARY_ELEMENT); | 866 _getResult(source, LIBRARY_ELEMENT); |
867 | 867 |
868 @override | 868 @override |
869 LineInfo getLineInfo(Source source) => _getResult(source, LINE_INFO); | 869 LineInfo getLineInfo(Source source) => _getResult(source, LINE_INFO); |
870 | 870 |
871 @override | 871 @override |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 entry.setValue(result, value, cache.TargetedResult.EMPTY_LIST, null); | 1071 entry.setValue(result, value, cache.TargetedResult.EMPTY_LIST, null); |
1072 } | 1072 } |
1073 setValue(BUILD_DIRECTIVES_ERRORS, AnalysisError.NO_ERRORS); | 1073 setValue(BUILD_DIRECTIVES_ERRORS, AnalysisError.NO_ERRORS); |
1074 setValue(BUILD_FUNCTION_TYPE_ALIASES_ERRORS, AnalysisError.NO_ERRORS); | 1074 setValue(BUILD_FUNCTION_TYPE_ALIASES_ERRORS, AnalysisError.NO_ERRORS); |
1075 setValue(BUILD_LIBRARY_ERRORS, AnalysisError.NO_ERRORS); | 1075 setValue(BUILD_LIBRARY_ERRORS, AnalysisError.NO_ERRORS); |
1076 // CLASS_ELEMENTS | 1076 // CLASS_ELEMENTS |
1077 setValue(COMPILATION_UNIT_ELEMENT, library.definingCompilationUnit); | 1077 setValue(COMPILATION_UNIT_ELEMENT, library.definingCompilationUnit); |
1078 // CONSTRUCTORS | 1078 // CONSTRUCTORS |
1079 // CONSTRUCTORS_ERRORS | 1079 // CONSTRUCTORS_ERRORS |
1080 entry.setState(CONTENT, CacheState.FLUSHED); | 1080 entry.setState(CONTENT, CacheState.FLUSHED); |
1081 setValue(EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 1081 setValue(EXPORTED_LIBRARIES, Source.EMPTY_LIST); |
1082 // EXPORT_SOURCE_CLOSURE | 1082 // EXPORT_SOURCE_CLOSURE |
1083 setValue(IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 1083 setValue(IMPORTED_LIBRARIES, Source.EMPTY_LIST); |
1084 // IMPORT_SOURCE_CLOSURE | 1084 // IMPORT_SOURCE_CLOSURE |
1085 setValue(INCLUDED_PARTS, Source.EMPTY_ARRAY); | 1085 setValue(INCLUDED_PARTS, Source.EMPTY_LIST); |
1086 setValue(IS_CLIENT, true); | 1086 setValue(IS_CLIENT, true); |
1087 setValue(IS_LAUNCHABLE, false); | 1087 setValue(IS_LAUNCHABLE, false); |
1088 setValue(LIBRARY_ELEMENT, library); | 1088 setValue(LIBRARY_ELEMENT, library); |
1089 setValue(LIBRARY_ELEMENT1, library); | 1089 setValue(LIBRARY_ELEMENT1, library); |
1090 setValue(LIBRARY_ELEMENT2, library); | 1090 setValue(LIBRARY_ELEMENT2, library); |
1091 setValue(LIBRARY_ELEMENT3, library); | 1091 setValue(LIBRARY_ELEMENT3, library); |
1092 setValue(LIBRARY_ELEMENT4, library); | 1092 setValue(LIBRARY_ELEMENT4, library); |
1093 setValue(LIBRARY_ELEMENT5, library); | 1093 setValue(LIBRARY_ELEMENT5, library); |
1094 setValue(LINE_INFO, new LineInfo(<int>[0])); | 1094 setValue(LINE_INFO, new LineInfo(<int>[0])); |
1095 setValue(PARSE_ERRORS, AnalysisError.NO_ERRORS); | 1095 setValue(PARSE_ERRORS, AnalysisError.NO_ERRORS); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 PendingFuture pendingFuture = | 2141 PendingFuture pendingFuture = |
2142 new PendingFuture<T>(_context, target, computeValue); | 2142 new PendingFuture<T>(_context, target, computeValue); |
2143 if (!pendingFuture.evaluate(entry)) { | 2143 if (!pendingFuture.evaluate(entry)) { |
2144 _context._pendingFutureTargets | 2144 _context._pendingFutureTargets |
2145 .putIfAbsent(target, () => <PendingFuture>[]) | 2145 .putIfAbsent(target, () => <PendingFuture>[]) |
2146 .add(pendingFuture); | 2146 .add(pendingFuture); |
2147 } | 2147 } |
2148 return pendingFuture.future; | 2148 return pendingFuture.future; |
2149 } | 2149 } |
2150 } | 2150 } |
OLD | NEW |