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

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

Issue 1448173002: Add ApplyChangesStatus to AnalysisContext.applyChanges() and use it in DAS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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) 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 test.src.context.context_test; 5 library test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
11 import 'package:analyzer/src/cancelable_future.dart'; 11 import 'package:analyzer/src/cancelable_future.dart';
12 import 'package:analyzer/src/context/cache.dart'; 12 import 'package:analyzer/src/context/cache.dart';
13 import 'package:analyzer/src/context/context.dart'; 13 import 'package:analyzer/src/context/context.dart';
14 import 'package:analyzer/src/generated/ast.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
15 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
16 import 'package:analyzer/src/generated/engine.dart' 16 import 'package:analyzer/src/generated/engine.dart'
17 show 17 show
18 AnalysisContext, 18 AnalysisContext,
19 AnalysisContextStatistics, 19 AnalysisContextStatistics,
20 AnalysisDelta, 20 AnalysisDelta,
21 AnalysisEngine, 21 AnalysisEngine,
22 AnalysisErrorInfo, 22 AnalysisErrorInfo,
23 AnalysisLevel, 23 AnalysisLevel,
24 AnalysisNotScheduledError, 24 AnalysisNotScheduledError,
25 AnalysisOptions, 25 AnalysisOptions,
26 AnalysisOptionsImpl, 26 AnalysisOptionsImpl,
27 AnalysisResult, 27 AnalysisResult,
28 ApplyChangesStatus,
28 CacheState, 29 CacheState,
29 ChangeNotice, 30 ChangeNotice,
30 ChangeSet, 31 ChangeSet,
31 IncrementalAnalysisCache, 32 IncrementalAnalysisCache,
32 TimestampedData; 33 TimestampedData;
33 import 'package:analyzer/src/generated/error.dart'; 34 import 'package:analyzer/src/generated/error.dart';
34 import 'package:analyzer/src/generated/java_engine.dart'; 35 import 'package:analyzer/src/generated/java_engine.dart';
35 import 'package:analyzer/src/generated/resolver.dart'; 36 import 'package:analyzer/src/generated/resolver.dart';
36 import 'package:analyzer/src/generated/scanner.dart'; 37 import 'package:analyzer/src/generated/scanner.dart';
37 import 'package:analyzer/src/generated/source.dart'; 38 import 'package:analyzer/src/generated/source.dart';
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 listener.assertNoMoreEvents(); 290 listener.assertNoMoreEvents();
290 }); 291 });
291 } 292 }
292 293
293 void test_applyChanges_empty() { 294 void test_applyChanges_empty() {
294 context.applyChanges(new ChangeSet()); 295 context.applyChanges(new ChangeSet());
295 expect(context.performAnalysisTask().changeNotices, isNull); 296 expect(context.performAnalysisTask().changeNotices, isNull);
296 } 297 }
297 298
298 void test_applyChanges_overriddenSource() { 299 void test_applyChanges_overriddenSource() {
299 // Note: addSource adds the source to the contentCache. 300 String content = "library test;";
300 Source source = addSource("/test.dart", "library test;"); 301 Source source = addSource("/test.dart", content);
302 context.setContents(source, content);
301 context.computeErrors(source); 303 context.computeErrors(source);
302 while (!context.sourcesNeedingProcessing.isEmpty) { 304 while (!context.sourcesNeedingProcessing.isEmpty) {
303 context.performAnalysisTask(); 305 context.performAnalysisTask();
304 } 306 }
305 // Adding the source as a changedSource should have no effect since 307 // Adding the source as a changedSource should have no effect since
306 // it is already overridden in the content cache. 308 // it is already overridden in the content cache.
307 ChangeSet changeSet = new ChangeSet(); 309 ChangeSet changeSet = new ChangeSet();
308 changeSet.changedSource(source); 310 changeSet.changedSource(source);
309 context.applyChanges(changeSet); 311 ApplyChangesStatus changesStatus = context.applyChanges(changeSet);
312 expect(changesStatus.hasChanges, isFalse);
310 expect(context.sourcesNeedingProcessing, hasLength(0)); 313 expect(context.sourcesNeedingProcessing, hasLength(0));
311 } 314 }
312 315
313 Future test_applyChanges_remove() { 316 Future test_applyChanges_remove() {
314 SourcesChangedListener listener = new SourcesChangedListener(); 317 SourcesChangedListener listener = new SourcesChangedListener();
315 context.onSourcesChanged.listen(listener.onData); 318 context.onSourcesChanged.listen(listener.onData);
316 String libAContents = r''' 319 String libAContents = r'''
317 library libA; 320 library libA;
318 import 'libB.dart';'''; 321 import 'libB.dart';''';
319 Source libA = addSource("/libA.dart", libAContents); 322 Source libA = addSource("/libA.dart", libAContents);
(...skipping 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 } 2727 }
2725 } 2728 }
2726 2729
2727 class _AnalysisContextImplTest_test_applyChanges_removeContainer 2730 class _AnalysisContextImplTest_test_applyChanges_removeContainer
2728 implements SourceContainer { 2731 implements SourceContainer {
2729 Source libB; 2732 Source libB;
2730 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); 2733 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB);
2731 @override 2734 @override
2732 bool contains(Source source) => source == libB; 2735 bool contains(Source source) => source == libB;
2733 } 2736 }
OLDNEW
« pkg/analyzer/lib/src/context/context.dart ('K') | « pkg/analyzer/test/generated/engine_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698