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

Unified Diff: pkg/analysis_server/test/analysis/update_content_test.dart

Issue 958373003: Don't remove indexing operations on potential source changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/analysis_server/test/analysis/update_content_test.dart
diff --git a/pkg/analysis_server/test/analysis/update_content_test.dart b/pkg/analysis_server/test/analysis/update_content_test.dart
index 5b780a7e436d826f4217b33544ddb527ca68dd00..2a8fa24a08806fdfbb7a3cc46f9fe189d5caee9a 100644
--- a/pkg/analysis_server/test/analysis/update_content_test.dart
+++ b/pkg/analysis_server/test/analysis/update_content_test.dart
@@ -6,6 +6,9 @@ library test.analysis.updateContent;
import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/protocol.dart';
+import 'package:analysis_server/src/services/index/index.dart';
+import 'package:analyzer/src/generated/ast.dart';
+import 'package:typed_mock/typed_mock.dart';
import 'package:unittest/unittest.dart';
import '../analysis_abstract.dart';
@@ -18,12 +21,21 @@ main() {
}
+compilationUnitMatcher(String file) {
+ return new _ArgumentMatcher_CompilationUnit(file);
+}
+
+
@reflectiveTest
class UpdateContentTest extends AbstractAnalysisTest {
Map<String, List<AnalysisError>> filesErrors = {};
int serverErrorCount = 0;
int navigationCount = 0;
+ Index createIndex() {
+ return new _MockIndex();
+ }
+
@override
void processNotification(Notification notification) {
if (notification.event == ANALYSIS_ERRORS) {
@@ -80,6 +92,29 @@ class UpdateContentTest extends AbstractAnalysisTest {
}
}
+ test_indexUnitAfterNopChange() async {
+ var testUnitMatcher = compilationUnitMatcher(testFile) as dynamic;
+ createProject();
+ addTestFile('main() { print(1); }');
+ await server.onAnalysisComplete;
+ verify(server.index.indexUnit(anyObject, testUnitMatcher)).times(1);
+ // add an overlay
+ server.updateContent('1', {
+ testFile: new AddContentOverlay('main() { print(2); }')
+ });
+ // Perform a single operation: analysis.
+ // It will schedule an indexing operation.
+ server.performOperation();
+ // Update the file and remove an overlay.
+ resourceProvider.updateFile(testFile, 'main() { print(2); }');
+ server.updateContent('2', {
+ testFile: new RemoveContentOverlay()
+ });
+ // Validate that at the end the unit was indexed.
+ await server.onAnalysisComplete;
+ verify(server.index.indexUnit(anyObject, testUnitMatcher)).times(2);
+ }
+
test_multiple_contexts() {
String fooPath = '/project1/foo.dart';
resourceProvider.newFile(fooPath, '''
@@ -160,3 +195,20 @@ f() {}
expect(filesErrors, isNotEmpty);
}
}
+
+
+class _ArgumentMatcher_CompilationUnit extends ArgumentMatcher {
+ final String file;
+
+ _ArgumentMatcher_CompilationUnit(this.file);
+
+ @override
+ bool matches(arg) {
+ return arg is CompilationUnit && arg.element.source.fullName == file;
+ }
+}
+
+
+class _MockIndex extends TypedMock implements Index {
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}

Powered by Google App Engine
This is Rietveld 408576698