| 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 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 if (entry == null) { | 1818 if (entry == null) { |
| 1819 return; | 1819 return; |
| 1820 } | 1820 } |
| 1821 | 1821 |
| 1822 String oldContents = compareWithOld ? entry.getValue(CONTENT) : null; | 1822 String oldContents = compareWithOld ? entry.getValue(CONTENT) : null; |
| 1823 | 1823 |
| 1824 // Flush so that from now on we will get new contents. | 1824 // Flush so that from now on we will get new contents. |
| 1825 // (For example, in getLibrariesContaining.) | 1825 // (For example, in getLibrariesContaining.) |
| 1826 entry.setState(CONTENT, CacheState.FLUSHED); | 1826 entry.setState(CONTENT, CacheState.FLUSHED); |
| 1827 | 1827 |
| 1828 if (oldContents != null) { | 1828 // Prepare the new contents. |
| 1829 // Fast path if the content is the same as it was last time. | 1829 TimestampedData<String> fileContents; |
| 1830 try { | 1830 try { |
| 1831 TimestampedData<String> fileContents = getContents(source); | 1831 fileContents = getContents(source); |
| 1832 if (fileContents.data == oldContents) { | 1832 } catch (e) {} |
| 1833 int time = fileContents.modificationTime; | 1833 |
| 1834 for (CacheEntry entry in _entriesFor(source)) { | 1834 // Update 'modificationTime' - we are going to update the entry. |
| 1835 entry.modificationTime = time; | 1835 { |
| 1836 } | 1836 int time = fileContents?.modificationTime ?? -1; |
| 1837 return; | 1837 for (CacheEntry entry in _entriesFor(source)) { |
| 1838 } | 1838 entry.modificationTime = time; |
| 1839 } catch (e) { | |
| 1840 entry.modificationTime = -1; | |
| 1841 } | 1839 } |
| 1842 } | 1840 } |
| 1841 |
| 1842 // Fast path if the contents is the same as it was last time. |
| 1843 if (oldContents != null && fileContents?.data == oldContents) { |
| 1844 return; |
| 1845 } |
| 1846 |
| 1843 // We need to invalidate the cache. | 1847 // We need to invalidate the cache. |
| 1844 { | 1848 { |
| 1845 if (analysisOptions.finerGrainedInvalidation && | 1849 if (analysisOptions.finerGrainedInvalidation && |
| 1846 AnalysisEngine.isDartFileName(source.fullName)) { | 1850 AnalysisEngine.isDartFileName(source.fullName)) { |
| 1847 // TODO(scheglov) Incorrect implementation in general. | 1851 // TODO(scheglov) Incorrect implementation in general. |
| 1848 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); | 1852 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); |
| 1849 entry.setState(PARSED_UNIT, CacheState.FLUSHED); | 1853 entry.setState(PARSED_UNIT, CacheState.FLUSHED); |
| 1850 List<Source> librarySources = getLibrariesContaining(source); | 1854 List<Source> librarySources = getLibrariesContaining(source); |
| 1851 if (librarySources.length == 1) { | 1855 if (librarySources.length == 1) { |
| 1852 Source librarySource = librarySources[0]; | 1856 Source librarySource = librarySources[0]; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 } | 2300 } |
| 2297 DartSdk sdk = factory.dartSdk; | 2301 DartSdk sdk = factory.dartSdk; |
| 2298 if (sdk == null) { | 2302 if (sdk == null) { |
| 2299 throw new IllegalArgumentException( | 2303 throw new IllegalArgumentException( |
| 2300 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2304 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2301 } | 2305 } |
| 2302 return new AnalysisCache( | 2306 return new AnalysisCache( |
| 2303 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2307 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2304 } | 2308 } |
| 2305 } | 2309 } |
| OLD | NEW |