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

Unified Diff: pkg/analysis_server/test/services/completion/imported_computer_test.dart

Issue 742163002: cache import suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/services/completion/imported_computer_test.dart
diff --git a/pkg/analysis_server/test/services/completion/imported_computer_test.dart b/pkg/analysis_server/test/services/completion/imported_computer_test.dart
index 80b23678e0e0871dc3dccc64b8db0458816aa94a..6c5e95444c77a6df95a8c2b32c64aa8e95975729 100644
--- a/pkg/analysis_server/test/services/completion/imported_computer_test.dart
+++ b/pkg/analysis_server/test/services/completion/imported_computer_test.dart
@@ -9,6 +9,9 @@ import 'package:unittest/unittest.dart';
import '../../reflective_tests.dart';
import 'completion_test_util.dart';
+import 'package:analysis_server/src/protocol.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
main() {
groupSep = ' | ';
@@ -19,8 +22,67 @@ main() {
class ImportedTypeComputerTest extends AbstractSelectorSuggestionTest {
@override
- void setUp() {
- super.setUp();
+ void setUpComputer() {
computer = new ImportedComputer();
}
+
+ /**
+ * Assert that the ImportedComputer uses cached results to produce identical
+ * suggestions to the original set of suggestions.
+ */
+ void assertCachedCompute(_) {
+ expect(request.unit.element, isNotNull);
+ List<CompletionSuggestion> oldSuggestions = request.suggestions;
+ /*
+ * Simulate a source change to flush the cached compilation unit
+ */
+ ChangeSet changes = new ChangeSet();
+ changes.addedSource(testSource);
+ context.applyChanges(changes);
+ /*
+ * Calculate a new completion at the same location
+ */
+ setUpComputer();
+ request = new DartCompletionRequest(
+ context,
+ searchEngine,
+ testSource,
+ completionOffset,
+ cache);
+ expect(computeFast(), isTrue);
+ expect(request.unit.element, isNull);
+ List<CompletionSuggestion> newSuggestions = request.suggestions;
+ expect(newSuggestions.length, oldSuggestions.length);
+ oldSuggestions.forEach((CompletionSuggestion s) {
+ expect(newSuggestions.contains(s), isTrue);
+ });
+ }
+
+ @override
+ test_ArgumentList() {
+ return super.test_ArgumentList().then((_) {
+ expect(request.cache.importKey, "import '/libA.dart';");
+ });
+ }
+
+ @override
+ test_ArgumentList_imported_function() {
+ return super.test_ArgumentList_imported_function().then((_) {
+ expect(request.cache.importKey, "import '/libA.dart';");
+ });
+ }
+
+ @override
+ test_AssignmentExpression_RHS() {
+ return super.test_AssignmentExpression_RHS().then((_) {
+ expect(request.cache.importKey, '');
+ });
+ }
+
+ @override
+ test_Block() {
+ return super.test_Block().then((_) {
+ expect(request.cache.importKey, 'import "/testAB.dart";import "/testCD.dart" hide D;import "/testEEF.dart" show EE;import "/testG.dart" as g;');
+ });
+ }
}

Powered by Google App Engine
This is Rietveld 408576698