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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 109853003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/lib/src/generated/scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.resolver; 4 library engine.resolver;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'java_core.dart'; 7 import 'java_core.dart';
8 import 'java_engine.dart'; 8 import 'java_engine.dart';
9 import 'instrumentation.dart'; 9 import 'instrumentation.dart';
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 static String _SRC = "src"; 1113 static String _SRC = "src";
1114 1114
1115 /** 1115 /**
1116 * The analysis context in which the element model will be built. 1116 * The analysis context in which the element model will be built.
1117 */ 1117 */
1118 InternalAnalysisContext _context; 1118 InternalAnalysisContext _context;
1119 1119
1120 /** 1120 /**
1121 * The error listener to which errors will be reported. 1121 * The error listener to which errors will be reported.
1122 */ 1122 */
1123 RecordingErrorListener errorListener; 1123 RecordingErrorListener _errorListener;
1124 1124
1125 /** 1125 /**
1126 * The modification time of the source for which an element is being built. 1126 * The modification time of the source for which an element is being built.
1127 */ 1127 */
1128 int _modificationStamp = 0; 1128 int _modificationStamp = 0;
1129 1129
1130 /** 1130 /**
1131 * The line information associated with the source for which an element is bei ng built, or 1131 * The line information associated with the source for which an element is bei ng built, or
1132 * `null` if we are not building an element. 1132 * `null` if we are not building an element.
1133 */ 1133 */
(...skipping 10 matching lines...) Expand all
1144 List<ht.XmlTagNode> _parentNodes; 1144 List<ht.XmlTagNode> _parentNodes;
1145 1145
1146 /** 1146 /**
1147 * The script elements being built. 1147 * The script elements being built.
1148 */ 1148 */
1149 List<HtmlScriptElement> _scripts; 1149 List<HtmlScriptElement> _scripts;
1150 1150
1151 /** 1151 /**
1152 * A set of the libraries that were resolved while resolving the HTML unit. 1152 * A set of the libraries that were resolved while resolving the HTML unit.
1153 */ 1153 */
1154 final Set<Library> resolvedLibraries = new Set<Library>(); 1154 Set<Library> _resolvedLibraries = new Set<Library>();
1155 1155
1156 /** 1156 /**
1157 * Initialize a newly created HTML unit builder. 1157 * Initialize a newly created HTML unit builder.
1158 * 1158 *
1159 * @param context the analysis context in which the element model will be buil t 1159 * @param context the analysis context in which the element model will be buil t
1160 */ 1160 */
1161 HtmlUnitBuilder(InternalAnalysisContext context) { 1161 HtmlUnitBuilder(InternalAnalysisContext context) {
1162 this._context = context; 1162 this._context = context;
1163 this.errorListener = new RecordingErrorListener(); 1163 this._errorListener = new RecordingErrorListener();
1164 } 1164 }
1165 1165
1166 /** 1166 /**
1167 * Build the HTML element for the given source. 1167 * Build the HTML element for the given source.
1168 * 1168 *
1169 * @param source the source describing the compilation unit 1169 * @param source the source describing the compilation unit
1170 * @return the HTML element that was built 1170 * @return the HTML element that was built
1171 * @throws AnalysisException if the analysis could not be performed 1171 * @throws AnalysisException if the analysis could not be performed
1172 */ 1172 */
1173 HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, s ource.modificationStamp, _context.parseHtmlUnit(source)); 1173 HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, s ource.modificationStamp, _context.parseHtmlUnit(source));
(...skipping 12 matching lines...) Expand all
1186 _lineInfo = _context.computeLineInfo(source); 1186 _lineInfo = _context.computeLineInfo(source);
1187 HtmlElementImpl result = new HtmlElementImpl(_context, source.shortName); 1187 HtmlElementImpl result = new HtmlElementImpl(_context, source.shortName);
1188 result.source = source; 1188 result.source = source;
1189 _htmlElement = result; 1189 _htmlElement = result;
1190 unit.accept(this); 1190 unit.accept(this);
1191 _htmlElement = null; 1191 _htmlElement = null;
1192 unit.element = result; 1192 unit.element = result;
1193 return result; 1193 return result;
1194 } 1194 }
1195 1195
1196 /**
1197 * Return the listener to which analysis errors will be reported.
1198 *
1199 * @return the listener to which analysis errors will be reported
1200 */
1201 RecordingErrorListener get errorListener => _errorListener;
1202
1203 /**
1204 * Return an array containing information about all of the libraries that were resolved.
1205 *
1206 * @return an array containing the libraries that were resolved
1207 */
1208 Set<Library> get resolvedLibraries => _resolvedLibraries;
1209
1196 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { 1210 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) {
1197 if (_parentNodes.contains(node)) { 1211 if (_parentNodes.contains(node)) {
1198 return reportCircularity(node); 1212 return reportCircularity(node);
1199 } 1213 }
1200 _parentNodes.add(node); 1214 _parentNodes.add(node);
1201 try { 1215 try {
1202 Source htmlSource = _htmlElement.source; 1216 Source htmlSource = _htmlElement.source;
1203 ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node); 1217 ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node);
1204 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute .text; 1218 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribute .text;
1205 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath == null) { 1219 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath == null) {
1206 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl (node); 1220 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl (node);
1207 try { 1221 try {
1208 LibraryResolver resolver = new LibraryResolver(_context); 1222 LibraryResolver resolver = new LibraryResolver(_context);
1209 LibraryElementImpl library = resolver.resolveEmbeddedLibrary(htmlSourc e, _modificationStamp, node.script, true) as LibraryElementImpl; 1223 LibraryElementImpl library = resolver.resolveEmbeddedLibrary(htmlSourc e, _modificationStamp, node.script, true) as LibraryElementImpl;
1210 script.scriptLibrary = library; 1224 script.scriptLibrary = library;
1211 resolvedLibraries.addAll(resolver.resolvedLibraries); 1225 _resolvedLibraries.addAll(resolver.resolvedLibraries);
1212 errorListener.addAll(resolver.errorListener); 1226 _errorListener.addAll(resolver.errorListener);
1213 } on AnalysisException catch (exception) { 1227 } on AnalysisException catch (exception) {
1214 AnalysisEngine.instance.logger.logError3(exception); 1228 AnalysisEngine.instance.logger.logError3(exception);
1215 } 1229 }
1216 node.scriptElement = script; 1230 node.scriptElement = script;
1217 _scripts.add(script); 1231 _scripts.add(script);
1218 } else { 1232 } else {
1219 ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl (node); 1233 ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl (node);
1220 if (scriptSourcePath != null) { 1234 if (scriptSourcePath != null) {
1221 try { 1235 try {
1222 scriptSourcePath = Uri.encodeFull(scriptSourcePath); 1236 scriptSourcePath = Uri.encodeFull(scriptSourcePath);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 /** 1330 /**
1317 * Report an error with the given error code at the given location. Use the gi ven arguments to 1331 * Report an error with the given error code at the given location. Use the gi ven arguments to
1318 * compose the error message. 1332 * compose the error message.
1319 * 1333 *
1320 * @param errorCode the error code of the error to be reported 1334 * @param errorCode the error code of the error to be reported
1321 * @param offset the offset of the first character to be highlighted 1335 * @param offset the offset of the first character to be highlighted
1322 * @param length the number of characters to be highlighted 1336 * @param length the number of characters to be highlighted
1323 * @param arguments the arguments used to compose the error message 1337 * @param arguments the arguments used to compose the error message
1324 */ 1338 */
1325 void reportError(ErrorCode errorCode, int offset, int length, List<Object> arg uments) { 1339 void reportError(ErrorCode errorCode, int offset, int length, List<Object> arg uments) {
1326 errorListener.onError(new AnalysisError.con2(_htmlElement.source, offset, le ngth, errorCode, arguments)); 1340 _errorListener.onError(new AnalysisError.con2(_htmlElement.source, offset, l ength, errorCode, arguments));
1327 } 1341 }
1328 1342
1329 /** 1343 /**
1330 * Report an error with the given error code at the location of the value of t he given attribute. 1344 * Report an error with the given error code at the location of the value of t he given attribute.
1331 * Use the given arguments to compose the error message. 1345 * Use the given arguments to compose the error message.
1332 * 1346 *
1333 * @param errorCode the error code of the error to be reported 1347 * @param errorCode the error code of the error to be reported
1334 * @param offset the offset of the first character to be highlighted 1348 * @param offset the offset of the first character to be highlighted
1335 * @param length the number of characters to be highlighted 1349 * @param length the number of characters to be highlighted
1336 * @param arguments the arguments used to compose the error message 1350 * @param arguments the arguments used to compose the error message
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 String fullName = source.fullName; 2546 String fullName = source.fullName;
2533 if (fullName != null) { 2547 if (fullName != null) {
2534 return fullName.replaceAll(r'\', '/'); 2548 return fullName.replaceAll(r'\', '/');
2535 } 2549 }
2536 } 2550 }
2537 return null; 2551 return null;
2538 } 2552 }
2539 } 2553 }
2540 2554
2541 /** 2555 /**
2556 * Instances of the class `ReturnDetector` determine whether the visited AST nod e is
2557 * guaranteed (modulo exceptions) to terminate by executing a return statement.
2558 */
2559 class ReturnDetector extends UnifyingASTVisitor<bool> {
2560 bool visitBlock(Block node) => visitStatements(node.statements);
2561
2562 bool visitBlockFunctionBody(BlockFunctionBody node) => node.block.accept(this) ;
2563
2564 bool visitIfStatement(IfStatement node) {
2565 Statement thenStatement = node.thenStatement;
2566 Statement elseStatement = node.elseStatement;
2567 if (thenStatement == null || elseStatement == null) {
2568 return false;
2569 }
2570 return thenStatement.accept(this) && elseStatement.accept(this);
2571 }
2572
2573 bool visitNode(ASTNode node) => false;
2574
2575 bool visitReturnStatement(ReturnStatement node) => true;
2576
2577 bool visitSwitchCase(SwitchCase node) => visitStatements(node.statements);
2578
2579 bool visitSwitchDefault(SwitchDefault node) => visitStatements(node.statements );
2580
2581 bool visitSwitchStatement(SwitchStatement node) {
2582 bool hasDefault = false;
2583 for (SwitchMember member in node.members) {
2584 if (!member.accept(this)) {
2585 return false;
2586 }
2587 if (member is SwitchDefault) {
2588 hasDefault = true;
2589 }
2590 }
2591 return hasDefault;
2592 }
2593
2594 bool visitStatements(NodeList<Statement> statements) {
2595 for (int i = statements.length - 1; i >= 0; i--) {
2596 if (statements[i].accept(this)) {
2597 return true;
2598 }
2599 }
2600 return false;
2601 }
2602 }
2603
2604 /**
2542 * Instances of the class `ToDoFinder` find to-do comments in Dart code. 2605 * Instances of the class `ToDoFinder` find to-do comments in Dart code.
2543 */ 2606 */
2544 class ToDoFinder { 2607 class ToDoFinder {
2545 /** 2608 /**
2546 * The error reporter by which to-do comments will be reported. 2609 * The error reporter by which to-do comments will be reported.
2547 */ 2610 */
2548 ErrorReporter _errorReporter; 2611 ErrorReporter _errorReporter;
2549 2612
2550 /** 2613 /**
2551 * Initialize a newly created to-do finder to report to-do comments to the giv en reporter. 2614 * Initialize a newly created to-do finder to report to-do comments to the giv en reporter.
(...skipping 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 /** 5923 /**
5861 * Instances of the class `SyntheticIdentifier` implement an identifier that can be used to 5924 * Instances of the class `SyntheticIdentifier` implement an identifier that can be used to
5862 * look up names in the lexical scope when there is no identifier in the AST str ucture. There is 5925 * look up names in the lexical scope when there is no identifier in the AST str ucture. There is
5863 * no identifier in the AST when the parser could not distinguish between a meth od invocation and 5926 * no identifier in the AST when the parser could not distinguish between a meth od invocation and
5864 * an invocation of a top-level function imported with a prefix. 5927 * an invocation of a top-level function imported with a prefix.
5865 */ 5928 */
5866 class ElementResolver_SyntheticIdentifier extends Identifier { 5929 class ElementResolver_SyntheticIdentifier extends Identifier {
5867 /** 5930 /**
5868 * The name of the synthetic identifier. 5931 * The name of the synthetic identifier.
5869 */ 5932 */
5870 String _name; 5933 final String name;
5871 5934
5872 /** 5935 /**
5873 * Initialize a newly created synthetic identifier to have the given name. 5936 * Initialize a newly created synthetic identifier to have the given name.
5874 * 5937 *
5875 * @param name the name of the synthetic identifier 5938 * @param name the name of the synthetic identifier
5876 */ 5939 */
5877 ElementResolver_SyntheticIdentifier(String name) { 5940 ElementResolver_SyntheticIdentifier(this.name);
5878 this._name = name;
5879 }
5880 5941
5881 accept(ASTVisitor visitor) => null; 5942 accept(ASTVisitor visitor) => null;
5882 5943
5883 sc.Token get beginToken => null; 5944 sc.Token get beginToken => null;
5884 5945
5885 Element get bestElement => null; 5946 Element get bestElement => null;
5886 5947
5887 sc.Token get endToken => null; 5948 sc.Token get endToken => null;
5888 5949
5889 String get name => _name;
5890
5891 int get precedence => 16; 5950 int get precedence => 16;
5892 5951
5893 Element get propagatedElement => null; 5952 Element get propagatedElement => null;
5894 5953
5895 Element get staticElement => null; 5954 Element get staticElement => null;
5896 5955
5897 void visitChildren(ASTVisitor visitor) { 5956 void visitChildren(ASTVisitor visitor) {
5898 } 5957 }
5899 } 5958 }
5900 5959
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
6569 InheritanceManager _inheritanceManager; 6628 InheritanceManager _inheritanceManager;
6570 6629
6571 /** 6630 /**
6572 * The listener to which analysis errors will be reported. 6631 * The listener to which analysis errors will be reported.
6573 */ 6632 */
6574 AnalysisErrorListener _errorListener; 6633 AnalysisErrorListener _errorListener;
6575 6634
6576 /** 6635 /**
6577 * The source specifying the defining compilation unit of this library. 6636 * The source specifying the defining compilation unit of this library.
6578 */ 6637 */
6579 Source librarySource; 6638 final Source librarySource;
6580 6639
6581 /** 6640 /**
6582 * The library element representing this library. 6641 * The library element representing this library.
6583 */ 6642 */
6584 LibraryElementImpl _libraryElement; 6643 LibraryElementImpl _libraryElement;
6585 6644
6586 /** 6645 /**
6587 * A list containing all of the libraries that are imported into this library. 6646 * A list containing all of the libraries that are imported into this library.
6588 */ 6647 */
6589 List<Library> imports = _EMPTY_ARRAY; 6648 List<Library> _importedLibraries = _EMPTY_ARRAY;
6590 6649
6591 /** 6650 /**
6592 * A table mapping URI-based directive to the actual URI value. 6651 * A table mapping URI-based directive to the actual URI value.
6593 */ 6652 */
6594 Map<UriBasedDirective, String> _directiveUris = new Map<UriBasedDirective, Str ing>(); 6653 Map<UriBasedDirective, String> _directiveUris = new Map<UriBasedDirective, Str ing>();
6595 6654
6596 /** 6655 /**
6597 * A flag indicating whether this library explicitly imports core. 6656 * A flag indicating whether this library explicitly imports core.
6598 */ 6657 */
6599 bool explicitlyImportsCore = false; 6658 bool explicitlyImportsCore = false;
6600 6659
6601 /** 6660 /**
6602 * A list containing all of the libraries that are exported from this library. 6661 * A list containing all of the libraries that are exported from this library.
6603 */ 6662 */
6604 List<Library> exports = _EMPTY_ARRAY; 6663 List<Library> _exportedLibraries = _EMPTY_ARRAY;
6605 6664
6606 /** 6665 /**
6607 * A table mapping the sources for the compilation units in this library to th eir corresponding 6666 * A table mapping the sources for the compilation units in this library to th eir corresponding
6608 * AST structures. 6667 * AST structures.
6609 */ 6668 */
6610 Map<Source, ResolvableCompilationUnit> _astMap = new Map<Source, ResolvableCom pilationUnit>(); 6669 Map<Source, ResolvableCompilationUnit> _astMap = new Map<Source, ResolvableCom pilationUnit>();
6611 6670
6612 /** 6671 /**
6613 * The library scope used when resolving elements within this library's compil ation units. 6672 * The library scope used when resolving elements within this library's compil ation units.
6614 */ 6673 */
6615 LibraryScope _libraryScope; 6674 LibraryScope _libraryScope;
6616 6675
6617 /** 6676 /**
6618 * An empty array that can be used to initialize lists of libraries. 6677 * An empty array that can be used to initialize lists of libraries.
6619 */ 6678 */
6620 static List<Library> _EMPTY_ARRAY = new List<Library>(0); 6679 static List<Library> _EMPTY_ARRAY = new List<Library>(0);
6621 6680
6622 /** 6681 /**
6623 * The prefix of a URI using the dart-ext scheme to reference a native code li brary. 6682 * The prefix of a URI using the dart-ext scheme to reference a native code li brary.
6624 */ 6683 */
6625 static String _DART_EXT_SCHEME = "dart-ext:"; 6684 static String _DART_EXT_SCHEME = "dart-ext:";
6626 6685
6627 /** 6686 /**
6628 * Initialize a newly created data holder that can maintain the data associate d with a library. 6687 * Initialize a newly created data holder that can maintain the data associate d with a library.
6629 * 6688 *
6630 * @param analysisContext the analysis context in which this library is being analyzed 6689 * @param analysisContext the analysis context in which this library is being analyzed
6631 * @param errorListener the listener to which analysis errors will be reported 6690 * @param errorListener the listener to which analysis errors will be reported
6632 * @param librarySource the source specifying the defining compilation unit of this library 6691 * @param librarySource the source specifying the defining compilation unit of this library
6633 */ 6692 */
6634 Library(InternalAnalysisContext analysisContext, AnalysisErrorListener errorLi stener, Source librarySource) { 6693 Library(InternalAnalysisContext analysisContext, AnalysisErrorListener errorLi stener, this.librarySource) {
6635 this._analysisContext = analysisContext; 6694 this._analysisContext = analysisContext;
6636 this._errorListener = errorListener; 6695 this._errorListener = errorListener;
6637 this.librarySource = librarySource;
6638 this._libraryElement = analysisContext.getLibraryElement(librarySource) as L ibraryElementImpl; 6696 this._libraryElement = analysisContext.getLibraryElement(librarySource) as L ibraryElementImpl;
6639 } 6697 }
6640 6698
6641 /** 6699 /**
6642 * Return the AST structure associated with the given source. 6700 * Return the AST structure associated with the given source.
6643 * 6701 *
6644 * @param source the source representing the compilation unit whose AST is to be returned 6702 * @param source the source representing the compilation unit whose AST is to be returned
6645 * @return the AST structure associated with the given source 6703 * @return the AST structure associated with the given source
6646 * @throws AnalysisException if an AST structure could not be created for the compilation unit 6704 * @throws AnalysisException if an AST structure could not be created for the compilation unit
6647 */ 6705 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6683 /** 6741 /**
6684 * Return the AST structure associated with the defining compilation unit for this library. 6742 * Return the AST structure associated with the defining compilation unit for this library.
6685 * 6743 *
6686 * @return the AST structure associated with the defining compilation unit for this library 6744 * @return the AST structure associated with the defining compilation unit for this library
6687 * @throws AnalysisException if an AST structure could not be created for the defining compilation 6745 * @throws AnalysisException if an AST structure could not be created for the defining compilation
6688 * unit 6746 * unit
6689 */ 6747 */
6690 CompilationUnit get definingCompilationUnit => getAST(librarySource); 6748 CompilationUnit get definingCompilationUnit => getAST(librarySource);
6691 6749
6692 /** 6750 /**
6751 * Return an array containing the libraries that are exported from this librar y.
6752 *
6753 * @return an array containing the libraries that are exported from this libra ry
6754 */
6755 List<Library> get exports => _exportedLibraries;
6756
6757 /**
6758 * Return an array containing the libraries that are imported into this librar y.
6759 *
6760 * @return an array containing the libraries that are imported into this libra ry
6761 */
6762 List<Library> get imports => _importedLibraries;
6763
6764 /**
6693 * Return an array containing the libraries that are either imported or export ed from this 6765 * Return an array containing the libraries that are either imported or export ed from this
6694 * library. 6766 * library.
6695 * 6767 *
6696 * @return the libraries that are either imported or exported from this librar y 6768 * @return the libraries that are either imported or exported from this librar y
6697 */ 6769 */
6698 List<Library> get importsAndExports { 6770 List<Library> get importsAndExports {
6699 Set<Library> libraries = new Set<Library>(); 6771 Set<Library> libraries = new Set<Library>();
6700 for (Library library in imports) { 6772 for (Library library in _importedLibraries) {
6701 libraries.add(library); 6773 libraries.add(library);
6702 } 6774 }
6703 for (Library library in exports) { 6775 for (Library library in _exportedLibraries) {
6704 libraries.add(library); 6776 libraries.add(library);
6705 } 6777 }
6706 return new List.from(libraries); 6778 return new List.from(libraries);
6707 } 6779 }
6708 6780
6709 /** 6781 /**
6710 * Return the inheritance manager for this library. 6782 * Return the inheritance manager for this library.
6711 * 6783 *
6712 * @return the inheritance manager for this library 6784 * @return the inheritance manager for this library
6713 */ 6785 */
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
6822 void setDefiningCompilationUnit(int modificationStamp, CompilationUnit unit) { 6894 void setDefiningCompilationUnit(int modificationStamp, CompilationUnit unit) {
6823 _astMap[librarySource] = new ResolvableCompilationUnit(modificationStamp, un it); 6895 _astMap[librarySource] = new ResolvableCompilationUnit(modificationStamp, un it);
6824 } 6896 }
6825 6897
6826 /** 6898 /**
6827 * Set the libraries that are exported by this library to be those in the give n array. 6899 * Set the libraries that are exported by this library to be those in the give n array.
6828 * 6900 *
6829 * @param exportedLibraries the libraries that are exported by this library 6901 * @param exportedLibraries the libraries that are exported by this library
6830 */ 6902 */
6831 void set exportedLibraries(List<Library> exportedLibraries) { 6903 void set exportedLibraries(List<Library> exportedLibraries) {
6832 this.exports = exportedLibraries; 6904 this._exportedLibraries = exportedLibraries;
6833 } 6905 }
6834 6906
6835 /** 6907 /**
6836 * Set the libraries that are imported into this library to be those in the gi ven array. 6908 * Set the libraries that are imported into this library to be those in the gi ven array.
6837 * 6909 *
6838 * @param importedLibraries the libraries that are imported into this library 6910 * @param importedLibraries the libraries that are imported into this library
6839 */ 6911 */
6840 void set importedLibraries(List<Library> importedLibraries) { 6912 void set importedLibraries(List<Library> importedLibraries) {
6841 this.imports = importedLibraries; 6913 this._importedLibraries = importedLibraries;
6842 } 6914 }
6843 6915
6844 /** 6916 /**
6845 * Set the library element representing this library to the given library elem ent. 6917 * Set the library element representing this library to the given library elem ent.
6846 * 6918 *
6847 * @param libraryElement the library element representing this library 6919 * @param libraryElement the library element representing this library
6848 */ 6920 */
6849 void set libraryElement(LibraryElementImpl libraryElement) { 6921 void set libraryElement(LibraryElementImpl libraryElement) {
6850 this._libraryElement = libraryElement; 6922 this._libraryElement = libraryElement;
6851 if (_inheritanceManager != null) { 6923 if (_inheritanceManager != null) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
7047 /** 7119 /**
7048 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent 7120 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent
7049 * libraries within a single context. 7121 * libraries within a single context.
7050 * 7122 *
7051 * @coverage dart.engine.resolver 7123 * @coverage dart.engine.resolver
7052 */ 7124 */
7053 class LibraryResolver { 7125 class LibraryResolver {
7054 /** 7126 /**
7055 * The analysis context in which the libraries are being analyzed. 7127 * The analysis context in which the libraries are being analyzed.
7056 */ 7128 */
7057 InternalAnalysisContext analysisContext; 7129 final InternalAnalysisContext analysisContext;
7058 7130
7059 /** 7131 /**
7060 * The listener to which analysis errors will be reported, this error listener is either 7132 * The listener to which analysis errors will be reported, this error listener is either
7061 * references [recordingErrorListener], or it unions the passed 7133 * references [recordingErrorListener], or it unions the passed
7062 * [AnalysisErrorListener] with the [recordingErrorListener]. 7134 * [AnalysisErrorListener] with the [recordingErrorListener].
7063 */ 7135 */
7064 RecordingErrorListener errorListener; 7136 RecordingErrorListener _errorListener;
7065 7137
7066 /** 7138 /**
7067 * A source object representing the core library (dart:core). 7139 * A source object representing the core library (dart:core).
7068 */ 7140 */
7069 Source _coreLibrarySource; 7141 Source _coreLibrarySource;
7070 7142
7071 /** 7143 /**
7072 * The object representing the core library. 7144 * The object representing the core library.
7073 */ 7145 */
7074 Library _coreLibrary; 7146 Library _coreLibrary;
7075 7147
7076 /** 7148 /**
7077 * The object used to access the types from the core library. 7149 * The object used to access the types from the core library.
7078 */ 7150 */
7079 TypeProvider _typeProvider; 7151 TypeProvider _typeProvider;
7080 7152
7081 /** 7153 /**
7082 * A table mapping library sources to the information being maintained for tho se libraries. 7154 * A table mapping library sources to the information being maintained for tho se libraries.
7083 */ 7155 */
7084 Map<Source, Library> _libraryMap = new Map<Source, Library>(); 7156 Map<Source, Library> _libraryMap = new Map<Source, Library>();
7085 7157
7086 /** 7158 /**
7087 * A collection containing the libraries that are being resolved together. 7159 * A collection containing the libraries that are being resolved together.
7088 */ 7160 */
7089 Set<Library> resolvedLibraries; 7161 Set<Library> _librariesInCycles;
7090 7162
7091 /** 7163 /**
7092 * Initialize a newly created library resolver to resolve libraries within the given context. 7164 * Initialize a newly created library resolver to resolve libraries within the given context.
7093 * 7165 *
7094 * @param analysisContext the analysis context in which the library is being a nalyzed 7166 * @param analysisContext the analysis context in which the library is being a nalyzed
7095 */ 7167 */
7096 LibraryResolver(InternalAnalysisContext analysisContext) { 7168 LibraryResolver(this.analysisContext) {
7097 this.analysisContext = analysisContext; 7169 this._errorListener = new RecordingErrorListener();
7098 this.errorListener = new RecordingErrorListener();
7099 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ; 7170 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ;
7100 } 7171 }
7101 7172
7102 /** 7173 /**
7174 * Return the listener to which analysis errors will be reported.
7175 *
7176 * @return the listener to which analysis errors will be reported
7177 */
7178 RecordingErrorListener get errorListener => _errorListener;
7179
7180 /**
7181 * Return an array containing information about all of the libraries that were resolved.
7182 *
7183 * @return an array containing the libraries that were resolved
7184 */
7185 Set<Library> get resolvedLibraries => _librariesInCycles;
7186
7187 /**
7103 * Resolve the library specified by the given source in the given context. The library is assumed 7188 * Resolve the library specified by the given source in the given context. The library is assumed
7104 * to be embedded in the given source. 7189 * to be embedded in the given source.
7105 * 7190 *
7106 * @param librarySource the source specifying the defining compilation unit of the library to be 7191 * @param librarySource the source specifying the defining compilation unit of the library to be
7107 * resolved 7192 * resolved
7108 * @param modificationStamp the time stamp of the source from which the compil ation unit was 7193 * @param modificationStamp the time stamp of the source from which the compil ation unit was
7109 * created 7194 * created
7110 * @param unit the compilation unit representing the embedded library 7195 * @param unit the compilation unit representing the embedded library
7111 * @param fullAnalysis `true` if a full analysis should be performed 7196 * @param fullAnalysis `true` if a full analysis should be performed
7112 * @return the element representing the resolved library 7197 * @return the element representing the resolved library
7113 * @throws AnalysisException if the library could not be resolved for some rea son 7198 * @throws AnalysisException if the library could not be resolved for some rea son
7114 */ 7199 */
7115 LibraryElement resolveEmbeddedLibrary(Source librarySource, int modificationSt amp, CompilationUnit unit, bool fullAnalysis) { 7200 LibraryElement resolveEmbeddedLibrary(Source librarySource, int modificationSt amp, CompilationUnit unit, bool fullAnalysis) {
7116 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.LibraryResolver.resolveEmbeddedLibrary"); 7201 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.LibraryResolver.resolveEmbeddedLibrary");
7117 try { 7202 try {
7118 instrumentation.metric("fullAnalysis", fullAnalysis); 7203 instrumentation.metric("fullAnalysis", fullAnalysis);
7119 instrumentation.data3("fullName", librarySource.fullName); 7204 instrumentation.data3("fullName", librarySource.fullName);
7120 Library targetLibrary = createLibrary2(librarySource, modificationStamp, u nit); 7205 Library targetLibrary = createLibrary2(librarySource, modificationStamp, u nit);
7121 _coreLibrary = _libraryMap[_coreLibrarySource]; 7206 _coreLibrary = _libraryMap[_coreLibrarySource];
7122 if (_coreLibrary == null) { 7207 if (_coreLibrary == null) {
7123 _coreLibrary = createLibrary(_coreLibrarySource); 7208 _coreLibrary = createLibrary(_coreLibrarySource);
7124 } 7209 }
7125 instrumentation.metric3("createLibrary", "complete"); 7210 instrumentation.metric3("createLibrary", "complete");
7126 computeLibraryDependencies2(targetLibrary, unit); 7211 computeLibraryDependencies2(targetLibrary, unit);
7127 resolvedLibraries = computeLibrariesInCycles(targetLibrary); 7212 _librariesInCycles = computeLibrariesInCycles(targetLibrary);
7128 buildElementModels(); 7213 buildElementModels();
7129 instrumentation.metric3("buildElementModels", "complete"); 7214 instrumentation.metric3("buildElementModels", "complete");
7130 LibraryElement coreElement = _coreLibrary.libraryElement; 7215 LibraryElement coreElement = _coreLibrary.libraryElement;
7131 if (coreElement == null) { 7216 if (coreElement == null) {
7132 throw new AnalysisException.con1("Could not resolve dart:core"); 7217 throw new AnalysisException.con1("Could not resolve dart:core");
7133 } 7218 }
7134 buildDirectiveModels(); 7219 buildDirectiveModels();
7135 instrumentation.metric3("buildDirectiveModels", "complete"); 7220 instrumentation.metric3("buildDirectiveModels", "complete");
7136 _typeProvider = new TypeProviderImpl(coreElement); 7221 _typeProvider = new TypeProviderImpl(coreElement);
7137 buildTypeHierarchies(); 7222 buildTypeHierarchies();
(...skipping 29 matching lines...) Expand all
7167 Library targetLibrary = createLibrary(librarySource); 7252 Library targetLibrary = createLibrary(librarySource);
7168 _coreLibrary = _libraryMap[_coreLibrarySource]; 7253 _coreLibrary = _libraryMap[_coreLibrarySource];
7169 if (_coreLibrary == null) { 7254 if (_coreLibrary == null) {
7170 _coreLibrary = createLibraryOrNull(_coreLibrarySource); 7255 _coreLibrary = createLibraryOrNull(_coreLibrarySource);
7171 if (_coreLibrary == null) { 7256 if (_coreLibrary == null) {
7172 throw new AnalysisException.con1("Core library does not exist"); 7257 throw new AnalysisException.con1("Core library does not exist");
7173 } 7258 }
7174 } 7259 }
7175 instrumentation.metric3("createLibrary", "complete"); 7260 instrumentation.metric3("createLibrary", "complete");
7176 computeLibraryDependencies(targetLibrary); 7261 computeLibraryDependencies(targetLibrary);
7177 resolvedLibraries = computeLibrariesInCycles(targetLibrary); 7262 _librariesInCycles = computeLibrariesInCycles(targetLibrary);
7178 buildElementModels(); 7263 buildElementModels();
7179 instrumentation.metric3("buildElementModels", "complete"); 7264 instrumentation.metric3("buildElementModels", "complete");
7180 LibraryElement coreElement = _coreLibrary.libraryElement; 7265 LibraryElement coreElement = _coreLibrary.libraryElement;
7181 if (coreElement == null) { 7266 if (coreElement == null) {
7182 throw new AnalysisException.con1("Could not resolve dart:core"); 7267 throw new AnalysisException.con1("Could not resolve dart:core");
7183 } 7268 }
7184 buildDirectiveModels(); 7269 buildDirectiveModels();
7185 instrumentation.metric3("buildDirectiveModels", "complete"); 7270 instrumentation.metric3("buildDirectiveModels", "complete");
7186 _typeProvider = new TypeProviderImpl(coreElement); 7271 _typeProvider = new TypeProviderImpl(coreElement);
7187 buildTypeHierarchies(); 7272 buildTypeHierarchies();
7188 instrumentation.metric3("buildTypeHierarchies", "complete"); 7273 instrumentation.metric3("buildTypeHierarchies", "complete");
7189 resolveReferencesAndTypes(); 7274 resolveReferencesAndTypes();
7190 instrumentation.metric3("resolveReferencesAndTypes", "complete"); 7275 instrumentation.metric3("resolveReferencesAndTypes", "complete");
7191 performConstantEvaluation(); 7276 performConstantEvaluation();
7192 instrumentation.metric3("performConstantEvaluation", "complete"); 7277 instrumentation.metric3("performConstantEvaluation", "complete");
7193 instrumentation.metric2("librariesInCycles", resolvedLibraries.length); 7278 instrumentation.metric2("librariesInCycles", _librariesInCycles.length);
7194 for (Library lib in resolvedLibraries) { 7279 for (Library lib in _librariesInCycles) {
7195 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size", lib.compilationUnitSources.length); 7280 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size", lib.compilationUnitSources.length);
7196 } 7281 }
7197 return targetLibrary.libraryElement; 7282 return targetLibrary.libraryElement;
7198 } finally { 7283 } finally {
7199 instrumentation.log(); 7284 instrumentation.log();
7200 } 7285 }
7201 } 7286 }
7202 7287
7203 /** 7288 /**
7204 * Add a dependency to the given map from the referencing library to the refer enced library. 7289 * Add a dependency to the given map from the referencing library to the refer enced library.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
7283 } 7368 }
7284 7369
7285 /** 7370 /**
7286 * Every library now has a corresponding [LibraryElement], so it is now possib le to resolve 7371 * Every library now has a corresponding [LibraryElement], so it is now possib le to resolve
7287 * the import and export directives. 7372 * the import and export directives.
7288 * 7373 *
7289 * @throws AnalysisException if the defining compilation unit for any of the l ibraries could not 7374 * @throws AnalysisException if the defining compilation unit for any of the l ibraries could not
7290 * be accessed 7375 * be accessed
7291 */ 7376 */
7292 void buildDirectiveModels() { 7377 void buildDirectiveModels() {
7293 for (Library library in resolvedLibraries) { 7378 for (Library library in _librariesInCycles) {
7294 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>(); 7379 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>();
7295 List<ImportElement> imports = new List<ImportElement>(); 7380 List<ImportElement> imports = new List<ImportElement>();
7296 List<ExportElement> exports = new List<ExportElement>(); 7381 List<ExportElement> exports = new List<ExportElement>();
7297 for (Directive directive in library.definingCompilationUnit.directives) { 7382 for (Directive directive in library.definingCompilationUnit.directives) {
7298 if (directive is ImportDirective) { 7383 if (directive is ImportDirective) {
7299 ImportDirective importDirective = directive as ImportDirective; 7384 ImportDirective importDirective = directive as ImportDirective;
7300 Source importedSource = library.getSource(importDirective); 7385 Source importedSource = library.getSource(importDirective);
7301 if (importedSource != null) { 7386 if (importedSource != null) {
7302 Library importedLibrary = _libraryMap[importedSource]; 7387 Library importedLibrary = _libraryMap[importedSource];
7303 if (importedLibrary != null) { 7388 if (importedLibrary != null) {
(...skipping 17 matching lines...) Expand all
7321 if (prefix == null) { 7406 if (prefix == null) {
7322 prefix = new PrefixElementImpl(prefixNode); 7407 prefix = new PrefixElementImpl(prefixNode);
7323 nameToPrefixMap[prefixName] = prefix; 7408 nameToPrefixMap[prefixName] = prefix;
7324 } 7409 }
7325 importElement.prefix = prefix; 7410 importElement.prefix = prefix;
7326 prefixNode.staticElement = prefix; 7411 prefixNode.staticElement = prefix;
7327 } 7412 }
7328 directive.element = importElement; 7413 directive.element = importElement;
7329 imports.add(importElement); 7414 imports.add(importElement);
7330 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) { 7415 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) {
7331 errorListener.onError(new AnalysisError.con2(library.librarySour ce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LIB RARY, [uriLiteral.toSource()])); 7416 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
7332 } 7417 }
7333 } 7418 }
7334 } 7419 }
7335 } else if (directive is ExportDirective) { 7420 } else if (directive is ExportDirective) {
7336 ExportDirective exportDirective = directive as ExportDirective; 7421 ExportDirective exportDirective = directive as ExportDirective;
7337 Source exportedSource = library.getSource(exportDirective); 7422 Source exportedSource = library.getSource(exportDirective);
7338 if (exportedSource != null) { 7423 if (exportedSource != null) {
7339 Library exportedLibrary = _libraryMap[exportedSource]; 7424 Library exportedLibrary = _libraryMap[exportedSource];
7340 if (exportedLibrary != null) { 7425 if (exportedLibrary != null) {
7341 ExportElementImpl exportElement = new ExportElementImpl(); 7426 ExportElementImpl exportElement = new ExportElementImpl();
7342 exportElement.uri = library.getUri(exportDirective); 7427 exportElement.uri = library.getUri(exportDirective);
7343 exportElement.combinators = buildCombinators(exportDirective); 7428 exportElement.combinators = buildCombinators(exportDirective);
7344 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment; 7429 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment;
7345 if (exportedLibraryElement != null) { 7430 if (exportedLibraryElement != null) {
7346 exportElement.exportedLibrary = exportedLibraryElement; 7431 exportElement.exportedLibrary = exportedLibraryElement;
7347 } 7432 }
7348 directive.element = exportElement; 7433 directive.element = exportElement;
7349 exports.add(exportElement); 7434 exports.add(exportElement);
7350 if (analysisContext.computeKindOf(exportedSource) != SourceKind.LI BRARY) { 7435 if (analysisContext.computeKindOf(exportedSource) != SourceKind.LI BRARY) {
7351 StringLiteral uriLiteral = exportDirective.uri; 7436 StringLiteral uriLiteral = exportDirective.uri;
7352 errorListener.onError(new AnalysisError.con2(library.librarySour ce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LIB RARY, [uriLiteral.toSource()])); 7437 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
7353 } 7438 }
7354 } 7439 }
7355 } 7440 }
7356 } 7441 }
7357 } 7442 }
7358 Source librarySource = library.librarySource; 7443 Source librarySource = library.librarySource;
7359 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource) { 7444 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource) {
7360 ImportElementImpl importElement = new ImportElementImpl(); 7445 ImportElementImpl importElement = new ImportElementImpl();
7361 importElement.importedLibrary = _coreLibrary.libraryElement; 7446 importElement.importedLibrary = _coreLibrary.libraryElement;
7362 importElement.synthetic = true; 7447 importElement.synthetic = true;
7363 imports.add(importElement); 7448 imports.add(importElement);
7364 } 7449 }
7365 LibraryElementImpl libraryElement = library.libraryElement; 7450 LibraryElementImpl libraryElement = library.libraryElement;
7366 libraryElement.imports = new List.from(imports); 7451 libraryElement.imports = new List.from(imports);
7367 libraryElement.exports = new List.from(exports); 7452 libraryElement.exports = new List.from(exports);
7368 } 7453 }
7369 } 7454 }
7370 7455
7371 /** 7456 /**
7372 * Build element models for all of the libraries in the current cycle. 7457 * Build element models for all of the libraries in the current cycle.
7373 * 7458 *
7374 * @throws AnalysisException if any of the element models cannot be built 7459 * @throws AnalysisException if any of the element models cannot be built
7375 */ 7460 */
7376 void buildElementModels() { 7461 void buildElementModels() {
7377 for (Library library in resolvedLibraries) { 7462 for (Library library in _librariesInCycles) {
7378 LibraryElementBuilder builder = new LibraryElementBuilder(this); 7463 LibraryElementBuilder builder = new LibraryElementBuilder(this);
7379 LibraryElementImpl libraryElement = builder.buildLibrary(library); 7464 LibraryElementImpl libraryElement = builder.buildLibrary(library);
7380 library.libraryElement = libraryElement; 7465 library.libraryElement = libraryElement;
7381 } 7466 }
7382 } 7467 }
7383 7468
7384 /** 7469 /**
7385 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 7470 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
7386 * cycle. 7471 * cycle.
7387 * 7472 *
7388 * @throws AnalysisException if any of the type hierarchies could not be resol ved 7473 * @throws AnalysisException if any of the type hierarchies could not be resol ved
7389 */ 7474 */
7390 void buildTypeHierarchies() { 7475 void buildTypeHierarchies() {
7391 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 7476 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
7392 try { 7477 try {
7393 for (Library library in resolvedLibraries) { 7478 for (Library library in _librariesInCycles) {
7394 for (Source source in library.compilationUnitSources) { 7479 for (Source source in library.compilationUnitSources) {
7395 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(library, so urce, _typeProvider); 7480 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(library, so urce, _typeProvider);
7396 library.getAST(source).accept(visitor); 7481 library.getAST(source).accept(visitor);
7397 } 7482 }
7398 } 7483 }
7399 } finally { 7484 } finally {
7400 timeCounter.stop(); 7485 timeCounter.stop();
7401 } 7486 }
7402 } 7487 }
7403 7488
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
7528 7613
7529 /** 7614 /**
7530 * Create an object to represent the information about the library defined by the compilation unit 7615 * Create an object to represent the information about the library defined by the compilation unit
7531 * with the given source. 7616 * with the given source.
7532 * 7617 *
7533 * @param librarySource the source of the library's defining compilation unit 7618 * @param librarySource the source of the library's defining compilation unit
7534 * @return the library object that was created 7619 * @return the library object that was created
7535 * @throws AnalysisException if the library source is not valid 7620 * @throws AnalysisException if the library source is not valid
7536 */ 7621 */
7537 Library createLibrary(Source librarySource) { 7622 Library createLibrary(Source librarySource) {
7538 Library library = new Library(analysisContext, errorListener, librarySource) ; 7623 Library library = new Library(analysisContext, _errorListener, librarySource );
7539 library.definingCompilationUnit; 7624 library.definingCompilationUnit;
7540 _libraryMap[librarySource] = library; 7625 _libraryMap[librarySource] = library;
7541 return library; 7626 return library;
7542 } 7627 }
7543 7628
7544 /** 7629 /**
7545 * Create an object to represent the information about the library defined by the compilation unit 7630 * Create an object to represent the information about the library defined by the compilation unit
7546 * with the given source. 7631 * with the given source.
7547 * 7632 *
7548 * @param librarySource the source of the library's defining compilation unit 7633 * @param librarySource the source of the library's defining compilation unit
7549 * @param modificationStamp the modification time of the source from which the compilation unit 7634 * @param modificationStamp the modification time of the source from which the compilation unit
7550 * was created 7635 * was created
7551 * @param unit the compilation unit that defines the library 7636 * @param unit the compilation unit that defines the library
7552 * @return the library object that was created 7637 * @return the library object that was created
7553 * @throws AnalysisException if the library source is not valid 7638 * @throws AnalysisException if the library source is not valid
7554 */ 7639 */
7555 Library createLibrary2(Source librarySource, int modificationStamp, Compilatio nUnit unit) { 7640 Library createLibrary2(Source librarySource, int modificationStamp, Compilatio nUnit unit) {
7556 Library library = new Library(analysisContext, errorListener, librarySource) ; 7641 Library library = new Library(analysisContext, _errorListener, librarySource );
7557 library.setDefiningCompilationUnit(modificationStamp, unit); 7642 library.setDefiningCompilationUnit(modificationStamp, unit);
7558 _libraryMap[librarySource] = library; 7643 _libraryMap[librarySource] = library;
7559 return library; 7644 return library;
7560 } 7645 }
7561 7646
7562 /** 7647 /**
7563 * Create an object to represent the information about the library defined by the compilation unit 7648 * Create an object to represent the information about the library defined by the compilation unit
7564 * with the given source. Return the library object that was created, or `null ` if the 7649 * with the given source. Return the library object that was created, or `null ` if the
7565 * source is not valid. 7650 * source is not valid.
7566 * 7651 *
7567 * @param librarySource the source of the library's defining compilation unit 7652 * @param librarySource the source of the library's defining compilation unit
7568 * @return the library object that was created 7653 * @return the library object that was created
7569 */ 7654 */
7570 Library createLibraryOrNull(Source librarySource) { 7655 Library createLibraryOrNull(Source librarySource) {
7571 if (!librarySource.exists()) { 7656 if (!librarySource.exists()) {
7572 return null; 7657 return null;
7573 } 7658 }
7574 Library library = new Library(analysisContext, errorListener, librarySource) ; 7659 Library library = new Library(analysisContext, _errorListener, librarySource );
7575 _libraryMap[librarySource] = library; 7660 _libraryMap[librarySource] = library;
7576 return library; 7661 return library;
7577 } 7662 }
7578 7663
7579 /** 7664 /**
7580 * Return an array containing the lexical identifiers associated with the node s in the given list. 7665 * Return an array containing the lexical identifiers associated with the node s in the given list.
7581 * 7666 *
7582 * @param names the AST nodes representing the identifiers 7667 * @param names the AST nodes representing the identifiers
7583 * @return the lexical identifiers associated with the nodes in the list 7668 * @return the lexical identifiers associated with the nodes in the list
7584 */ 7669 */
7585 List<String> getIdentifiers(NodeList<SimpleIdentifier> names) { 7670 List<String> getIdentifiers(NodeList<SimpleIdentifier> names) {
7586 int count = names.length; 7671 int count = names.length;
7587 List<String> identifiers = new List<String>(count); 7672 List<String> identifiers = new List<String>(count);
7588 for (int i = 0; i < count; i++) { 7673 for (int i = 0; i < count; i++) {
7589 identifiers[i] = names[i].name; 7674 identifiers[i] = names[i].name;
7590 } 7675 }
7591 return identifiers; 7676 return identifiers;
7592 } 7677 }
7593 7678
7594 /** 7679 /**
7595 * Compute a value for all of the constants in the libraries being analyzed. 7680 * Compute a value for all of the constants in the libraries being analyzed.
7596 */ 7681 */
7597 void performConstantEvaluation() { 7682 void performConstantEvaluation() {
7598 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 7683 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
7599 try { 7684 try {
7600 ConstantValueComputer computer = new ConstantValueComputer(); 7685 ConstantValueComputer computer = new ConstantValueComputer();
7601 for (Library library in resolvedLibraries) { 7686 for (Library library in _librariesInCycles) {
7602 for (Source source in library.compilationUnitSources) { 7687 for (Source source in library.compilationUnitSources) {
7603 try { 7688 try {
7604 CompilationUnit unit = library.getAST(source); 7689 CompilationUnit unit = library.getAST(source);
7605 if (unit != null) { 7690 if (unit != null) {
7606 computer.add(unit); 7691 computer.add(unit);
7607 } 7692 }
7608 } on AnalysisException catch (exception) { 7693 } on AnalysisException catch (exception) {
7609 AnalysisEngine.instance.logger.logError2("Internal Error: Could not access AST for ${source.fullName} during constant evaluation", exception); 7694 AnalysisEngine.instance.logger.logError2("Internal Error: Could not access AST for ${source.fullName} during constant evaluation", exception);
7610 } 7695 }
7611 } 7696 }
7612 } 7697 }
7613 computer.computeValues(); 7698 computer.computeValues();
7614 } finally { 7699 } finally {
7615 timeCounter.stop(); 7700 timeCounter.stop();
7616 } 7701 }
7617 } 7702 }
7618 7703
7619 /** 7704 /**
7620 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle. 7705 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle.
7621 * 7706 *
7622 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the 7707 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the
7623 * libraries could not have their types analyzed 7708 * libraries could not have their types analyzed
7624 */ 7709 */
7625 void resolveReferencesAndTypes() { 7710 void resolveReferencesAndTypes() {
7626 for (Library library in resolvedLibraries) { 7711 for (Library library in _librariesInCycles) {
7627 resolveReferencesAndTypes2(library); 7712 resolveReferencesAndTypes2(library);
7628 } 7713 }
7629 } 7714 }
7630 7715
7631 /** 7716 /**
7632 * Resolve the identifiers and perform type analysis in the given library. 7717 * Resolve the identifiers and perform type analysis in the given library.
7633 * 7718 *
7634 * @param library the library to be resolved 7719 * @param library the library to be resolved
7635 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 7720 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
7636 * the library cannot be analyzed 7721 * the library cannot be analyzed
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
7677 } 7762 }
7678 7763
7679 /** 7764 /**
7680 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as 7765 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as
7681 * performant as this class. 7766 * performant as this class.
7682 */ 7767 */
7683 class MemberMap { 7768 class MemberMap {
7684 /** 7769 /**
7685 * The current size of this map. 7770 * The current size of this map.
7686 */ 7771 */
7687 int size = 0; 7772 int _size = 0;
7688 7773
7689 /** 7774 /**
7690 * The array of keys. 7775 * The array of keys.
7691 */ 7776 */
7692 List<String> _keys; 7777 List<String> _keys;
7693 7778
7694 /** 7779 /**
7695 * The array of ExecutableElement values. 7780 * The array of ExecutableElement values.
7696 */ 7781 */
7697 List<ExecutableElement> _values; 7782 List<ExecutableElement> _values;
7698 7783
7699 /** 7784 /**
7700 * Default constructor. 7785 * Default constructor.
7701 */ 7786 */
7702 MemberMap() : this.con1(10); 7787 MemberMap() : this.con1(10);
7703 7788
7704 /** 7789 /**
7705 * This constructor takes an initial capacity of the map. 7790 * This constructor takes an initial capacity of the map.
7706 * 7791 *
7707 * @param initialCapacity the initial capacity 7792 * @param initialCapacity the initial capacity
7708 */ 7793 */
7709 MemberMap.con1(int initialCapacity) { 7794 MemberMap.con1(int initialCapacity) {
7710 initArrays(initialCapacity); 7795 initArrays(initialCapacity);
7711 } 7796 }
7712 7797
7713 /** 7798 /**
7714 * Copy constructor. 7799 * Copy constructor.
7715 */ 7800 */
7716 MemberMap.con2(MemberMap memberMap) { 7801 MemberMap.con2(MemberMap memberMap) {
7717 initArrays(memberMap.size + 5); 7802 initArrays(memberMap._size + 5);
7718 for (int i = 0; i < memberMap.size; i++) { 7803 for (int i = 0; i < memberMap._size; i++) {
7719 _keys[i] = memberMap._keys[i]; 7804 _keys[i] = memberMap._keys[i];
7720 _values[i] = memberMap._values[i]; 7805 _values[i] = memberMap._values[i];
7721 } 7806 }
7722 size = memberMap.size; 7807 _size = memberMap._size;
7723 } 7808 }
7724 7809
7725 /** 7810 /**
7726 * Given some key, return the ExecutableElement value from the map, if the key does not exist in 7811 * Given some key, return the ExecutableElement value from the map, if the key does not exist in
7727 * the map, `null` is returned. 7812 * the map, `null` is returned.
7728 * 7813 *
7729 * @param key some key to look up in the map 7814 * @param key some key to look up in the map
7730 * @return the associated ExecutableElement value from the map, if the key doe s not exist in the 7815 * @return the associated ExecutableElement value from the map, if the key doe s not exist in the
7731 * map, `null` is returned 7816 * map, `null` is returned
7732 */ 7817 */
7733 ExecutableElement get(String key) { 7818 ExecutableElement get(String key) {
7734 for (int i = 0; i < size; i++) { 7819 for (int i = 0; i < _size; i++) {
7735 if (_keys[i] != null && _keys[i] == key) { 7820 if (_keys[i] != null && _keys[i] == key) {
7736 return _values[i]; 7821 return _values[i];
7737 } 7822 }
7738 } 7823 }
7739 return null; 7824 return null;
7740 } 7825 }
7741 7826
7742 /** 7827 /**
7743 * Get and return the key at the specified location. If the key/value pair has been removed from 7828 * Get and return the key at the specified location. If the key/value pair has been removed from
7744 * the set, then `null` is returned. 7829 * the set, then `null` is returned.
7745 * 7830 *
7746 * @param i some non-zero value less than size 7831 * @param i some non-zero value less than size
7747 * @return the key at the passed index 7832 * @return the key at the passed index
7748 * @throw ArrayIndexOutOfBoundsException this exception is thrown if the passe d index is less than 7833 * @throw ArrayIndexOutOfBoundsException this exception is thrown if the passe d index is less than
7749 * zero or greater than or equal to the capacity of the arrays 7834 * zero or greater than or equal to the capacity of the arrays
7750 */ 7835 */
7751 String getKey(int i) => _keys[i]; 7836 String getKey(int i) => _keys[i];
7752 7837
7753 /** 7838 /**
7839 * The size of the map.
7840 *
7841 * @return the size of the map.
7842 */
7843 int get size => _size;
7844
7845 /**
7754 * Get and return the ExecutableElement at the specified location. If the key/ value pair has been 7846 * Get and return the ExecutableElement at the specified location. If the key/ value pair has been
7755 * removed from the set, then then `null` is returned. 7847 * removed from the set, then then `null` is returned.
7756 * 7848 *
7757 * @param i some non-zero value less than size 7849 * @param i some non-zero value less than size
7758 * @return the key at the passed index 7850 * @return the key at the passed index
7759 * @throw ArrayIndexOutOfBoundsException this exception is thrown if the passe d index is less than 7851 * @throw ArrayIndexOutOfBoundsException this exception is thrown if the passe d index is less than
7760 * zero or greater than or equal to the capacity of the arrays 7852 * zero or greater than or equal to the capacity of the arrays
7761 */ 7853 */
7762 ExecutableElement getValue(int i) => _values[i]; 7854 ExecutableElement getValue(int i) => _values[i];
7763 7855
7764 /** 7856 /**
7765 * Given some key/value pair, store the pair in the map. If the key exists alr eady, then the new 7857 * Given some key/value pair, store the pair in the map. If the key exists alr eady, then the new
7766 * value overrides the old value. 7858 * value overrides the old value.
7767 * 7859 *
7768 * @param key the key to store in the map 7860 * @param key the key to store in the map
7769 * @param value the ExecutableElement value to store in the map 7861 * @param value the ExecutableElement value to store in the map
7770 */ 7862 */
7771 void put(String key, ExecutableElement value) { 7863 void put(String key, ExecutableElement value) {
7772 for (int i = 0; i < size; i++) { 7864 for (int i = 0; i < _size; i++) {
7773 if (_keys[i] != null && _keys[i] == key) { 7865 if (_keys[i] != null && _keys[i] == key) {
7774 _values[i] = value; 7866 _values[i] = value;
7775 return; 7867 return;
7776 } 7868 }
7777 } 7869 }
7778 if (size == _keys.length) { 7870 if (_size == _keys.length) {
7779 int newArrayLength = size * 2; 7871 int newArrayLength = _size * 2;
7780 List<String> keys_new_array = new List<String>(newArrayLength); 7872 List<String> keys_new_array = new List<String>(newArrayLength);
7781 List<ExecutableElement> values_new_array = new List<ExecutableElement>(new ArrayLength); 7873 List<ExecutableElement> values_new_array = new List<ExecutableElement>(new ArrayLength);
7782 for (int i = 0; i < size; i++) { 7874 for (int i = 0; i < _size; i++) {
7783 keys_new_array[i] = _keys[i]; 7875 keys_new_array[i] = _keys[i];
7784 } 7876 }
7785 for (int i = 0; i < size; i++) { 7877 for (int i = 0; i < _size; i++) {
7786 values_new_array[i] = _values[i]; 7878 values_new_array[i] = _values[i];
7787 } 7879 }
7788 _keys = keys_new_array; 7880 _keys = keys_new_array;
7789 _values = values_new_array; 7881 _values = values_new_array;
7790 } 7882 }
7791 _keys[size] = key; 7883 _keys[_size] = key;
7792 _values[size] = value; 7884 _values[_size] = value;
7793 size++; 7885 _size++;
7794 } 7886 }
7795 7887
7796 /** 7888 /**
7797 * Given some String key, this method replaces the associated key and value pa ir with `null` 7889 * Given some String key, this method replaces the associated key and value pa ir with `null`
7798 * . The size is not decremented with this call, instead it is expected that t he users check for 7890 * . The size is not decremented with this call, instead it is expected that t he users check for
7799 * `null`. 7891 * `null`.
7800 * 7892 *
7801 * @param key the key of the key/value pair to remove from the map 7893 * @param key the key of the key/value pair to remove from the map
7802 */ 7894 */
7803 void remove(String key) { 7895 void remove(String key) {
7804 for (int i = 0; i < size; i++) { 7896 for (int i = 0; i < _size; i++) {
7805 if (_keys[i] == key) { 7897 if (_keys[i] == key) {
7806 _keys[i] = null; 7898 _keys[i] = null;
7807 _values[i] = null; 7899 _values[i] = null;
7808 return; 7900 return;
7809 } 7901 }
7810 } 7902 }
7811 } 7903 }
7812 7904
7813 /** 7905 /**
7814 * Sets the ExecutableElement at the specified location. 7906 * Sets the ExecutableElement at the specified location.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
7849 7941
7850 /** 7942 /**
7851 * The enclosing [ClassElement], this is what will determine if the error code should, or 7943 * The enclosing [ClassElement], this is what will determine if the error code should, or
7852 * should not, be generated on the source. 7944 * should not, be generated on the source.
7853 */ 7945 */
7854 Element _enclosingElement; 7946 Element _enclosingElement;
7855 7947
7856 /** 7948 /**
7857 * The conditional analysis error. 7949 * The conditional analysis error.
7858 */ 7950 */
7859 AnalysisError analysisError; 7951 final AnalysisError analysisError;
7860 7952
7861 /** 7953 /**
7862 * Instantiate a new ProxyConditionalErrorCode with some enclosing element and the conditional 7954 * Instantiate a new ProxyConditionalErrorCode with some enclosing element and the conditional
7863 * analysis error. 7955 * analysis error.
7864 * 7956 *
7865 * @param enclosingElement the enclosing element 7957 * @param enclosingElement the enclosing element
7866 * @param analysisError the conditional analysis error 7958 * @param analysisError the conditional analysis error
7867 */ 7959 */
7868 ProxyConditionalAnalysisError(Element enclosingElement, AnalysisError analysis Error) { 7960 ProxyConditionalAnalysisError(Element enclosingElement, this.analysisError) {
7869 this._enclosingElement = enclosingElement; 7961 this._enclosingElement = enclosingElement;
7870 this.analysisError = analysisError;
7871 } 7962 }
7872 7963
7873 /** 7964 /**
7874 * Return `true` iff the enclosing class has the proxy annotation. 7965 * Return `true` iff the enclosing class has the proxy annotation.
7875 * 7966 *
7876 * @return `true` iff the enclosing class has the proxy annotation 7967 * @return `true` iff the enclosing class has the proxy annotation
7877 */ 7968 */
7878 bool shouldIncludeErrorCode() => !classHasProxyAnnotation(_enclosingElement); 7969 bool shouldIncludeErrorCode() => !classHasProxyAnnotation(_enclosingElement);
7879 } 7970 }
7880 7971
(...skipping 16 matching lines...) Expand all
7897 7988
7898 /** 7989 /**
7899 * The object used to compute the type associated with the current node. 7990 * The object used to compute the type associated with the current node.
7900 */ 7991 */
7901 StaticTypeAnalyzer _typeAnalyzer; 7992 StaticTypeAnalyzer _typeAnalyzer;
7902 7993
7903 /** 7994 /**
7904 * The class element representing the class containing the current node, or `n ull` if the 7995 * The class element representing the class containing the current node, or `n ull` if the
7905 * current node is not contained in a class. 7996 * current node is not contained in a class.
7906 */ 7997 */
7907 ClassElement enclosingClass = null; 7998 ClassElement _enclosingClass = null;
7908 7999
7909 /** 8000 /**
7910 * The element representing the function containing the current node, or `null ` if the 8001 * The element representing the function containing the current node, or `null ` if the
7911 * current node is not contained in a function. 8002 * current node is not contained in a function.
7912 */ 8003 */
7913 ExecutableElement enclosingFunction = null; 8004 ExecutableElement _enclosingFunction = null;
7914 8005
7915 /** 8006 /**
7916 * The object keeping track of which elements have had their types overridden. 8007 * The object keeping track of which elements have had their types overridden.
7917 */ 8008 */
7918 final TypeOverrideManager overrideManager = new TypeOverrideManager(); 8009 TypeOverrideManager _overrideManager = new TypeOverrideManager();
7919 8010
7920 /** 8011 /**
7921 * The object keeping track of which elements have had their types promoted. 8012 * The object keeping track of which elements have had their types promoted.
7922 */ 8013 */
7923 final TypePromotionManager promoteManager = new TypePromotionManager(); 8014 TypePromotionManager _promoteManager = new TypePromotionManager();
7924 8015
7925 /** 8016 /**
7926 * Proxy conditional error codes. 8017 * Proxy conditional error codes.
7927 */ 8018 */
7928 final List<ProxyConditionalAnalysisError> proxyConditionalAnalysisErrors = new List<ProxyConditionalAnalysisError>(); 8019 List<ProxyConditionalAnalysisError> _proxyConditionalAnalysisErrors = new List <ProxyConditionalAnalysisError>();
7929 8020
7930 /** 8021 /**
7931 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 8022 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
7932 * 8023 *
7933 * @param library the library containing the compilation unit being resolved 8024 * @param library the library containing the compilation unit being resolved
7934 * @param source the source representing the compilation unit being visited 8025 * @param source the source representing the compilation unit being visited
7935 * @param typeProvider the object used to access the types from the core libra ry 8026 * @param typeProvider the object used to access the types from the core libra ry
7936 */ 8027 */
7937 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider ) : super.con1(library, source, typeProvider) { 8028 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider ) : super.con1(library, source, typeProvider) {
7938 this._inheritanceManager = library.inheritanceManager; 8029 this._inheritanceManager = library.inheritanceManager;
(...skipping 26 matching lines...) Expand all
7965 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited 8056 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited
7966 * @param errorListener the error listener that will be informed of any errors that are found 8057 * @param errorListener the error listener that will be informed of any errors that are found
7967 * during resolution 8058 * during resolution
7968 */ 8059 */
7969 ResolverVisitor.con3(LibraryElement definingLibrary, Source source, TypeProvid er typeProvider, Scope nameScope, AnalysisErrorListener errorListener) : super.c on3(definingLibrary, source, typeProvider, nameScope, errorListener) { 8060 ResolverVisitor.con3(LibraryElement definingLibrary, Source source, TypeProvid er typeProvider, Scope nameScope, AnalysisErrorListener errorListener) : super.c on3(definingLibrary, source, typeProvider, nameScope, errorListener) {
7970 this._inheritanceManager = new InheritanceManager(definingLibrary); 8061 this._inheritanceManager = new InheritanceManager(definingLibrary);
7971 this._elementResolver = new ElementResolver(this); 8062 this._elementResolver = new ElementResolver(this);
7972 this._typeAnalyzer = new StaticTypeAnalyzer(this); 8063 this._typeAnalyzer = new StaticTypeAnalyzer(this);
7973 } 8064 }
7974 8065
8066 /**
8067 * Return the object keeping track of which elements have had their types over ridden.
8068 *
8069 * @return the object keeping track of which elements have had their types ove rridden
8070 */
8071 TypeOverrideManager get overrideManager => _overrideManager;
8072
8073 /**
8074 * Return the object keeping track of which elements have had their types prom oted.
8075 *
8076 * @return the object keeping track of which elements have had their types pro moted
8077 */
8078 TypePromotionManager get promoteManager => _promoteManager;
8079
8080 List<ProxyConditionalAnalysisError> get proxyConditionalAnalysisErrors => _pro xyConditionalAnalysisErrors;
8081
7975 Object visitAsExpression(AsExpression node) { 8082 Object visitAsExpression(AsExpression node) {
7976 super.visitAsExpression(node); 8083 super.visitAsExpression(node);
7977 override(node.expression, node.type.type); 8084 override(node.expression, node.type.type);
7978 return null; 8085 return null;
7979 } 8086 }
7980 8087
7981 Object visitAssertStatement(AssertStatement node) { 8088 Object visitAssertStatement(AssertStatement node) {
7982 super.visitAssertStatement(node); 8089 super.visitAssertStatement(node);
7983 propagateTrueState(node.condition); 8090 propagateTrueState(node.condition);
7984 return null; 8091 return null;
7985 } 8092 }
7986 8093
7987 Object visitBinaryExpression(BinaryExpression node) { 8094 Object visitBinaryExpression(BinaryExpression node) {
7988 sc.TokenType operatorType = node.operator.type; 8095 sc.TokenType operatorType = node.operator.type;
7989 Expression leftOperand = node.leftOperand; 8096 Expression leftOperand = node.leftOperand;
7990 Expression rightOperand = node.rightOperand; 8097 Expression rightOperand = node.rightOperand;
7991 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { 8098 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) {
7992 safelyVisit(leftOperand); 8099 safelyVisit(leftOperand);
7993 if (rightOperand != null) { 8100 if (rightOperand != null) {
7994 try { 8101 try {
7995 overrideManager.enterScope(); 8102 _overrideManager.enterScope();
7996 promoteManager.enterScope(); 8103 _promoteManager.enterScope();
7997 propagateTrueState(leftOperand); 8104 propagateTrueState(leftOperand);
7998 promoteTypes(leftOperand); 8105 promoteTypes(leftOperand);
7999 clearTypePromotionsIfPotentiallyMutatedIn(leftOperand); 8106 clearTypePromotionsIfPotentiallyMutatedIn(leftOperand);
8000 clearTypePromotionsIfPotentiallyMutatedIn(rightOperand); 8107 clearTypePromotionsIfPotentiallyMutatedIn(rightOperand);
8001 clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(rightOper and); 8108 clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(rightOper and);
8002 rightOperand.accept(this); 8109 rightOperand.accept(this);
8003 } finally { 8110 } finally {
8004 overrideManager.exitScope(); 8111 _overrideManager.exitScope();
8005 promoteManager.exitScope(); 8112 _promoteManager.exitScope();
8006 } 8113 }
8007 } 8114 }
8008 } else if (identical(operatorType, sc.TokenType.BAR_BAR)) { 8115 } else if (identical(operatorType, sc.TokenType.BAR_BAR)) {
8009 safelyVisit(leftOperand); 8116 safelyVisit(leftOperand);
8010 if (rightOperand != null) { 8117 if (rightOperand != null) {
8011 try { 8118 try {
8012 overrideManager.enterScope(); 8119 _overrideManager.enterScope();
8013 propagateFalseState(leftOperand); 8120 propagateFalseState(leftOperand);
8014 rightOperand.accept(this); 8121 rightOperand.accept(this);
8015 } finally { 8122 } finally {
8016 overrideManager.exitScope(); 8123 _overrideManager.exitScope();
8017 } 8124 }
8018 } 8125 }
8019 } else { 8126 } else {
8020 safelyVisit(leftOperand); 8127 safelyVisit(leftOperand);
8021 safelyVisit(rightOperand); 8128 safelyVisit(rightOperand);
8022 } 8129 }
8023 node.accept(_elementResolver); 8130 node.accept(_elementResolver);
8024 node.accept(_typeAnalyzer); 8131 node.accept(_typeAnalyzer);
8025 return null; 8132 return null;
8026 } 8133 }
8027 8134
8028 Object visitBlockFunctionBody(BlockFunctionBody node) { 8135 Object visitBlockFunctionBody(BlockFunctionBody node) {
8029 try { 8136 try {
8030 overrideManager.enterScope(); 8137 _overrideManager.enterScope();
8031 super.visitBlockFunctionBody(node); 8138 super.visitBlockFunctionBody(node);
8032 } finally { 8139 } finally {
8033 overrideManager.exitScope(); 8140 _overrideManager.exitScope();
8034 } 8141 }
8035 return null; 8142 return null;
8036 } 8143 }
8037 8144
8038 Object visitBreakStatement(BreakStatement node) { 8145 Object visitBreakStatement(BreakStatement node) {
8039 node.accept(_elementResolver); 8146 node.accept(_elementResolver);
8040 node.accept(_typeAnalyzer); 8147 node.accept(_typeAnalyzer);
8041 return null; 8148 return null;
8042 } 8149 }
8043 8150
8044 Object visitClassDeclaration(ClassDeclaration node) { 8151 Object visitClassDeclaration(ClassDeclaration node) {
8045 ClassElement outerType = enclosingClass; 8152 ClassElement outerType = _enclosingClass;
8046 try { 8153 try {
8047 enclosingClass = node.element; 8154 _enclosingClass = node.element;
8048 _typeAnalyzer.thisType = enclosingClass == null ? null : enclosingClass.ty pe; 8155 _typeAnalyzer.thisType = _enclosingClass == null ? null : _enclosingClass. type;
8049 super.visitClassDeclaration(node); 8156 super.visitClassDeclaration(node);
8050 } finally { 8157 } finally {
8051 _typeAnalyzer.thisType = outerType == null ? null : outerType.type; 8158 _typeAnalyzer.thisType = outerType == null ? null : outerType.type;
8052 enclosingClass = outerType; 8159 _enclosingClass = outerType;
8053 } 8160 }
8054 return null; 8161 return null;
8055 } 8162 }
8056 8163
8057 Object visitCommentReference(CommentReference node) { 8164 Object visitCommentReference(CommentReference node) {
8058 node.accept(_elementResolver); 8165 node.accept(_elementResolver);
8059 node.accept(_typeAnalyzer); 8166 node.accept(_typeAnalyzer);
8060 return null; 8167 return null;
8061 } 8168 }
8062 8169
8063 Object visitCompilationUnit(CompilationUnit node) { 8170 Object visitCompilationUnit(CompilationUnit node) {
8064 try { 8171 try {
8065 overrideManager.enterScope(); 8172 _overrideManager.enterScope();
8066 NodeList<Directive> directives = node.directives; 8173 NodeList<Directive> directives = node.directives;
8067 int directiveCount = directives.length; 8174 int directiveCount = directives.length;
8068 for (int i = 0; i < directiveCount; i++) { 8175 for (int i = 0; i < directiveCount; i++) {
8069 directives[i].accept(this); 8176 directives[i].accept(this);
8070 } 8177 }
8071 NodeList<CompilationUnitMember> declarations = node.declarations; 8178 NodeList<CompilationUnitMember> declarations = node.declarations;
8072 int declarationCount = declarations.length; 8179 int declarationCount = declarations.length;
8073 for (int i = 0; i < declarationCount; i++) { 8180 for (int i = 0; i < declarationCount; i++) {
8074 CompilationUnitMember declaration = declarations[i]; 8181 CompilationUnitMember declaration = declarations[i];
8075 if (declaration is! ClassDeclaration) { 8182 if (declaration is! ClassDeclaration) {
8076 declaration.accept(this); 8183 declaration.accept(this);
8077 } 8184 }
8078 } 8185 }
8079 for (int i = 0; i < declarationCount; i++) { 8186 for (int i = 0; i < declarationCount; i++) {
8080 CompilationUnitMember declaration = declarations[i]; 8187 CompilationUnitMember declaration = declarations[i];
8081 if (declaration is ClassDeclaration) { 8188 if (declaration is ClassDeclaration) {
8082 declaration.accept(this); 8189 declaration.accept(this);
8083 } 8190 }
8084 } 8191 }
8085 } finally { 8192 } finally {
8086 overrideManager.exitScope(); 8193 _overrideManager.exitScope();
8087 } 8194 }
8088 node.accept(_elementResolver); 8195 node.accept(_elementResolver);
8089 node.accept(_typeAnalyzer); 8196 node.accept(_typeAnalyzer);
8090 return null; 8197 return null;
8091 } 8198 }
8092 8199
8093 Object visitConditionalExpression(ConditionalExpression node) { 8200 Object visitConditionalExpression(ConditionalExpression node) {
8094 Expression condition = node.condition; 8201 Expression condition = node.condition;
8095 safelyVisit(condition); 8202 safelyVisit(condition);
8096 Expression thenExpression = node.thenExpression; 8203 Expression thenExpression = node.thenExpression;
8097 if (thenExpression != null) { 8204 if (thenExpression != null) {
8098 try { 8205 try {
8099 overrideManager.enterScope(); 8206 _overrideManager.enterScope();
8100 promoteManager.enterScope(); 8207 _promoteManager.enterScope();
8101 propagateTrueState(condition); 8208 propagateTrueState(condition);
8102 promoteTypes(condition); 8209 promoteTypes(condition);
8103 clearTypePromotionsIfPotentiallyMutatedIn(thenExpression); 8210 clearTypePromotionsIfPotentiallyMutatedIn(thenExpression);
8104 clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenExpress ion); 8211 clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenExpress ion);
8105 thenExpression.accept(this); 8212 thenExpression.accept(this);
8106 } finally { 8213 } finally {
8107 overrideManager.exitScope(); 8214 _overrideManager.exitScope();
8108 promoteManager.exitScope(); 8215 _promoteManager.exitScope();
8109 } 8216 }
8110 } 8217 }
8111 Expression elseExpression = node.elseExpression; 8218 Expression elseExpression = node.elseExpression;
8112 if (elseExpression != null) { 8219 if (elseExpression != null) {
8113 try { 8220 try {
8114 overrideManager.enterScope(); 8221 _overrideManager.enterScope();
8115 propagateFalseState(condition); 8222 propagateFalseState(condition);
8116 elseExpression.accept(this); 8223 elseExpression.accept(this);
8117 } finally { 8224 } finally {
8118 overrideManager.exitScope(); 8225 _overrideManager.exitScope();
8119 } 8226 }
8120 } 8227 }
8121 node.accept(_elementResolver); 8228 node.accept(_elementResolver);
8122 node.accept(_typeAnalyzer); 8229 node.accept(_typeAnalyzer);
8123 bool thenIsAbrupt = isAbruptTermination(thenExpression); 8230 bool thenIsAbrupt = isAbruptTermination(thenExpression);
8124 bool elseIsAbrupt = isAbruptTermination(elseExpression); 8231 bool elseIsAbrupt = isAbruptTermination(elseExpression);
8125 if (elseIsAbrupt && !thenIsAbrupt) { 8232 if (elseIsAbrupt && !thenIsAbrupt) {
8126 propagateTrueState(condition); 8233 propagateTrueState(condition);
8127 propagateState(thenExpression); 8234 propagateState(thenExpression);
8128 } else if (thenIsAbrupt && !elseIsAbrupt) { 8235 } else if (thenIsAbrupt && !elseIsAbrupt) {
8129 propagateFalseState(condition); 8236 propagateFalseState(condition);
8130 propagateState(elseExpression); 8237 propagateState(elseExpression);
8131 } 8238 }
8132 return null; 8239 return null;
8133 } 8240 }
8134 8241
8135 Object visitConstructorDeclaration(ConstructorDeclaration node) { 8242 Object visitConstructorDeclaration(ConstructorDeclaration node) {
8136 ExecutableElement outerFunction = enclosingFunction; 8243 ExecutableElement outerFunction = _enclosingFunction;
8137 try { 8244 try {
8138 enclosingFunction = node.element; 8245 _enclosingFunction = node.element;
8139 super.visitConstructorDeclaration(node); 8246 super.visitConstructorDeclaration(node);
8140 } finally { 8247 } finally {
8141 enclosingFunction = outerFunction; 8248 _enclosingFunction = outerFunction;
8142 } 8249 }
8143 return null; 8250 return null;
8144 } 8251 }
8145 8252
8146 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { 8253 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
8147 safelyVisit(node.expression); 8254 safelyVisit(node.expression);
8148 node.accept(_elementResolver); 8255 node.accept(_elementResolver);
8149 node.accept(_typeAnalyzer); 8256 node.accept(_typeAnalyzer);
8150 return null; 8257 return null;
8151 } 8258 }
8152 8259
8153 Object visitConstructorName(ConstructorName node) { 8260 Object visitConstructorName(ConstructorName node) {
8154 node.accept(_elementResolver); 8261 node.accept(_elementResolver);
8155 node.accept(_typeAnalyzer); 8262 node.accept(_typeAnalyzer);
8156 return null; 8263 return null;
8157 } 8264 }
8158 8265
8159 Object visitContinueStatement(ContinueStatement node) { 8266 Object visitContinueStatement(ContinueStatement node) {
8160 node.accept(_elementResolver); 8267 node.accept(_elementResolver);
8161 node.accept(_typeAnalyzer); 8268 node.accept(_typeAnalyzer);
8162 return null; 8269 return null;
8163 } 8270 }
8164 8271
8165 Object visitDoStatement(DoStatement node) { 8272 Object visitDoStatement(DoStatement node) {
8166 try { 8273 try {
8167 overrideManager.enterScope(); 8274 _overrideManager.enterScope();
8168 super.visitDoStatement(node); 8275 super.visitDoStatement(node);
8169 } finally { 8276 } finally {
8170 overrideManager.exitScope(); 8277 _overrideManager.exitScope();
8171 } 8278 }
8172 return null; 8279 return null;
8173 } 8280 }
8174 8281
8175 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { 8282 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
8176 try { 8283 try {
8177 overrideManager.enterScope(); 8284 _overrideManager.enterScope();
8178 super.visitExpressionFunctionBody(node); 8285 super.visitExpressionFunctionBody(node);
8179 } finally { 8286 } finally {
8180 overrideManager.exitScope(); 8287 _overrideManager.exitScope();
8181 } 8288 }
8182 return null; 8289 return null;
8183 } 8290 }
8184 8291
8185 Object visitFieldDeclaration(FieldDeclaration node) { 8292 Object visitFieldDeclaration(FieldDeclaration node) {
8186 try { 8293 try {
8187 overrideManager.enterScope(); 8294 _overrideManager.enterScope();
8188 super.visitFieldDeclaration(node); 8295 super.visitFieldDeclaration(node);
8189 } finally { 8296 } finally {
8190 Map<Element, Type2> overrides = overrideManager.captureOverrides(node.fiel ds); 8297 Map<Element, Type2> overrides = _overrideManager.captureOverrides(node.fie lds);
8191 overrideManager.exitScope(); 8298 _overrideManager.exitScope();
8192 overrideManager.applyOverrides(overrides); 8299 _overrideManager.applyOverrides(overrides);
8193 } 8300 }
8194 return null; 8301 return null;
8195 } 8302 }
8196 8303
8197 Object visitForEachStatement(ForEachStatement node) { 8304 Object visitForEachStatement(ForEachStatement node) {
8198 try { 8305 try {
8199 overrideManager.enterScope(); 8306 _overrideManager.enterScope();
8200 super.visitForEachStatement(node); 8307 super.visitForEachStatement(node);
8201 } finally { 8308 } finally {
8202 overrideManager.exitScope(); 8309 _overrideManager.exitScope();
8203 } 8310 }
8204 return null; 8311 return null;
8205 } 8312 }
8206 8313
8207 Object visitForStatement(ForStatement node) { 8314 Object visitForStatement(ForStatement node) {
8208 try { 8315 try {
8209 overrideManager.enterScope(); 8316 _overrideManager.enterScope();
8210 super.visitForStatement(node); 8317 super.visitForStatement(node);
8211 } finally { 8318 } finally {
8212 overrideManager.exitScope(); 8319 _overrideManager.exitScope();
8213 } 8320 }
8214 return null; 8321 return null;
8215 } 8322 }
8216 8323
8217 Object visitFunctionDeclaration(FunctionDeclaration node) { 8324 Object visitFunctionDeclaration(FunctionDeclaration node) {
8218 ExecutableElement outerFunction = enclosingFunction; 8325 ExecutableElement outerFunction = _enclosingFunction;
8219 try { 8326 try {
8220 SimpleIdentifier functionName = node.name; 8327 SimpleIdentifier functionName = node.name;
8221 enclosingFunction = functionName.staticElement as ExecutableElement; 8328 _enclosingFunction = functionName.staticElement as ExecutableElement;
8222 super.visitFunctionDeclaration(node); 8329 super.visitFunctionDeclaration(node);
8223 } finally { 8330 } finally {
8224 enclosingFunction = outerFunction; 8331 _enclosingFunction = outerFunction;
8225 } 8332 }
8226 return null; 8333 return null;
8227 } 8334 }
8228 8335
8229 Object visitFunctionExpression(FunctionExpression node) { 8336 Object visitFunctionExpression(FunctionExpression node) {
8230 ExecutableElement outerFunction = enclosingFunction; 8337 ExecutableElement outerFunction = _enclosingFunction;
8231 try { 8338 try {
8232 enclosingFunction = node.element; 8339 _enclosingFunction = node.element;
8233 overrideManager.enterScope(); 8340 _overrideManager.enterScope();
8234 super.visitFunctionExpression(node); 8341 super.visitFunctionExpression(node);
8235 } finally { 8342 } finally {
8236 overrideManager.exitScope(); 8343 _overrideManager.exitScope();
8237 enclosingFunction = outerFunction; 8344 _enclosingFunction = outerFunction;
8238 } 8345 }
8239 return null; 8346 return null;
8240 } 8347 }
8241 8348
8242 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 8349 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
8243 safelyVisit(node.function); 8350 safelyVisit(node.function);
8244 node.accept(_elementResolver); 8351 node.accept(_elementResolver);
8245 inferFunctionExpressionsParametersTypes(node.argumentList); 8352 inferFunctionExpressionsParametersTypes(node.argumentList);
8246 safelyVisit(node.argumentList); 8353 safelyVisit(node.argumentList);
8247 node.accept(_typeAnalyzer); 8354 node.accept(_typeAnalyzer);
8248 return null; 8355 return null;
8249 } 8356 }
8250 8357
8251 Object visitHideCombinator(HideCombinator node) => null; 8358 Object visitHideCombinator(HideCombinator node) => null;
8252 8359
8253 Object visitIfStatement(IfStatement node) { 8360 Object visitIfStatement(IfStatement node) {
8254 Expression condition = node.condition; 8361 Expression condition = node.condition;
8255 safelyVisit(condition); 8362 safelyVisit(condition);
8256 Map<Element, Type2> thenOverrides = null; 8363 Map<Element, Type2> thenOverrides = null;
8257 Statement thenStatement = node.thenStatement; 8364 Statement thenStatement = node.thenStatement;
8258 if (thenStatement != null) { 8365 if (thenStatement != null) {
8259 try { 8366 try {
8260 overrideManager.enterScope(); 8367 _overrideManager.enterScope();
8261 promoteManager.enterScope(); 8368 _promoteManager.enterScope();
8262 propagateTrueState(condition); 8369 propagateTrueState(condition);
8263 promoteTypes(condition); 8370 promoteTypes(condition);
8264 clearTypePromotionsIfPotentiallyMutatedIn(thenStatement); 8371 clearTypePromotionsIfPotentiallyMutatedIn(thenStatement);
8265 clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenStateme nt); 8372 clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenStateme nt);
8266 visitStatementInScope(thenStatement); 8373 visitStatementInScope(thenStatement);
8267 } finally { 8374 } finally {
8268 thenOverrides = overrideManager.captureLocalOverrides(); 8375 thenOverrides = _overrideManager.captureLocalOverrides();
8269 overrideManager.exitScope(); 8376 _overrideManager.exitScope();
8270 promoteManager.exitScope(); 8377 _promoteManager.exitScope();
8271 } 8378 }
8272 } 8379 }
8273 Map<Element, Type2> elseOverrides = null; 8380 Map<Element, Type2> elseOverrides = null;
8274 Statement elseStatement = node.elseStatement; 8381 Statement elseStatement = node.elseStatement;
8275 if (elseStatement != null) { 8382 if (elseStatement != null) {
8276 try { 8383 try {
8277 overrideManager.enterScope(); 8384 _overrideManager.enterScope();
8278 propagateFalseState(condition); 8385 propagateFalseState(condition);
8279 visitStatementInScope(elseStatement); 8386 visitStatementInScope(elseStatement);
8280 } finally { 8387 } finally {
8281 elseOverrides = overrideManager.captureLocalOverrides(); 8388 elseOverrides = _overrideManager.captureLocalOverrides();
8282 overrideManager.exitScope(); 8389 _overrideManager.exitScope();
8283 } 8390 }
8284 } 8391 }
8285 node.accept(_elementResolver); 8392 node.accept(_elementResolver);
8286 node.accept(_typeAnalyzer); 8393 node.accept(_typeAnalyzer);
8287 bool thenIsAbrupt = isAbruptTermination2(thenStatement); 8394 bool thenIsAbrupt = isAbruptTermination2(thenStatement);
8288 bool elseIsAbrupt = isAbruptTermination2(elseStatement); 8395 bool elseIsAbrupt = isAbruptTermination2(elseStatement);
8289 if (elseIsAbrupt && !thenIsAbrupt) { 8396 if (elseIsAbrupt && !thenIsAbrupt) {
8290 propagateTrueState(condition); 8397 propagateTrueState(condition);
8291 if (thenOverrides != null) { 8398 if (thenOverrides != null) {
8292 overrideManager.applyOverrides(thenOverrides); 8399 _overrideManager.applyOverrides(thenOverrides);
8293 } 8400 }
8294 } else if (thenIsAbrupt && !elseIsAbrupt) { 8401 } else if (thenIsAbrupt && !elseIsAbrupt) {
8295 propagateFalseState(condition); 8402 propagateFalseState(condition);
8296 if (elseOverrides != null) { 8403 if (elseOverrides != null) {
8297 overrideManager.applyOverrides(elseOverrides); 8404 _overrideManager.applyOverrides(elseOverrides);
8298 } 8405 }
8299 } 8406 }
8300 return null; 8407 return null;
8301 } 8408 }
8302 8409
8303 Object visitLabel(Label node) => null; 8410 Object visitLabel(Label node) => null;
8304 8411
8305 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 8412 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
8306 8413
8307 Object visitMethodDeclaration(MethodDeclaration node) { 8414 Object visitMethodDeclaration(MethodDeclaration node) {
8308 ExecutableElement outerFunction = enclosingFunction; 8415 ExecutableElement outerFunction = _enclosingFunction;
8309 try { 8416 try {
8310 enclosingFunction = node.element; 8417 _enclosingFunction = node.element;
8311 super.visitMethodDeclaration(node); 8418 super.visitMethodDeclaration(node);
8312 } finally { 8419 } finally {
8313 enclosingFunction = outerFunction; 8420 _enclosingFunction = outerFunction;
8314 } 8421 }
8315 return null; 8422 return null;
8316 } 8423 }
8317 8424
8318 Object visitMethodInvocation(MethodInvocation node) { 8425 Object visitMethodInvocation(MethodInvocation node) {
8319 safelyVisit(node.target); 8426 safelyVisit(node.target);
8320 node.accept(_elementResolver); 8427 node.accept(_elementResolver);
8321 inferFunctionExpressionsParametersTypes(node.argumentList); 8428 inferFunctionExpressionsParametersTypes(node.argumentList);
8322 safelyVisit(node.argumentList); 8429 safelyVisit(node.argumentList);
8323 node.accept(_typeAnalyzer); 8430 node.accept(_typeAnalyzer);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8356 8463
8357 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 8464 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
8358 safelyVisit(node.argumentList); 8465 safelyVisit(node.argumentList);
8359 node.accept(_elementResolver); 8466 node.accept(_elementResolver);
8360 node.accept(_typeAnalyzer); 8467 node.accept(_typeAnalyzer);
8361 return null; 8468 return null;
8362 } 8469 }
8363 8470
8364 Object visitSwitchCase(SwitchCase node) { 8471 Object visitSwitchCase(SwitchCase node) {
8365 try { 8472 try {
8366 overrideManager.enterScope(); 8473 _overrideManager.enterScope();
8367 super.visitSwitchCase(node); 8474 super.visitSwitchCase(node);
8368 } finally { 8475 } finally {
8369 overrideManager.exitScope(); 8476 _overrideManager.exitScope();
8370 } 8477 }
8371 return null; 8478 return null;
8372 } 8479 }
8373 8480
8374 Object visitSwitchDefault(SwitchDefault node) { 8481 Object visitSwitchDefault(SwitchDefault node) {
8375 try { 8482 try {
8376 overrideManager.enterScope(); 8483 _overrideManager.enterScope();
8377 super.visitSwitchDefault(node); 8484 super.visitSwitchDefault(node);
8378 } finally { 8485 } finally {
8379 overrideManager.exitScope(); 8486 _overrideManager.exitScope();
8380 } 8487 }
8381 return null; 8488 return null;
8382 } 8489 }
8383 8490
8384 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 8491 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
8385 try { 8492 try {
8386 overrideManager.enterScope(); 8493 _overrideManager.enterScope();
8387 super.visitTopLevelVariableDeclaration(node); 8494 super.visitTopLevelVariableDeclaration(node);
8388 } finally { 8495 } finally {
8389 Map<Element, Type2> overrides = overrideManager.captureOverrides(node.vari ables); 8496 Map<Element, Type2> overrides = _overrideManager.captureOverrides(node.var iables);
8390 overrideManager.exitScope(); 8497 _overrideManager.exitScope();
8391 overrideManager.applyOverrides(overrides); 8498 _overrideManager.applyOverrides(overrides);
8392 } 8499 }
8393 return null; 8500 return null;
8394 } 8501 }
8395 8502
8396 Object visitTypeName(TypeName node) => null; 8503 Object visitTypeName(TypeName node) => null;
8397 8504
8398 Object visitWhileStatement(WhileStatement node) { 8505 Object visitWhileStatement(WhileStatement node) {
8399 Expression condition = node.condition; 8506 Expression condition = node.condition;
8400 safelyVisit(condition); 8507 safelyVisit(condition);
8401 Statement body = node.body; 8508 Statement body = node.body;
8402 if (body != null) { 8509 if (body != null) {
8403 try { 8510 try {
8404 overrideManager.enterScope(); 8511 _overrideManager.enterScope();
8405 propagateTrueState(condition); 8512 propagateTrueState(condition);
8406 visitStatementInScope(body); 8513 visitStatementInScope(body);
8407 } finally { 8514 } finally {
8408 overrideManager.exitScope(); 8515 _overrideManager.exitScope();
8409 } 8516 }
8410 } 8517 }
8411 node.accept(_elementResolver); 8518 node.accept(_elementResolver);
8412 node.accept(_typeAnalyzer); 8519 node.accept(_typeAnalyzer);
8413 return null; 8520 return null;
8414 } 8521 }
8415 8522
8416 /** 8523 /**
8524 * Return the class element representing the class containing the current node , or `null` if
8525 * the current node is not contained in a class.
8526 *
8527 * @return the class element representing the class containing the current nod e
8528 */
8529 ClassElement get enclosingClass => _enclosingClass;
8530
8531 /**
8532 * Return the element representing the function containing the current node, o r `null` if
8533 * the current node is not contained in a function.
8534 *
8535 * @return the element representing the function containing the current node
8536 */
8537 ExecutableElement get enclosingFunction => _enclosingFunction;
8538
8539 /**
8417 * Return the propagated element associated with the given expression whose ty pe can be 8540 * Return the propagated element associated with the given expression whose ty pe can be
8418 * overridden, or `null` if there is no element whose type can be overridden. 8541 * overridden, or `null` if there is no element whose type can be overridden.
8419 * 8542 *
8420 * @param expression the expression with which the element is associated 8543 * @param expression the expression with which the element is associated
8421 * @return the element associated with the given expression 8544 * @return the element associated with the given expression
8422 */ 8545 */
8423 VariableElement getOverridablePropagatedElement(Expression expression) { 8546 VariableElement getOverridablePropagatedElement(Expression expression) {
8424 Element element = null; 8547 Element element = null;
8425 if (expression is SimpleIdentifier) { 8548 if (expression is SimpleIdentifier) {
8426 element = (expression as SimpleIdentifier).propagatedElement; 8549 element = (expression as SimpleIdentifier).propagatedElement;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
8519 return; 8642 return;
8520 } 8643 }
8521 if (element is PropertyInducingElement) { 8644 if (element is PropertyInducingElement) {
8522 PropertyInducingElement variable = element as PropertyInducingElement; 8645 PropertyInducingElement variable = element as PropertyInducingElement;
8523 if (!variable.isConst && !variable.isFinal) { 8646 if (!variable.isConst && !variable.isFinal) {
8524 return; 8647 return;
8525 } 8648 }
8526 } 8649 }
8527 Type2 currentType = getBestType(element); 8650 Type2 currentType = getBestType(element);
8528 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { 8651 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) {
8529 overrideManager.setType(element, potentialType); 8652 _overrideManager.setType(element, potentialType);
8530 } 8653 }
8531 } 8654 }
8532 8655
8533 /** 8656 /**
8534 * Report a conditional analysis error with the given error code and arguments . 8657 * Report a conditional analysis error with the given error code and arguments .
8535 * 8658 *
8536 * @param enclosingElement the enclosing element 8659 * @param enclosingElement the enclosing element
8537 * @param errorCode the error code of the error to be reported 8660 * @param errorCode the error code of the error to be reported
8538 * @param node the node specifying the location of the error 8661 * @param node the node specifying the location of the error
8539 * @param arguments the arguments to the error, used to compose the error mess age 8662 * @param arguments the arguments to the error, used to compose the error mess age
8540 */ 8663 */
8541 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC ode errorCode, ASTNode node, List<Object> arguments) { 8664 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC ode errorCode, ASTNode node, List<Object> arguments) {
8542 proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclosi ngElement, new AnalysisError.con2(source, node.offset, node.length, errorCode, a rguments))); 8665 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, node.offset, node.length, errorCode, arguments)));
8543 } 8666 }
8544 8667
8545 /** 8668 /**
8546 * Report a conditional analysis error with the given error code and arguments . 8669 * Report a conditional analysis error with the given error code and arguments .
8547 * 8670 *
8548 * @param enclosingElement the enclosing element 8671 * @param enclosingElement the enclosing element
8549 * @param errorCode the error code of the error to be reported 8672 * @param errorCode the error code of the error to be reported
8550 * @param offset the offset of the location of the error 8673 * @param offset the offset of the location of the error
8551 * @param length the length of the location of the error 8674 * @param length the length of the location of the error
8552 * @param arguments the arguments to the error, used to compose the error mess age 8675 * @param arguments the arguments to the error, used to compose the error mess age
8553 */ 8676 */
8554 void reportErrorProxyConditionalAnalysisError2(Element enclosingElement, Error Code errorCode, int offset, int length, List<Object> arguments) { 8677 void reportErrorProxyConditionalAnalysisError2(Element enclosingElement, Error Code errorCode, int offset, int length, List<Object> arguments) {
8555 proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclosi ngElement, new AnalysisError.con2(source, offset, length, errorCode, arguments)) ); 8678 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, offset, length, errorCode, arguments) ));
8556 } 8679 }
8557 8680
8558 /** 8681 /**
8559 * Report a conditional analysis error with the given error code and arguments . 8682 * Report a conditional analysis error with the given error code and arguments .
8560 * 8683 *
8561 * @param enclosingElement the enclosing element 8684 * @param enclosingElement the enclosing element
8562 * @param errorCode the error code of the error to be reported 8685 * @param errorCode the error code of the error to be reported
8563 * @param token the token specifying the location of the error 8686 * @param token the token specifying the location of the error
8564 * @param arguments the arguments to the error, used to compose the error mess age 8687 * @param arguments the arguments to the error, used to compose the error mess age
8565 */ 8688 */
8566 void reportErrorProxyConditionalAnalysisError3(Element enclosingElement, Error Code errorCode, sc.Token token, List<Object> arguments) { 8689 void reportErrorProxyConditionalAnalysisError3(Element enclosingElement, Error Code errorCode, sc.Token token, List<Object> arguments) {
8567 proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclosi ngElement, new AnalysisError.con2(source, token.offset, token.length, errorCode, arguments))); 8690 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, token.offset, token.length, errorCode , arguments)));
8568 } 8691 }
8569 8692
8570 void visitForEachStatementInScope(ForEachStatement node) { 8693 void visitForEachStatementInScope(ForEachStatement node) {
8571 Expression iterator = node.iterator; 8694 Expression iterator = node.iterator;
8572 safelyVisit(iterator); 8695 safelyVisit(iterator);
8573 DeclaredIdentifier loopVariable = node.loopVariable; 8696 DeclaredIdentifier loopVariable = node.loopVariable;
8574 SimpleIdentifier identifier = node.identifier; 8697 SimpleIdentifier identifier = node.identifier;
8575 safelyVisit(loopVariable); 8698 safelyVisit(loopVariable);
8576 safelyVisit(identifier); 8699 safelyVisit(identifier);
8577 Statement body = node.body; 8700 Statement body = node.body;
8578 if (body != null) { 8701 if (body != null) {
8579 try { 8702 try {
8580 overrideManager.enterScope(); 8703 _overrideManager.enterScope();
8581 if (loopVariable != null && iterator != null) { 8704 if (loopVariable != null && iterator != null) {
8582 LocalVariableElement loopElement = loopVariable.element; 8705 LocalVariableElement loopElement = loopVariable.element;
8583 if (loopElement != null) { 8706 if (loopElement != null) {
8584 Type2 iteratorElementType = getIteratorElementType(iterator); 8707 Type2 iteratorElementType = getIteratorElementType(iterator);
8585 override2(loopElement, iteratorElementType); 8708 override2(loopElement, iteratorElementType);
8586 recordPropagatedType(loopVariable.identifier, iteratorElementType); 8709 recordPropagatedType(loopVariable.identifier, iteratorElementType);
8587 } 8710 }
8588 } else if (identifier != null && iterator != null) { 8711 } else if (identifier != null && iterator != null) {
8589 Element identifierElement = identifier.staticElement; 8712 Element identifierElement = identifier.staticElement;
8590 if (identifierElement is VariableElement) { 8713 if (identifierElement is VariableElement) {
8591 Type2 iteratorElementType = getIteratorElementType(iterator); 8714 Type2 iteratorElementType = getIteratorElementType(iterator);
8592 override2(identifierElement as VariableElement, iteratorElementType) ; 8715 override2(identifierElement as VariableElement, iteratorElementType) ;
8593 recordPropagatedType(identifier, iteratorElementType); 8716 recordPropagatedType(identifier, iteratorElementType);
8594 } 8717 }
8595 } 8718 }
8596 visitStatementInScope(body); 8719 visitStatementInScope(body);
8597 } finally { 8720 } finally {
8598 overrideManager.exitScope(); 8721 _overrideManager.exitScope();
8599 } 8722 }
8600 } 8723 }
8601 node.accept(_elementResolver); 8724 node.accept(_elementResolver);
8602 node.accept(_typeAnalyzer); 8725 node.accept(_typeAnalyzer);
8603 } 8726 }
8604 8727
8605 void visitForStatementInScope(ForStatement node) { 8728 void visitForStatementInScope(ForStatement node) {
8606 safelyVisit(node.variables); 8729 safelyVisit(node.variables);
8607 safelyVisit(node.initialization); 8730 safelyVisit(node.initialization);
8608 safelyVisit(node.condition); 8731 safelyVisit(node.condition);
8609 overrideManager.enterScope(); 8732 _overrideManager.enterScope();
8610 try { 8733 try {
8611 propagateTrueState(node.condition); 8734 propagateTrueState(node.condition);
8612 visitStatementInScope(node.body); 8735 visitStatementInScope(node.body);
8613 node.updaters.accept(this); 8736 node.updaters.accept(this);
8614 } finally { 8737 } finally {
8615 overrideManager.exitScope(); 8738 _overrideManager.exitScope();
8616 } 8739 }
8617 } 8740 }
8618 8741
8619 /** 8742 /**
8620 * Checks each promoted variable in the current scope for compliance with the following 8743 * Checks each promoted variable in the current scope for compliance with the following
8621 * specification statement: 8744 * specification statement:
8622 * 8745 *
8623 * If the variable <i>v</i> is accessed by a closure in <i>s<sub>1</sub></i> t hen the variable 8746 * If the variable <i>v</i> is accessed by a closure in <i>s<sub>1</sub></i> t hen the variable
8624 * <i>v</i> is not potentially mutated anywhere in the scope of <i>v</i>. 8747 * <i>v</i> is not potentially mutated anywhere in the scope of <i>v</i>.
8625 */ 8748 */
8626 void clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(ASTNode targ et) { 8749 void clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(ASTNode targ et) {
8627 for (Element element in promoteManager.promotedElements) { 8750 for (Element element in _promoteManager.promotedElements) {
8628 if ((element as VariableElementImpl).isPotentiallyMutatedInScope) { 8751 if ((element as VariableElementImpl).isPotentiallyMutatedInScope) {
8629 if (isVariableAccessedInClosure(element, target)) { 8752 if (isVariableAccessedInClosure(element, target)) {
8630 promoteManager.setType(element, null); 8753 _promoteManager.setType(element, null);
8631 } 8754 }
8632 } 8755 }
8633 } 8756 }
8634 } 8757 }
8635 8758
8636 /** 8759 /**
8637 * Checks each promoted variable in the current scope for compliance with the following 8760 * Checks each promoted variable in the current scope for compliance with the following
8638 * specification statement: 8761 * specification statement:
8639 * 8762 *
8640 * <i>v</i> is not potentially mutated in <i>s<sub>1</sub></i> or within a clo sure. 8763 * <i>v</i> is not potentially mutated in <i>s<sub>1</sub></i> or within a clo sure.
8641 */ 8764 */
8642 void clearTypePromotionsIfPotentiallyMutatedIn(ASTNode target) { 8765 void clearTypePromotionsIfPotentiallyMutatedIn(ASTNode target) {
8643 for (Element element in promoteManager.promotedElements) { 8766 for (Element element in _promoteManager.promotedElements) {
8644 if (isVariablePotentiallyMutatedIn(element, target)) { 8767 if (isVariablePotentiallyMutatedIn(element, target)) {
8645 promoteManager.setType(element, null); 8768 _promoteManager.setType(element, null);
8646 } 8769 }
8647 } 8770 }
8648 } 8771 }
8649 8772
8650 /** 8773 /**
8651 * Return the best type information available for the given element. If the ty pe of the element 8774 * Return the best type information available for the given element. If the ty pe of the element
8652 * has been overridden, then return the overriding type. Otherwise, return the static type. 8775 * has been overridden, then return the overriding type. Otherwise, return the static type.
8653 * 8776 *
8654 * @param element the element for which type information is to be returned 8777 * @param element the element for which type information is to be returned
8655 * @return the best type information available for the given element 8778 * @return the best type information available for the given element
8656 */ 8779 */
8657 Type2 getBestType(Element element) { 8780 Type2 getBestType(Element element) {
8658 Type2 bestType = overrideManager.getType(element); 8781 Type2 bestType = _overrideManager.getType(element);
8659 if (bestType == null) { 8782 if (bestType == null) {
8660 if (element is LocalVariableElement) { 8783 if (element is LocalVariableElement) {
8661 bestType = (element as LocalVariableElement).type; 8784 bestType = (element as LocalVariableElement).type;
8662 } else if (element is ParameterElement) { 8785 } else if (element is ParameterElement) {
8663 bestType = (element as ParameterElement).type; 8786 bestType = (element as ParameterElement).type;
8664 } 8787 }
8665 } 8788 }
8666 return bestType; 8789 return bestType;
8667 } 8790 }
8668 8791
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8710 FunctionType expectedClosureType = mayByFunctionType as FunctionType; 8833 FunctionType expectedClosureType = mayByFunctionType as FunctionType;
8711 closure.propagatedType = expectedClosureType; 8834 closure.propagatedType = expectedClosureType;
8712 NodeList<FormalParameter> parameters = closure.parameters.parameters; 8835 NodeList<FormalParameter> parameters = closure.parameters.parameters;
8713 List<ParameterElement> expectedParameters = expectedClosureType.parameters; 8836 List<ParameterElement> expectedParameters = expectedClosureType.parameters;
8714 for (int i = 0; i < parameters.length && i < expectedParameters.length; i++) { 8837 for (int i = 0; i < parameters.length && i < expectedParameters.length; i++) {
8715 FormalParameter parameter = parameters[i]; 8838 FormalParameter parameter = parameters[i];
8716 ParameterElement element = parameter.element; 8839 ParameterElement element = parameter.element;
8717 Type2 currentType = getBestType(element); 8840 Type2 currentType = getBestType(element);
8718 Type2 expectedType = expectedParameters[i].type; 8841 Type2 expectedType = expectedParameters[i].type;
8719 if (currentType == null || expectedType.isMoreSpecificThan(currentType)) { 8842 if (currentType == null || expectedType.isMoreSpecificThan(currentType)) {
8720 overrideManager.setType(element, expectedType); 8843 _overrideManager.setType(element, expectedType);
8721 } 8844 }
8722 } 8845 }
8723 } 8846 }
8724 8847
8725 /** 8848 /**
8726 * Try to infer types of parameters of the [FunctionExpression] arguments. 8849 * Try to infer types of parameters of the [FunctionExpression] arguments.
8727 */ 8850 */
8728 void inferFunctionExpressionsParametersTypes(ArgumentList argumentList) { 8851 void inferFunctionExpressionsParametersTypes(ArgumentList argumentList) {
8729 for (Expression argument in argumentList.arguments) { 8852 for (Expression argument in argumentList.arguments) {
8730 ParameterElement parameter = argument.propagatedParameterElement; 8853 ParameterElement parameter = argument.propagatedParameterElement;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
8811 * @param expression the expression used to access the static element whose ty pes might be 8934 * @param expression the expression used to access the static element whose ty pes might be
8812 * promoted 8935 * promoted
8813 * @param potentialType the potential type of the elements 8936 * @param potentialType the potential type of the elements
8814 */ 8937 */
8815 void promote(Expression expression, Type2 potentialType) { 8938 void promote(Expression expression, Type2 potentialType) {
8816 VariableElement element = getPromotionStaticElement(expression); 8939 VariableElement element = getPromotionStaticElement(expression);
8817 if (element != null) { 8940 if (element != null) {
8818 if ((element as VariableElementImpl).isPotentiallyMutatedInClosure) { 8941 if ((element as VariableElementImpl).isPotentiallyMutatedInClosure) {
8819 return; 8942 return;
8820 } 8943 }
8821 Type2 type = promoteManager.getType(element); 8944 Type2 type = _promoteManager.getType(element);
8822 if (type == null) { 8945 if (type == null) {
8823 type = expression.staticType; 8946 type = expression.staticType;
8824 } 8947 }
8825 if (type == null || type.isDynamic) { 8948 if (type == null || type.isDynamic) {
8826 return; 8949 return;
8827 } 8950 }
8828 if (potentialType == null || potentialType.isDynamic) { 8951 if (potentialType == null || potentialType.isDynamic) {
8829 return; 8952 return;
8830 } 8953 }
8831 if (!potentialType.isMoreSpecificThan(type)) { 8954 if (!potentialType.isMoreSpecificThan(type)) {
8832 return; 8955 return;
8833 } 8956 }
8834 promoteManager.setType(element, potentialType); 8957 _promoteManager.setType(element, potentialType);
8835 } 8958 }
8836 } 8959 }
8837 8960
8838 /** 8961 /**
8839 * Promotes type information using given condition. 8962 * Promotes type information using given condition.
8840 */ 8963 */
8841 void promoteTypes(Expression condition) { 8964 void promoteTypes(Expression condition) {
8842 if (condition is BinaryExpression) { 8965 if (condition is BinaryExpression) {
8843 BinaryExpression binary = condition as BinaryExpression; 8966 BinaryExpression binary = condition as BinaryExpression;
8844 if (identical(binary.operator.type, sc.TokenType.AMPERSAND_AMPERSAND)) { 8967 if (identical(binary.operator.type, sc.TokenType.AMPERSAND_AMPERSAND)) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
8932 void recordPropagatedType(Expression expression, Type2 type) { 9055 void recordPropagatedType(Expression expression, Type2 type) {
8933 if (type != null && !type.isDynamic) { 9056 if (type != null && !type.isDynamic) {
8934 expression.propagatedType = type; 9057 expression.propagatedType = type;
8935 } 9058 }
8936 } 9059 }
8937 9060
8938 get elementResolver_J2DAccessor => _elementResolver; 9061 get elementResolver_J2DAccessor => _elementResolver;
8939 9062
8940 set elementResolver_J2DAccessor(__v) => _elementResolver = __v; 9063 set elementResolver_J2DAccessor(__v) => _elementResolver = __v;
8941 9064
8942 get labelScope_J2DAccessor => labelScope; 9065 get labelScope_J2DAccessor => _labelScope;
8943 9066
8944 set labelScope_J2DAccessor(__v) => labelScope = __v; 9067 set labelScope_J2DAccessor(__v) => _labelScope = __v;
8945 9068
8946 get nameScope_J2DAccessor => nameScope; 9069 get nameScope_J2DAccessor => _nameScope;
8947 9070
8948 set nameScope_J2DAccessor(__v) => nameScope = __v; 9071 set nameScope_J2DAccessor(__v) => _nameScope = __v;
8949 9072
8950 get typeAnalyzer_J2DAccessor => _typeAnalyzer; 9073 get typeAnalyzer_J2DAccessor => _typeAnalyzer;
8951 9074
8952 set typeAnalyzer_J2DAccessor(__v) => _typeAnalyzer = __v; 9075 set typeAnalyzer_J2DAccessor(__v) => _typeAnalyzer = __v;
8953 9076
8954 get enclosingClass_J2DAccessor => enclosingClass; 9077 get enclosingClass_J2DAccessor => _enclosingClass;
8955 9078
8956 set enclosingClass_J2DAccessor(__v) => enclosingClass = __v; 9079 set enclosingClass_J2DAccessor(__v) => _enclosingClass = __v;
8957 } 9080 }
8958 9081
8959 class RecursiveASTVisitor_8 extends RecursiveASTVisitor<Object> { 9082 class RecursiveASTVisitor_8 extends RecursiveASTVisitor<Object> {
8960 List<bool> result; 9083 List<bool> result;
8961 9084
8962 Element variable; 9085 Element variable;
8963 9086
8964 RecursiveASTVisitor_8(this.result, this.variable) : super(); 9087 RecursiveASTVisitor_8(this.result, this.variable) : super();
8965 9088
8966 bool _inClosure = false; 9089 bool _inClosure = false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
9009 /** 9132 /**
9010 * The abstract class `ScopedVisitor` maintains name and label scopes as an AST structure is 9133 * The abstract class `ScopedVisitor` maintains name and label scopes as an AST structure is
9011 * being visited. 9134 * being visited.
9012 * 9135 *
9013 * @coverage dart.engine.resolver 9136 * @coverage dart.engine.resolver
9014 */ 9137 */
9015 abstract class ScopedVisitor extends UnifyingASTVisitor<Object> { 9138 abstract class ScopedVisitor extends UnifyingASTVisitor<Object> {
9016 /** 9139 /**
9017 * The element for the library containing the compilation unit being visited. 9140 * The element for the library containing the compilation unit being visited.
9018 */ 9141 */
9019 LibraryElement definingLibrary; 9142 LibraryElement _definingLibrary;
9020 9143
9021 /** 9144 /**
9022 * The source representing the compilation unit being visited. 9145 * The source representing the compilation unit being visited.
9023 */ 9146 */
9024 Source source; 9147 final Source source;
9025 9148
9026 /** 9149 /**
9027 * The error listener that will be informed of any errors that are found durin g resolution. 9150 * The error listener that will be informed of any errors that are found durin g resolution.
9028 */ 9151 */
9029 AnalysisErrorListener _errorListener; 9152 AnalysisErrorListener _errorListener;
9030 9153
9031 /** 9154 /**
9032 * The scope used to resolve identifiers. 9155 * The scope used to resolve identifiers.
9033 */ 9156 */
9034 Scope nameScope; 9157 Scope _nameScope;
9035 9158
9036 /** 9159 /**
9037 * The object used to access the types from the core library. 9160 * The object used to access the types from the core library.
9038 */ 9161 */
9039 TypeProvider typeProvider; 9162 final TypeProvider typeProvider;
9040 9163
9041 /** 9164 /**
9042 * The scope used to resolve labels for `break` and `continue` statements, or 9165 * The scope used to resolve labels for `break` and `continue` statements, or
9043 * `null` if no labels have been defined in the current context. 9166 * `null` if no labels have been defined in the current context.
9044 */ 9167 */
9045 LabelScope labelScope; 9168 LabelScope _labelScope;
9046 9169
9047 /** 9170 /**
9048 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 9171 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
9049 * 9172 *
9050 * @param library the library containing the compilation unit being resolved 9173 * @param library the library containing the compilation unit being resolved
9051 * @param source the source representing the compilation unit being visited 9174 * @param source the source representing the compilation unit being visited
9052 * @param typeProvider the object used to access the types from the core libra ry 9175 * @param typeProvider the object used to access the types from the core libra ry
9053 */ 9176 */
9054 ScopedVisitor.con1(Library library, Source source, TypeProvider typeProvider) { 9177 ScopedVisitor.con1(Library library, this.source, this.typeProvider) {
9055 this.definingLibrary = library.libraryElement; 9178 this._definingLibrary = library.libraryElement;
9056 this.source = source;
9057 LibraryScope libraryScope = library.libraryScope; 9179 LibraryScope libraryScope = library.libraryScope;
9058 this._errorListener = libraryScope.errorListener; 9180 this._errorListener = libraryScope.errorListener;
9059 this.nameScope = libraryScope; 9181 this._nameScope = libraryScope;
9060 this.typeProvider = typeProvider;
9061 } 9182 }
9062 9183
9063 /** 9184 /**
9064 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 9185 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
9065 * 9186 *
9066 * @param definingLibrary the element for the library containing the compilati on unit being 9187 * @param definingLibrary the element for the library containing the compilati on unit being
9067 * visited 9188 * visited
9068 * @param source the source representing the compilation unit being visited 9189 * @param source the source representing the compilation unit being visited
9069 * @param typeProvider the object used to access the types from the core libra ry 9190 * @param typeProvider the object used to access the types from the core libra ry
9070 * @param errorListener the error listener that will be informed of any errors that are found 9191 * @param errorListener the error listener that will be informed of any errors that are found
9071 * during resolution 9192 * during resolution
9072 */ 9193 */
9073 ScopedVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) { 9194 ScopedVisitor.con2(LibraryElement definingLibrary, this.source, this.typeProvi der, AnalysisErrorListener errorListener) {
9074 this.definingLibrary = definingLibrary; 9195 this._definingLibrary = definingLibrary;
9075 this.source = source;
9076 this._errorListener = errorListener; 9196 this._errorListener = errorListener;
9077 this.nameScope = new LibraryScope(definingLibrary, errorListener); 9197 this._nameScope = new LibraryScope(definingLibrary, errorListener);
9078 this.typeProvider = typeProvider;
9079 } 9198 }
9080 9199
9081 /** 9200 /**
9082 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 9201 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
9083 * 9202 *
9084 * @param definingLibrary the element for the library containing the compilati on unit being 9203 * @param definingLibrary the element for the library containing the compilati on unit being
9085 * visited 9204 * visited
9086 * @param source the source representing the compilation unit being visited 9205 * @param source the source representing the compilation unit being visited
9087 * @param typeProvider the object used to access the types from the core libra ry 9206 * @param typeProvider the object used to access the types from the core libra ry
9088 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited 9207 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited
9089 * @param errorListener the error listener that will be informed of any errors that are found 9208 * @param errorListener the error listener that will be informed of any errors that are found
9090 * during resolution 9209 * during resolution
9091 */ 9210 */
9092 ScopedVisitor.con3(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener) { 9211 ScopedVisitor.con3(LibraryElement definingLibrary, this.source, this.typeProvi der, Scope nameScope, AnalysisErrorListener errorListener) {
9093 this.definingLibrary = definingLibrary; 9212 this._definingLibrary = definingLibrary;
9094 this.source = source;
9095 this._errorListener = errorListener; 9213 this._errorListener = errorListener;
9096 this.nameScope = nameScope; 9214 this._nameScope = nameScope;
9097 this.typeProvider = typeProvider;
9098 } 9215 }
9099 9216
9100 /** 9217 /**
9218 * Return the library element for the library containing the compilation unit being resolved.
9219 *
9220 * @return the library element for the library containing the compilation unit being resolved
9221 */
9222 LibraryElement get definingLibrary => _definingLibrary;
9223
9224 /**
9101 * Report an error with the given analysis error. 9225 * Report an error with the given analysis error.
9102 * 9226 *
9103 * @param errorCode analysis error 9227 * @param errorCode analysis error
9104 */ 9228 */
9105 void reportError(AnalysisError analysisError) { 9229 void reportError(AnalysisError analysisError) {
9106 _errorListener.onError(analysisError); 9230 _errorListener.onError(analysisError);
9107 } 9231 }
9108 9232
9109 Object visitBlock(Block node) { 9233 Object visitBlock(Block node) {
9110 Scope outerScope = nameScope; 9234 Scope outerScope = _nameScope;
9111 try { 9235 try {
9112 EnclosedScope enclosedScope = new EnclosedScope(nameScope); 9236 EnclosedScope enclosedScope = new EnclosedScope(_nameScope);
9113 hideNamesDefinedInBlock(enclosedScope, node); 9237 hideNamesDefinedInBlock(enclosedScope, node);
9114 nameScope = enclosedScope; 9238 _nameScope = enclosedScope;
9115 super.visitBlock(node); 9239 super.visitBlock(node);
9116 } finally { 9240 } finally {
9117 nameScope = outerScope; 9241 _nameScope = outerScope;
9118 } 9242 }
9119 return null; 9243 return null;
9120 } 9244 }
9121 9245
9122 Object visitCatchClause(CatchClause node) { 9246 Object visitCatchClause(CatchClause node) {
9123 SimpleIdentifier exception = node.exceptionParameter; 9247 SimpleIdentifier exception = node.exceptionParameter;
9124 if (exception != null) { 9248 if (exception != null) {
9125 Scope outerScope = nameScope; 9249 Scope outerScope = _nameScope;
9126 try { 9250 try {
9127 nameScope = new EnclosedScope(nameScope); 9251 _nameScope = new EnclosedScope(_nameScope);
9128 nameScope.define(exception.staticElement); 9252 _nameScope.define(exception.staticElement);
9129 SimpleIdentifier stackTrace = node.stackTraceParameter; 9253 SimpleIdentifier stackTrace = node.stackTraceParameter;
9130 if (stackTrace != null) { 9254 if (stackTrace != null) {
9131 nameScope.define(stackTrace.staticElement); 9255 _nameScope.define(stackTrace.staticElement);
9132 } 9256 }
9133 super.visitCatchClause(node); 9257 super.visitCatchClause(node);
9134 } finally { 9258 } finally {
9135 nameScope = outerScope; 9259 _nameScope = outerScope;
9136 } 9260 }
9137 } else { 9261 } else {
9138 super.visitCatchClause(node); 9262 super.visitCatchClause(node);
9139 } 9263 }
9140 return null; 9264 return null;
9141 } 9265 }
9142 9266
9143 Object visitClassDeclaration(ClassDeclaration node) { 9267 Object visitClassDeclaration(ClassDeclaration node) {
9144 Scope outerScope = nameScope; 9268 Scope outerScope = _nameScope;
9145 try { 9269 try {
9146 nameScope = new ClassScope(nameScope, node.element); 9270 _nameScope = new ClassScope(_nameScope, node.element);
9147 super.visitClassDeclaration(node); 9271 super.visitClassDeclaration(node);
9148 } finally { 9272 } finally {
9149 nameScope = outerScope; 9273 _nameScope = outerScope;
9150 } 9274 }
9151 return null; 9275 return null;
9152 } 9276 }
9153 9277
9154 Object visitClassTypeAlias(ClassTypeAlias node) { 9278 Object visitClassTypeAlias(ClassTypeAlias node) {
9155 Scope outerScope = nameScope; 9279 Scope outerScope = _nameScope;
9156 try { 9280 try {
9157 nameScope = new ClassScope(nameScope, node.element); 9281 _nameScope = new ClassScope(_nameScope, node.element);
9158 super.visitClassTypeAlias(node); 9282 super.visitClassTypeAlias(node);
9159 } finally { 9283 } finally {
9160 nameScope = outerScope; 9284 _nameScope = outerScope;
9161 } 9285 }
9162 return null; 9286 return null;
9163 } 9287 }
9164 9288
9165 Object visitConstructorDeclaration(ConstructorDeclaration node) { 9289 Object visitConstructorDeclaration(ConstructorDeclaration node) {
9166 Scope outerScope = nameScope; 9290 Scope outerScope = _nameScope;
9167 try { 9291 try {
9168 nameScope = new FunctionScope(nameScope, node.element); 9292 _nameScope = new FunctionScope(_nameScope, node.element);
9169 super.visitConstructorDeclaration(node); 9293 super.visitConstructorDeclaration(node);
9170 } finally { 9294 } finally {
9171 nameScope = outerScope; 9295 _nameScope = outerScope;
9172 } 9296 }
9173 return null; 9297 return null;
9174 } 9298 }
9175 9299
9176 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 9300 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
9177 VariableElement element = node.element; 9301 VariableElement element = node.element;
9178 if (element != null) { 9302 if (element != null) {
9179 nameScope.define(element); 9303 _nameScope.define(element);
9180 } 9304 }
9181 super.visitDeclaredIdentifier(node); 9305 super.visitDeclaredIdentifier(node);
9182 return null; 9306 return null;
9183 } 9307 }
9184 9308
9185 Object visitDoStatement(DoStatement node) { 9309 Object visitDoStatement(DoStatement node) {
9186 LabelScope outerLabelScope = labelScope; 9310 LabelScope outerLabelScope = _labelScope;
9187 try { 9311 try {
9188 labelScope = new LabelScope.con1(labelScope, false, false); 9312 _labelScope = new LabelScope.con1(_labelScope, false, false);
9189 visitStatementInScope(node.body); 9313 visitStatementInScope(node.body);
9190 safelyVisit(node.condition); 9314 safelyVisit(node.condition);
9191 } finally { 9315 } finally {
9192 labelScope = outerLabelScope; 9316 _labelScope = outerLabelScope;
9193 } 9317 }
9194 return null; 9318 return null;
9195 } 9319 }
9196 9320
9197 Object visitForEachStatement(ForEachStatement node) { 9321 Object visitForEachStatement(ForEachStatement node) {
9198 Scope outerNameScope = nameScope; 9322 Scope outerNameScope = _nameScope;
9199 LabelScope outerLabelScope = labelScope; 9323 LabelScope outerLabelScope = _labelScope;
9200 try { 9324 try {
9201 nameScope = new EnclosedScope(nameScope); 9325 _nameScope = new EnclosedScope(_nameScope);
9202 labelScope = new LabelScope.con1(outerLabelScope, false, false); 9326 _labelScope = new LabelScope.con1(outerLabelScope, false, false);
9203 visitForEachStatementInScope(node); 9327 visitForEachStatementInScope(node);
9204 } finally { 9328 } finally {
9205 labelScope = outerLabelScope; 9329 _labelScope = outerLabelScope;
9206 nameScope = outerNameScope; 9330 _nameScope = outerNameScope;
9207 } 9331 }
9208 return null; 9332 return null;
9209 } 9333 }
9210 9334
9211 Object visitFormalParameterList(FormalParameterList node) { 9335 Object visitFormalParameterList(FormalParameterList node) {
9212 super.visitFormalParameterList(node); 9336 super.visitFormalParameterList(node);
9213 if (nameScope is FunctionScope) { 9337 if (_nameScope is FunctionScope) {
9214 (nameScope as FunctionScope).defineParameters(); 9338 (_nameScope as FunctionScope).defineParameters();
9215 } 9339 }
9216 if (nameScope is FunctionTypeScope) { 9340 if (_nameScope is FunctionTypeScope) {
9217 (nameScope as FunctionTypeScope).defineParameters(); 9341 (_nameScope as FunctionTypeScope).defineParameters();
9218 } 9342 }
9219 return null; 9343 return null;
9220 } 9344 }
9221 9345
9222 Object visitForStatement(ForStatement node) { 9346 Object visitForStatement(ForStatement node) {
9223 Scope outerNameScope = nameScope; 9347 Scope outerNameScope = _nameScope;
9224 LabelScope outerLabelScope = labelScope; 9348 LabelScope outerLabelScope = _labelScope;
9225 try { 9349 try {
9226 nameScope = new EnclosedScope(nameScope); 9350 _nameScope = new EnclosedScope(_nameScope);
9227 labelScope = new LabelScope.con1(outerLabelScope, false, false); 9351 _labelScope = new LabelScope.con1(outerLabelScope, false, false);
9228 visitForStatementInScope(node); 9352 visitForStatementInScope(node);
9229 } finally { 9353 } finally {
9230 labelScope = outerLabelScope; 9354 _labelScope = outerLabelScope;
9231 nameScope = outerNameScope; 9355 _nameScope = outerNameScope;
9232 } 9356 }
9233 return null; 9357 return null;
9234 } 9358 }
9235 9359
9236 Object visitFunctionDeclaration(FunctionDeclaration node) { 9360 Object visitFunctionDeclaration(FunctionDeclaration node) {
9237 ExecutableElement function = node.element; 9361 ExecutableElement function = node.element;
9238 Scope outerScope = nameScope; 9362 Scope outerScope = _nameScope;
9239 try { 9363 try {
9240 nameScope = new FunctionScope(nameScope, function); 9364 _nameScope = new FunctionScope(_nameScope, function);
9241 super.visitFunctionDeclaration(node); 9365 super.visitFunctionDeclaration(node);
9242 } finally { 9366 } finally {
9243 nameScope = outerScope; 9367 _nameScope = outerScope;
9244 } 9368 }
9245 if (function.enclosingElement is! CompilationUnitElement) { 9369 if (function.enclosingElement is! CompilationUnitElement) {
9246 nameScope.define(function); 9370 _nameScope.define(function);
9247 } 9371 }
9248 return null; 9372 return null;
9249 } 9373 }
9250 9374
9251 Object visitFunctionExpression(FunctionExpression node) { 9375 Object visitFunctionExpression(FunctionExpression node) {
9252 if (node.parent is FunctionDeclaration) { 9376 if (node.parent is FunctionDeclaration) {
9253 super.visitFunctionExpression(node); 9377 super.visitFunctionExpression(node);
9254 } else { 9378 } else {
9255 Scope outerScope = nameScope; 9379 Scope outerScope = _nameScope;
9256 try { 9380 try {
9257 ExecutableElement functionElement = node.element; 9381 ExecutableElement functionElement = node.element;
9258 if (functionElement == null) { 9382 if (functionElement == null) {
9259 } else { 9383 } else {
9260 nameScope = new FunctionScope(nameScope, functionElement); 9384 _nameScope = new FunctionScope(_nameScope, functionElement);
9261 } 9385 }
9262 super.visitFunctionExpression(node); 9386 super.visitFunctionExpression(node);
9263 } finally { 9387 } finally {
9264 nameScope = outerScope; 9388 _nameScope = outerScope;
9265 } 9389 }
9266 } 9390 }
9267 return null; 9391 return null;
9268 } 9392 }
9269 9393
9270 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 9394 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
9271 Scope outerScope = nameScope; 9395 Scope outerScope = _nameScope;
9272 try { 9396 try {
9273 nameScope = new FunctionTypeScope(nameScope, node.element); 9397 _nameScope = new FunctionTypeScope(_nameScope, node.element);
9274 super.visitFunctionTypeAlias(node); 9398 super.visitFunctionTypeAlias(node);
9275 } finally { 9399 } finally {
9276 nameScope = outerScope; 9400 _nameScope = outerScope;
9277 } 9401 }
9278 return null; 9402 return null;
9279 } 9403 }
9280 9404
9281 Object visitIfStatement(IfStatement node) { 9405 Object visitIfStatement(IfStatement node) {
9282 safelyVisit(node.condition); 9406 safelyVisit(node.condition);
9283 visitStatementInScope(node.thenStatement); 9407 visitStatementInScope(node.thenStatement);
9284 visitStatementInScope(node.elseStatement); 9408 visitStatementInScope(node.elseStatement);
9285 return null; 9409 return null;
9286 } 9410 }
9287 9411
9288 Object visitLabeledStatement(LabeledStatement node) { 9412 Object visitLabeledStatement(LabeledStatement node) {
9289 LabelScope outerScope = addScopesFor(node.labels); 9413 LabelScope outerScope = addScopesFor(node.labels);
9290 try { 9414 try {
9291 super.visitLabeledStatement(node); 9415 super.visitLabeledStatement(node);
9292 } finally { 9416 } finally {
9293 labelScope = outerScope; 9417 _labelScope = outerScope;
9294 } 9418 }
9295 return null; 9419 return null;
9296 } 9420 }
9297 9421
9298 Object visitMethodDeclaration(MethodDeclaration node) { 9422 Object visitMethodDeclaration(MethodDeclaration node) {
9299 Scope outerScope = nameScope; 9423 Scope outerScope = _nameScope;
9300 try { 9424 try {
9301 nameScope = new FunctionScope(nameScope, node.element); 9425 _nameScope = new FunctionScope(_nameScope, node.element);
9302 super.visitMethodDeclaration(node); 9426 super.visitMethodDeclaration(node);
9303 } finally { 9427 } finally {
9304 nameScope = outerScope; 9428 _nameScope = outerScope;
9305 } 9429 }
9306 return null; 9430 return null;
9307 } 9431 }
9308 9432
9309 Object visitSwitchCase(SwitchCase node) { 9433 Object visitSwitchCase(SwitchCase node) {
9310 node.expression.accept(this); 9434 node.expression.accept(this);
9311 Scope outerNameScope = nameScope; 9435 Scope outerNameScope = _nameScope;
9312 try { 9436 try {
9313 nameScope = new EnclosedScope(nameScope); 9437 _nameScope = new EnclosedScope(_nameScope);
9314 node.statements.accept(this); 9438 node.statements.accept(this);
9315 } finally { 9439 } finally {
9316 nameScope = outerNameScope; 9440 _nameScope = outerNameScope;
9317 } 9441 }
9318 return null; 9442 return null;
9319 } 9443 }
9320 9444
9321 Object visitSwitchDefault(SwitchDefault node) { 9445 Object visitSwitchDefault(SwitchDefault node) {
9322 Scope outerNameScope = nameScope; 9446 Scope outerNameScope = _nameScope;
9323 try { 9447 try {
9324 nameScope = new EnclosedScope(nameScope); 9448 _nameScope = new EnclosedScope(_nameScope);
9325 node.statements.accept(this); 9449 node.statements.accept(this);
9326 } finally { 9450 } finally {
9327 nameScope = outerNameScope; 9451 _nameScope = outerNameScope;
9328 } 9452 }
9329 return null; 9453 return null;
9330 } 9454 }
9331 9455
9332 Object visitSwitchStatement(SwitchStatement node) { 9456 Object visitSwitchStatement(SwitchStatement node) {
9333 LabelScope outerScope = labelScope; 9457 LabelScope outerScope = _labelScope;
9334 try { 9458 try {
9335 labelScope = new LabelScope.con1(outerScope, true, false); 9459 _labelScope = new LabelScope.con1(outerScope, true, false);
9336 for (SwitchMember member in node.members) { 9460 for (SwitchMember member in node.members) {
9337 for (Label label in member.labels) { 9461 for (Label label in member.labels) {
9338 SimpleIdentifier labelName = label.label; 9462 SimpleIdentifier labelName = label.label;
9339 LabelElement labelElement = labelName.staticElement as LabelElement; 9463 LabelElement labelElement = labelName.staticElement as LabelElement;
9340 labelScope = new LabelScope.con2(labelScope, labelName.name, labelElem ent); 9464 _labelScope = new LabelScope.con2(_labelScope, labelName.name, labelEl ement);
9341 } 9465 }
9342 } 9466 }
9343 super.visitSwitchStatement(node); 9467 super.visitSwitchStatement(node);
9344 } finally { 9468 } finally {
9345 labelScope = outerScope; 9469 _labelScope = outerScope;
9346 } 9470 }
9347 return null; 9471 return null;
9348 } 9472 }
9349 9473
9350 Object visitVariableDeclaration(VariableDeclaration node) { 9474 Object visitVariableDeclaration(VariableDeclaration node) {
9351 super.visitVariableDeclaration(node); 9475 super.visitVariableDeclaration(node);
9352 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) { 9476 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) {
9353 VariableElement element = node.element; 9477 VariableElement element = node.element;
9354 if (element != null) { 9478 if (element != null) {
9355 nameScope.define(element); 9479 _nameScope.define(element);
9356 } 9480 }
9357 } 9481 }
9358 return null; 9482 return null;
9359 } 9483 }
9360 9484
9361 Object visitWhileStatement(WhileStatement node) { 9485 Object visitWhileStatement(WhileStatement node) {
9362 LabelScope outerScope = labelScope; 9486 LabelScope outerScope = _labelScope;
9363 try { 9487 try {
9364 labelScope = new LabelScope.con1(outerScope, false, false); 9488 _labelScope = new LabelScope.con1(outerScope, false, false);
9365 safelyVisit(node.condition); 9489 safelyVisit(node.condition);
9366 visitStatementInScope(node.body); 9490 visitStatementInScope(node.body);
9367 } finally { 9491 } finally {
9368 labelScope = outerScope; 9492 _labelScope = outerScope;
9369 } 9493 }
9370 return null; 9494 return null;
9371 } 9495 }
9372 9496
9373 /** 9497 /**
9498 * Return the label scope in which the current node is being resolved.
9499 *
9500 * @return the label scope in which the current node is being resolved
9501 */
9502 LabelScope get labelScope => _labelScope;
9503
9504 /**
9505 * Return the name scope in which the current node is being resolved.
9506 *
9507 * @return the name scope in which the current node is being resolved
9508 */
9509 Scope get nameScope => _nameScope;
9510
9511 /**
9374 * Report an error with the given error code and arguments. 9512 * Report an error with the given error code and arguments.
9375 * 9513 *
9376 * @param errorCode the error code of the error to be reported 9514 * @param errorCode the error code of the error to be reported
9377 * @param node the node specifying the location of the error 9515 * @param node the node specifying the location of the error
9378 * @param arguments the arguments to the error, used to compose the error mess age 9516 * @param arguments the arguments to the error, used to compose the error mess age
9379 */ 9517 */
9380 void reportError6(ErrorCode errorCode, ASTNode node, List<Object> arguments) { 9518 void reportError6(ErrorCode errorCode, ASTNode node, List<Object> arguments) {
9381 _errorListener.onError(new AnalysisError.con2(source, node.offset, node.leng th, errorCode, arguments)); 9519 _errorListener.onError(new AnalysisError.con2(source, node.offset, node.leng th, errorCode, arguments));
9382 } 9520 }
9383 9521
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
9447 /** 9585 /**
9448 * Visit the given statement after it's scope has been created. This is used b y ResolverVisitor to 9586 * Visit the given statement after it's scope has been created. This is used b y ResolverVisitor to
9449 * correctly visit the 'then' and 'else' statements of an 'if' statement. 9587 * correctly visit the 'then' and 'else' statements of an 'if' statement.
9450 * 9588 *
9451 * @param node the statement to be visited 9589 * @param node the statement to be visited
9452 */ 9590 */
9453 void visitStatementInScope(Statement node) { 9591 void visitStatementInScope(Statement node) {
9454 if (node is Block) { 9592 if (node is Block) {
9455 visitBlock(node as Block); 9593 visitBlock(node as Block);
9456 } else if (node != null) { 9594 } else if (node != null) {
9457 Scope outerNameScope = nameScope; 9595 Scope outerNameScope = _nameScope;
9458 try { 9596 try {
9459 nameScope = new EnclosedScope(nameScope); 9597 _nameScope = new EnclosedScope(_nameScope);
9460 node.accept(this); 9598 node.accept(this);
9461 } finally { 9599 } finally {
9462 nameScope = outerNameScope; 9600 _nameScope = outerNameScope;
9463 } 9601 }
9464 } 9602 }
9465 } 9603 }
9466 9604
9467 /** 9605 /**
9468 * Add scopes for each of the given labels. 9606 * Add scopes for each of the given labels.
9469 * 9607 *
9470 * @param labels the labels for which new scopes are to be added 9608 * @param labels the labels for which new scopes are to be added
9471 * @return the scope that was in effect before the new scopes were added 9609 * @return the scope that was in effect before the new scopes were added
9472 */ 9610 */
9473 LabelScope addScopesFor(NodeList<Label> labels) { 9611 LabelScope addScopesFor(NodeList<Label> labels) {
9474 LabelScope outerScope = labelScope; 9612 LabelScope outerScope = _labelScope;
9475 for (Label label in labels) { 9613 for (Label label in labels) {
9476 SimpleIdentifier labelNameNode = label.label; 9614 SimpleIdentifier labelNameNode = label.label;
9477 String labelName = labelNameNode.name; 9615 String labelName = labelNameNode.name;
9478 LabelElement labelElement = labelNameNode.staticElement as LabelElement; 9616 LabelElement labelElement = labelNameNode.staticElement as LabelElement;
9479 labelScope = new LabelScope.con2(labelScope, labelName, labelElement); 9617 _labelScope = new LabelScope.con2(_labelScope, labelName, labelElement);
9480 } 9618 }
9481 return outerScope; 9619 return outerScope;
9482 } 9620 }
9483 9621
9484 /** 9622 /**
9485 * Marks the local declarations of the given [Block] hidden in the enclosing s cope. 9623 * Marks the local declarations of the given [Block] hidden in the enclosing s cope.
9486 * According to the scoping rules name is hidden if block defines it, but name is defined after 9624 * According to the scoping rules name is hidden if block defines it, but name is defined after
9487 * its declaration statement. 9625 * its declaration statement.
9488 */ 9626 */
9489 void hideNamesDefinedInBlock(EnclosedScope scope, Block block) { 9627 void hideNamesDefinedInBlock(EnclosedScope scope, Block block) {
(...skipping 3468 matching lines...) Expand 10 before | Expand all | Expand 10 after
12958 /** 13096 /**
12959 * Instances of the class `EnclosedScope` implement a scope that is lexically en closed in 13097 * Instances of the class `EnclosedScope` implement a scope that is lexically en closed in
12960 * another scope. 13098 * another scope.
12961 * 13099 *
12962 * @coverage dart.engine.resolver 13100 * @coverage dart.engine.resolver
12963 */ 13101 */
12964 class EnclosedScope extends Scope { 13102 class EnclosedScope extends Scope {
12965 /** 13103 /**
12966 * The scope in which this scope is lexically enclosed. 13104 * The scope in which this scope is lexically enclosed.
12967 */ 13105 */
12968 Scope _enclosingScope; 13106 final Scope enclosingScope;
12969 13107
12970 /** 13108 /**
12971 * A table mapping names that will be defined in this scope, but right now are not initialized. 13109 * A table mapping names that will be defined in this scope, but right now are not initialized.
12972 * According to the scoping rules these names are hidden, even if they were de fined in an outer 13110 * According to the scoping rules these names are hidden, even if they were de fined in an outer
12973 * scope. 13111 * scope.
12974 */ 13112 */
12975 Map<String, Element> _hiddenElements = new Map<String, Element>(); 13113 Map<String, Element> _hiddenElements = new Map<String, Element>();
12976 13114
12977 /** 13115 /**
13116 * A flag indicating whether there are any names defined in this scope.
13117 */
13118 bool _hasHiddenName = false;
13119
13120 /**
12978 * Initialize a newly created scope enclosed within another scope. 13121 * Initialize a newly created scope enclosed within another scope.
12979 * 13122 *
12980 * @param enclosingScope the scope in which this scope is lexically enclosed 13123 * @param enclosingScope the scope in which this scope is lexically enclosed
12981 */ 13124 */
12982 EnclosedScope(Scope enclosingScope) { 13125 EnclosedScope(this.enclosingScope);
12983 this._enclosingScope = enclosingScope;
12984 }
12985 13126
12986 Scope get enclosingScope => _enclosingScope; 13127 AnalysisErrorListener get errorListener => enclosingScope.errorListener;
12987
12988 AnalysisErrorListener get errorListener => _enclosingScope.errorListener;
12989 13128
12990 /** 13129 /**
12991 * Record that given element is declared in this scope, but hasn't been initia lized yet, so it is 13130 * Record that given element is declared in this scope, but hasn't been initia lized yet, so it is
12992 * error to use. If there is already an element with the given name defined in an outer scope, 13131 * error to use. If there is already an element with the given name defined in an outer scope,
12993 * then it will become unavailable. 13132 * then it will become unavailable.
12994 * 13133 *
12995 * @param element the element declared, but not initialized in this scope 13134 * @param element the element declared, but not initialized in this scope
12996 */ 13135 */
12997 void hide(Element element) { 13136 void hide(Element element) {
12998 if (element != null) { 13137 if (element != null) {
12999 String name = element.name; 13138 String name = element.name;
13000 if (name != null && !name.isEmpty) { 13139 if (name != null && !name.isEmpty) {
13001 _hiddenElements[name] = element; 13140 _hiddenElements[name] = element;
13141 _hasHiddenName = true;
13002 } 13142 }
13003 } 13143 }
13004 } 13144 }
13005 13145
13006 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) { 13146 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) {
13007 Element element = localLookup(name, referencingLibrary); 13147 Element element = localLookup(name, referencingLibrary);
13008 if (element != null) { 13148 if (element != null) {
13009 return element; 13149 return element;
13010 } 13150 }
13011 Element hiddenElement = _hiddenElements[name]; 13151 if (_hasHiddenName) {
13012 if (hiddenElement != null) { 13152 Element hiddenElement = _hiddenElements[name];
13013 errorListener.onError(new AnalysisError.con2(getSource(identifier), identi fier.offset, identifier.length, CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATI ON, [])); 13153 if (hiddenElement != null) {
13014 return hiddenElement; 13154 errorListener.onError(new AnalysisError.con2(getSource(identifier), iden tifier.offset, identifier.length, CompileTimeErrorCode.REFERENCED_BEFORE_DECLARA TION, []));
13155 return hiddenElement;
13156 }
13015 } 13157 }
13016 return _enclosingScope.lookup3(identifier, name, referencingLibrary); 13158 return enclosingScope.lookup3(identifier, name, referencingLibrary);
13017 } 13159 }
13018 } 13160 }
13019 13161
13020 /** 13162 /**
13021 * Instances of the class `FunctionScope` implement the scope defined by a funct ion. 13163 * Instances of the class `FunctionScope` implement the scope defined by a funct ion.
13022 * 13164 *
13023 * @coverage dart.engine.resolver 13165 * @coverage dart.engine.resolver
13024 */ 13166 */
13025 class FunctionScope extends EnclosedScope { 13167 class FunctionScope extends EnclosedScope {
13026 ExecutableElement _functionElement; 13168 ExecutableElement _functionElement;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
13133 13275
13134 /** 13276 /**
13135 * The marker used to look up a label element for an unlabeled `break` or `con tinue`. 13277 * The marker used to look up a label element for an unlabeled `break` or `con tinue`.
13136 */ 13278 */
13137 static String EMPTY_LABEL = ""; 13279 static String EMPTY_LABEL = "";
13138 13280
13139 /** 13281 /**
13140 * The label element returned for scopes that can be the target of an unlabele d `break` or 13282 * The label element returned for scopes that can be the target of an unlabele d `break` or
13141 * `continue`. 13283 * `continue`.
13142 */ 13284 */
13143 static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier.full(ne w sc.StringToken(sc.TokenType.IDENTIFIER, "", 0)); 13285 static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier(new sc. StringToken(sc.TokenType.IDENTIFIER, "", 0));
13144 13286
13145 /** 13287 /**
13146 * Initialize a newly created scope to represent the potential target of an un labeled 13288 * Initialize a newly created scope to represent the potential target of an un labeled
13147 * `break` or `continue`. 13289 * `break` or `continue`.
13148 * 13290 *
13149 * @param outerScope the label scope enclosing the new label scope 13291 * @param outerScope the label scope enclosing the new label scope
13150 * @param onSwitchStatement `true` if this label is associated with a `switch` 13292 * @param onSwitchStatement `true` if this label is associated with a `switch`
13151 * statement 13293 * statement
13152 * @param onSwitchMember `true` if this label is associated with a `switch` me mber 13294 * @param onSwitchMember `true` if this label is associated with a `switch` me mber
13153 */ 13295 */
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
13201 */ 13343 */
13202 class LibraryImportScope extends Scope { 13344 class LibraryImportScope extends Scope {
13203 /** 13345 /**
13204 * The element representing the library in which this scope is enclosed. 13346 * The element representing the library in which this scope is enclosed.
13205 */ 13347 */
13206 LibraryElement _definingLibrary; 13348 LibraryElement _definingLibrary;
13207 13349
13208 /** 13350 /**
13209 * The listener that is to be informed when an error is encountered. 13351 * The listener that is to be informed when an error is encountered.
13210 */ 13352 */
13211 AnalysisErrorListener _errorListener; 13353 final AnalysisErrorListener errorListener;
13212 13354
13213 /** 13355 /**
13214 * A list of the namespaces representing the names that are available in this scope from imported 13356 * A list of the namespaces representing the names that are available in this scope from imported
13215 * libraries. 13357 * libraries.
13216 */ 13358 */
13217 List<Namespace> _importedNamespaces; 13359 List<Namespace> _importedNamespaces;
13218 13360
13219 /** 13361 /**
13220 * Initialize a newly created scope representing the names imported into the g iven library. 13362 * Initialize a newly created scope representing the names imported into the g iven library.
13221 * 13363 *
13222 * @param definingLibrary the element representing the library that imports th e names defined in 13364 * @param definingLibrary the element representing the library that imports th e names defined in
13223 * this scope 13365 * this scope
13224 * @param errorListener the listener that is to be informed when an error is e ncountered 13366 * @param errorListener the listener that is to be informed when an error is e ncountered
13225 */ 13367 */
13226 LibraryImportScope(LibraryElement definingLibrary, AnalysisErrorListener error Listener) { 13368 LibraryImportScope(LibraryElement definingLibrary, this.errorListener) {
13227 this._definingLibrary = definingLibrary; 13369 this._definingLibrary = definingLibrary;
13228 this._errorListener = errorListener;
13229 createImportedNamespaces(definingLibrary); 13370 createImportedNamespaces(definingLibrary);
13230 } 13371 }
13231 13372
13232 void define(Element element) { 13373 void define(Element element) {
13233 if (!Scope.isPrivateName(element.displayName)) { 13374 if (!Scope.isPrivateName(element.displayName)) {
13234 super.define(element); 13375 super.define(element);
13235 } 13376 }
13236 } 13377 }
13237 13378
13238 AnalysisErrorListener get errorListener => _errorListener;
13239
13240 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) { 13379 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) {
13241 Element foundElement = localLookup(name, referencingLibrary); 13380 Element foundElement = localLookup(name, referencingLibrary);
13242 if (foundElement != null) { 13381 if (foundElement != null) {
13243 return foundElement; 13382 return foundElement;
13244 } 13383 }
13245 for (Namespace nameSpace in _importedNamespaces) { 13384 for (Namespace nameSpace in _importedNamespaces) {
13246 Element element = nameSpace.get(name); 13385 Element element = nameSpace.get(name);
13247 if (element != null) { 13386 if (element != null) {
13248 if (foundElement == null) { 13387 if (foundElement == null) {
13249 foundElement = element; 13388 foundElement = element;
13250 } else if (foundElement != element) { 13389 } else if (foundElement != element) {
13251 foundElement = MultiplyDefinedElementImpl.fromElements(_definingLibrar y.context, foundElement, element); 13390 foundElement = MultiplyDefinedElementImpl.fromElements(_definingLibrar y.context, foundElement, element);
13252 } 13391 }
13253 } 13392 }
13254 } 13393 }
13255 if (foundElement is MultiplyDefinedElementImpl) { 13394 if (foundElement is MultiplyDefinedElementImpl) {
13256 foundElement = removeSdkElements(identifier, name, foundElement as Multipl yDefinedElementImpl); 13395 foundElement = removeSdkElements(identifier, name, foundElement as Multipl yDefinedElementImpl);
13257 } 13396 }
13258 if (foundElement is MultiplyDefinedElementImpl) { 13397 if (foundElement is MultiplyDefinedElementImpl) {
13259 String foundEltName = foundElement.displayName; 13398 String foundEltName = foundElement.displayName;
13260 List<Element> conflictingMembers = (foundElement as MultiplyDefinedElement Impl).conflictingElements; 13399 List<Element> conflictingMembers = (foundElement as MultiplyDefinedElement Impl).conflictingElements;
13261 String libName1 = getLibraryName(conflictingMembers[0], ""); 13400 String libName1 = getLibraryName(conflictingMembers[0], "");
13262 String libName2 = getLibraryName(conflictingMembers[1], ""); 13401 String libName2 = getLibraryName(conflictingMembers[1], "");
13263 _errorListener.onError(new AnalysisError.con2(getSource(identifier), ident ifier.offset, identifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltNa me, libName1, libName2])); 13402 errorListener.onError(new AnalysisError.con2(getSource(identifier), identi fier.offset, identifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltNam e, libName1, libName2]));
13264 return foundElement; 13403 return foundElement;
13265 } 13404 }
13266 if (foundElement != null) { 13405 if (foundElement != null) {
13267 defineWithoutChecking2(name, foundElement); 13406 defineWithoutChecking2(name, foundElement);
13268 } 13407 }
13269 return foundElement; 13408 return foundElement;
13270 } 13409 }
13271 13410
13272 /** 13411 /**
13273 * Create all of the namespaces associated with the libraries imported into th is library. The 13412 * Create all of the namespaces associated with the libraries imported into th is library. The
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
13322 for (Element member in conflictingMembers) { 13461 for (Element member in conflictingMembers) {
13323 if (member.library.isInSdk) { 13462 if (member.library.isInSdk) {
13324 sdkElement = member; 13463 sdkElement = member;
13325 } else { 13464 } else {
13326 conflictingMembers[to++] = member; 13465 conflictingMembers[to++] = member;
13327 } 13466 }
13328 } 13467 }
13329 if (sdkElement != null && to > 0) { 13468 if (sdkElement != null && to > 0) {
13330 String sdkLibName = getLibraryName(sdkElement, ""); 13469 String sdkLibName = getLibraryName(sdkElement, "");
13331 String otherLibName = getLibraryName(conflictingMembers[0], ""); 13470 String otherLibName = getLibraryName(conflictingMembers[0], "");
13332 _errorListener.onError(new AnalysisError.con2(getSource(identifier), ident ifier.offset, identifier.length, StaticWarningCode.CONFLICTING_DART_IMPORT, [nam e, sdkLibName, otherLibName])); 13471 errorListener.onError(new AnalysisError.con2(getSource(identifier), identi fier.offset, identifier.length, StaticWarningCode.CONFLICTING_DART_IMPORT, [name , sdkLibName, otherLibName]));
13333 } 13472 }
13334 if (to == length) { 13473 if (to == length) {
13335 return foundElement; 13474 return foundElement;
13336 } else if (to == 1) { 13475 } else if (to == 1) {
13337 return conflictingMembers[0]; 13476 return conflictingMembers[0];
13338 } else if (to == 0) { 13477 } else if (to == 0) {
13339 AnalysisEngine.instance.logger.logInformation("Multiply defined SDK elemen t: ${foundElement}"); 13478 AnalysisEngine.instance.logger.logInformation("Multiply defined SDK elemen t: ${foundElement}");
13340 return foundElement; 13479 return foundElement;
13341 } 13480 }
13342 List<Element> remaining = new List<Element>(to); 13481 List<Element> remaining = new List<Element>(to);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
13718 */ 13857 */
13719 static bool isPrivateName(String name) => name != null && name.startsWith(PRIV ATE_NAME_PREFIX); 13858 static bool isPrivateName(String name) => name != null && name.startsWith(PRIV ATE_NAME_PREFIX);
13720 13859
13721 /** 13860 /**
13722 * A table mapping names that are defined in this scope to the element represe nting the thing 13861 * A table mapping names that are defined in this scope to the element represe nting the thing
13723 * declared with that name. 13862 * declared with that name.
13724 */ 13863 */
13725 Map<String, Element> _definedNames = new Map<String, Element>(); 13864 Map<String, Element> _definedNames = new Map<String, Element>();
13726 13865
13727 /** 13866 /**
13867 * A flag indicating whether there are any names defined in this scope.
13868 */
13869 bool _hasName = false;
13870
13871 /**
13728 * Add the given element to this scope. If there is already an element with th e given name defined 13872 * Add the given element to this scope. If there is already an element with th e given name defined
13729 * in this scope, then an error will be generated and the original element wil l continue to be 13873 * in this scope, then an error will be generated and the original element wil l continue to be
13730 * mapped to the name. If there is an element with the given name in an enclos ing scope, then a 13874 * mapped to the name. If there is an element with the given name in an enclos ing scope, then a
13731 * warning will be generated but the given element will hide the inherited ele ment. 13875 * warning will be generated but the given element will hide the inherited ele ment.
13732 * 13876 *
13733 * @param element the element to be added to this scope 13877 * @param element the element to be added to this scope
13734 */ 13878 */
13735 void define(Element element) { 13879 void define(Element element) {
13736 String name = getName(element); 13880 String name = getName(element);
13737 if (name != null && !name.isEmpty) { 13881 if (name != null && !name.isEmpty) {
13738 if (_definedNames.containsKey(name)) { 13882 if (_definedNames.containsKey(name)) {
13739 errorListener.onError(getErrorForDuplicate(_definedNames[name], element) ); 13883 errorListener.onError(getErrorForDuplicate(_definedNames[name], element) );
13740 } else { 13884 } else {
13741 _definedNames[name] = element; 13885 _definedNames[name] = element;
13886 _hasName = true;
13742 } 13887 }
13743 } 13888 }
13744 } 13889 }
13745 13890
13746 /** 13891 /**
13747 * Return the scope in which this scope is lexically enclosed. 13892 * Return the scope in which this scope is lexically enclosed.
13748 * 13893 *
13749 * @return the scope in which this scope is lexically enclosed 13894 * @return the scope in which this scope is lexically enclosed
13750 */ 13895 */
13751 Scope get enclosingScope => null; 13896 Scope get enclosingScope => null;
13752 13897
13753 /** 13898 /**
13754 * Return the element with which the given identifier is associated, or `null` if the name 13899 * Return the element with which the given identifier is associated, or `null` if the name
13755 * is not defined within this scope. 13900 * is not defined within this scope.
13756 * 13901 *
13757 * @param identifier the identifier associated with the element to be returned 13902 * @param identifier the identifier associated with the element to be returned
13758 * @param referencingLibrary the library that contains the reference to the na me, used to 13903 * @param referencingLibrary the library that contains the reference to the na me, used to
13759 * implement library-level privacy 13904 * implement library-level privacy
13760 * @return the element with which the given identifier is associated 13905 * @return the element with which the given identifier is associated
13761 */ 13906 */
13762 Element lookup(Identifier identifier, LibraryElement referencingLibrary) => lo okup3(identifier, identifier.name, referencingLibrary); 13907 Element lookup(Identifier identifier, LibraryElement referencingLibrary) => lo okup3(identifier, identifier.name, referencingLibrary);
13763 13908
13764 /** 13909 /**
13765 * Add the given element to this scope without checking for duplication or hid ing. 13910 * Add the given element to this scope without checking for duplication or hid ing.
13766 * 13911 *
13767 * @param element the element to be added to this scope 13912 * @param element the element to be added to this scope
13768 */ 13913 */
13769 void defineWithoutChecking(Element element) { 13914 void defineWithoutChecking(Element element) {
13770 _definedNames[getName(element)] = element; 13915 _definedNames[getName(element)] = element;
13916 _hasName = true;
13771 } 13917 }
13772 13918
13773 /** 13919 /**
13774 * Add the given element to this scope without checking for duplication or hid ing. 13920 * Add the given element to this scope without checking for duplication or hid ing.
13775 * 13921 *
13776 * @param name the name of the element to be added 13922 * @param name the name of the element to be added
13777 * @param element the element to be added to this scope 13923 * @param element the element to be added to this scope
13778 */ 13924 */
13779 void defineWithoutChecking2(String name, Element element) { 13925 void defineWithoutChecking2(String name, Element element) {
13780 _definedNames[name] = element; 13926 _definedNames[name] = element;
13927 _hasName = true;
13781 } 13928 }
13782 13929
13783 /** 13930 /**
13784 * Return the error code to be used when reporting that a name being defined l ocally conflicts 13931 * Return the error code to be used when reporting that a name being defined l ocally conflicts
13785 * with another element of the same name in the local scope. 13932 * with another element of the same name in the local scope.
13786 * 13933 *
13787 * @param existing the first element to be declared with the conflicting name 13934 * @param existing the first element to be declared with the conflicting name
13788 * @param duplicate another element declared with the conflicting name 13935 * @param duplicate another element declared with the conflicting name
13789 * @return the error code used to report duplicate names within a scope 13936 * @return the error code used to report duplicate names within a scope
13790 */ 13937 */
(...skipping 30 matching lines...) Expand all
13821 /** 13968 /**
13822 * Return the element with which the given name is associated, or `null` if th e name is not 13969 * Return the element with which the given name is associated, or `null` if th e name is not
13823 * defined within this scope. This method only returns elements that are direc tly defined within 13970 * defined within this scope. This method only returns elements that are direc tly defined within
13824 * this scope, not elements that are defined in an enclosing scope. 13971 * this scope, not elements that are defined in an enclosing scope.
13825 * 13972 *
13826 * @param name the name associated with the element to be returned 13973 * @param name the name associated with the element to be returned
13827 * @param referencingLibrary the library that contains the reference to the na me, used to 13974 * @param referencingLibrary the library that contains the reference to the na me, used to
13828 * implement library-level privacy 13975 * implement library-level privacy
13829 * @return the element with which the given name is associated 13976 * @return the element with which the given name is associated
13830 */ 13977 */
13831 Element localLookup(String name, LibraryElement referencingLibrary) => _define dNames[name]; 13978 Element localLookup(String name, LibraryElement referencingLibrary) {
13979 if (_hasName) {
13980 return _definedNames[name];
13981 }
13982 return null;
13983 }
13832 13984
13833 /** 13985 /**
13834 * Return the element with which the given name is associated, or `null` if th e name is not 13986 * Return the element with which the given name is associated, or `null` if th e name is not
13835 * defined within this scope. 13987 * defined within this scope.
13836 * 13988 *
13837 * @param identifier the identifier node to lookup element for, used to report correct kind of a 13989 * @param identifier the identifier node to lookup element for, used to report correct kind of a
13838 * problem and associate problem with 13990 * problem and associate problem with
13839 * @param name the name associated with the element to be returned 13991 * @param name the name associated with the element to be returned
13840 * @param referencingLibrary the library that contains the reference to the na me, used to 13992 * @param referencingLibrary the library that contains the reference to the na me, used to
13841 * implement library-level privacy 13993 * implement library-level privacy
(...skipping 4873 matching lines...) Expand 10 before | Expand all | Expand 10 after
18715 static final ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = new Resol verErrorCode.con1('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_TI ME_ERROR, "Libraries that have parts must have a library directive"); 18867 static final ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART = new Resol verErrorCode.con1('MISSING_LIBRARY_DIRECTIVE_WITH_PART', 2, ErrorType.COMPILE_TI ME_ERROR, "Libraries that have parts must have a library directive");
18716 18868
18717 static final List<ResolverErrorCode> values = [ 18869 static final List<ResolverErrorCode> values = [
18718 BREAK_LABEL_ON_SWITCH_MEMBER, 18870 BREAK_LABEL_ON_SWITCH_MEMBER,
18719 CONTINUE_LABEL_ON_SWITCH, 18871 CONTINUE_LABEL_ON_SWITCH,
18720 MISSING_LIBRARY_DIRECTIVE_WITH_PART]; 18872 MISSING_LIBRARY_DIRECTIVE_WITH_PART];
18721 18873
18722 /** 18874 /**
18723 * The type of this error. 18875 * The type of this error.
18724 */ 18876 */
18725 ErrorType _type; 18877 final ErrorType type;
18726 18878
18727 /** 18879 /**
18728 * The template used to create the message to be displayed for this error. 18880 * The template used to create the message to be displayed for this error.
18729 */ 18881 */
18730 String _message; 18882 final String message;
18731 18883
18732 /** 18884 /**
18733 * The template used to create the correction to be displayed for this error, or `null` if 18885 * The template used to create the correction to be displayed for this error, or `null` if
18734 * there is no correction information for this error. 18886 * there is no correction information for this error.
18735 */ 18887 */
18736 String correction9; 18888 String correction9;
18737 18889
18738 /** 18890 /**
18739 * Initialize a newly created error code to have the given type and message. 18891 * Initialize a newly created error code to have the given type and message.
18740 * 18892 *
18741 * @param type the type of this error 18893 * @param type the type of this error
18742 * @param message the message template used to create the message to be displa yed for the error 18894 * @param message the message template used to create the message to be displa yed for the error
18743 */ 18895 */
18744 ResolverErrorCode.con1(String name, int ordinal, ErrorType type, String messag e) : super(name, ordinal) { 18896 ResolverErrorCode.con1(String name, int ordinal, this.type, this.message) : su per(name, ordinal);
18745 this._type = type;
18746 this._message = message;
18747 }
18748 18897
18749 /** 18898 /**
18750 * Initialize a newly created error code to have the given type, message and c orrection. 18899 * Initialize a newly created error code to have the given type, message and c orrection.
18751 * 18900 *
18752 * @param type the type of this error 18901 * @param type the type of this error
18753 * @param message the template used to create the message to be displayed for the error 18902 * @param message the template used to create the message to be displayed for the error
18754 * @param correction the template used to create the correction to be displaye d for the error 18903 * @param correction the template used to create the correction to be displaye d for the error
18755 */ 18904 */
18756 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag e, String correction) : super(name, ordinal) { 18905 ResolverErrorCode.con2(String name, int ordinal, this.type, this.message, Stri ng correction) : super(name, ordinal) {
18757 this._type = type;
18758 this._message = message;
18759 this.correction9 = correction; 18906 this.correction9 = correction;
18760 } 18907 }
18761 18908
18762 String get correction => correction9; 18909 String get correction => correction9;
18763 18910
18764 ErrorSeverity get errorSeverity => _type.severity; 18911 ErrorSeverity get errorSeverity => type.severity;
18765
18766 String get message => _message;
18767
18768 ErrorType get type => _type;
18769 } 18912 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/lib/src/generated/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698