| OLD | NEW |
| 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 analyzer.src.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/cancelable_future.dart'; | 10 import 'package:analyzer/src/cancelable_future.dart'; |
| (...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 return SourcePriority.LIBRARY; | 1330 return SourcePriority.LIBRARY; |
| 1331 } else if (kind == SourceKind.PART) { | 1331 } else if (kind == SourceKind.PART) { |
| 1332 return SourcePriority.NORMAL_PART; | 1332 return SourcePriority.NORMAL_PART; |
| 1333 } | 1333 } |
| 1334 return SourcePriority.UNKNOWN; | 1334 return SourcePriority.UNKNOWN; |
| 1335 } | 1335 } |
| 1336 | 1336 |
| 1337 Object /*V*/ _computeResult( | 1337 Object /*V*/ _computeResult( |
| 1338 AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) { | 1338 AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) { |
| 1339 cache.CacheEntry entry = getCacheEntry(target); | 1339 cache.CacheEntry entry = getCacheEntry(target); |
| 1340 if (descriptor is CompositeResultDescriptor) { | |
| 1341 List compositeResults = []; | |
| 1342 for (ResultDescriptor descriptor in descriptor.contributors) { | |
| 1343 List value = _computeResult(target, descriptor); | |
| 1344 compositeResults.addAll(value); | |
| 1345 } | |
| 1346 return compositeResults; | |
| 1347 } | |
| 1348 CacheState state = entry.getState(descriptor); | 1340 CacheState state = entry.getState(descriptor); |
| 1349 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { | 1341 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { |
| 1350 _driver.computeResult(target, descriptor); | 1342 _driver.computeResult(target, descriptor); |
| 1351 } | 1343 } |
| 1352 state = entry.getState(descriptor); | 1344 state = entry.getState(descriptor); |
| 1353 if (state == CacheState.ERROR) { | 1345 if (state == CacheState.ERROR) { |
| 1354 throw new AnalysisException( | 1346 throw new AnalysisException( |
| 1355 'Cannot compute $descriptor for $target', entry.exception); | 1347 'Cannot compute $descriptor for $target', entry.exception); |
| 1356 } | 1348 } |
| 1357 return entry.getValue(descriptor); | 1349 return entry.getValue(descriptor); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 _pendingNotices[source] = notice; | 1473 _pendingNotices[source] = notice; |
| 1482 } | 1474 } |
| 1483 return notice; | 1475 return notice; |
| 1484 } | 1476 } |
| 1485 | 1477 |
| 1486 Object _getResult(AnalysisTarget target, ResultDescriptor descriptor) { | 1478 Object _getResult(AnalysisTarget target, ResultDescriptor descriptor) { |
| 1487 cache.CacheEntry entry = _cache.get(target); | 1479 cache.CacheEntry entry = _cache.get(target); |
| 1488 if (entry == null) { | 1480 if (entry == null) { |
| 1489 return descriptor.defaultValue; | 1481 return descriptor.defaultValue; |
| 1490 } | 1482 } |
| 1491 if (descriptor is CompositeResultDescriptor) { | |
| 1492 List compositeResults = []; | |
| 1493 for (ResultDescriptor descriptor in descriptor.contributors) { | |
| 1494 List value = _getResult(target, descriptor); | |
| 1495 compositeResults.addAll(value); | |
| 1496 } | |
| 1497 return compositeResults; | |
| 1498 } | |
| 1499 if (entry.isValid(descriptor)) { | 1483 if (entry.isValid(descriptor)) { |
| 1500 return entry.getValue(descriptor); | 1484 return entry.getValue(descriptor); |
| 1501 } | 1485 } |
| 1502 return descriptor.defaultValue; | 1486 return descriptor.defaultValue; |
| 1503 } | 1487 } |
| 1504 | 1488 |
| 1505 /** | 1489 /** |
| 1506 * Return a list containing all of the sources known to this context that have | 1490 * Return a list containing all of the sources known to this context that have |
| 1507 * the given [kind]. | 1491 * the given [kind]. |
| 1508 */ | 1492 */ |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2145 PendingFuture pendingFuture = | 2129 PendingFuture pendingFuture = |
| 2146 new PendingFuture<T>(_context, target, computeValue); | 2130 new PendingFuture<T>(_context, target, computeValue); |
| 2147 if (!pendingFuture.evaluate(entry)) { | 2131 if (!pendingFuture.evaluate(entry)) { |
| 2148 _context._pendingFutureTargets | 2132 _context._pendingFutureTargets |
| 2149 .putIfAbsent(target, () => <PendingFuture>[]) | 2133 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2150 .add(pendingFuture); | 2134 .add(pendingFuture); |
| 2151 } | 2135 } |
| 2152 return pendingFuture.future; | 2136 return pendingFuture.future; |
| 2153 } | 2137 } |
| 2154 } | 2138 } |
| OLD | NEW |