OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.engine; | 5 library analyzer.src.generated.engine; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 * of any known library). | 1048 * of any known library). |
1049 */ | 1049 */ |
1050 class AnalysisNotScheduledError implements Exception {} | 1050 class AnalysisNotScheduledError implements Exception {} |
1051 | 1051 |
1052 /** | 1052 /** |
1053 * A set of analysis options used to control the behavior of an analysis | 1053 * A set of analysis options used to control the behavior of an analysis |
1054 * context. | 1054 * context. |
1055 */ | 1055 */ |
1056 abstract class AnalysisOptions { | 1056 abstract class AnalysisOptions { |
1057 /** | 1057 /** |
| 1058 * The length of the list returned by [encodeCrossContextOptions]. |
| 1059 */ |
| 1060 static const int crossContextOptionsLength = 2; |
| 1061 |
| 1062 /** |
1058 * Function that returns `true` if analysis is to parse and analyze function | 1063 * Function that returns `true` if analysis is to parse and analyze function |
1059 * bodies for a given source. | 1064 * bodies for a given source. |
1060 */ | 1065 */ |
1061 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; | 1066 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; |
1062 | 1067 |
1063 /** | 1068 /** |
1064 * DEPRECATED: Return the maximum number of sources for which AST structures s
hould be | 1069 * DEPRECATED: Return the maximum number of sources for which AST structures s
hould be |
1065 * kept in the cache. | 1070 * kept in the cache. |
1066 * | 1071 * |
1067 * This setting no longer has any effect. | 1072 * This setting no longer has any effect. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 | 1213 |
1209 /** | 1214 /** |
1210 * Return `true` if dependencies between computed results should be tracked | 1215 * Return `true` if dependencies between computed results should be tracked |
1211 * by analysis cache. This option should only be set to `false` if analysis | 1216 * by analysis cache. This option should only be set to `false` if analysis |
1212 * is performed in such a way that none of the inputs is ever changed | 1217 * is performed in such a way that none of the inputs is ever changed |
1213 * during the life time of the context. | 1218 * during the life time of the context. |
1214 */ | 1219 */ |
1215 bool get trackCacheDependencies; | 1220 bool get trackCacheDependencies; |
1216 | 1221 |
1217 /** | 1222 /** |
1218 * Return an integer encoding of the values of the options that need to be the | 1223 * Return a list of integers encoding of the values of the options that need |
1219 * same across all of the contexts associated with partitions that are to be | 1224 * to be the same across all of the contexts associated with partitions that |
1220 * shared by a single analysis context. | 1225 * are to be shared by a single analysis context. |
| 1226 * |
| 1227 * The length of the list is guaranteed to equal [crossContextOptionsLength]. |
1221 */ | 1228 */ |
1222 int encodeCrossContextOptions(); | 1229 List<int> encodeCrossContextOptions(); |
1223 | 1230 |
1224 /** | 1231 /** |
1225 * Set the values of the cross-context options to match those in the given set | 1232 * Set the values of the cross-context options to match those in the given set |
1226 * of [options]. | 1233 * of [options]. |
1227 */ | 1234 */ |
1228 void setCrossContextOptionsFrom(AnalysisOptions options); | 1235 void setCrossContextOptionsFrom(AnalysisOptions options); |
| 1236 |
| 1237 /** |
| 1238 * Determine whether two lists returned by [encodeCrossContextOptions] are |
| 1239 * equal. |
| 1240 */ |
| 1241 static bool crossContextOptionsEqual(List<int> a, List<int> b) { |
| 1242 assert(a.length == crossContextOptionsLength); |
| 1243 assert(b.length == crossContextOptionsLength); |
| 1244 if (a.length != b.length) { |
| 1245 return false; |
| 1246 } |
| 1247 for (int i = 0; i < a.length; i++) { |
| 1248 if (a[i] != b[i]) { |
| 1249 return false; |
| 1250 } |
| 1251 } |
| 1252 return true; |
| 1253 } |
1229 } | 1254 } |
1230 | 1255 |
1231 /** | 1256 /** |
1232 * A set of analysis options used to control the behavior of an analysis | 1257 * A set of analysis options used to control the behavior of an analysis |
1233 * context. | 1258 * context. |
1234 */ | 1259 */ |
1235 class AnalysisOptionsImpl implements AnalysisOptions { | 1260 class AnalysisOptionsImpl implements AnalysisOptions { |
1236 /** | 1261 /** |
1237 * DEPRECATED: The maximum number of sources for which data should be kept in
the cache. | 1262 * DEPRECATED: The maximum number of sources for which data should be kept in
the cache. |
1238 * | 1263 * |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 | 1471 |
1447 /** | 1472 /** |
1448 * A flag indicating whether interface libraries are to be supported (DEP 40). | 1473 * A flag indicating whether interface libraries are to be supported (DEP 40). |
1449 */ | 1474 */ |
1450 bool get enableConditionalDirectives => true; | 1475 bool get enableConditionalDirectives => true; |
1451 | 1476 |
1452 @deprecated | 1477 @deprecated |
1453 void set enableConditionalDirectives(_) {} | 1478 void set enableConditionalDirectives(_) {} |
1454 | 1479 |
1455 @override | 1480 @override |
1456 int encodeCrossContextOptions() => | 1481 List<int> encodeCrossContextOptions() { |
1457 (enableAssertMessage ? ENABLE_ASSERT_FLAG : 0) | | 1482 int flags = (enableAssertMessage ? ENABLE_ASSERT_FLAG : 0) | |
1458 (enableGenericMethods ? ENABLE_GENERIC_METHODS_FLAG : 0) | | 1483 (enableGenericMethods ? ENABLE_GENERIC_METHODS_FLAG : 0) | |
1459 (enableLazyAssignmentOperators ? ENABLE_LAZY_ASSIGNMENT_OPERATORS : 0) | | 1484 (enableLazyAssignmentOperators ? ENABLE_LAZY_ASSIGNMENT_OPERATORS : 0) | |
1460 (enableStrictCallChecks ? ENABLE_STRICT_CALL_CHECKS_FLAG : 0) | | 1485 (enableStrictCallChecks ? ENABLE_STRICT_CALL_CHECKS_FLAG : 0) | |
1461 (enableSuperMixins ? ENABLE_SUPER_MIXINS_FLAG : 0) | | 1486 (enableSuperMixins ? ENABLE_SUPER_MIXINS_FLAG : 0) | |
1462 (strongMode ? ENABLE_STRONG_MODE_FLAG : 0) | | 1487 (strongMode ? ENABLE_STRONG_MODE_FLAG : 0) | |
1463 (strongModeHints ? ENABLE_STRONG_MODE_HINTS_FLAG : 0); | 1488 (strongModeHints ? ENABLE_STRONG_MODE_HINTS_FLAG : 0); |
| 1489 return <int>[flags, patchPlatform]; |
| 1490 } |
1464 | 1491 |
1465 @override | 1492 @override |
1466 void setCrossContextOptionsFrom(AnalysisOptions options) { | 1493 void setCrossContextOptionsFrom(AnalysisOptions options) { |
1467 enableAssertMessage = options.enableAssertMessage; | 1494 enableAssertMessage = options.enableAssertMessage; |
1468 enableGenericMethods = options.enableGenericMethods; | 1495 enableGenericMethods = options.enableGenericMethods; |
1469 enableLazyAssignmentOperators = options.enableLazyAssignmentOperators; | 1496 enableLazyAssignmentOperators = options.enableLazyAssignmentOperators; |
1470 enableStrictCallChecks = options.enableStrictCallChecks; | 1497 enableStrictCallChecks = options.enableStrictCallChecks; |
1471 enableSuperMixins = options.enableSuperMixins; | 1498 enableSuperMixins = options.enableSuperMixins; |
1472 strongMode = options.strongMode; | 1499 strongMode = options.strongMode; |
1473 if (options is AnalysisOptionsImpl) { | 1500 if (options is AnalysisOptionsImpl) { |
1474 strongModeHints = options.strongModeHints; | 1501 strongModeHints = options.strongModeHints; |
1475 } | 1502 } |
| 1503 patchPlatform = options.patchPlatform; |
1476 } | 1504 } |
1477 | 1505 |
1478 /** | 1506 /** |
1479 * Produce a human readable list of option names corresponding to the options | 1507 * Produce a human readable list of option names corresponding to the options |
1480 * encoded in the given [encoding], presumably from invoking the method | 1508 * encoded in the given [encoding], presumably from invoking the method |
1481 * [encodeCrossContextOptions]. | 1509 * [encodeCrossContextOptions]. |
1482 */ | 1510 */ |
1483 static String decodeCrossContextOptions(int encoding) { | 1511 static String decodeCrossContextOptions(List<int> encoding) { |
1484 if (encoding == 0) { | 1512 List<String> parts = []; |
| 1513 int flags = encoding[0]; |
| 1514 if (flags & ENABLE_ASSERT_FLAG > 0) { |
| 1515 parts.add('assert'); |
| 1516 } |
| 1517 if (flags & ENABLE_GENERIC_METHODS_FLAG > 0) { |
| 1518 parts.add('genericMethods'); |
| 1519 } |
| 1520 if (flags & ENABLE_LAZY_ASSIGNMENT_OPERATORS > 0) { |
| 1521 parts.add('lazyAssignmentOperators'); |
| 1522 } |
| 1523 if (flags & ENABLE_STRICT_CALL_CHECKS_FLAG > 0) { |
| 1524 parts.add('strictCallChecks'); |
| 1525 } |
| 1526 if (flags & ENABLE_SUPER_MIXINS_FLAG > 0) { |
| 1527 parts.add('superMixins'); |
| 1528 } |
| 1529 if (flags & ENABLE_STRONG_MODE_FLAG > 0) { |
| 1530 parts.add('strongMode'); |
| 1531 } |
| 1532 if (flags & ENABLE_STRONG_MODE_HINTS_FLAG > 0) { |
| 1533 parts.add('strongModeHints'); |
| 1534 } |
| 1535 int patchPlatform = encoding[1]; |
| 1536 if (patchPlatform != 0) { |
| 1537 parts.add('patchPlatform=$patchPlatform'); |
| 1538 } |
| 1539 if (parts.isEmpty) { |
1485 return 'none'; | 1540 return 'none'; |
| 1541 } else { |
| 1542 return parts.join(', '); |
1486 } | 1543 } |
1487 StringBuffer buffer = new StringBuffer(); | |
1488 bool needsSeparator = false; | |
1489 void add(String optionName) { | |
1490 if (needsSeparator) { | |
1491 buffer.write(', '); | |
1492 } | |
1493 buffer.write(optionName); | |
1494 needsSeparator = true; | |
1495 } | |
1496 | |
1497 if (encoding & ENABLE_ASSERT_FLAG > 0) { | |
1498 add('assert'); | |
1499 } | |
1500 if (encoding & ENABLE_GENERIC_METHODS_FLAG > 0) { | |
1501 add('genericMethods'); | |
1502 } | |
1503 if (encoding & ENABLE_LAZY_ASSIGNMENT_OPERATORS > 0) { | |
1504 add('lazyAssignmentOperators'); | |
1505 } | |
1506 if (encoding & ENABLE_STRICT_CALL_CHECKS_FLAG > 0) { | |
1507 add('strictCallChecks'); | |
1508 } | |
1509 if (encoding & ENABLE_SUPER_MIXINS_FLAG > 0) { | |
1510 add('superMixins'); | |
1511 } | |
1512 if (encoding & ENABLE_STRONG_MODE_FLAG > 0) { | |
1513 add('strongMode'); | |
1514 } | |
1515 if (encoding & ENABLE_STRONG_MODE_HINTS_FLAG > 0) { | |
1516 add('strongModeHints'); | |
1517 } | |
1518 return buffer.toString(); | |
1519 } | 1544 } |
1520 | 1545 |
1521 /** | 1546 /** |
1522 * Predicate used for [analyzeFunctionBodiesPredicate] when | 1547 * Predicate used for [analyzeFunctionBodiesPredicate] when |
1523 * [analyzeFunctionBodies] is set to `true`. | 1548 * [analyzeFunctionBodies] is set to `true`. |
1524 */ | 1549 */ |
1525 static bool _analyzeAllFunctionBodies(Source _) => true; | 1550 static bool _analyzeAllFunctionBodies(Source _) => true; |
1526 | 1551 |
1527 /** | 1552 /** |
1528 * Predicate used for [analyzeFunctionBodiesPredicate] when | 1553 * Predicate used for [analyzeFunctionBodiesPredicate] when |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 * The data that was created from the source. | 2734 * The data that was created from the source. |
2710 */ | 2735 */ |
2711 final E data; | 2736 final E data; |
2712 | 2737 |
2713 /** | 2738 /** |
2714 * Initialize a newly created holder to associate the given [data] with the | 2739 * Initialize a newly created holder to associate the given [data] with the |
2715 * given [modificationTime]. | 2740 * given [modificationTime]. |
2716 */ | 2741 */ |
2717 TimestampedData(this.modificationTime, this.data); | 2742 TimestampedData(this.modificationTime, this.data); |
2718 } | 2743 } |
OLD | NEW |