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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 HashMap<AnalysisTarget, List<PendingFuture>> get pendingFutureSources_forTesti
ng => | 343 HashMap<AnalysisTarget, List<PendingFuture>> get pendingFutureSources_forTesti
ng => |
344 _pendingFutureTargets; | 344 _pendingFutureTargets; |
345 | 345 |
346 @override | 346 @override |
347 List<Source> get prioritySources => _priorityOrder; | 347 List<Source> get prioritySources => _priorityOrder; |
348 | 348 |
349 @override | 349 @override |
350 List<AnalysisTarget> get priorityTargets => prioritySources; | 350 List<AnalysisTarget> get priorityTargets => prioritySources; |
351 | 351 |
352 @override | 352 @override |
| 353 CachePartition get privateAnalysisCachePartition => _privatePartition; |
| 354 |
| 355 @override |
353 SourceFactory get sourceFactory => _sourceFactory; | 356 SourceFactory get sourceFactory => _sourceFactory; |
354 | 357 |
355 @override | 358 @override |
356 void set sourceFactory(SourceFactory factory) { | 359 void set sourceFactory(SourceFactory factory) { |
357 if (identical(_sourceFactory, factory)) { | 360 if (identical(_sourceFactory, factory)) { |
358 return; | 361 return; |
359 } else if (factory.context != null) { | 362 } else if (factory.context != null) { |
360 throw new IllegalStateException( | 363 throw new IllegalStateException( |
361 "Source factories cannot be shared between contexts"); | 364 "Source factories cannot be shared between contexts"); |
362 } | 365 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // TODO(brianwilkerson) Implement this. | 763 // TODO(brianwilkerson) Implement this. |
761 // SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); | 764 // SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); |
762 // if (sourceEntry is HtmlEntry) { | 765 // if (sourceEntry is HtmlEntry) { |
763 // return sourceEntry.getValue(HtmlEntry.ELEMENT); | 766 // return sourceEntry.getValue(HtmlEntry.ELEMENT); |
764 // } | 767 // } |
765 return null; | 768 return null; |
766 } | 769 } |
767 | 770 |
768 @override | 771 @override |
769 List<Source> getHtmlFilesReferencing(Source source) { | 772 List<Source> getHtmlFilesReferencing(Source source) { |
| 773 // TODO(brianwilkerson) Implement this. |
770 SourceKind sourceKind = getKindOf(source); | 774 SourceKind sourceKind = getKindOf(source); |
771 if (sourceKind == null) { | 775 if (sourceKind == null) { |
772 return Source.EMPTY_LIST; | 776 return Source.EMPTY_LIST; |
773 } | 777 } |
774 List<Source> htmlSources = <Source>[]; | 778 List<Source> htmlSources = <Source>[]; |
775 while (true) { | 779 // while (true) { |
776 if (sourceKind == SourceKind.PART) { | 780 // if (sourceKind == SourceKind.PART) { |
777 List<Source> librarySources = getLibrariesContaining(source); | 781 // List<Source> librarySources = getLibrariesContaining(source); |
778 for (Source source in _cache.sources) { | 782 // for (Source source in _cache.sources) { |
779 CacheEntry entry = _cache.get(source); | 783 // CacheEntry entry = _cache.get(source); |
780 if (entry.getValue(SOURCE_KIND) == SourceKind.HTML) { | 784 // if (entry.getValue(SOURCE_KIND) == SourceKind.HTML) { |
781 List<Source> referencedLibraries = | 785 // List<Source> referencedLibraries = |
782 (entry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARIES); | 786 // (entry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARIES); |
783 if (_containsAny(referencedLibraries, librarySources)) { | 787 // if (_containsAny(referencedLibraries, librarySources)) { |
784 htmlSources.add(source); | 788 // htmlSources.add(source); |
785 } | 789 // } |
786 } | 790 // } |
787 } | 791 // } |
788 } else { | 792 // } else { |
789 for (Source source in _cache.sources) { | 793 // for (Source source in _cache.sources) { |
790 CacheEntry entry = _cache.get(source); | 794 // CacheEntry entry = _cache.get(source); |
791 if (entry.getValue(SOURCE_KIND) == SourceKind.HTML) { | 795 // if (entry.getValue(SOURCE_KIND) == SourceKind.HTML) { |
792 List<Source> referencedLibraries = | 796 // List<Source> referencedLibraries = |
793 (entry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARIES); | 797 // (entry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARIES); |
794 if (_contains(referencedLibraries, source)) { | 798 // if (_contains(referencedLibraries, source)) { |
795 htmlSources.add(source); | 799 // htmlSources.add(source); |
796 } | 800 // } |
797 } | 801 // } |
798 } | 802 // } |
799 } | 803 // } |
800 break; | 804 // break; |
801 } | 805 // } |
802 if (htmlSources.isEmpty) { | 806 if (htmlSources.isEmpty) { |
803 return Source.EMPTY_LIST; | 807 return Source.EMPTY_LIST; |
804 } | 808 } |
805 return htmlSources; | 809 return htmlSources; |
806 } | 810 } |
807 | 811 |
808 @override | 812 @override |
809 SourceKind getKindOf(Source source) { | 813 SourceKind getKindOf(Source source) { |
810 String name = source.shortName; | 814 String name = source.shortName; |
811 if (AnalysisEngine.isDartFileName(name)) { | 815 if (AnalysisEngine.isDartFileName(name)) { |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 } else if (!entry.explicitlyAdded) { | 1171 } else if (!entry.explicitlyAdded) { |
1168 return _options.generateImplicitErrors; | 1172 return _options.generateImplicitErrors; |
1169 } else { | 1173 } else { |
1170 return true; | 1174 return true; |
1171 } | 1175 } |
1172 } | 1176 } |
1173 | 1177 |
1174 @override | 1178 @override |
1175 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 1179 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
1176 DataDescriptor rowDesc, CacheState state)) { | 1180 DataDescriptor rowDesc, CacheState state)) { |
1177 // TODO(brianwilkerson) Figure out where this is used and adjust the call | 1181 // TODO(brianwilkerson) Figure out where this is used and either remove it |
1178 // sites to use CacheEntry's. | 1182 // or adjust the call sites to use CacheEntry's. |
1179 // bool hintsEnabled = _options.hint; | 1183 // bool hintsEnabled = _options.hint; |
1180 // bool lintsEnabled = _options.lint; | 1184 // bool lintsEnabled = _options.lint; |
1181 // MapIterator<AnalysisTarget, cache.CacheEntry> iterator = _cache.iterator()
; | 1185 // MapIterator<AnalysisTarget, cache.CacheEntry> iterator = _cache.iterator()
; |
1182 // while (iterator.moveNext()) { | 1186 // while (iterator.moveNext()) { |
1183 // Source source = iterator.key; | 1187 // Source source = iterator.key; |
1184 // cache.CacheEntry entry = iterator.value; | 1188 // cache.CacheEntry entry = iterator.value; |
1185 // for (DataDescriptor descriptor in entry.descriptors) { | 1189 // for (DataDescriptor descriptor in entry.descriptors) { |
1186 // if (descriptor == DartEntry.SOURCE_KIND) { | 1190 // if (descriptor == DartEntry.SOURCE_KIND) { |
1187 // // The source kind is always valid, so the state isn't interesting. | 1191 // // The source kind is always valid, so the state isn't interesting. |
1188 // continue; | 1192 // continue; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 * given [source] has been updated to the given [errors]. | 1558 * given [source] has been updated to the given [errors]. |
1555 */ | 1559 */ |
1556 void _notifyErrors( | 1560 void _notifyErrors( |
1557 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 1561 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
1558 int count = _listeners.length; | 1562 int count = _listeners.length; |
1559 for (int i = 0; i < count; i++) { | 1563 for (int i = 0; i < count; i++) { |
1560 _listeners[i].computedErrors(this, source, errors, lineInfo); | 1564 _listeners[i].computedErrors(this, source, errors, lineInfo); |
1561 } | 1565 } |
1562 } | 1566 } |
1563 | 1567 |
1564 @override | |
1565 CachePartition get privateAnalysisCachePartition => _privatePartition; | |
1566 | |
1567 /** | 1568 /** |
1568 * Remove the given [source] from the priority order if it is in the list. | 1569 * Remove the given [source] from the priority order if it is in the list. |
1569 */ | 1570 */ |
1570 void _removeFromPriorityOrder(Source source) { | 1571 void _removeFromPriorityOrder(Source source) { |
1571 int count = _priorityOrder.length; | 1572 int count = _priorityOrder.length; |
1572 List<Source> newOrder = <Source>[]; | 1573 List<Source> newOrder = <Source>[]; |
1573 for (int i = 0; i < count; i++) { | 1574 for (int i = 0; i < count; i++) { |
1574 if (_priorityOrder[i] != source) { | 1575 if (_priorityOrder[i] != source) { |
1575 newOrder.add(_priorityOrder[i]); | 1576 newOrder.add(_priorityOrder[i]); |
1576 } | 1577 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 PendingFuture pendingFuture = | 1971 PendingFuture pendingFuture = |
1971 new PendingFuture<T>(_context, target, computeValue); | 1972 new PendingFuture<T>(_context, target, computeValue); |
1972 if (!pendingFuture.evaluate(entry)) { | 1973 if (!pendingFuture.evaluate(entry)) { |
1973 _context._pendingFutureTargets | 1974 _context._pendingFutureTargets |
1974 .putIfAbsent(target, () => <PendingFuture>[]) | 1975 .putIfAbsent(target, () => <PendingFuture>[]) |
1975 .add(pendingFuture); | 1976 .add(pendingFuture); |
1976 } | 1977 } |
1977 return pendingFuture.future; | 1978 return pendingFuture.future; |
1978 } | 1979 } |
1979 } | 1980 } |
OLD | NEW |