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/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 693 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
694 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 694 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
695 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 695 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
696 } | 696 } |
697 return new AnalysisFutureHelper<CompilationUnit>(this, | 697 return new AnalysisFutureHelper<CompilationUnit>(this, |
698 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT) | 698 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT) |
699 .computeAsync(); | 699 .computeAsync(); |
700 } | 700 } |
701 | 701 |
702 @override | 702 @override |
703 Object/*=V*/ computeResult/*<V>*/( | 703 V computeResult<V>(AnalysisTarget target, ResultDescriptor<V> descriptor) { |
704 AnalysisTarget target, ResultDescriptor/*<V>*/ descriptor) { | |
705 // Make sure we are not trying to invoke the task model in a reentrant | 704 // Make sure we are not trying to invoke the task model in a reentrant |
706 // fashion. | 705 // fashion. |
707 assert(!driver.isTaskRunning); | 706 assert(!driver.isTaskRunning); |
708 CacheEntry entry = getCacheEntry(target); | 707 CacheEntry entry = getCacheEntry(target); |
709 CacheState state = entry.getState(descriptor); | 708 CacheState state = entry.getState(descriptor); |
710 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { | 709 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { |
711 // Check the result provider. | 710 // Check the result provider. |
712 bool success = aboutToComputeResult(entry, descriptor); | 711 bool success = aboutToComputeResult(entry, descriptor); |
713 if (success) { | 712 if (success) { |
714 return entry.getValue(descriptor); | 713 return entry.getValue(descriptor); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 833 |
835 @override | 834 @override |
836 CompilationUnitElement getCompilationUnitElement( | 835 CompilationUnitElement getCompilationUnitElement( |
837 Source unitSource, Source librarySource) { | 836 Source unitSource, Source librarySource) { |
838 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); | 837 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); |
839 return getResult(target, COMPILATION_UNIT_ELEMENT); | 838 return getResult(target, COMPILATION_UNIT_ELEMENT); |
840 } | 839 } |
841 | 840 |
842 @deprecated | 841 @deprecated |
843 @override | 842 @override |
844 Object/*=V*/ getConfigurationData/*<V>*/(ResultDescriptor/*<V>*/ key) => | 843 V getConfigurationData<V>(ResultDescriptor<V> key) => |
845 (_configurationData[key] ?? key?.defaultValue) as Object/*=V*/; | 844 (_configurationData[key] ?? key?.defaultValue) as V; |
846 | 845 |
847 @override | 846 @override |
848 TimestampedData<String> getContents(Source source) { | 847 TimestampedData<String> getContents(Source source) { |
849 String contents = _contentCache.getContents(source); | 848 String contents = _contentCache.getContents(source); |
850 if (contents != null) { | 849 if (contents != null) { |
851 return new TimestampedData<String>( | 850 return new TimestampedData<String>( |
852 _contentCache.getModificationStamp(source), contents); | 851 _contentCache.getModificationStamp(source), contents); |
853 } | 852 } |
854 return source.contents; | 853 return source.contents; |
855 } | 854 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 Source unitSource, Source librarySource) { | 1018 Source unitSource, Source librarySource) { |
1020 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 1019 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
1021 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 1020 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
1022 return null; | 1021 return null; |
1023 } | 1022 } |
1024 return getResult( | 1023 return getResult( |
1025 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); | 1024 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT); |
1026 } | 1025 } |
1027 | 1026 |
1028 @override | 1027 @override |
1029 Object/*=V*/ getResult/*<V>*/( | 1028 V getResult<V>(AnalysisTarget target, ResultDescriptor<V> result) { |
1030 AnalysisTarget target, ResultDescriptor/*<V>*/ result) { | |
1031 return _cache.getValue(target, result); | 1029 return _cache.getValue(target, result); |
1032 } | 1030 } |
1033 | 1031 |
1034 @override | 1032 @override |
1035 List<Source> getSourcesWithFullName(String path) { | 1033 List<Source> getSourcesWithFullName(String path) { |
1036 return analysisCache.getSourcesWithFullName(path); | 1034 return analysisCache.getSourcesWithFullName(path); |
1037 } | 1035 } |
1038 | 1036 |
1039 @override | 1037 @override |
1040 bool handleContentsChanged( | 1038 bool handleContentsChanged( |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 } | 1653 } |
1656 } | 1654 } |
1657 | 1655 |
1658 /** | 1656 /** |
1659 * Log the given debugging [message]. | 1657 * Log the given debugging [message]. |
1660 */ | 1658 */ |
1661 void _logInformation(String message) { | 1659 void _logInformation(String message) { |
1662 AnalysisEngine.instance.logger.logInformation(message); | 1660 AnalysisEngine.instance.logger.logInformation(message); |
1663 } | 1661 } |
1664 | 1662 |
1665 bool _notEqual/*<T>*/(List/*<T>*/ first, List/*<T>*/ second) { | 1663 bool _notEqual<T>(List<T> first, List<T> second) { |
1666 int length = first.length; | 1664 int length = first.length; |
1667 if (length != second.length) { | 1665 if (length != second.length) { |
1668 return true; | 1666 return true; |
1669 } | 1667 } |
1670 for (int i = 0; i < length; i++) { | 1668 for (int i = 0; i < length; i++) { |
1671 if (first[i] != second[i]) { | 1669 if (first[i] != second[i]) { |
1672 return true; | 1670 return true; |
1673 } | 1671 } |
1674 } | 1672 } |
1675 return false; | 1673 return false; |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 } | 2108 } |
2111 DartSdk sdk = factory.dartSdk; | 2109 DartSdk sdk = factory.dartSdk; |
2112 if (sdk == null) { | 2110 if (sdk == null) { |
2113 throw new ArgumentError( | 2111 throw new ArgumentError( |
2114 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2112 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
2115 } | 2113 } |
2116 return new AnalysisCache( | 2114 return new AnalysisCache( |
2117 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2115 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
2118 } | 2116 } |
2119 } | 2117 } |
OLD | NEW |