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

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

Issue 1151563004: Optimize AnalysisContext.getSourcesWithFullName(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/context/cache_test.dart
diff --git a/pkg/analyzer/test/src/context/cache_test.dart b/pkg/analyzer/test/src/context/cache_test.dart
index 4e8909fb33415d15919f137882be5202e7afc196..b26b44795b83f73c8c1a275c457de456e45dbdb1 100644
--- a/pkg/analyzer/test/src/context/cache_test.dart
+++ b/pkg/analyzer/test/src/context/cache_test.dart
@@ -67,6 +67,33 @@ class AnalysisCacheTest extends AbstractCacheTest {
expect(cache.getContextFor(target), context);
}
+ void test_getSourcesWithFullName() {
+ String filePath = '/foo/lib/file.dart';
+ // no sources
+ expect(cache.getSourcesWithFullName(filePath), isEmpty);
+ // add source1
+ TestSourceWithUri source1 =
+ new TestSourceWithUri(filePath, Uri.parse('file://$filePath'));
+ cache.put(new CacheEntry(source1));
+ expect(cache.getSourcesWithFullName(filePath), unorderedEquals([source1]));
+ // add source2
+ TestSourceWithUri source2 =
+ new TestSourceWithUri(filePath, Uri.parse('package:foo/file.dart'));
+ cache.put(new CacheEntry(source2));
+ expect(cache.getSourcesWithFullName(filePath),
+ unorderedEquals([source1, source2]));
+ // remove source1
+ cache.remove(source1);
+ expect(cache.getSourcesWithFullName(filePath), unorderedEquals([source2]));
+ // remove source2
+ cache.remove(source2);
+ expect(cache.getSourcesWithFullName(filePath), isEmpty);
+ // ignored
+ cache.remove(source1);
+ cache.remove(source2);
+ expect(cache.getSourcesWithFullName(filePath), isEmpty);
+ }
+
void test_getState_hasEntry_flushed() {
ResultDescriptor result = new ResultDescriptor('result', -1);
AnalysisTarget target = new TestSource();
« 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