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

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 2337073003: Safe handle removed file while incremental invalidation. (Closed)
Patch Set: Created 4 years, 3 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/context.dart ('k') | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.test.src.context.context_test; 5 library analyzer.test.src.context.context_test;
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 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 @override 2871 @override
2872 void setUp() { 2872 void setUp() {
2873 super.setUp(); 2873 super.setUp();
2874 AnalysisOptionsImpl options = 2874 AnalysisOptionsImpl options =
2875 new AnalysisOptionsImpl.from(context.analysisOptions); 2875 new AnalysisOptionsImpl.from(context.analysisOptions);
2876 options.incremental = true; 2876 options.incremental = true;
2877 options.finerGrainedInvalidation = true; 2877 options.finerGrainedInvalidation = true;
2878 context.analysisOptions = options; 2878 context.analysisOptions = options;
2879 } 2879 }
2880 2880
2881 void test_applyChanges_changedSource_removeFile() {
2882 File file = resourceProvider.newFile('/test.dart', 'main() {}');
2883 Source source = file.createSource();
2884 context.applyChanges(new ChangeSet()..addedSource(source));
2885 // Analyze all.
2886 _performPendingAnalysisTasks();
2887 expect(context.getResolvedCompilationUnit2(source, source), isNotNull);
2888 // Delete the file, but tell the context that it is changed.
2889 // This might happen as a race condition.
2890 // Or it might be a mishandling of file notification events.
2891 file.delete();
2892 context.applyChanges(new ChangeSet()..changedSource(source));
2893 // All the analysis results are gone.
2894 void noResolvedUnits() {
2895 LibrarySpecificUnit unit = new LibrarySpecificUnit(source, source);
2896 RESOLVED_UNIT_RESULTS.forEach((result) {
2897 expect(context.getResult(unit, result), isNull);
2898 });
2899 }
2900
2901 noResolvedUnits();
2902 // Analyze again.
2903 // The source does not exist, so still no resolution.
2904 _performPendingAnalysisTasks();
2905 noResolvedUnits();
2906 expect(context.getModificationStamp(source), -1);
2907 }
2908
2881 void test_class_addMethod_useAsHole_inTopLevelVariable() { 2909 void test_class_addMethod_useAsHole_inTopLevelVariable() {
2882 Source a = addSource( 2910 Source a = addSource(
2883 '/a.dart', 2911 '/a.dart',
2884 r''' 2912 r'''
2885 class A { 2913 class A {
2886 } 2914 }
2887 '''); 2915 ''');
2888 Source b = addSource( 2916 Source b = addSource(
2889 '/b.dart', 2917 '/b.dart',
2890 r''' 2918 r'''
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after
5241 * Initialize the visitor. 5269 * Initialize the visitor.
5242 */ 5270 */
5243 _ElementGatherer(); 5271 _ElementGatherer();
5244 5272
5245 @override 5273 @override
5246 void visitElement(Element element) { 5274 void visitElement(Element element) {
5247 elements[element] = element; 5275 elements[element] = element;
5248 super.visitElement(element); 5276 super.visitElement(element);
5249 } 5277 }
5250 } 5278 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698