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

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

Issue 2834773003: Remove the limited invalidation feature. (Closed)
Patch Set: Created 3 years, 8 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
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/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 11 matching lines...) Expand all
22 import 'package:analyzer/src/generated/constant.dart'; 22 import 'package:analyzer/src/generated/constant.dart';
23 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
24 import 'package:analyzer/src/generated/incremental_resolver.dart'; 24 import 'package:analyzer/src/generated/incremental_resolver.dart';
25 import 'package:analyzer/src/generated/resolver.dart'; 25 import 'package:analyzer/src/generated/resolver.dart';
26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 26 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
27 import 'package:analyzer/src/generated/source.dart'; 27 import 'package:analyzer/src/generated/source.dart';
28 import 'package:analyzer/src/generated/utilities_collection.dart'; 28 import 'package:analyzer/src/generated/utilities_collection.dart';
29 import 'package:analyzer/src/task/dart.dart'; 29 import 'package:analyzer/src/task/dart.dart';
30 import 'package:analyzer/src/task/dart_work_manager.dart'; 30 import 'package:analyzer/src/task/dart_work_manager.dart';
31 import 'package:analyzer/src/task/driver.dart'; 31 import 'package:analyzer/src/task/driver.dart';
32 import 'package:analyzer/src/task/incremental_element_builder.dart';
33 import 'package:analyzer/src/task/manager.dart'; 32 import 'package:analyzer/src/task/manager.dart';
34 import 'package:analyzer/task/dart.dart'; 33 import 'package:analyzer/task/dart.dart';
35 import 'package:analyzer/task/general.dart'; 34 import 'package:analyzer/task/general.dart';
36 import 'package:analyzer/task/html.dart'; 35 import 'package:analyzer/task/html.dart';
37 import 'package:analyzer/task/model.dart'; 36 import 'package:analyzer/task/model.dart';
38 import 'package:html/dom.dart' show Document; 37 import 'package:html/dom.dart' show Document;
39 38
40 /** 39 /**
41 * Type of callback functions used by PendingFuture. Functions of this type 40 * Type of callback functions used by PendingFuture. Functions of this type
42 * should perform a computation based on the data in [entry] and return it. If 41 * should perform a computation based on the data in [entry] and return it. If
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 this._options.incrementalValidation = options.incrementalValidation; 329 this._options.incrementalValidation = options.incrementalValidation;
331 this._options.lint = options.lint; 330 this._options.lint = options.lint;
332 this._options.lintRules = options.lintRules; 331 this._options.lintRules = options.lintRules;
333 this._options.preserveComments = options.preserveComments; 332 this._options.preserveComments = options.preserveComments;
334 if (this._options.strongMode != options.strongMode) { 333 if (this._options.strongMode != options.strongMode) {
335 _typeSystem = null; 334 _typeSystem = null;
336 } 335 }
337 this._options.strongMode = options.strongMode; 336 this._options.strongMode = options.strongMode;
338 this._options.trackCacheDependencies = options.trackCacheDependencies; 337 this._options.trackCacheDependencies = options.trackCacheDependencies;
339 this._options.disableCacheFlushing = options.disableCacheFlushing; 338 this._options.disableCacheFlushing = options.disableCacheFlushing;
340 this._options.finerGrainedInvalidation = options.finerGrainedInvalidation;
341 this._options.patchPaths = options.patchPaths; 339 this._options.patchPaths = options.patchPaths;
342 if (options is AnalysisOptionsImpl) { 340 if (options is AnalysisOptionsImpl) {
343 this._options.strongModeHints = options.strongModeHints; 341 this._options.strongModeHints = options.strongModeHints;
344 this._options.implicitCasts = options.implicitCasts; 342 this._options.implicitCasts = options.implicitCasts;
345 this._options.nonnullableTypes = options.nonnullableTypes; 343 this._options.nonnullableTypes = options.nonnullableTypes;
346 this._options.implicitDynamic = options.implicitDynamic; 344 this._options.implicitDynamic = options.implicitDynamic;
347 } 345 }
348 if (needsRecompute) { 346 if (needsRecompute) {
349 for (WorkManager workManager in workManagers) { 347 for (WorkManager workManager in workManagers) {
350 workManager.onAnalysisOptionsChanged(); 348 workManager.onAnalysisOptionsChanged();
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 // Fast path if the contents is the same as it was last time. 1832 // Fast path if the contents is the same as it was last time.
1835 if (oldContents != null && fileContents?.data == oldContents) { 1833 if (oldContents != null && fileContents?.data == oldContents) {
1836 return; 1834 return;
1837 } 1835 }
1838 1836
1839 // We're going to update the cache, so reset the driver. 1837 // We're going to update the cache, so reset the driver.
1840 driver.reset(); 1838 driver.reset();
1841 1839
1842 // We need to invalidate the cache. 1840 // We need to invalidate the cache.
1843 { 1841 {
1844 if (analysisOptions.finerGrainedInvalidation &&
1845 AnalysisEngine.isDartFileName(source.fullName)) {
1846 // TODO(scheglov) Incorrect implementation in general.
1847 entry.setState(TOKEN_STREAM, CacheState.FLUSHED);
1848 entry.setState(PARSED_UNIT, CacheState.FLUSHED);
1849 SourceKind sourceKind = getKindOf(source);
1850 List<Source> partSources = getResult(source, INCLUDED_PARTS);
1851 if (sourceKind == SourceKind.LIBRARY && partSources.isEmpty) {
1852 Source librarySource = source;
1853 // Try to find an old unit which has element model.
1854 CacheEntry unitEntry =
1855 getCacheEntry(new LibrarySpecificUnit(librarySource, source));
1856 CompilationUnit oldUnit = RESOLVED_UNIT_RESULTS
1857 .skipWhile((result) => result != RESOLVED_UNIT2)
1858 .map(unitEntry.getValue)
1859 .firstWhere((unit) => unit != null, orElse: () => null);
1860 // If we have the old unit, we can try to update it.
1861 if (oldUnit != null) {
1862 // Safely parse the source.
1863 CompilationUnit newUnit;
1864 try {
1865 newUnit = parseCompilationUnit(source);
1866 } catch (_) {
1867 // The source might have been removed by this time.
1868 // We cannot perform incremental invalidation.
1869 }
1870 // If the new unit was parsed successfully, continue.
1871 if (newUnit != null) {
1872 IncrementalCompilationUnitElementBuilder builder =
1873 new IncrementalCompilationUnitElementBuilder(
1874 oldUnit, newUnit);
1875 builder.build();
1876 CompilationUnitElementDelta unitDelta = builder.unitDelta;
1877 if (!unitDelta.hasDirectiveChange) {
1878 unitEntry.setValueIncremental(
1879 COMPILATION_UNIT_CONSTANTS, builder.unitConstants, false);
1880 DartDelta dartDelta = new DartDelta(source);
1881 unitDelta.addedDeclarations.forEach(dartDelta.elementChanged);
1882 unitDelta.removedDeclarations.forEach(dartDelta.elementChanged);
1883 unitDelta.classDeltas.values.forEach(dartDelta.classChanged);
1884 entry.setState(CONTENT, CacheState.INVALID, delta: dartDelta);
1885 return;
1886 }
1887 }
1888 }
1889 }
1890 }
1891 entry.setState(CONTENT, CacheState.INVALID); 1842 entry.setState(CONTENT, CacheState.INVALID);
1892 entry.setState(MODIFICATION_TIME, CacheState.INVALID); 1843 entry.setState(MODIFICATION_TIME, CacheState.INVALID);
1893 entry.setState(SOURCE_KIND, CacheState.INVALID); 1844 entry.setState(SOURCE_KIND, CacheState.INVALID);
1894 } 1845 }
1895 for (WorkManager workManager in workManagers) { 1846 for (WorkManager workManager in workManagers) {
1896 workManager.applyChange( 1847 workManager.applyChange(
1897 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST); 1848 Source.EMPTY_LIST, <Source>[source], Source.EMPTY_LIST);
1898 } 1849 }
1899 } 1850 }
1900 1851
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 } 2227 }
2277 DartSdk sdk = factory.dartSdk; 2228 DartSdk sdk = factory.dartSdk;
2278 if (sdk == null) { 2229 if (sdk == null) {
2279 throw new ArgumentError( 2230 throw new ArgumentError(
2280 "The source factory for an SDK analysis context must have a DartUriRes olver"); 2231 "The source factory for an SDK analysis context must have a DartUriRes olver");
2281 } 2232 }
2282 return new AnalysisCache( 2233 return new AnalysisCache(
2283 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); 2234 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
2284 } 2235 }
2285 } 2236 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/server/driver.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698