Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: pkg/analyzer/lib/src/context/context.dart

Issue 1204373002: Initial version of limiting invalidation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 import 'package:analyzer/src/generated/resolver.dart'; 28 import 'package:analyzer/src/generated/resolver.dart';
29 import 'package:analyzer/src/generated/scanner.dart'; 29 import 'package:analyzer/src/generated/scanner.dart';
30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 30 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
31 import 'package:analyzer/src/generated/source.dart'; 31 import 'package:analyzer/src/generated/source.dart';
32 import 'package:analyzer/src/generated/utilities_collection.dart'; 32 import 'package:analyzer/src/generated/utilities_collection.dart';
33 import 'package:analyzer/src/task/dart.dart'; 33 import 'package:analyzer/src/task/dart.dart';
34 import 'package:analyzer/src/task/dart_work_manager.dart'; 34 import 'package:analyzer/src/task/dart_work_manager.dart';
35 import 'package:analyzer/src/task/driver.dart'; 35 import 'package:analyzer/src/task/driver.dart';
36 import 'package:analyzer/src/task/html.dart'; 36 import 'package:analyzer/src/task/html.dart';
37 import 'package:analyzer/src/task/html_work_manager.dart'; 37 import 'package:analyzer/src/task/html_work_manager.dart';
38 import 'package:analyzer/src/task/incremental_element_builder.dart';
38 import 'package:analyzer/src/task/manager.dart'; 39 import 'package:analyzer/src/task/manager.dart';
39 import 'package:analyzer/task/dart.dart'; 40 import 'package:analyzer/task/dart.dart';
40 import 'package:analyzer/task/general.dart'; 41 import 'package:analyzer/task/general.dart';
41 import 'package:analyzer/task/html.dart'; 42 import 'package:analyzer/task/html.dart';
42 import 'package:analyzer/task/model.dart'; 43 import 'package:analyzer/task/model.dart';
43 import 'package:html/dom.dart' show Document; 44 import 'package:html/dom.dart' show Document;
44 45
45 /** 46 /**
46 * Type of callback functions used by PendingFuture. Functions of this type 47 * Type of callback functions used by PendingFuture. Functions of this type
47 * should perform a computation based on the data in [entry] and return it. If 48 * should perform a computation based on the data in [entry] and return it. If
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 if (fileContents.data == sourceContent) { 1714 if (fileContents.data == sourceContent) {
1714 int time = fileContents.modificationTime; 1715 int time = fileContents.modificationTime;
1715 for (CacheEntry entry in _entriesFor(source)) { 1716 for (CacheEntry entry in _entriesFor(source)) {
1716 entry.modificationTime = time; 1717 entry.modificationTime = time;
1717 } 1718 }
1718 return; 1719 return;
1719 } 1720 }
1720 } catch (e) {} 1721 } catch (e) {}
1721 } 1722 }
1722 // We need to invalidate the cache. 1723 // We need to invalidate the cache.
1723 entry.setState(CONTENT, CacheState.INVALID); 1724 {
1725 Object delta = null;
1726 if (AnalysisEngine.instance.limitInvalidationInTaskModel &&
1727 AnalysisEngine.isDartFileName(source.fullName)) {
1728 // TODO(scheglov) Incorrect implementation in general.
1729 entry.setState(TOKEN_STREAM, CacheState.FLUSHED);
1730 entry.setState(SCAN_ERRORS, CacheState.FLUSHED);
1731 entry.setState(PARSED_UNIT, CacheState.FLUSHED);
1732 entry.setState(PARSE_ERRORS, CacheState.FLUSHED);
1733 CompilationUnit oldUnit = getResolvedCompilationUnit2(source, source);
1734 if (oldUnit != null) {
1735 CompilationUnit newUnit = parseCompilationUnit(source);
1736 IncrementalCompilationUnitElementBuilder builder =
1737 new IncrementalCompilationUnitElementBuilder(oldUnit, newUnit);
1738 builder.build();
1739 CompilationUnitElementDelta unitDelta = builder.unitDelta;
1740 DartDelta dartDelta = new DartDelta(source);
1741 dartDelta.hasDirectiveChange = unitDelta.hasDirectiveChange;
1742 unitDelta.addedDeclarations.forEach(dartDelta.elementAdded);
1743 unitDelta.removedDeclarations.forEach(dartDelta.elementRemoved);
1744 delta = dartDelta;
1745 }
1746 }
1747 entry.setState(CONTENT, CacheState.INVALID, delta: delta);
1748 }
1724 dartWorkManager.applyChange( 1749 dartWorkManager.applyChange(
1725 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); 1750 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST);
1726 htmlWorkManager.applyChange( 1751 htmlWorkManager.applyChange(
1727 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); 1752 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST);
1728 } 1753 }
1729 1754
1730 /** 1755 /**
1731 * Record that the give [source] has been deleted. 1756 * Record that the give [source] has been deleted.
1732 */ 1757 */
1733 void _sourceDeleted(Source source) { 1758 void _sourceDeleted(Source source) {
(...skipping 29 matching lines...) Expand all
1763 */ 1788 */
1764 void _sourceRemoved(Source source) { 1789 void _sourceRemoved(Source source) {
1765 _cache.remove(source); 1790 _cache.remove(source);
1766 _removeFromPriorityOrder(source); 1791 _removeFromPriorityOrder(source);
1767 } 1792 }
1768 1793
1769 /** 1794 /**
1770 * TODO(scheglov) A hackish, limited incremental resolution implementation. 1795 * TODO(scheglov) A hackish, limited incremental resolution implementation.
1771 */ 1796 */
1772 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { 1797 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) {
1798 if (AnalysisEngine.instance.limitInvalidationInTaskModel) {
1799 return false;
1800 }
1773 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { 1801 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() {
1774 incrementalResolutionValidation_lastUnitSource = null; 1802 incrementalResolutionValidation_lastUnitSource = null;
1775 incrementalResolutionValidation_lastLibrarySource = null; 1803 incrementalResolutionValidation_lastLibrarySource = null;
1776 incrementalResolutionValidation_lastUnit = null; 1804 incrementalResolutionValidation_lastUnit = null;
1777 // prepare the entry 1805 // prepare the entry
1778 CacheEntry sourceEntry = _cache.get(unitSource); 1806 CacheEntry sourceEntry = _cache.get(unitSource);
1779 if (sourceEntry == null) { 1807 if (sourceEntry == null) {
1780 return false; 1808 return false;
1781 } 1809 }
1782 // prepare the (only) library source 1810 // prepare the (only) library source
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 new PendingFuture<T>(_context, target, computeValue); 2043 new PendingFuture<T>(_context, target, computeValue);
2016 if (!pendingFuture.evaluate(entry)) { 2044 if (!pendingFuture.evaluate(entry)) {
2017 _context._pendingFutureTargets 2045 _context._pendingFutureTargets
2018 .putIfAbsent(target, () => <PendingFuture>[]) 2046 .putIfAbsent(target, () => <PendingFuture>[])
2019 .add(pendingFuture); 2047 .add(pendingFuture);
2020 scheduleComputation(); 2048 scheduleComputation();
2021 } 2049 }
2022 return pendingFuture.future; 2050 return pendingFuture.future;
2023 } 2051 }
2024 } 2052 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698