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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.task.driver_test; 5 library test.src.task.driver_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/engine.dart' 8 import 'package:analyzer/src/generated/engine.dart'
9 show 9 show
10 AnalysisContext, 10 AnalysisContext,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void test_get() { 60 void test_get() {
61 AnalysisTarget target = new TestSource(); 61 AnalysisTarget target = new TestSource();
62 expect(cache.get(target), isNull); 62 expect(cache.get(target), isNull);
63 } 63 }
64 64
65 void test_getContextFor() { 65 void test_getContextFor() {
66 AnalysisTarget target = new TestSource(); 66 AnalysisTarget target = new TestSource();
67 expect(cache.getContextFor(target), context); 67 expect(cache.getContextFor(target), context);
68 } 68 }
69 69
70 void test_getSourcesWithFullName() {
71 String filePath = '/foo/lib/file.dart';
72 // no sources
73 expect(cache.getSourcesWithFullName(filePath), isEmpty);
74 // add source1
75 TestSourceWithUri source1 =
76 new TestSourceWithUri(filePath, Uri.parse('file://$filePath'));
77 cache.put(new CacheEntry(source1));
78 expect(cache.getSourcesWithFullName(filePath), unorderedEquals([source1]));
79 // add source2
80 TestSourceWithUri source2 =
81 new TestSourceWithUri(filePath, Uri.parse('package:foo/file.dart'));
82 cache.put(new CacheEntry(source2));
83 expect(cache.getSourcesWithFullName(filePath),
84 unorderedEquals([source1, source2]));
85 // remove source1
86 cache.remove(source1);
87 expect(cache.getSourcesWithFullName(filePath), unorderedEquals([source2]));
88 // remove source2
89 cache.remove(source2);
90 expect(cache.getSourcesWithFullName(filePath), isEmpty);
91 // ignored
92 cache.remove(source1);
93 cache.remove(source2);
94 expect(cache.getSourcesWithFullName(filePath), isEmpty);
95 }
96
70 void test_getState_hasEntry_flushed() { 97 void test_getState_hasEntry_flushed() {
71 ResultDescriptor result = new ResultDescriptor('result', -1); 98 ResultDescriptor result = new ResultDescriptor('result', -1);
72 AnalysisTarget target = new TestSource(); 99 AnalysisTarget target = new TestSource();
73 CacheEntry entry = new CacheEntry(target); 100 CacheEntry entry = new CacheEntry(target);
74 cache.put(entry); 101 cache.put(entry);
75 entry.setState(result, CacheState.FLUSHED); 102 entry.setState(result, CacheState.FLUSHED);
76 expect(cache.getState(target, result), CacheState.FLUSHED); 103 expect(cache.getState(target, result), CacheState.FLUSHED);
77 } 104 }
78 105
79 void test_getState_hasEntry_valid() { 106 void test_getState_hasEntry_valid() {
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 922
896 class _InternalAnalysisContextMock extends TypedMock 923 class _InternalAnalysisContextMock extends TypedMock
897 implements InternalAnalysisContext { 924 implements InternalAnalysisContext {
898 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 925 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
899 } 926 }
900 927
901 class _TestAnalysisTarget implements AnalysisTarget { 928 class _TestAnalysisTarget implements AnalysisTarget {
902 @override 929 @override
903 Source get source => null; 930 Source get source => null;
904 } 931 }
OLDNEW
« 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