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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 1776023002: Add AnalysisContext.onResultInvalidated(descriptor). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update Analysis Server. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/src/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index d7e0a589a8332abb27ec4495d480e703e2f97f9f..63130a5cbcfd905f9872605145a5105d4ff7d183 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -1463,6 +1463,46 @@ main() {}''');
expect(context.isServerLibrary(source), isFalse);
}
+ void test_onResultInvalidated_removeSource() {
+ Source source = addSource('/test.dart', 'main() {}');
+ _analyzeAll_assertFinished();
+ // listen for changes
+ bool listenerInvoked = false;
+ context.onResultChanged(RESOLVED_UNIT).listen((ResultChangedEvent event) {
+ Source eventSource = event.target.source;
+ expect(event.wasComputed, isFalse);
+ expect(event.wasInvalidated, isTrue);
+ expect(event.descriptor, RESOLVED_UNIT);
+ expect(eventSource, source);
+ listenerInvoked = true;
+ });
+ // apply changes
+ expect(listenerInvoked, false);
+ context.applyChanges(new ChangeSet()..removedSource(source));
+ // verify
+ expect(listenerInvoked, isTrue);
+ }
+
+ void test_onResultInvalidated_setContents() {
+ Source source = addSource('/test.dart', 'main() {}');
+ _analyzeAll_assertFinished();
+ // listen for changes
+ bool listenerInvoked = false;
+ context.onResultChanged(RESOLVED_UNIT).listen((ResultChangedEvent event) {
+ Source eventSource = event.target.source;
+ expect(event.wasComputed, isFalse);
+ expect(event.wasInvalidated, isTrue);
+ expect(event.descriptor, RESOLVED_UNIT);
+ expect(eventSource, source);
+ listenerInvoked = true;
+ });
+ // apply changes
+ expect(listenerInvoked, false);
+ context.setContents(source, 'class B {}');
+ // verify
+ expect(listenerInvoked, isTrue);
+ }
+
void test_parseCompilationUnit_errors() {
Source source = addSource("/lib.dart", "library {");
CompilationUnit compilationUnit = context.parseCompilationUnit(source);
@@ -1930,20 +1970,26 @@ library expectedToFindSemicolon
// JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an element model", _context.getLibraryElement(source));
}
- void test_performAnalysisTask_onResultComputed() {
+ void test_performAnalysisTask_onResultChanged() {
Set<String> libraryElementUris = new Set<String>();
Set<String> parsedUnitUris = new Set<String>();
Set<String> resolvedUnitUris = new Set<String>();
// listen
- context.onResultComputed(LIBRARY_ELEMENT).listen((event) {
+ context.onResultChanged(LIBRARY_ELEMENT).listen((event) {
+ expect(event.wasComputed, isTrue);
+ expect(event.wasInvalidated, isFalse);
Source librarySource = event.target;
libraryElementUris.add(librarySource.uri.toString());
});
- context.onResultComputed(PARSED_UNIT).listen((event) {
+ context.onResultChanged(PARSED_UNIT).listen((event) {
+ expect(event.wasComputed, isTrue);
+ expect(event.wasInvalidated, isFalse);
Source source = event.target;
parsedUnitUris.add(source.uri.toString());
});
- context.onResultComputed(RESOLVED_UNIT).listen((event) {
+ context.onResultChanged(RESOLVED_UNIT).listen((event) {
+ expect(event.wasComputed, isTrue);
+ expect(event.wasInvalidated, isFalse);
LibrarySpecificUnit target = event.target;
Source librarySource = target.library;
resolvedUnitUris.add(librarySource.uri.toString());
« pkg/analyzer/lib/src/generated/engine.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