| 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 engine; | 5 library 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/source/embedder.dart'; | 10 import 'package:analyzer/source/embedder.dart'; |
| 11 import 'package:analyzer/src/cancelable_future.dart'; | 11 import 'package:analyzer/src/cancelable_future.dart'; |
| 12 import 'package:analyzer/src/context/cache.dart'; | 12 import 'package:analyzer/src/context/cache.dart'; |
| 13 import 'package:analyzer/src/context/context.dart'; | 13 import 'package:analyzer/src/context/context.dart'; |
| 14 import 'package:analyzer/src/plugin/command_line_plugin.dart'; | 14 import 'package:analyzer/src/plugin/command_line_plugin.dart'; |
| 15 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 15 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
| 16 import 'package:analyzer/src/plugin/options_plugin.dart'; | 16 import 'package:analyzer/src/plugin/options_plugin.dart'; |
| 17 import 'package:analyzer/src/task/manager.dart'; | 17 import 'package:analyzer/src/task/manager.dart'; |
| 18 import 'package:analyzer/task/dart.dart'; | 18 import 'package:analyzer/task/dart.dart'; |
| 19 import 'package:analyzer/task/model.dart'; | 19 import 'package:analyzer/task/model.dart'; |
| 20 import 'package:html/dom.dart' show Document; | 20 import 'package:html/dom.dart' show Document; |
| 21 import 'package:path/path.dart' as pathos; | 21 import 'package:path/path.dart' as pathos; |
| 22 import 'package:plugin/manager.dart'; | 22 import 'package:plugin/manager.dart'; |
| 23 import 'package:plugin/plugin.dart'; | 23 import 'package:plugin/plugin.dart'; |
| 24 | 24 |
| 25 import '../../instrumentation/instrumentation.dart'; | 25 import '../../instrumentation/instrumentation.dart'; |
| 26 import 'ast.dart'; | 26 import 'ast.dart'; |
| 27 import 'constant.dart'; | 27 import 'constant.dart'; |
| 28 import 'element.dart'; | 28 import 'element.dart'; |
| 29 import 'error.dart'; | 29 import 'error.dart'; |
| 30 import 'html.dart' as ht; | |
| 31 import 'java_core.dart'; | 30 import 'java_core.dart'; |
| 32 import 'java_engine.dart'; | 31 import 'java_engine.dart'; |
| 33 import 'resolver.dart'; | 32 import 'resolver.dart'; |
| 34 import 'source.dart'; | 33 import 'source.dart'; |
| 35 import 'utilities_general.dart'; | 34 import 'utilities_general.dart'; |
| 36 | 35 |
| 37 /** | 36 /** |
| 38 * Used by [AnalysisOptions] to allow function bodies to be analyzed in some | 37 * Used by [AnalysisOptions] to allow function bodies to be analyzed in some |
| 39 * sources but not others. | 38 * sources but not others. |
| 40 */ | 39 */ |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 * Throws an [AnalysisException] if the errors could not be determined because | 246 * Throws an [AnalysisException] if the errors could not be determined because |
| 248 * the analysis could not be performed. | 247 * the analysis could not be performed. |
| 249 * | 248 * |
| 250 * <b>Note:</b> This method cannot be used in an async environment. | 249 * <b>Note:</b> This method cannot be used in an async environment. |
| 251 * | 250 * |
| 252 * See [getErrors]. | 251 * See [getErrors]. |
| 253 */ | 252 */ |
| 254 List<AnalysisError> computeErrors(Source source); | 253 List<AnalysisError> computeErrors(Source source); |
| 255 | 254 |
| 256 /** | 255 /** |
| 257 * Return the element model corresponding to the HTML file defined by the | |
| 258 * given [source]. If the element model does not yet exist it will be created. | |
| 259 * The process of creating an element model for an HTML file can be | |
| 260 * long-running, depending on the size of the file and the number of libraries | |
| 261 * that are defined in it (via script tags) that also need to have a model | |
| 262 * built for them. | |
| 263 * | |
| 264 * Throws AnalysisException if the element model could not be determined | |
| 265 * because the analysis could not be performed. | |
| 266 * | |
| 267 * <b>Note:</b> This method cannot be used in an async environment. | |
| 268 * | |
| 269 * See [getHtmlElement]. | |
| 270 */ | |
| 271 @deprecated | |
| 272 HtmlElement computeHtmlElement(Source source); | |
| 273 | |
| 274 /** | |
| 275 * Return the kind of the given [source], computing it's kind if it is not | 256 * Return the kind of the given [source], computing it's kind if it is not |
| 276 * already known. Return [SourceKind.UNKNOWN] if the source is not contained | 257 * already known. Return [SourceKind.UNKNOWN] if the source is not contained |
| 277 * in this context. | 258 * in this context. |
| 278 * | 259 * |
| 279 * <b>Note:</b> This method cannot be used in an async environment. | 260 * <b>Note:</b> This method cannot be used in an async environment. |
| 280 * | 261 * |
| 281 * See [getKindOf]. | 262 * See [getKindOf]. |
| 282 */ | 263 */ |
| 283 SourceKind computeKindOf(Source source); | 264 SourceKind computeKindOf(Source source); |
| 284 | 265 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 * Return an analysis error info containing the list of all of the errors and | 371 * Return an analysis error info containing the list of all of the errors and |
| 391 * the line info associated with the given [source]. The list of errors will | 372 * the line info associated with the given [source]. The list of errors will |
| 392 * be empty if the source is not known to this context or if there are no | 373 * be empty if the source is not known to this context or if there are no |
| 393 * errors in the source. The errors contained in the list can be incomplete. | 374 * errors in the source. The errors contained in the list can be incomplete. |
| 394 * | 375 * |
| 395 * See [computeErrors]. | 376 * See [computeErrors]. |
| 396 */ | 377 */ |
| 397 AnalysisErrorInfo getErrors(Source source); | 378 AnalysisErrorInfo getErrors(Source source); |
| 398 | 379 |
| 399 /** | 380 /** |
| 400 * Return the element model corresponding to the HTML file defined by the | |
| 401 * given [source], or `null` if the source does not represent an HTML file, | |
| 402 * the element representing the file has not yet been created, or the analysis | |
| 403 * of the HTML file failed for some reason. | |
| 404 * | |
| 405 * See [computeHtmlElement]. | |
| 406 */ | |
| 407 @deprecated | |
| 408 HtmlElement getHtmlElement(Source source); | |
| 409 | |
| 410 /** | |
| 411 * Return the sources for the HTML files that reference the compilation unit | 381 * Return the sources for the HTML files that reference the compilation unit |
| 412 * with the given [source]. If the source does not represent a Dart source or | 382 * with the given [source]. If the source does not represent a Dart source or |
| 413 * is not known to this context, the returned list will be empty. The contents | 383 * is not known to this context, the returned list will be empty. The contents |
| 414 * of the list can be incomplete. | 384 * of the list can be incomplete. |
| 415 */ | 385 */ |
| 416 List<Source> getHtmlFilesReferencing(Source source); | 386 List<Source> getHtmlFilesReferencing(Source source); |
| 417 | 387 |
| 418 /** | 388 /** |
| 419 * Return the kind of the given [source], or `null` if the kind is not known | 389 * Return the kind of the given [source], or `null` if the kind is not known |
| 420 * to this context. | 390 * to this context. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 * Return a fully resolved AST for the compilation unit defined by the given | 463 * Return a fully resolved AST for the compilation unit defined by the given |
| 494 * [unitSource] within the library defined by the given [librarySource], or | 464 * [unitSource] within the library defined by the given [librarySource], or |
| 495 * `null` if the resolved AST is not already computed. | 465 * `null` if the resolved AST is not already computed. |
| 496 * | 466 * |
| 497 * See [resolveCompilationUnit2]. | 467 * See [resolveCompilationUnit2]. |
| 498 */ | 468 */ |
| 499 CompilationUnit getResolvedCompilationUnit2( | 469 CompilationUnit getResolvedCompilationUnit2( |
| 500 Source unitSource, Source librarySource); | 470 Source unitSource, Source librarySource); |
| 501 | 471 |
| 502 /** | 472 /** |
| 503 * Return the fully resolved HTML unit defined by the given [htmlSource], or | |
| 504 * `null` if the resolved unit is not already computed. | |
| 505 * | |
| 506 * See [resolveHtmlUnit]. | |
| 507 */ | |
| 508 @deprecated | |
| 509 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); | |
| 510 | |
| 511 /** | |
| 512 * Return the value of the given [result] for the given [target]. | 473 * Return the value of the given [result] for the given [target]. |
| 513 * | 474 * |
| 514 * If the corresponding [target] does not exist, or the [result] is not | 475 * If the corresponding [target] does not exist, or the [result] is not |
| 515 * computed yet, then the default value is returned. | 476 * computed yet, then the default value is returned. |
| 516 */ | 477 */ |
| 517 Object /*V*/ getResult( | 478 Object /*V*/ getResult( |
| 518 AnalysisTarget target, ResultDescriptor /*<V>*/ result); | 479 AnalysisTarget target, ResultDescriptor /*<V>*/ result); |
| 519 | 480 |
| 520 /** | 481 /** |
| 521 * Return a list of the sources being analyzed in this context whose full path | 482 * Return a list of the sources being analyzed in this context whose full path |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 /** | 533 /** |
| 573 * Parse a single HTML [source] to produce a document model. | 534 * Parse a single HTML [source] to produce a document model. |
| 574 * | 535 * |
| 575 * Throws an [AnalysisException] if the analysis could not be performed | 536 * Throws an [AnalysisException] if the analysis could not be performed |
| 576 * | 537 * |
| 577 * <b>Note:</b> This method cannot be used in an async environment. | 538 * <b>Note:</b> This method cannot be used in an async environment. |
| 578 */ | 539 */ |
| 579 Document parseHtmlDocument(Source source); | 540 Document parseHtmlDocument(Source source); |
| 580 | 541 |
| 581 /** | 542 /** |
| 582 * Parse a single HTML [source] to produce an AST structure. The resulting | |
| 583 * HTML AST structure may or may not be resolved, and may have a slightly | |
| 584 * different structure depending upon whether it is resolved. | |
| 585 * | |
| 586 * Throws an [AnalysisException] if the analysis could not be performed | |
| 587 * | |
| 588 * <b>Note:</b> This method cannot be used in an async environment. | |
| 589 */ | |
| 590 @deprecated // use parseHtmlDocument(source) | |
| 591 ht.HtmlUnit parseHtmlUnit(Source source); | |
| 592 | |
| 593 /** | |
| 594 * Perform the next unit of work required to keep the analysis results | 543 * Perform the next unit of work required to keep the analysis results |
| 595 * up-to-date and return information about the consequent changes to the | 544 * up-to-date and return information about the consequent changes to the |
| 596 * analysis results. This method can be long running. | 545 * analysis results. This method can be long running. |
| 597 * | 546 * |
| 598 * The implementation that uses the task model notifies subscribers of | 547 * The implementation that uses the task model notifies subscribers of |
| 599 * [onResultComputed] about computed results. | 548 * [onResultComputed] about computed results. |
| 600 * | 549 * |
| 601 * The following results are computed for Dart sources. | 550 * The following results are computed for Dart sources. |
| 602 * | 551 * |
| 603 * 1. For explicit and implicit sources: | 552 * 1. For explicit and implicit sources: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 * Throws an [AnalysisException] if the analysis could not be performed. | 587 * Throws an [AnalysisException] if the analysis could not be performed. |
| 639 * | 588 * |
| 640 * <b>Note:</b> This method cannot be used in an async environment. | 589 * <b>Note:</b> This method cannot be used in an async environment. |
| 641 * | 590 * |
| 642 * See [getResolvedCompilationUnit2]. | 591 * See [getResolvedCompilationUnit2]. |
| 643 */ | 592 */ |
| 644 CompilationUnit resolveCompilationUnit2( | 593 CompilationUnit resolveCompilationUnit2( |
| 645 Source unitSource, Source librarySource); | 594 Source unitSource, Source librarySource); |
| 646 | 595 |
| 647 /** | 596 /** |
| 648 * Parse and resolve a single [htmlSource] within the given context to produce | |
| 649 * a fully resolved AST. | |
| 650 * | |
| 651 * Throws an [AnalysisException] if the analysis could not be performed. | |
| 652 * | |
| 653 * <b>Note:</b> This method cannot be used in an async environment. | |
| 654 */ | |
| 655 @deprecated | |
| 656 ht.HtmlUnit resolveHtmlUnit(Source htmlSource); | |
| 657 | |
| 658 /** | |
| 659 * Set the contents of the given [source] to the given [contents] and mark the | 597 * Set the contents of the given [source] to the given [contents] and mark the |
| 660 * source as having changed. The additional [offset] and [length] information | 598 * source as having changed. The additional [offset] and [length] information |
| 661 * is used by the context to determine what reanalysis is necessary. | 599 * is used by the context to determine what reanalysis is necessary. |
| 662 */ | 600 */ |
| 663 void setChangedContents( | 601 void setChangedContents( |
| 664 Source source, String contents, int offset, int oldLength, int newLength); | 602 Source source, String contents, int offset, int oldLength, int newLength); |
| 665 | 603 |
| 666 /** | 604 /** |
| 667 * Associate this configuration [data] object with the given descriptor [key]. | 605 * Associate this configuration [data] object with the given descriptor [key]. |
| 668 * | 606 * |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 */ | 999 */ |
| 1062 void includedSource(AnalysisContext context, Source source); | 1000 void includedSource(AnalysisContext context, Source source); |
| 1063 | 1001 |
| 1064 /** | 1002 /** |
| 1065 * Reports that the given Dart [source] was parsed in the given [context], | 1003 * Reports that the given Dart [source] was parsed in the given [context], |
| 1066 * producing the given [unit]. | 1004 * producing the given [unit]. |
| 1067 */ | 1005 */ |
| 1068 void parsedDart(AnalysisContext context, Source source, CompilationUnit unit); | 1006 void parsedDart(AnalysisContext context, Source source, CompilationUnit unit); |
| 1069 | 1007 |
| 1070 /** | 1008 /** |
| 1071 * Reports that the given HTML [source] was parsed in the given [context]. | |
| 1072 */ | |
| 1073 @deprecated | |
| 1074 void parsedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); | |
| 1075 | |
| 1076 /** | |
| 1077 * Reports that the given Dart [source] was resolved in the given [context]. | 1009 * Reports that the given Dart [source] was resolved in the given [context]. |
| 1078 */ | 1010 */ |
| 1079 void resolvedDart( | 1011 void resolvedDart( |
| 1080 AnalysisContext context, Source source, CompilationUnit unit); | 1012 AnalysisContext context, Source source, CompilationUnit unit); |
| 1081 | |
| 1082 /** | |
| 1083 * Reports that the given HTML [source] was resolved in the given [context]. | |
| 1084 */ | |
| 1085 @deprecated | |
| 1086 void resolvedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); | |
| 1087 } | 1013 } |
| 1088 | 1014 |
| 1089 /** | 1015 /** |
| 1090 * Futures returned by [AnalysisContext] for pending analysis results will | 1016 * Futures returned by [AnalysisContext] for pending analysis results will |
| 1091 * complete with this error if it is determined that analysis results will | 1017 * complete with this error if it is determined that analysis results will |
| 1092 * never become available (e.g. because the requested source is not subject to | 1018 * never become available (e.g. because the requested source is not subject to |
| 1093 * analysis, or because the requested source is a part file which is not a part | 1019 * analysis, or because the requested source is a part file which is not a part |
| 1094 * of any known library). | 1020 * of any known library). |
| 1095 */ | 1021 */ |
| 1096 class AnalysisNotScheduledError implements Exception {} | 1022 class AnalysisNotScheduledError implements Exception {} |
| 1097 | 1023 |
| 1098 /** | 1024 /** |
| 1099 * A set of analysis options used to control the behavior of an analysis | 1025 * A set of analysis options used to control the behavior of an analysis |
| 1100 * context. | 1026 * context. |
| 1101 */ | 1027 */ |
| 1102 abstract class AnalysisOptions { | 1028 abstract class AnalysisOptions { |
| 1103 /** | 1029 /** |
| 1104 * If analysis is to parse and analyze all function bodies, return `true`. | |
| 1105 * If analysis is to skip all function bodies, return `false`. If analysis | |
| 1106 * is to parse and analyze function bodies in some sources and not in others, | |
| 1107 * throw an exception. | |
| 1108 * | |
| 1109 * This getter is deprecated; consider using [analyzeFunctionBodiesPredicate] | |
| 1110 * instead. | |
| 1111 */ | |
| 1112 @deprecated // Use this.analyzeFunctionBodiesPredicate | |
| 1113 bool get analyzeFunctionBodies; | |
| 1114 | |
| 1115 /** | |
| 1116 * Function that returns `true` if analysis is to parse and analyze function | 1030 * Function that returns `true` if analysis is to parse and analyze function |
| 1117 * bodies for a given source. | 1031 * bodies for a given source. |
| 1118 */ | 1032 */ |
| 1119 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; | 1033 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; |
| 1120 | 1034 |
| 1121 /** | 1035 /** |
| 1122 * Return the maximum number of sources for which AST structures should be | 1036 * Return the maximum number of sources for which AST structures should be |
| 1123 * kept in the cache. | 1037 * kept in the cache. |
| 1124 */ | 1038 */ |
| 1125 int get cacheSize; | 1039 int get cacheSize; |
| 1126 | 1040 |
| 1127 /** | 1041 /** |
| 1128 * Return `true` if analysis is to generate dart2js related hint results. | 1042 * Return `true` if analysis is to generate dart2js related hint results. |
| 1129 */ | 1043 */ |
| 1130 bool get dart2jsHint; | 1044 bool get dart2jsHint; |
| 1131 | 1045 |
| 1132 /** | 1046 /** |
| 1133 * Return `true` to enable custom assert messages (DEP 37). | 1047 * Return `true` to enable custom assert messages (DEP 37). |
| 1134 */ | 1048 */ |
| 1135 bool get enableAssertMessage; | 1049 bool get enableAssertMessage; |
| 1136 | 1050 |
| 1137 /** | 1051 /** |
| 1138 * Return `true` if analysis is to include the new async support. | |
| 1139 */ | |
| 1140 @deprecated // Always true | |
| 1141 bool get enableAsync; | |
| 1142 | |
| 1143 /** | |
| 1144 * Return `true` to enable interface libraries (DEP 40). | 1052 * Return `true` to enable interface libraries (DEP 40). |
| 1145 */ | 1053 */ |
| 1146 bool get enableConditionalDirectives; | 1054 bool get enableConditionalDirectives; |
| 1147 | 1055 |
| 1148 /** | 1056 /** |
| 1149 * Return `true` if analysis is to include the new deferred loading support. | |
| 1150 */ | |
| 1151 @deprecated // Always true | |
| 1152 bool get enableDeferredLoading; | |
| 1153 | |
| 1154 /** | |
| 1155 * Return `true` if analysis is to include the new enum support. | |
| 1156 */ | |
| 1157 @deprecated // Always true | |
| 1158 bool get enableEnum; | |
| 1159 | |
| 1160 /** | |
| 1161 * Return `true` to enable generic methods (DEP 22). | 1057 * Return `true` to enable generic methods (DEP 22). |
| 1162 */ | 1058 */ |
| 1163 bool get enableGenericMethods => null; | 1059 bool get enableGenericMethods => null; |
| 1164 | 1060 |
| 1165 /** | 1061 /** |
| 1166 * Return `true` to enable null-aware operators (DEP 9). | |
| 1167 */ | |
| 1168 @deprecated // Always true | |
| 1169 bool get enableNullAwareOperators; | |
| 1170 | |
| 1171 /** | |
| 1172 * Return `true` to strictly follow the specification when generating | 1062 * Return `true` to strictly follow the specification when generating |
| 1173 * warnings on "call" methods (fixes dartbug.com/21938). | 1063 * warnings on "call" methods (fixes dartbug.com/21938). |
| 1174 */ | 1064 */ |
| 1175 bool get enableStrictCallChecks; | 1065 bool get enableStrictCallChecks; |
| 1176 | 1066 |
| 1177 /** | 1067 /** |
| 1178 * Return `true` if mixins are allowed to inherit from types other than | 1068 * Return `true` if mixins are allowed to inherit from types other than |
| 1179 * Object, and are allowed to reference `super`. | 1069 * Object, and are allowed to reference `super`. |
| 1180 */ | 1070 */ |
| 1181 bool get enableSuperMixins; | 1071 bool get enableSuperMixins; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 * A set of analysis options used to control the behavior of an analysis | 1125 * A set of analysis options used to control the behavior of an analysis |
| 1236 * context. | 1126 * context. |
| 1237 */ | 1127 */ |
| 1238 class AnalysisOptionsImpl implements AnalysisOptions { | 1128 class AnalysisOptionsImpl implements AnalysisOptions { |
| 1239 /** | 1129 /** |
| 1240 * The maximum number of sources for which data should be kept in the cache. | 1130 * The maximum number of sources for which data should be kept in the cache. |
| 1241 */ | 1131 */ |
| 1242 static const int DEFAULT_CACHE_SIZE = 64; | 1132 static const int DEFAULT_CACHE_SIZE = 64; |
| 1243 | 1133 |
| 1244 /** | 1134 /** |
| 1245 * The default value for enabling deferred loading. | |
| 1246 */ | |
| 1247 @deprecated | |
| 1248 static bool DEFAULT_ENABLE_DEFERRED_LOADING = true; | |
| 1249 | |
| 1250 /** | |
| 1251 * The default value for enabling enum support. | |
| 1252 */ | |
| 1253 @deprecated | |
| 1254 static bool DEFAULT_ENABLE_ENUM = true; | |
| 1255 | |
| 1256 /** | |
| 1257 * A predicate indicating whether analysis is to parse and analyze function | 1135 * A predicate indicating whether analysis is to parse and analyze function |
| 1258 * bodies. | 1136 * bodies. |
| 1259 */ | 1137 */ |
| 1260 AnalyzeFunctionBodiesPredicate _analyzeFunctionBodiesPredicate = | 1138 AnalyzeFunctionBodiesPredicate _analyzeFunctionBodiesPredicate = |
| 1261 _analyzeAllFunctionBodies; | 1139 _analyzeAllFunctionBodies; |
| 1262 | 1140 |
| 1263 /** | 1141 /** |
| 1264 * The maximum number of sources for which AST structures should be kept in | 1142 * The maximum number of sources for which AST structures should be kept in |
| 1265 * the cache. | 1143 * the cache. |
| 1266 */ | 1144 */ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 /** | 1231 /** |
| 1354 * Initialize a newly created set of analysis options to have their default | 1232 * Initialize a newly created set of analysis options to have their default |
| 1355 * values. | 1233 * values. |
| 1356 */ | 1234 */ |
| 1357 AnalysisOptionsImpl(); | 1235 AnalysisOptionsImpl(); |
| 1358 | 1236 |
| 1359 /** | 1237 /** |
| 1360 * Initialize a newly created set of analysis options to have the same values | 1238 * Initialize a newly created set of analysis options to have the same values |
| 1361 * as those in the given set of analysis [options]. | 1239 * as those in the given set of analysis [options]. |
| 1362 */ | 1240 */ |
| 1363 @deprecated // Use new AnalysisOptionsImpl.from(options) | |
| 1364 AnalysisOptionsImpl.con1(AnalysisOptions options) { | |
| 1365 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; | |
| 1366 cacheSize = options.cacheSize; | |
| 1367 dart2jsHint = options.dart2jsHint; | |
| 1368 enableAssertMessage = options.enableAssertMessage; | |
| 1369 enableStrictCallChecks = options.enableStrictCallChecks; | |
| 1370 enableGenericMethods = options.enableGenericMethods; | |
| 1371 enableSuperMixins = options.enableSuperMixins; | |
| 1372 generateImplicitErrors = options.generateImplicitErrors; | |
| 1373 generateSdkErrors = options.generateSdkErrors; | |
| 1374 hint = options.hint; | |
| 1375 incremental = options.incremental; | |
| 1376 incrementalApi = options.incrementalApi; | |
| 1377 incrementalValidation = options.incrementalValidation; | |
| 1378 lint = options.lint; | |
| 1379 preserveComments = options.preserveComments; | |
| 1380 strongMode = options.strongMode; | |
| 1381 } | |
| 1382 | |
| 1383 /** | |
| 1384 * Initialize a newly created set of analysis options to have the same values | |
| 1385 * as those in the given set of analysis [options]. | |
| 1386 */ | |
| 1387 AnalysisOptionsImpl.from(AnalysisOptions options) { | 1241 AnalysisOptionsImpl.from(AnalysisOptions options) { |
| 1388 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; | 1242 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
| 1389 cacheSize = options.cacheSize; | 1243 cacheSize = options.cacheSize; |
| 1390 dart2jsHint = options.dart2jsHint; | 1244 dart2jsHint = options.dart2jsHint; |
| 1391 enableAssertMessage = options.enableAssertMessage; | 1245 enableAssertMessage = options.enableAssertMessage; |
| 1392 enableStrictCallChecks = options.enableStrictCallChecks; | 1246 enableStrictCallChecks = options.enableStrictCallChecks; |
| 1393 enableGenericMethods = options.enableGenericMethods; | 1247 enableGenericMethods = options.enableGenericMethods; |
| 1394 enableSuperMixins = options.enableSuperMixins; | 1248 enableSuperMixins = options.enableSuperMixins; |
| 1395 generateImplicitErrors = options.generateImplicitErrors; | 1249 generateImplicitErrors = options.generateImplicitErrors; |
| 1396 generateSdkErrors = options.generateSdkErrors; | 1250 generateSdkErrors = options.generateSdkErrors; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1426 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate => | 1280 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate => |
| 1427 _analyzeFunctionBodiesPredicate; | 1281 _analyzeFunctionBodiesPredicate; |
| 1428 | 1282 |
| 1429 set analyzeFunctionBodiesPredicate(AnalyzeFunctionBodiesPredicate value) { | 1283 set analyzeFunctionBodiesPredicate(AnalyzeFunctionBodiesPredicate value) { |
| 1430 if (value == null) { | 1284 if (value == null) { |
| 1431 throw new ArgumentError.notNull('analyzeFunctionBodiesPredicate'); | 1285 throw new ArgumentError.notNull('analyzeFunctionBodiesPredicate'); |
| 1432 } | 1286 } |
| 1433 _analyzeFunctionBodiesPredicate = value; | 1287 _analyzeFunctionBodiesPredicate = value; |
| 1434 } | 1288 } |
| 1435 | 1289 |
| 1436 @deprecated | |
| 1437 @override | |
| 1438 bool get enableAsync => true; | |
| 1439 | |
| 1440 @deprecated | |
| 1441 void set enableAsync(bool enable) { | |
| 1442 // Async support cannot be disabled | |
| 1443 } | |
| 1444 | |
| 1445 @deprecated | |
| 1446 @override | |
| 1447 bool get enableDeferredLoading => true; | |
| 1448 | |
| 1449 @deprecated | |
| 1450 void set enableDeferredLoading(bool enable) { | |
| 1451 // Deferred loading support cannot be disabled | |
| 1452 } | |
| 1453 | |
| 1454 @deprecated | |
| 1455 @override | |
| 1456 bool get enableEnum => true; | |
| 1457 | |
| 1458 @deprecated | |
| 1459 void set enableEnum(bool enable) { | |
| 1460 // Enum support cannot be disabled | |
| 1461 } | |
| 1462 | |
| 1463 @deprecated | |
| 1464 @override | |
| 1465 bool get enableNullAwareOperators => true; | |
| 1466 | |
| 1467 @deprecated | |
| 1468 void set enableNullAwareOperators(bool enable) { | |
| 1469 // Null-aware operator support cannot be disabled | |
| 1470 } | |
| 1471 | |
| 1472 /** | 1290 /** |
| 1473 * Predicate used for [analyzeFunctionBodiesPredicate] when | 1291 * Predicate used for [analyzeFunctionBodiesPredicate] when |
| 1474 * [analyzeFunctionBodies] is set to `true`. | 1292 * [analyzeFunctionBodies] is set to `true`. |
| 1475 */ | 1293 */ |
| 1476 static bool _analyzeAllFunctionBodies(Source _) => true; | 1294 static bool _analyzeAllFunctionBodies(Source _) => true; |
| 1477 | 1295 |
| 1478 /** | 1296 /** |
| 1479 * Predicate used for [analyzeFunctionBodiesPredicate] when | 1297 * Predicate used for [analyzeFunctionBodiesPredicate] when |
| 1480 * [analyzeFunctionBodies] is set to `false`. | 1298 * [analyzeFunctionBodies] is set to `false`. |
| 1481 */ | 1299 */ |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 */ | 1440 */ |
| 1623 CompilationUnit get parsedDartUnit; | 1441 CompilationUnit get parsedDartUnit; |
| 1624 | 1442 |
| 1625 /** | 1443 /** |
| 1626 * The fully resolved Dart AST that changed as a result of the analysis, or | 1444 * The fully resolved Dart AST that changed as a result of the analysis, or |
| 1627 * `null` if the AST was not changed. | 1445 * `null` if the AST was not changed. |
| 1628 */ | 1446 */ |
| 1629 CompilationUnit get resolvedDartUnit; | 1447 CompilationUnit get resolvedDartUnit; |
| 1630 | 1448 |
| 1631 /** | 1449 /** |
| 1632 * The fully resolved HTML AST that changed as a result of the analysis, or | |
| 1633 * `null` if the AST was not changed. | |
| 1634 */ | |
| 1635 @deprecated | |
| 1636 ht.HtmlUnit get resolvedHtmlUnit; | |
| 1637 | |
| 1638 /** | |
| 1639 * Return the source for which the result is being reported. | 1450 * Return the source for which the result is being reported. |
| 1640 */ | 1451 */ |
| 1641 Source get source; | 1452 Source get source; |
| 1642 } | 1453 } |
| 1643 | 1454 |
| 1644 /** | 1455 /** |
| 1645 * An implementation of a [ChangeNotice]. | 1456 * An implementation of a [ChangeNotice]. |
| 1646 */ | 1457 */ |
| 1647 class ChangeNoticeImpl implements ChangeNotice { | 1458 class ChangeNoticeImpl implements ChangeNotice { |
| 1648 /** | 1459 /** |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1661 */ | 1472 */ |
| 1662 CompilationUnit parsedDartUnit; | 1473 CompilationUnit parsedDartUnit; |
| 1663 | 1474 |
| 1664 /** | 1475 /** |
| 1665 * The fully resolved Dart AST that changed as a result of the analysis, or | 1476 * The fully resolved Dart AST that changed as a result of the analysis, or |
| 1666 * `null` if the AST was not changed. | 1477 * `null` if the AST was not changed. |
| 1667 */ | 1478 */ |
| 1668 CompilationUnit resolvedDartUnit; | 1479 CompilationUnit resolvedDartUnit; |
| 1669 | 1480 |
| 1670 /** | 1481 /** |
| 1671 * The fully resolved HTML AST that changed as a result of the analysis, or | |
| 1672 * `null` if the AST was not changed. | |
| 1673 */ | |
| 1674 @deprecated | |
| 1675 ht.HtmlUnit resolvedHtmlUnit; | |
| 1676 | |
| 1677 /** | |
| 1678 * The errors that changed as a result of the analysis, or `null` if errors | 1482 * The errors that changed as a result of the analysis, or `null` if errors |
| 1679 * were not changed. | 1483 * were not changed. |
| 1680 */ | 1484 */ |
| 1681 List<AnalysisError> _errors; | 1485 List<AnalysisError> _errors; |
| 1682 | 1486 |
| 1683 /** | 1487 /** |
| 1684 * The line information associated with the source, or `null` if errors were | 1488 * The line information associated with the source, or `null` if errors were |
| 1685 * not changed. | 1489 * not changed. |
| 1686 */ | 1490 */ |
| 1687 LineInfo _lineInfo; | 1491 LineInfo _lineInfo; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 | 1864 |
| 2061 /** | 1865 /** |
| 2062 * The partition that contains analysis results that are not shared with other | 1866 * The partition that contains analysis results that are not shared with other |
| 2063 * contexts. | 1867 * contexts. |
| 2064 * | 1868 * |
| 2065 * TODO(scheglov) add the type, once we have only one cache. | 1869 * TODO(scheglov) add the type, once we have only one cache. |
| 2066 */ | 1870 */ |
| 2067 dynamic get privateAnalysisCachePartition; | 1871 dynamic get privateAnalysisCachePartition; |
| 2068 | 1872 |
| 2069 /** | 1873 /** |
| 2070 * A factory to override how [ResolverVisitor] is created. | |
| 2071 */ | |
| 2072 ResolverVisitorFactory get resolverVisitorFactory; | |
| 2073 | |
| 2074 /** | |
| 2075 * Sets the [TypeProvider] for this context. | 1874 * Sets the [TypeProvider] for this context. |
| 2076 */ | 1875 */ |
| 2077 void set typeProvider(TypeProvider typeProvider); | 1876 void set typeProvider(TypeProvider typeProvider); |
| 2078 | 1877 |
| 2079 /** | 1878 /** |
| 2080 * A factory to override how [TypeResolverVisitor] is created. | |
| 2081 */ | |
| 2082 TypeResolverVisitorFactory get typeResolverVisitorFactory; | |
| 2083 | |
| 2084 /** | |
| 2085 * A list of all [WorkManager]s used by this context. | 1879 * A list of all [WorkManager]s used by this context. |
| 2086 */ | 1880 */ |
| 2087 List<WorkManager> get workManagers; | 1881 List<WorkManager> get workManagers; |
| 2088 | 1882 |
| 2089 /** | 1883 /** |
| 2090 * Return a list containing the sources of the libraries that are exported by | 1884 * Return a list containing the sources of the libraries that are exported by |
| 2091 * the library with the given [source]. The list will be empty if the given | 1885 * the library with the given [source]. The list will be empty if the given |
| 2092 * source is invalid, if the given source does not represent a library, or if | 1886 * source is invalid, if the given source does not represent a library, or if |
| 2093 * the library does not export any other libraries. | 1887 * the library does not export any other libraries. |
| 2094 * | 1888 * |
| 2095 * Throws an [AnalysisException] if the exported libraries could not be | 1889 * Throws an [AnalysisException] if the exported libraries could not be |
| 2096 * computed. | 1890 * computed. |
| 2097 */ | 1891 */ |
| 2098 List<Source> computeExportedLibraries(Source source); | 1892 List<Source> computeExportedLibraries(Source source); |
| 2099 | 1893 |
| 2100 /** | 1894 /** |
| 2101 * Return a list containing the sources of the libraries that are imported by | 1895 * Return a list containing the sources of the libraries that are imported by |
| 2102 * the library with the given [source]. The list will be empty if the given | 1896 * the library with the given [source]. The list will be empty if the given |
| 2103 * source is invalid, if the given source does not represent a library, or if | 1897 * source is invalid, if the given source does not represent a library, or if |
| 2104 * the library does not import any other libraries. | 1898 * the library does not import any other libraries. |
| 2105 * | 1899 * |
| 2106 * Throws an [AnalysisException] if the imported libraries could not be | 1900 * Throws an [AnalysisException] if the imported libraries could not be |
| 2107 * computed. | 1901 * computed. |
| 2108 */ | 1902 */ |
| 2109 List<Source> computeImportedLibraries(Source source); | 1903 List<Source> computeImportedLibraries(Source source); |
| 2110 | 1904 |
| 2111 /** | 1905 /** |
| 2112 * Return an AST structure corresponding to the given [source], but ensure | |
| 2113 * that the structure has not already been resolved and will not be resolved | |
| 2114 * by any other threads or in any other library. | |
| 2115 * | |
| 2116 * Throws an [AnalysisException] if the analysis could not be performed. | |
| 2117 * | |
| 2118 * <b>Note:</b> This method cannot be used in an async environment | |
| 2119 */ | |
| 2120 CompilationUnit computeResolvableCompilationUnit(Source source); | |
| 2121 | |
| 2122 /** | |
| 2123 * Return all the resolved [CompilationUnit]s for the given [source] if not | 1906 * Return all the resolved [CompilationUnit]s for the given [source] if not |
| 2124 * flushed, otherwise return `null` and ensures that the [CompilationUnit]s | 1907 * flushed, otherwise return `null` and ensures that the [CompilationUnit]s |
| 2125 * will be eventually returned to the client from [performAnalysisTask]. | 1908 * will be eventually returned to the client from [performAnalysisTask]. |
| 2126 */ | 1909 */ |
| 2127 List<CompilationUnit> ensureResolvedDartUnits(Source source); | 1910 List<CompilationUnit> ensureResolvedDartUnits(Source source); |
| 2128 | 1911 |
| 2129 /** | 1912 /** |
| 2130 * Return the cache entry associated with the given [target]. | 1913 * Return the cache entry associated with the given [target]. |
| 2131 */ | 1914 */ |
| 2132 CacheEntry getCacheEntry(AnalysisTarget target); | 1915 CacheEntry getCacheEntry(AnalysisTarget target); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 */ | 1962 */ |
| 2180 bool shouldErrorsBeAnalyzed(Source source); | 1963 bool shouldErrorsBeAnalyzed(Source source); |
| 2181 | 1964 |
| 2182 /** | 1965 /** |
| 2183 * For testing only: flush all representations of the AST (both resolved and | 1966 * For testing only: flush all representations of the AST (both resolved and |
| 2184 * unresolved) for the given [source] out of the cache. | 1967 * unresolved) for the given [source] out of the cache. |
| 2185 */ | 1968 */ |
| 2186 void test_flushAstStructures(Source source); | 1969 void test_flushAstStructures(Source source); |
| 2187 | 1970 |
| 2188 /** | 1971 /** |
| 2189 * Call the given callback function for eache cache item in the context. | |
| 2190 */ | |
| 2191 @deprecated | |
| 2192 void visitCacheItems(void callback( | |
| 2193 Source source, dynamic dartEntry, dynamic rowDesc, CacheState state)); | |
| 2194 | |
| 2195 /** | |
| 2196 * Visit all entries of the content cache. | 1972 * Visit all entries of the content cache. |
| 2197 */ | 1973 */ |
| 2198 void visitContentCache(ContentCacheVisitor visitor); | 1974 void visitContentCache(ContentCacheVisitor visitor); |
| 2199 } | 1975 } |
| 2200 | 1976 |
| 2201 /** | 1977 /** |
| 2202 * An object that can be used to receive information about errors within the | 1978 * An object that can be used to receive information about errors within the |
| 2203 * analysis engine. Implementations usually write this information to a file, | 1979 * analysis engine. Implementations usually write this information to a file, |
| 2204 * but can also record the information for later use (such as during testing) or | 1980 * but can also record the information for later use (such as during testing) or |
| 2205 * even ignore the information. | 1981 * even ignore the information. |
| 2206 */ | 1982 */ |
| 2207 abstract class Logger { | 1983 abstract class Logger { |
| 2208 /** | 1984 /** |
| 2209 * A logger that ignores all logging. | 1985 * A logger that ignores all logging. |
| 2210 */ | 1986 */ |
| 2211 static final Logger NULL = new NullLogger(); | 1987 static final Logger NULL = new NullLogger(); |
| 2212 | 1988 |
| 2213 /** | 1989 /** |
| 2214 * Log the given message as an error. The [message] is expected to be an | 1990 * Log the given message as an error. The [message] is expected to be an |
| 2215 * explanation of why the error occurred or what it means. The [exception] is | 1991 * explanation of why the error occurred or what it means. The [exception] is |
| 2216 * expected to be the reason for the error. At least one argument must be | 1992 * expected to be the reason for the error. At least one argument must be |
| 2217 * provided. | 1993 * provided. |
| 2218 */ | 1994 */ |
| 2219 void logError(String message, [CaughtException exception]); | 1995 void logError(String message, [CaughtException exception]); |
| 2220 | 1996 |
| 2221 /** | 1997 /** |
| 2222 * Log the given [exception] as one representing an error. The [message] is an | |
| 2223 * explanation of why the error occurred or what it means. | |
| 2224 */ | |
| 2225 @deprecated // Use logError(message, exception) | |
| 2226 void logError2(String message, Object exception); | |
| 2227 | |
| 2228 /** | |
| 2229 * Log the given informational message. The [message] is expected to be an | 1998 * Log the given informational message. The [message] is expected to be an |
| 2230 * explanation of why the error occurred or what it means. The [exception] is | 1999 * explanation of why the error occurred or what it means. The [exception] is |
| 2231 * expected to be the reason for the error. | 2000 * expected to be the reason for the error. |
| 2232 */ | 2001 */ |
| 2233 void logInformation(String message, [CaughtException exception]); | 2002 void logInformation(String message, [CaughtException exception]); |
| 2234 | |
| 2235 /** | |
| 2236 * Log the given [exception] as one representing an informational message. The | |
| 2237 * [message] is an explanation of why the error occurred or what it means. | |
| 2238 */ | |
| 2239 @deprecated // Use logInformation(message, exception) | |
| 2240 void logInformation2(String message, Object exception); | |
| 2241 } | 2003 } |
| 2242 | 2004 |
| 2243 /** | 2005 /** |
| 2244 * An implementation of [Logger] that does nothing. | 2006 * An implementation of [Logger] that does nothing. |
| 2245 */ | 2007 */ |
| 2246 class NullLogger implements Logger { | 2008 class NullLogger implements Logger { |
| 2247 @override | 2009 @override |
| 2248 void logError(String message, [CaughtException exception]) {} | 2010 void logError(String message, [CaughtException exception]) {} |
| 2249 | 2011 |
| 2250 @override | 2012 @override |
| 2251 void logError2(String message, Object exception) {} | |
| 2252 | |
| 2253 @override | |
| 2254 void logInformation(String message, [CaughtException exception]) {} | 2013 void logInformation(String message, [CaughtException exception]) {} |
| 2255 | |
| 2256 @override | |
| 2257 void logInformation2(String message, Object exception) {} | |
| 2258 } | 2014 } |
| 2259 | 2015 |
| 2260 /** | 2016 /** |
| 2261 * An exception created when an analysis attempt fails because a source was | 2017 * An exception created when an analysis attempt fails because a source was |
| 2262 * deleted between the time the analysis started and the time the results of the | 2018 * deleted between the time the analysis started and the time the results of the |
| 2263 * analysis were ready to be recorded. | 2019 * analysis were ready to be recorded. |
| 2264 */ | 2020 */ |
| 2265 class ObsoleteSourceAnalysisException extends AnalysisException { | 2021 class ObsoleteSourceAnalysisException extends AnalysisException { |
| 2266 /** | 2022 /** |
| 2267 * The source that was removed while it was being analyzed. | 2023 * The source that was removed while it was being analyzed. |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2634 * The data that was created from the source. | 2390 * The data that was created from the source. |
| 2635 */ | 2391 */ |
| 2636 final E data; | 2392 final E data; |
| 2637 | 2393 |
| 2638 /** | 2394 /** |
| 2639 * Initialize a newly created holder to associate the given [data] with the | 2395 * Initialize a newly created holder to associate the given [data] with the |
| 2640 * given [modificationTime]. | 2396 * given [modificationTime]. |
| 2641 */ | 2397 */ |
| 2642 TimestampedData(this.modificationTime, this.data); | 2398 TimestampedData(this.modificationTime, this.data); |
| 2643 } | 2399 } |
| OLD | NEW |