| 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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 | 948 |
| 949 @override | 949 @override |
| 950 bool handleContentsChanged( | 950 bool handleContentsChanged( |
| 951 Source source, String originalContents, String newContents, bool notify) { | 951 Source source, String originalContents, String newContents, bool notify) { |
| 952 CacheEntry entry = _cache.get(source); | 952 CacheEntry entry = _cache.get(source); |
| 953 if (entry == null) { | 953 if (entry == null) { |
| 954 return false; | 954 return false; |
| 955 } | 955 } |
| 956 bool changed = newContents != originalContents; | 956 bool changed = newContents != originalContents; |
| 957 if (newContents != null) { | 957 if (newContents != null) { |
| 958 if (newContents != originalContents) { | 958 if (changed) { |
| 959 if (!analysisOptions.incremental || | 959 if (!analysisOptions.incremental || |
| 960 !_tryPoorMansIncrementalResolution(source, newContents)) { | 960 !_tryPoorMansIncrementalResolution(source, newContents)) { |
| 961 _sourceChanged(source); | 961 _sourceChanged(source); |
| 962 } | 962 } |
| 963 entry.modificationTime = _contentCache.getModificationStamp(source); | 963 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 964 entry.setValue(CONTENT, newContents, TargetedResult.EMPTY_LIST); | 964 entry.setValue(CONTENT, newContents, TargetedResult.EMPTY_LIST); |
| 965 } else { | 965 } else { |
| 966 entry.modificationTime = _contentCache.getModificationStamp(source); | 966 entry.modificationTime = _contentCache.getModificationStamp(source); |
| 967 } | 967 } |
| 968 } else if (originalContents != null) { | 968 } else if (originalContents != null) { |
| 969 changed = newContents != originalContents; | |
| 970 // We are removing the overlay for the file, check if the file's | 969 // We are removing the overlay for the file, check if the file's |
| 971 // contents is the same as it was in the overlay. | 970 // contents is the same as it was in the overlay. |
| 972 try { | 971 try { |
| 973 TimestampedData<String> fileContents = getContents(source); | 972 TimestampedData<String> fileContents = getContents(source); |
| 974 String fileContentsData = fileContents.data; | 973 String fileContentsData = fileContents.data; |
| 975 if (fileContentsData == originalContents) { | 974 if (fileContentsData == originalContents) { |
| 976 entry.setValue(CONTENT, fileContentsData, TargetedResult.EMPTY_LIST); | 975 entry.setValue(CONTENT, fileContentsData, TargetedResult.EMPTY_LIST); |
| 977 entry.modificationTime = fileContents.modificationTime; | 976 entry.modificationTime = fileContents.modificationTime; |
| 978 changed = false; | 977 changed = false; |
| 979 } | 978 } |
| 979 newContents = fileContentsData; |
| 980 } catch (e) {} | 980 } catch (e) {} |
| 981 // If not the same content (e.g. the file is being closed without save), | 981 // If not the same content (e.g. the file is being closed without save), |
| 982 // then force analysis. | 982 // then force analysis. |
| 983 if (changed) { | 983 if (changed) { |
| 984 _sourceChanged(source); | 984 if (!analysisOptions.incremental || |
| 985 !_tryPoorMansIncrementalResolution(source, newContents)) { |
| 986 _sourceChanged(source); |
| 987 } |
| 985 } | 988 } |
| 986 } | 989 } |
| 987 if (notify && changed) { | 990 if (notify && changed) { |
| 988 _onSourcesChangedController | 991 _onSourcesChangedController |
| 989 .add(new SourcesChangedEvent.changedContent(source, newContents)); | 992 .add(new SourcesChangedEvent.changedContent(source, newContents)); |
| 990 } | 993 } |
| 991 return changed; | 994 return changed; |
| 992 } | 995 } |
| 993 | 996 |
| 994 @override | 997 @override |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 new PendingFuture<T>(_context, target, computeValue); | 2026 new PendingFuture<T>(_context, target, computeValue); |
| 2024 if (!pendingFuture.evaluate(entry)) { | 2027 if (!pendingFuture.evaluate(entry)) { |
| 2025 _context._pendingFutureTargets | 2028 _context._pendingFutureTargets |
| 2026 .putIfAbsent(target, () => <PendingFuture>[]) | 2029 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2027 .add(pendingFuture); | 2030 .add(pendingFuture); |
| 2028 scheduleComputation(); | 2031 scheduleComputation(); |
| 2029 } | 2032 } |
| 2030 return pendingFuture.future; | 2033 return pendingFuture.future; |
| 2031 } | 2034 } |
| 2032 } | 2035 } |
| OLD | NEW |