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

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

Issue 2357553003: Fix newly introduced errors and warnings (Closed)
Patch Set: Created 4 years, 3 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/cache_test.dart
diff --git a/pkg/analyzer/test/src/context/cache_test.dart b/pkg/analyzer/test/src/context/cache_test.dart
index 914a674b32a0966b8ec392c27e0219ede829e744..d6af6ce666d657006f221194fc8f6e43a24f2d88 100644
--- a/pkg/analyzer/test/src/context/cache_test.dart
+++ b/pkg/analyzer/test/src/context/cache_test.dart
@@ -58,8 +58,8 @@ class AnalysisCacheTest extends AbstractCacheTest {
test_flush() {
AnalysisTarget target = new TestSource();
- ResultDescriptor resultA = new ResultDescriptor('A', null);
- ResultDescriptor resultB = new ResultDescriptor('B', null);
+ ResultDescriptor<String> resultA = new ResultDescriptor<String>('A', null);
scheglov 2016/09/21 00:05:07 I would just drop the LHS type.
Jennifer Messerly 2016/09/21 00:20:30 yeah +1 to that. But I do wonder about this one.
Brian Wilkerson 2016/09/21 15:00:43 I expect someone will write a bulk edit tool at so
+ ResultDescriptor<String> resultB = new ResultDescriptor<String>('B', null);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
// put values
@@ -124,7 +124,8 @@ class AnalysisCacheTest extends AbstractCacheTest {
}
void test_getState_hasEntry_valid() {
- ResultDescriptor result = new ResultDescriptor('result', -1);
+ ResultDescriptor<String> result =
+ new ResultDescriptor<String>('result', null);
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
@@ -139,7 +140,7 @@ class AnalysisCacheTest extends AbstractCacheTest {
}
void test_getValue_hasEntry_valid() {
- ResultDescriptor result = new ResultDescriptor('result', -1);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('result', -1);
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
@@ -182,9 +183,9 @@ class AnalysisCacheTest extends AbstractCacheTest {
cache.put(entry1);
cache.put(entry2);
cache.put(entry3);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
- ResultDescriptor result3 = new ResultDescriptor('result3', -3);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('result3', -3);
// set results, all of them are VALID
entry1.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry2.setValue(result2, 222, [new TargetedResult(target1, result1)]);
@@ -207,8 +208,8 @@ class AnalysisCacheTest extends AbstractCacheTest {
AnalysisTarget target = new TestSource('/a.dart');
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
// set results, all of them are VALID
entry.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry.setValue(result2, 222, [new TargetedResult(target, result1)]);
@@ -258,8 +259,10 @@ class AnalysisCacheTest extends AbstractCacheTest {
@reflectiveTest
class CacheEntryTest extends AbstractCacheTest {
test_dispose() {
- ResultDescriptor descriptor1 = new ResultDescriptor('result1', -1);
- ResultDescriptor descriptor2 = new ResultDescriptor('result2', -2);
+ ResultDescriptor<int> descriptor1 =
+ new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> descriptor2 =
+ new ResultDescriptor<int>('result2', -2);
AnalysisTarget target1 = new TestSource('1.dart');
AnalysisTarget target2 = new TestSource('2.dart');
TargetedResult result1 = new TargetedResult(target1, descriptor1);
@@ -300,7 +303,7 @@ class CacheEntryTest extends AbstractCacheTest {
test_fixExceptionState_noError_exception() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', null);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('test', null);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
// set one result to ERROR
@@ -324,8 +327,8 @@ class CacheEntryTest extends AbstractCacheTest {
test_flush() {
AnalysisTarget target = new TestSource();
- ResultDescriptor resultA = new ResultDescriptor('A', null);
- ResultDescriptor resultB = new ResultDescriptor('B', null);
+ ResultDescriptor<String> resultA = new ResultDescriptor<String>('A', null);
+ ResultDescriptor<String> resultB = new ResultDescriptor<String>('B', null);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
// put values
@@ -359,13 +362,17 @@ class CacheEntryTest extends AbstractCacheTest {
}
test_getValue_flushResults() {
- ResultCachingPolicy cachingPolicy = new SimpleResultCachingPolicy(2, 2);
- ResultDescriptor descriptor1 =
- new ResultDescriptor('result1', null, cachingPolicy: cachingPolicy);
- ResultDescriptor descriptor2 =
- new ResultDescriptor('result2', null, cachingPolicy: cachingPolicy);
- ResultDescriptor descriptor3 =
- new ResultDescriptor('result3', null, cachingPolicy: cachingPolicy);
+ ResultCachingPolicy<int> cachingPolicy =
+ new SimpleResultCachingPolicy<int>(2, 2);
+ ResultDescriptor<int> descriptor1 = new ResultDescriptor<int>(
+ 'result1', null,
+ cachingPolicy: cachingPolicy);
+ ResultDescriptor<int> descriptor2 = new ResultDescriptor<int>(
+ 'result2', null,
+ cachingPolicy: cachingPolicy);
+ ResultDescriptor<int> descriptor3 = new ResultDescriptor<int>(
+ 'result3', null,
+ cachingPolicy: cachingPolicy);
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
@@ -406,7 +413,8 @@ class CacheEntryTest extends AbstractCacheTest {
test_invalidateAllInformation() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', null);
+ ResultDescriptor<String> result =
+ new ResultDescriptor<String>('test', null);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
entry.setValue(result, 'value', TargetedResult.EMPTY_LIST);
@@ -417,9 +425,9 @@ class CacheEntryTest extends AbstractCacheTest {
test_setErrorState() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result1 = new ResultDescriptor('res1', 1);
- ResultDescriptor result2 = new ResultDescriptor('res2', 2);
- ResultDescriptor result3 = new ResultDescriptor('res3', 3);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('res1', 1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('res2', 2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('res3', 3);
// prepare some good state
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
@@ -446,10 +454,10 @@ class CacheEntryTest extends AbstractCacheTest {
CacheEntry entry2 = new CacheEntry(target2);
cache.put(entry1);
cache.put(entry2);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
- ResultDescriptor result3 = new ResultDescriptor('result3', -3);
- ResultDescriptor result4 = new ResultDescriptor('result4', -4);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('result3', -3);
+ ResultDescriptor<int> result4 = new ResultDescriptor<int>('result4', -4);
// set results, all of them are VALID
entry1.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry2.setValue(result2, 222, [new TargetedResult(target1, result1)]);
@@ -508,7 +516,7 @@ class CacheEntryTest extends AbstractCacheTest {
test_setState_error() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', null);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('test', null);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
entry.setValue(result, 42, TargetedResult.EMPTY_LIST);
@@ -523,7 +531,7 @@ class CacheEntryTest extends AbstractCacheTest {
test_setState_flushed() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', 1);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('test', 1);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
// set VALID
@@ -538,7 +546,7 @@ class CacheEntryTest extends AbstractCacheTest {
test_setState_inProcess() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', 1);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('test', 1);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
// set VALID
@@ -553,7 +561,7 @@ class CacheEntryTest extends AbstractCacheTest {
test_setState_invalid() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', 1);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('test', 1);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
// set VALID
@@ -581,7 +589,7 @@ class CacheEntryTest extends AbstractCacheTest {
CacheEntry entry2 = new CacheEntry(target2);
cache.put(entry1);
cache.put(entry2);
- ResultDescriptor result = new ResultDescriptor('result', -1);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('result', -1);
// Set each result as VALID with a dependency on on the other.
entry1.setValue(result, 100, [new TargetedResult(target2, result)]);
entry2.setValue(result, 200, [new TargetedResult(target1, result)]);
@@ -611,10 +619,10 @@ class CacheEntryTest extends AbstractCacheTest {
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
- ResultDescriptor result3 = new ResultDescriptor('result3', -3);
- ResultDescriptor result4 = new ResultDescriptor('result4', -4);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('result3', -3);
+ ResultDescriptor<int> result4 = new ResultDescriptor<int>('result4', -4);
// set results, all of them are VALID
entry.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry.setValue(result2, 222, [new TargetedResult(target, result1)]);
@@ -647,7 +655,7 @@ class CacheEntryTest extends AbstractCacheTest {
CacheEntry entry = new CacheEntry(target);
entry.explicitlyAdded = true;
cache.put(entry);
- ResultDescriptor result = new ResultDescriptor('result1', -1);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('result1', -1);
// set results, all of them are VALID
entry.setValue(result, 111, TargetedResult.EMPTY_LIST);
expect(entry.getState(result), CacheState.VALID);
@@ -664,9 +672,9 @@ class CacheEntryTest extends AbstractCacheTest {
CacheEntry entry2 = new CacheEntry(target2);
cache.put(entry1);
cache.put(entry2);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
- ResultDescriptor result3 = new ResultDescriptor('result3', -3);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('result3', -3);
// set results, all of them are VALID
entry1.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry2.setValue(result2, 222, [new TargetedResult(target1, result1)]);
@@ -687,9 +695,9 @@ class CacheEntryTest extends AbstractCacheTest {
Source target = new TestSource('/test.dart');
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
- ResultDescriptor result3 = new ResultDescriptor('result3', -3);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('result3', -3);
// set results, all of them are VALID
entry.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry.setValue(result2, 222, [new TargetedResult(target, result1)]);
@@ -734,7 +742,8 @@ class CacheEntryTest extends AbstractCacheTest {
test_setValue() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', null);
+ ResultDescriptor<String> result =
+ new ResultDescriptor<String>('test', null);
String value = 'value';
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
@@ -744,13 +753,17 @@ class CacheEntryTest extends AbstractCacheTest {
}
test_setValue_flushResults() {
- ResultCachingPolicy cachingPolicy = new SimpleResultCachingPolicy(2, 2);
- ResultDescriptor descriptor1 =
- new ResultDescriptor('result1', null, cachingPolicy: cachingPolicy);
- ResultDescriptor descriptor2 =
- new ResultDescriptor('result2', null, cachingPolicy: cachingPolicy);
- ResultDescriptor descriptor3 =
- new ResultDescriptor('result3', null, cachingPolicy: cachingPolicy);
+ ResultCachingPolicy<int> cachingPolicy =
+ new SimpleResultCachingPolicy<int>(2, 2);
+ ResultDescriptor<int> descriptor1 = new ResultDescriptor<int>(
+ 'result1', null,
+ cachingPolicy: cachingPolicy);
+ ResultDescriptor<int> descriptor2 = new ResultDescriptor<int>(
+ 'result2', null,
+ cachingPolicy: cachingPolicy);
+ ResultDescriptor<int> descriptor3 = new ResultDescriptor<int>(
+ 'result3', null,
+ cachingPolicy: cachingPolicy);
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
@@ -772,12 +785,13 @@ class CacheEntryTest extends AbstractCacheTest {
}
test_setValue_flushResults_keepForPrioritySources() {
- ResultCachingPolicy cachingPolicy = new SimpleResultCachingPolicy(2, 2);
- ResultDescriptor newResult(String name) =>
- new ResultDescriptor(name, null, cachingPolicy: cachingPolicy);
- ResultDescriptor descriptor1 = newResult('result1');
- ResultDescriptor descriptor2 = newResult('result2');
- ResultDescriptor descriptor3 = newResult('result3');
+ ResultCachingPolicy<int> cachingPolicy =
+ new SimpleResultCachingPolicy<int>(2, 2);
+ ResultDescriptor<int> newResult(String name) =>
+ new ResultDescriptor<int>(name, null, cachingPolicy: cachingPolicy);
+ ResultDescriptor<int> descriptor1 = newResult('result1');
+ ResultDescriptor<int> descriptor2 = newResult('result2');
+ ResultDescriptor<int> descriptor3 = newResult('result3');
TestSource source1 = new TestSource('/a.dart');
TestSource source2 = new TestSource('/b.dart');
TestSource source3 = new TestSource('/c.dart');
@@ -812,8 +826,8 @@ class CacheEntryTest extends AbstractCacheTest {
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
// set results, all of them are VALID
entry.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry.setValue(result2, 222, [new TargetedResult(target, result1)]);
@@ -836,8 +850,8 @@ class CacheEntryTest extends AbstractCacheTest {
CacheEntry entry2 = new CacheEntry(target2);
cache.put(entry1);
cache.put(entry2);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
// set results, all of them are VALID
entry2.setValue(result2, 222, [new TargetedResult(target1, result1)]);
entry1.setValue(result1, 111, TargetedResult.EMPTY_LIST);
@@ -855,9 +869,9 @@ class CacheEntryTest extends AbstractCacheTest {
AnalysisTarget target = new TestSource();
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
- ResultDescriptor result1 = new ResultDescriptor('result1', -1);
- ResultDescriptor result2 = new ResultDescriptor('result2', -2);
- ResultDescriptor result3 = new ResultDescriptor('result3', -3);
+ ResultDescriptor<int> result1 = new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> result2 = new ResultDescriptor<int>('result2', -2);
+ ResultDescriptor<int> result3 = new ResultDescriptor<int>('result3', -3);
// set results, all of them are VALID
entry.setValue(result1, 111, TargetedResult.EMPTY_LIST);
entry.setValue(result2, 222, [new TargetedResult(target, result1)]);
@@ -890,7 +904,7 @@ class CacheEntryTest extends AbstractCacheTest {
test_toString_nonEmpty() {
AnalysisTarget target = new TestSource();
- ResultDescriptor result = new ResultDescriptor('test', null);
+ ResultDescriptor<int> result = new ResultDescriptor<int>('test', null);
CacheEntry entry = new CacheEntry(target);
cache.put(entry);
entry.setValue(result, 42, TargetedResult.EMPTY_LIST);
@@ -1246,8 +1260,10 @@ class UniversalCachePartitionTest extends CachePartitionTest {
when(context.analysisCache).thenReturn(cache);
// configure
// prepare entries
- ResultDescriptor descriptor1 = new ResultDescriptor('result1', -1);
- ResultDescriptor descriptor2 = new ResultDescriptor('result2', -2);
+ ResultDescriptor<int> descriptor1 =
+ new ResultDescriptor<int>('result1', -1);
+ ResultDescriptor<int> descriptor2 =
+ new ResultDescriptor<int>('result2', -2);
AnalysisTarget target1 = new TestSource('1.dart');
AnalysisTarget target2 = new TestSource('2.dart');
TargetedResult result1 = new TargetedResult(target1, descriptor1);

Powered by Google App Engine
This is Rietveld 408576698