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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 } | 758 } |
759 | 759 |
760 @override | 760 @override |
761 CompilationUnitElement getCompilationUnitElement( | 761 CompilationUnitElement getCompilationUnitElement( |
762 Source unitSource, Source librarySource) { | 762 Source unitSource, Source librarySource) { |
763 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); | 763 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); |
764 return getResult(target, COMPILATION_UNIT_ELEMENT); | 764 return getResult(target, COMPILATION_UNIT_ELEMENT); |
765 } | 765 } |
766 | 766 |
767 @override | 767 @override |
768 Object getConfigurationData(ResultDescriptor key) => _configurationData[key]; | 768 Object getConfigurationData(ResultDescriptor key) => |
| 769 _configurationData[key] ?? key?.defaultValue; |
769 | 770 |
770 @override | 771 @override |
771 TimestampedData<String> getContents(Source source) { | 772 TimestampedData<String> getContents(Source source) { |
772 String contents = _contentCache.getContents(source); | 773 String contents = _contentCache.getContents(source); |
773 if (contents != null) { | 774 if (contents != null) { |
774 return new TimestampedData<String>( | 775 return new TimestampedData<String>( |
775 _contentCache.getModificationStamp(source), contents); | 776 _contentCache.getModificationStamp(source), contents); |
776 } | 777 } |
777 return source.contents; | 778 return source.contents; |
778 } | 779 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 } | 1018 } |
1018 } | 1019 } |
1019 if (notify && changed) { | 1020 if (notify && changed) { |
1020 _onSourcesChangedController | 1021 _onSourcesChangedController |
1021 .add(new SourcesChangedEvent.changedContent(source, newContents)); | 1022 .add(new SourcesChangedEvent.changedContent(source, newContents)); |
1022 } | 1023 } |
1023 return changed; | 1024 return changed; |
1024 } | 1025 } |
1025 | 1026 |
1026 /** | 1027 /** |
1027 * Invalidate analysis cache. | 1028 * Invalidate analysis cache and notify work managers that they have work |
| 1029 * to do. |
1028 */ | 1030 */ |
1029 void invalidateCachedResults() { | 1031 void invalidateCachedResults() { |
1030 _cache = createCacheFromSourceFactory(_sourceFactory); | 1032 _cache = createCacheFromSourceFactory(_sourceFactory); |
| 1033 for (WorkManager workManager in workManagers) { |
| 1034 workManager.onAnalysisOptionsChanged(); |
| 1035 } |
1031 } | 1036 } |
1032 | 1037 |
1033 @override | 1038 @override |
1034 void invalidateLibraryHints(Source librarySource) { | 1039 void invalidateLibraryHints(Source librarySource) { |
1035 List<Source> sources = getResult(librarySource, UNITS); | 1040 List<Source> sources = getResult(librarySource, UNITS); |
1036 if (sources != null) { | 1041 if (sources != null) { |
1037 for (Source source in sources) { | 1042 for (Source source in sources) { |
1038 getCacheEntry(source).setState(HINTS, CacheState.INVALID); | 1043 getCacheEntry(source).setState(HINTS, CacheState.INVALID); |
1039 } | 1044 } |
1040 } | 1045 } |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2129 DartSdk sdk = factory.dartSdk; | 2134 DartSdk sdk = factory.dartSdk; |
2130 if (sdk == null) { | 2135 if (sdk == null) { |
2131 throw new IllegalArgumentException( | 2136 throw new IllegalArgumentException( |
2132 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2137 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
2133 } | 2138 } |
2134 return new AnalysisCache(<CachePartition>[ | 2139 return new AnalysisCache(<CachePartition>[ |
2135 AnalysisEngine.instance.partitionManager_new.forSdk(sdk) | 2140 AnalysisEngine.instance.partitionManager_new.forSdk(sdk) |
2136 ]); | 2141 ]); |
2137 } | 2142 } |
2138 } | 2143 } |
OLD | NEW |