| 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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 for (CacheEntry entry in _entriesFor(source)) { | 1849 for (CacheEntry entry in _entriesFor(source)) { |
| 1850 entry.modificationTime = time; | 1850 entry.modificationTime = time; |
| 1851 } | 1851 } |
| 1852 } | 1852 } |
| 1853 | 1853 |
| 1854 // Fast path if the contents is the same as it was last time. | 1854 // Fast path if the contents is the same as it was last time. |
| 1855 if (oldContents != null && fileContents?.data == oldContents) { | 1855 if (oldContents != null && fileContents?.data == oldContents) { |
| 1856 return; | 1856 return; |
| 1857 } | 1857 } |
| 1858 | 1858 |
| 1859 // We're going to update the cache, so reset the driver. |
| 1860 driver.reset(); |
| 1861 |
| 1859 // We need to invalidate the cache. | 1862 // We need to invalidate the cache. |
| 1860 { | 1863 { |
| 1861 if (analysisOptions.finerGrainedInvalidation && | 1864 if (analysisOptions.finerGrainedInvalidation && |
| 1862 AnalysisEngine.isDartFileName(source.fullName)) { | 1865 AnalysisEngine.isDartFileName(source.fullName)) { |
| 1863 // TODO(scheglov) Incorrect implementation in general. | 1866 // TODO(scheglov) Incorrect implementation in general. |
| 1864 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); | 1867 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); |
| 1865 entry.setState(PARSED_UNIT, CacheState.FLUSHED); | 1868 entry.setState(PARSED_UNIT, CacheState.FLUSHED); |
| 1866 SourceKind sourceKind = getKindOf(source); | 1869 SourceKind sourceKind = getKindOf(source); |
| 1867 List<Source> partSources = getResult(source, INCLUDED_PARTS); | 1870 List<Source> partSources = getResult(source, INCLUDED_PARTS); |
| 1868 if (sourceKind == SourceKind.LIBRARY && partSources.isEmpty) { | 1871 if (sourceKind == SourceKind.LIBRARY && partSources.isEmpty) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1891 entry.setState(CONTENT, CacheState.INVALID, delta: dartDelta); | 1894 entry.setState(CONTENT, CacheState.INVALID, delta: dartDelta); |
| 1892 return; | 1895 return; |
| 1893 } | 1896 } |
| 1894 } | 1897 } |
| 1895 } | 1898 } |
| 1896 } | 1899 } |
| 1897 entry.setState(CONTENT, CacheState.INVALID); | 1900 entry.setState(CONTENT, CacheState.INVALID); |
| 1898 entry.setState(MODIFICATION_TIME, CacheState.INVALID); | 1901 entry.setState(MODIFICATION_TIME, CacheState.INVALID); |
| 1899 entry.setState(SOURCE_KIND, CacheState.INVALID); | 1902 entry.setState(SOURCE_KIND, CacheState.INVALID); |
| 1900 } | 1903 } |
| 1901 driver.reset(); | |
| 1902 for (WorkManager workManager in workManagers) { | 1904 for (WorkManager workManager in workManagers) { |
| 1903 workManager.applyChange( | 1905 workManager.applyChange( |
| 1904 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); | 1906 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); |
| 1905 } | 1907 } |
| 1906 } | 1908 } |
| 1907 | 1909 |
| 1908 /** | 1910 /** |
| 1909 * Record that the give [source] has been deleted. | 1911 * Record that the give [source] has been deleted. |
| 1910 */ | 1912 */ |
| 1911 void _sourceDeleted(Source source) { | 1913 void _sourceDeleted(Source source) { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 } | 2298 } |
| 2297 DartSdk sdk = factory.dartSdk; | 2299 DartSdk sdk = factory.dartSdk; |
| 2298 if (sdk == null) { | 2300 if (sdk == null) { |
| 2299 throw new IllegalArgumentException( | 2301 throw new IllegalArgumentException( |
| 2300 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2302 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2301 } | 2303 } |
| 2302 return new AnalysisCache( | 2304 return new AnalysisCache( |
| 2303 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2305 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2304 } | 2306 } |
| 2305 } | 2307 } |
| OLD | NEW |