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

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

Issue 23769004: java2dart improvement - use field if getter/setter are trivial. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 library engine.resolver; 3 library engine.resolver;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
8 import 'source.dart'; 8 import 'source.dart';
9 import 'error.dart'; 9 import 'error.dart';
10 import 'scanner.dart' as sc; 10 import 'scanner.dart' as sc;
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 static String _TYPE = "type"; 1021 static String _TYPE = "type";
1022 1022
1023 /** 1023 /**
1024 * The analysis context in which the element model will be built. 1024 * The analysis context in which the element model will be built.
1025 */ 1025 */
1026 InternalAnalysisContext _context; 1026 InternalAnalysisContext _context;
1027 1027
1028 /** 1028 /**
1029 * The error listener to which errors will be reported. 1029 * The error listener to which errors will be reported.
1030 */ 1030 */
1031 RecordingErrorListener _errorListener; 1031 RecordingErrorListener errorListener;
1032 1032
1033 /** 1033 /**
1034 * The modification time of the source for which an element is being built. 1034 * The modification time of the source for which an element is being built.
1035 */ 1035 */
1036 int _modificationStamp = 0; 1036 int _modificationStamp = 0;
1037 1037
1038 /** 1038 /**
1039 * The line information associated with the source for which an element is bei ng built, or 1039 * The line information associated with the source for which an element is bei ng built, or
1040 * `null` if we are not building an element. 1040 * `null` if we are not building an element.
1041 */ 1041 */
(...skipping 10 matching lines...) Expand all
1052 List<ht.XmlTagNode> _parentNodes; 1052 List<ht.XmlTagNode> _parentNodes;
1053 1053
1054 /** 1054 /**
1055 * The script elements being built. 1055 * The script elements being built.
1056 */ 1056 */
1057 List<HtmlScriptElement> _scripts; 1057 List<HtmlScriptElement> _scripts;
1058 1058
1059 /** 1059 /**
1060 * A set of the libraries that were resolved while resolving the HTML unit. 1060 * A set of the libraries that were resolved while resolving the HTML unit.
1061 */ 1061 */
1062 Set<Library> _resolvedLibraries = new Set<Library>(); 1062 final Set<Library> resolvedLibraries = new Set<Library>();
1063 1063
1064 /** 1064 /**
1065 * Initialize a newly created HTML unit builder. 1065 * Initialize a newly created HTML unit builder.
1066 * 1066 *
1067 * @param context the analysis context in which the element model will be buil t 1067 * @param context the analysis context in which the element model will be buil t
1068 */ 1068 */
1069 HtmlUnitBuilder(InternalAnalysisContext context) { 1069 HtmlUnitBuilder(InternalAnalysisContext context) {
1070 this._context = context; 1070 this._context = context;
1071 this._errorListener = new RecordingErrorListener(); 1071 this.errorListener = new RecordingErrorListener();
1072 } 1072 }
1073 1073
1074 /** 1074 /**
1075 * Build the HTML element for the given source. 1075 * Build the HTML element for the given source.
1076 * 1076 *
1077 * @param source the source describing the compilation unit 1077 * @param source the source describing the compilation unit
1078 * @return the HTML element that was built 1078 * @return the HTML element that was built
1079 * @throws AnalysisException if the analysis could not be performed 1079 * @throws AnalysisException if the analysis could not be performed
1080 */ 1080 */
1081 HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, s ource.modificationStamp, _context.parseHtmlUnit(source)); 1081 HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, s ource.modificationStamp, _context.parseHtmlUnit(source));
(...skipping 11 matching lines...) Expand all
1093 this._modificationStamp = modificationStamp2; 1093 this._modificationStamp = modificationStamp2;
1094 _lineInfo = _context.computeLineInfo(source2); 1094 _lineInfo = _context.computeLineInfo(source2);
1095 HtmlElementImpl result = new HtmlElementImpl(_context, source2.shortName); 1095 HtmlElementImpl result = new HtmlElementImpl(_context, source2.shortName);
1096 result.source = source2; 1096 result.source = source2;
1097 _htmlElement = result; 1097 _htmlElement = result;
1098 unit.accept(this); 1098 unit.accept(this);
1099 _htmlElement = null; 1099 _htmlElement = null;
1100 unit.element = result; 1100 unit.element = result;
1101 return result; 1101 return result;
1102 } 1102 }
1103
1104 /**
1105 * Return the listener to which analysis errors will be reported.
1106 *
1107 * @return the listener to which analysis errors will be reported
1108 */
1109 RecordingErrorListener get errorListener => _errorListener;
1110
1111 /**
1112 * Return an array containing information about all of the libraries that were resolved.
1113 *
1114 * @return an array containing the libraries that were resolved
1115 */
1116 Set<Library> get resolvedLibraries => _resolvedLibraries;
1117 Object visitHtmlUnit(ht.HtmlUnit node) { 1103 Object visitHtmlUnit(ht.HtmlUnit node) {
1118 _parentNodes = new List<ht.XmlTagNode>(); 1104 _parentNodes = new List<ht.XmlTagNode>();
1119 _scripts = new List<HtmlScriptElement>(); 1105 _scripts = new List<HtmlScriptElement>();
1120 try { 1106 try {
1121 node.visitChildren(this); 1107 node.visitChildren(this);
1122 _htmlElement.scripts = new List.from(_scripts); 1108 _htmlElement.scripts = new List.from(_scripts);
1123 } finally { 1109 } finally {
1124 _scripts = null; 1110 _scripts = null;
1125 _parentNodes = null; 1111 _parentNodes = null;
1126 } 1112 }
(...skipping 27 matching lines...) Expand all
1154 try { 1140 try {
1155 if (isScriptNode(node)) { 1141 if (isScriptNode(node)) {
1156 Source htmlSource = _htmlElement.source; 1142 Source htmlSource = _htmlElement.source;
1157 ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node); 1143 ht.XmlAttributeNode scriptAttribute = getScriptSourcePath(node);
1158 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribu te.text; 1144 String scriptSourcePath = scriptAttribute == null ? null : scriptAttribu te.text;
1159 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePa th == null) { 1145 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePa th == null) {
1160 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementIm pl(node); 1146 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementIm pl(node);
1161 String contents = node.content; 1147 String contents = node.content;
1162 int attributeEnd = node.attributeEnd.end; 1148 int attributeEnd = node.attributeEnd.end;
1163 LineInfo_Location location = _lineInfo.getLocation(attributeEnd); 1149 LineInfo_Location location = _lineInfo.getLocation(attributeEnd);
1164 sc.StringScanner scanner = new sc.StringScanner(htmlSource, contents, _errorListener); 1150 sc.StringScanner scanner = new sc.StringScanner(htmlSource, contents, errorListener);
1165 scanner.setSourceStart(location.lineNumber, location.columnNumber, att ributeEnd); 1151 scanner.setSourceStart(location.lineNumber, location.columnNumber, att ributeEnd);
1166 sc.Token firstToken = scanner.tokenize(); 1152 sc.Token firstToken = scanner.tokenize();
1167 List<int> lineStarts = scanner.lineStarts; 1153 List<int> lineStarts = scanner.lineStarts;
1168 Parser parser = new Parser(htmlSource, _errorListener); 1154 Parser parser = new Parser(htmlSource, errorListener);
1169 CompilationUnit unit = parser.parseCompilationUnit(firstToken); 1155 CompilationUnit unit = parser.parseCompilationUnit(firstToken);
1170 unit.lineInfo = new LineInfo(lineStarts); 1156 unit.lineInfo = new LineInfo(lineStarts);
1171 try { 1157 try {
1172 LibraryResolver resolver = new LibraryResolver(_context); 1158 LibraryResolver resolver = new LibraryResolver(_context);
1173 LibraryElementImpl library = resolver.resolveEmbeddedLibrary(htmlSou rce, _modificationStamp, unit, true) as LibraryElementImpl; 1159 LibraryElementImpl library = resolver.resolveEmbeddedLibrary(htmlSou rce, _modificationStamp, unit, true) as LibraryElementImpl;
1174 script.scriptLibrary = library; 1160 script.scriptLibrary = library;
1175 _resolvedLibraries.addAll(resolver.resolvedLibraries); 1161 resolvedLibraries.addAll(resolver.resolvedLibraries);
1176 _errorListener.addAll(resolver.errorListener); 1162 errorListener.addAll(resolver.errorListener);
1177 } on AnalysisException catch (exception) { 1163 } on AnalysisException catch (exception) {
1178 AnalysisEngine.instance.logger.logError3(exception); 1164 AnalysisEngine.instance.logger.logError3(exception);
1179 } 1165 }
1180 _scripts.add(script); 1166 _scripts.add(script);
1181 } else { 1167 } else {
1182 ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementIm pl(node); 1168 ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementIm pl(node);
1183 if (scriptSourcePath != null) { 1169 if (scriptSourcePath != null) {
1184 try { 1170 try {
1185 scriptSourcePath = Uri.encodeFull(scriptSourcePath); 1171 scriptSourcePath = Uri.encodeFull(scriptSourcePath);
1186 parseUriWithException(scriptSourcePath); 1172 parseUriWithException(scriptSourcePath);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 /** 1232 /**
1247 * Report an error with the given error code at the given location. Use the gi ven arguments to 1233 * Report an error with the given error code at the given location. Use the gi ven arguments to
1248 * compose the error message. 1234 * compose the error message.
1249 * 1235 *
1250 * @param errorCode the error code of the error to be reported 1236 * @param errorCode the error code of the error to be reported
1251 * @param offset the offset of the first character to be highlighted 1237 * @param offset the offset of the first character to be highlighted
1252 * @param length the number of characters to be highlighted 1238 * @param length the number of characters to be highlighted
1253 * @param arguments the arguments used to compose the error message 1239 * @param arguments the arguments used to compose the error message
1254 */ 1240 */
1255 void reportError(ErrorCode errorCode, int offset, int length, List<Object> arg uments) { 1241 void reportError(ErrorCode errorCode, int offset, int length, List<Object> arg uments) {
1256 _errorListener.onError(new AnalysisError.con2(_htmlElement.source, offset, l ength, errorCode, arguments)); 1242 errorListener.onError(new AnalysisError.con2(_htmlElement.source, offset, le ngth, errorCode, arguments));
1257 } 1243 }
1258 1244
1259 /** 1245 /**
1260 * Report an error with the given error code at the location of the value of t he given attribute. 1246 * Report an error with the given error code at the location of the value of t he given attribute.
1261 * Use the given arguments to compose the error message. 1247 * Use the given arguments to compose the error message.
1262 * 1248 *
1263 * @param errorCode the error code of the error to be reported 1249 * @param errorCode the error code of the error to be reported
1264 * @param offset the offset of the first character to be highlighted 1250 * @param offset the offset of the first character to be highlighted
1265 * @param length the number of characters to be highlighted 1251 * @param length the number of characters to be highlighted
1266 * @param arguments the arguments used to compose the error message 1252 * @param arguments the arguments used to compose the error message
(...skipping 3541 matching lines...) Expand 10 before | Expand all | Expand 10 after
4808 InheritanceManager _inheritanceManager; 4794 InheritanceManager _inheritanceManager;
4809 4795
4810 /** 4796 /**
4811 * The listener to which analysis errors will be reported. 4797 * The listener to which analysis errors will be reported.
4812 */ 4798 */
4813 AnalysisErrorListener _errorListener; 4799 AnalysisErrorListener _errorListener;
4814 4800
4815 /** 4801 /**
4816 * The source specifying the defining compilation unit of this library. 4802 * The source specifying the defining compilation unit of this library.
4817 */ 4803 */
4818 Source _librarySource; 4804 Source librarySource;
4819 4805
4820 /** 4806 /**
4821 * The library element representing this library. 4807 * The library element representing this library.
4822 */ 4808 */
4823 LibraryElementImpl _libraryElement; 4809 LibraryElementImpl _libraryElement;
4824 4810
4825 /** 4811 /**
4826 * A list containing all of the libraries that are imported into this library. 4812 * A list containing all of the libraries that are imported into this library.
4827 */ 4813 */
4828 List<Library> _importedLibraries = _EMPTY_ARRAY; 4814 List<Library> imports = _EMPTY_ARRAY;
4829 4815
4830 /** 4816 /**
4831 * A table mapping URI-based directive to the actual URI value. 4817 * A table mapping URI-based directive to the actual URI value.
4832 */ 4818 */
4833 Map<UriBasedDirective, String> _directiveUris = new Map<UriBasedDirective, Str ing>(); 4819 Map<UriBasedDirective, String> _directiveUris = new Map<UriBasedDirective, Str ing>();
4834 4820
4835 /** 4821 /**
4836 * A flag indicating whether this library explicitly imports core. 4822 * A flag indicating whether this library explicitly imports core.
4837 */ 4823 */
4838 bool _explicitlyImportsCore = false; 4824 bool explicitlyImportsCore = false;
4839 4825
4840 /** 4826 /**
4841 * A list containing all of the libraries that are exported from this library. 4827 * A list containing all of the libraries that are exported from this library.
4842 */ 4828 */
4843 List<Library> _exportedLibraries = _EMPTY_ARRAY; 4829 List<Library> exports = _EMPTY_ARRAY;
4844 4830
4845 /** 4831 /**
4846 * A table mapping the sources for the compilation units in this library to th eir corresponding 4832 * A table mapping the sources for the compilation units in this library to th eir corresponding
4847 * AST structures. 4833 * AST structures.
4848 */ 4834 */
4849 Map<Source, ResolvableCompilationUnit> _astMap = new Map<Source, ResolvableCom pilationUnit>(); 4835 Map<Source, ResolvableCompilationUnit> _astMap = new Map<Source, ResolvableCom pilationUnit>();
4850 4836
4851 /** 4837 /**
4852 * The library scope used when resolving elements within this library's compil ation units. 4838 * The library scope used when resolving elements within this library's compil ation units.
4853 */ 4839 */
4854 LibraryScope _libraryScope; 4840 LibraryScope _libraryScope;
4855 4841
4856 /** 4842 /**
4857 * An empty array that can be used to initialize lists of libraries. 4843 * An empty array that can be used to initialize lists of libraries.
4858 */ 4844 */
4859 static List<Library> _EMPTY_ARRAY = new List<Library>(0); 4845 static List<Library> _EMPTY_ARRAY = new List<Library>(0);
4860 4846
4861 /** 4847 /**
4862 * Initialize a newly created data holder that can maintain the data associate d with a library. 4848 * Initialize a newly created data holder that can maintain the data associate d with a library.
4863 * 4849 *
4864 * @param analysisContext the analysis context in which this library is being analyzed 4850 * @param analysisContext the analysis context in which this library is being analyzed
4865 * @param errorListener the listener to which analysis errors will be reported 4851 * @param errorListener the listener to which analysis errors will be reported
4866 * @param librarySource the source specifying the defining compilation unit of this library 4852 * @param librarySource the source specifying the defining compilation unit of this library
4867 */ 4853 */
4868 Library(InternalAnalysisContext analysisContext, AnalysisErrorListener errorLi stener, Source librarySource) { 4854 Library(InternalAnalysisContext analysisContext, AnalysisErrorListener errorLi stener, Source librarySource) {
4869 this._analysisContext = analysisContext; 4855 this._analysisContext = analysisContext;
4870 this._errorListener = errorListener; 4856 this._errorListener = errorListener;
4871 this._librarySource = librarySource; 4857 this.librarySource = librarySource;
4872 this._libraryElement = analysisContext.getLibraryElement(librarySource) as L ibraryElementImpl; 4858 this._libraryElement = analysisContext.getLibraryElement(librarySource) as L ibraryElementImpl;
4873 } 4859 }
4874 4860
4875 /** 4861 /**
4876 * Return the AST structure associated with the given source. 4862 * Return the AST structure associated with the given source.
4877 * 4863 *
4878 * @param source the source representing the compilation unit whose AST is to be returned 4864 * @param source the source representing the compilation unit whose AST is to be returned
4879 * @return the AST structure associated with the given source 4865 * @return the AST structure associated with the given source
4880 * @throws AnalysisException if an AST structure could not be created for the compilation unit 4866 * @throws AnalysisException if an AST structure could not be created for the compilation unit
4881 */ 4867 */
(...skipping 10 matching lines...) Expand all
4892 * Return an array of the [CompilationUnit]s that make up the library. The fir st unit is 4878 * Return an array of the [CompilationUnit]s that make up the library. The fir st unit is
4893 * always the defining unit. 4879 * always the defining unit.
4894 * 4880 *
4895 * @return an array of the [CompilationUnit]s that make up the library. The fi rst unit is 4881 * @return an array of the [CompilationUnit]s that make up the library. The fi rst unit is
4896 * always the defining unit 4882 * always the defining unit
4897 */ 4883 */
4898 List<CompilationUnit> get compilationUnits { 4884 List<CompilationUnit> get compilationUnits {
4899 List<CompilationUnit> unitArrayList = new List<CompilationUnit>(); 4885 List<CompilationUnit> unitArrayList = new List<CompilationUnit>();
4900 unitArrayList.add(definingCompilationUnit); 4886 unitArrayList.add(definingCompilationUnit);
4901 for (Source source in _astMap.keys.toSet()) { 4887 for (Source source in _astMap.keys.toSet()) {
4902 if (_librarySource != source) { 4888 if (librarySource != source) {
4903 unitArrayList.add(getAST(source)); 4889 unitArrayList.add(getAST(source));
4904 } 4890 }
4905 } 4891 }
4906 return new List.from(unitArrayList); 4892 return new List.from(unitArrayList);
4907 } 4893 }
4908 4894
4909 /** 4895 /**
4910 * Return a collection containing the sources for the compilation units in thi s library, including 4896 * Return a collection containing the sources for the compilation units in thi s library, including
4911 * the defining compilation unit. 4897 * the defining compilation unit.
4912 * 4898 *
4913 * @return the sources for the compilation units in this library 4899 * @return the sources for the compilation units in this library
4914 */ 4900 */
4915 Set<Source> get compilationUnitSources => _astMap.keys.toSet(); 4901 Set<Source> get compilationUnitSources => _astMap.keys.toSet();
4916 4902
4917 /** 4903 /**
4918 * Return the AST structure associated with the defining compilation unit for this library. 4904 * Return the AST structure associated with the defining compilation unit for this library.
4919 * 4905 *
4920 * @return the AST structure associated with the defining compilation unit for this library 4906 * @return the AST structure associated with the defining compilation unit for this library
4921 * @throws AnalysisException if an AST structure could not be created for the defining compilation 4907 * @throws AnalysisException if an AST structure could not be created for the defining compilation
4922 * unit 4908 * unit
4923 */ 4909 */
4924 CompilationUnit get definingCompilationUnit => getAST(_librarySource); 4910 CompilationUnit get definingCompilationUnit => getAST(librarySource);
4925
4926 /**
4927 * Return `true` if this library explicitly imports core.
4928 *
4929 * @return `true` if this library explicitly imports core
4930 */
4931 bool get explicitlyImportsCore => _explicitlyImportsCore;
4932
4933 /**
4934 * Return an array containing the libraries that are exported from this librar y.
4935 *
4936 * @return an array containing the libraries that are exported from this libra ry
4937 */
4938 List<Library> get exports => _exportedLibraries;
4939
4940 /**
4941 * Return an array containing the libraries that are imported into this librar y.
4942 *
4943 * @return an array containing the libraries that are imported into this libra ry
4944 */
4945 List<Library> get imports => _importedLibraries;
4946 4911
4947 /** 4912 /**
4948 * Return an array containing the libraries that are either imported or export ed from this 4913 * Return an array containing the libraries that are either imported or export ed from this
4949 * library. 4914 * library.
4950 * 4915 *
4951 * @return the libraries that are either imported or exported from this librar y 4916 * @return the libraries that are either imported or exported from this librar y
4952 */ 4917 */
4953 List<Library> get importsAndExports { 4918 List<Library> get importsAndExports {
4954 Set<Library> libraries = new Set<Library>(); 4919 Set<Library> libraries = new Set<Library>();
4955 for (Library library in _importedLibraries) { 4920 for (Library library in imports) {
4956 javaSetAdd(libraries, library); 4921 javaSetAdd(libraries, library);
4957 } 4922 }
4958 for (Library library in _exportedLibraries) { 4923 for (Library library in exports) {
4959 javaSetAdd(libraries, library); 4924 javaSetAdd(libraries, library);
4960 } 4925 }
4961 return new List.from(libraries); 4926 return new List.from(libraries);
4962 } 4927 }
4963 4928
4964 /** 4929 /**
4965 * Return the inheritance manager for this library. 4930 * Return the inheritance manager for this library.
4966 * 4931 *
4967 * @return the inheritance manager for this library 4932 * @return the inheritance manager for this library
4968 */ 4933 */
4969 InheritanceManager get inheritanceManager { 4934 InheritanceManager get inheritanceManager {
4970 if (_inheritanceManager == null) { 4935 if (_inheritanceManager == null) {
4971 return _inheritanceManager = new InheritanceManager(_libraryElement); 4936 return _inheritanceManager = new InheritanceManager(_libraryElement);
4972 } 4937 }
4973 return _inheritanceManager; 4938 return _inheritanceManager;
4974 } 4939 }
4975 4940
4976 /** 4941 /**
4977 * Return the library element representing this library, creating it if necess ary. 4942 * Return the library element representing this library, creating it if necess ary.
4978 * 4943 *
4979 * @return the library element representing this library 4944 * @return the library element representing this library
4980 */ 4945 */
4981 LibraryElementImpl get libraryElement { 4946 LibraryElementImpl get libraryElement {
4982 if (_libraryElement == null) { 4947 if (_libraryElement == null) {
4983 try { 4948 try {
4984 _libraryElement = _analysisContext.computeLibraryElement(_librarySource) as LibraryElementImpl; 4949 _libraryElement = _analysisContext.computeLibraryElement(librarySource) as LibraryElementImpl;
4985 } on AnalysisException catch (exception) { 4950 } on AnalysisException catch (exception) {
4986 AnalysisEngine.instance.logger.logError2("Could not compute ilbrary elem ent for ${_librarySource.fullName}", exception); 4951 AnalysisEngine.instance.logger.logError2("Could not compute ilbrary elem ent for ${librarySource.fullName}", exception);
4987 } 4952 }
4988 } 4953 }
4989 return _libraryElement; 4954 return _libraryElement;
4990 } 4955 }
4991 4956
4992 /** 4957 /**
4993 * Return the library scope used when resolving elements within this library's compilation units. 4958 * Return the library scope used when resolving elements within this library's compilation units.
4994 * 4959 *
4995 * @return the library scope used when resolving elements within this library' s compilation units 4960 * @return the library scope used when resolving elements within this library' s compilation units
4996 */ 4961 */
4997 LibraryScope get libraryScope { 4962 LibraryScope get libraryScope {
4998 if (_libraryScope == null) { 4963 if (_libraryScope == null) {
4999 _libraryScope = new LibraryScope(_libraryElement, _errorListener); 4964 _libraryScope = new LibraryScope(_libraryElement, _errorListener);
5000 } 4965 }
5001 return _libraryScope; 4966 return _libraryScope;
5002 } 4967 }
5003 4968
5004 /** 4969 /**
5005 * Return the source specifying the defining compilation unit of this library.
5006 *
5007 * @return the source specifying the defining compilation unit of this library
5008 */
5009 Source get librarySource => _librarySource;
5010
5011 /**
5012 * Return the modification time associated with the given source. 4970 * Return the modification time associated with the given source.
5013 * 4971 *
5014 * @param source the source representing the compilation unit whose modificati on time is to be 4972 * @param source the source representing the compilation unit whose modificati on time is to be
5015 * returned 4973 * returned
5016 * @return the modification time associated with the given source 4974 * @return the modification time associated with the given source
5017 * @throws AnalysisException if an AST structure could not be created for the compilation unit 4975 * @throws AnalysisException if an AST structure could not be created for the compilation unit
5018 */ 4976 */
5019 int getModificationTime(Source source) { 4977 int getModificationTime(Source source) {
5020 ResolvableCompilationUnit holder = _astMap[source]; 4978 ResolvableCompilationUnit holder = _astMap[source];
5021 if (holder == null) { 4979 if (holder == null) {
5022 holder = _analysisContext.computeResolvableCompilationUnit(source); 4980 holder = _analysisContext.computeResolvableCompilationUnit(source);
5023 _astMap[source] = holder; 4981 _astMap[source] = holder;
5024 } 4982 }
5025 return holder.modificationTime; 4983 return holder.modificationTime;
5026 } 4984 }
5027 4985
5028 /** 4986 /**
5029 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the 4987 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the
5030 * library, or `null` if the URI is not valid. If the URI is not valid, report the error. 4988 * library, or `null` if the URI is not valid. If the URI is not valid, report the error.
5031 * 4989 *
5032 * @param directive the directive which URI should be resolved 4990 * @param directive the directive which URI should be resolved
5033 * @return the result of resolving the URI against the URI of the library 4991 * @return the result of resolving the URI against the URI of the library
5034 */ 4992 */
5035 Source getSource(UriBasedDirective directive) { 4993 Source getSource(UriBasedDirective directive) {
5036 StringLiteral uriLiteral = directive.uri; 4994 StringLiteral uriLiteral = directive.uri;
5037 if (uriLiteral is StringInterpolation) { 4995 if (uriLiteral is StringInterpolation) {
5038 _errorListener.onError(new AnalysisError.con2(_librarySource, uriLiteral.o ffset, uriLiteral.length, CompileTimeErrorCode.URI_WITH_INTERPOLATION, [])); 4996 _errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.of fset, uriLiteral.length, CompileTimeErrorCode.URI_WITH_INTERPOLATION, []));
5039 return null; 4997 return null;
5040 } 4998 }
5041 String uriContent = uriLiteral.stringValue.trim(); 4999 String uriContent = uriLiteral.stringValue.trim();
5042 _directiveUris[directive] = uriContent; 5000 _directiveUris[directive] = uriContent;
5043 uriContent = Uri.encodeFull(uriContent); 5001 uriContent = Uri.encodeFull(uriContent);
5044 try { 5002 try {
5045 parseUriWithException(uriContent); 5003 parseUriWithException(uriContent);
5046 Source source = _analysisContext.sourceFactory.resolveUri(_librarySource, uriContent); 5004 Source source = _analysisContext.sourceFactory.resolveUri(librarySource, u riContent);
5047 if (source == null || !source.exists()) { 5005 if (source == null || !source.exists()) {
5048 _errorListener.onError(new AnalysisError.con2(_librarySource, uriLiteral .offset, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent ])); 5006 _errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral. offset, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent] ));
5049 } 5007 }
5050 return source; 5008 return source;
5051 } on URISyntaxException catch (exception) { 5009 } on URISyntaxException catch (exception) {
5052 _errorListener.onError(new AnalysisError.con2(_librarySource, uriLiteral.o ffset, uriLiteral.length, CompileTimeErrorCode.INVALID_URI, [uriContent])); 5010 _errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.of fset, uriLiteral.length, CompileTimeErrorCode.INVALID_URI, [uriContent]));
5053 } 5011 }
5054 return null; 5012 return null;
5055 } 5013 }
5056 5014
5057 /** 5015 /**
5058 * Returns the URI value of the given directive. 5016 * Returns the URI value of the given directive.
5059 */ 5017 */
5060 String getUri(UriBasedDirective directive) => _directiveUris[directive]; 5018 String getUri(UriBasedDirective directive) => _directiveUris[directive];
5061 5019
5062 /** 5020 /**
5063 * Set the AST structure associated with the defining compilation unit for thi s library to the 5021 * Set the AST structure associated with the defining compilation unit for thi s library to the
5064 * given AST structure. 5022 * given AST structure.
5065 * 5023 *
5066 * @param modificationStamp the modification time of the source from which the compilation unit 5024 * @param modificationStamp the modification time of the source from which the compilation unit
5067 * was created 5025 * was created
5068 * @param unit the AST structure associated with the defining compilation unit for this library 5026 * @param unit the AST structure associated with the defining compilation unit for this library
5069 */ 5027 */
5070 void setDefiningCompilationUnit(int modificationStamp, CompilationUnit unit) { 5028 void setDefiningCompilationUnit(int modificationStamp, CompilationUnit unit) {
5071 _astMap[_librarySource] = new ResolvableCompilationUnit(modificationStamp, u nit); 5029 _astMap[librarySource] = new ResolvableCompilationUnit(modificationStamp, un it);
5072 } 5030 }
5073 5031
5074 /** 5032 /**
5075 * Set whether this library explicitly imports core to match the given value.
5076 *
5077 * @param explicitlyImportsCore `true` if this library explicitly imports core
5078 */
5079 void set explicitlyImportsCore(bool explicitlyImportsCore2) {
5080 this._explicitlyImportsCore = explicitlyImportsCore2;
5081 }
5082
5083 /**
5084 * Set the libraries that are exported by this library to be those in the give n array. 5033 * Set the libraries that are exported by this library to be those in the give n array.
5085 * 5034 *
5086 * @param exportedLibraries the libraries that are exported by this library 5035 * @param exportedLibraries the libraries that are exported by this library
5087 */ 5036 */
5088 void set exportedLibraries(List<Library> exportedLibraries2) { 5037 void set exportedLibraries(List<Library> exportedLibraries2) {
5089 this._exportedLibraries = exportedLibraries2; 5038 this.exports = exportedLibraries2;
5090 } 5039 }
5091 5040
5092 /** 5041 /**
5093 * Set the libraries that are imported into this library to be those in the gi ven array. 5042 * Set the libraries that are imported into this library to be those in the gi ven array.
5094 * 5043 *
5095 * @param importedLibraries the libraries that are imported into this library 5044 * @param importedLibraries the libraries that are imported into this library
5096 */ 5045 */
5097 void set importedLibraries(List<Library> importedLibraries2) { 5046 void set importedLibraries(List<Library> importedLibraries2) {
5098 this._importedLibraries = importedLibraries2; 5047 this.imports = importedLibraries2;
5099 } 5048 }
5100 5049
5101 /** 5050 /**
5102 * Set the library element representing this library to the given library elem ent. 5051 * Set the library element representing this library to the given library elem ent.
5103 * 5052 *
5104 * @param libraryElement the library element representing this library 5053 * @param libraryElement the library element representing this library
5105 */ 5054 */
5106 void set libraryElement(LibraryElementImpl libraryElement2) { 5055 void set libraryElement(LibraryElementImpl libraryElement2) {
5107 this._libraryElement = libraryElement2; 5056 this._libraryElement = libraryElement2;
5108 if (_inheritanceManager != null) { 5057 if (_inheritanceManager != null) {
5109 _inheritanceManager.libraryElement = libraryElement2; 5058 _inheritanceManager.libraryElement = libraryElement2;
5110 } 5059 }
5111 } 5060 }
5112 String toString() => _librarySource.shortName; 5061 String toString() => librarySource.shortName;
5113 } 5062 }
5114 /** 5063 /**
5115 * Instances of the class `LibraryElementBuilder` build an element model for a s ingle library. 5064 * Instances of the class `LibraryElementBuilder` build an element model for a s ingle library.
5116 * 5065 *
5117 * @coverage dart.engine.resolver 5066 * @coverage dart.engine.resolver
5118 */ 5067 */
5119 class LibraryElementBuilder { 5068 class LibraryElementBuilder {
5120 5069
5121 /** 5070 /**
5122 * The analysis context in which the element model will be built. 5071 * The analysis context in which the element model will be built.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
5303 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent 5252 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent
5304 * libraries within a single context. 5253 * libraries within a single context.
5305 * 5254 *
5306 * @coverage dart.engine.resolver 5255 * @coverage dart.engine.resolver
5307 */ 5256 */
5308 class LibraryResolver { 5257 class LibraryResolver {
5309 5258
5310 /** 5259 /**
5311 * The analysis context in which the libraries are being analyzed. 5260 * The analysis context in which the libraries are being analyzed.
5312 */ 5261 */
5313 InternalAnalysisContext _analysisContext; 5262 InternalAnalysisContext analysisContext;
5314 5263
5315 /** 5264 /**
5316 * A flag indicating whether analysis is to generate hint results (e.g. type i nference based 5265 * A flag indicating whether analysis is to generate hint results (e.g. type i nference based
5317 * information and pub best practices). 5266 * information and pub best practices).
5318 */ 5267 */
5319 bool _enableHints = false; 5268 bool _enableHints = false;
5320 5269
5321 /** 5270 /**
5322 * The listener to which analysis errors will be reported, this error listener is either 5271 * The listener to which analysis errors will be reported, this error listener is either
5323 * references [recordingErrorListener], or it unions the passed 5272 * references [recordingErrorListener], or it unions the passed
5324 * [AnalysisErrorListener] with the [recordingErrorListener]. 5273 * [AnalysisErrorListener] with the [recordingErrorListener].
5325 */ 5274 */
5326 RecordingErrorListener _errorListener; 5275 RecordingErrorListener errorListener;
5327 5276
5328 /** 5277 /**
5329 * A source object representing the core library (dart:core). 5278 * A source object representing the core library (dart:core).
5330 */ 5279 */
5331 Source _coreLibrarySource; 5280 Source _coreLibrarySource;
5332 5281
5333 /** 5282 /**
5334 * The object representing the core library. 5283 * The object representing the core library.
5335 */ 5284 */
5336 Library _coreLibrary; 5285 Library _coreLibrary;
5337 5286
5338 /** 5287 /**
5339 * The object used to access the types from the core library. 5288 * The object used to access the types from the core library.
5340 */ 5289 */
5341 TypeProvider _typeProvider; 5290 TypeProvider _typeProvider;
5342 5291
5343 /** 5292 /**
5344 * A table mapping library sources to the information being maintained for tho se libraries. 5293 * A table mapping library sources to the information being maintained for tho se libraries.
5345 */ 5294 */
5346 Map<Source, Library> _libraryMap = new Map<Source, Library>(); 5295 Map<Source, Library> _libraryMap = new Map<Source, Library>();
5347 5296
5348 /** 5297 /**
5349 * A collection containing the libraries that are being resolved together. 5298 * A collection containing the libraries that are being resolved together.
5350 */ 5299 */
5351 Set<Library> _librariesInCycles; 5300 Set<Library> resolvedLibraries;
5352 5301
5353 /** 5302 /**
5354 * Initialize a newly created library resolver to resolve libraries within the given context. 5303 * Initialize a newly created library resolver to resolve libraries within the given context.
5355 * 5304 *
5356 * @param analysisContext the analysis context in which the library is being a nalyzed 5305 * @param analysisContext the analysis context in which the library is being a nalyzed
5357 */ 5306 */
5358 LibraryResolver(InternalAnalysisContext analysisContext) { 5307 LibraryResolver(InternalAnalysisContext analysisContext) {
5359 this._analysisContext = analysisContext; 5308 this.analysisContext = analysisContext;
5360 this._errorListener = new RecordingErrorListener(); 5309 this.errorListener = new RecordingErrorListener();
5361 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ; 5310 _coreLibrarySource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ;
5362 _enableHints = analysisContext.analysisOptions.hint; 5311 _enableHints = analysisContext.analysisOptions.hint;
5363 } 5312 }
5364 5313
5365 /** 5314 /**
5366 * Return the analysis context in which the libraries are being analyzed.
5367 *
5368 * @return the analysis context in which the libraries are being analyzed
5369 */
5370 InternalAnalysisContext get analysisContext => _analysisContext;
5371
5372 /**
5373 * Return the listener to which analysis errors will be reported.
5374 *
5375 * @return the listener to which analysis errors will be reported
5376 */
5377 RecordingErrorListener get errorListener => _errorListener;
5378
5379 /**
5380 * Return an array containing information about all of the libraries that were resolved.
5381 *
5382 * @return an array containing the libraries that were resolved
5383 */
5384 Set<Library> get resolvedLibraries => _librariesInCycles;
5385
5386 /**
5387 * Resolve the library specified by the given source in the given context. The library is assumed 5315 * Resolve the library specified by the given source in the given context. The library is assumed
5388 * to be embedded in the given source. 5316 * to be embedded in the given source.
5389 * 5317 *
5390 * @param librarySource the source specifying the defining compilation unit of the library to be 5318 * @param librarySource the source specifying the defining compilation unit of the library to be
5391 * resolved 5319 * resolved
5392 * @param modificationStamp the time stamp of the source from which the compil ation unit was 5320 * @param modificationStamp the time stamp of the source from which the compil ation unit was
5393 * created 5321 * created
5394 * @param unit the compilation unit representing the embedded library 5322 * @param unit the compilation unit representing the embedded library
5395 * @param fullAnalysis `true` if a full analysis should be performed 5323 * @param fullAnalysis `true` if a full analysis should be performed
5396 * @return the element representing the resolved library 5324 * @return the element representing the resolved library
5397 * @throws AnalysisException if the library could not be resolved for some rea son 5325 * @throws AnalysisException if the library could not be resolved for some rea son
5398 */ 5326 */
5399 LibraryElement resolveEmbeddedLibrary(Source librarySource, int modificationSt amp, CompilationUnit unit, bool fullAnalysis) { 5327 LibraryElement resolveEmbeddedLibrary(Source librarySource, int modificationSt amp, CompilationUnit unit, bool fullAnalysis) {
5400 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.LibraryResolver.resolveEmbeddedLibrary"); 5328 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.LibraryResolver.resolveEmbeddedLibrary");
5401 try { 5329 try {
5402 instrumentation.metric("fullAnalysis", fullAnalysis); 5330 instrumentation.metric("fullAnalysis", fullAnalysis);
5403 instrumentation.data3("fullName", librarySource.fullName); 5331 instrumentation.data3("fullName", librarySource.fullName);
5404 Library targetLibrary = createLibrary2(librarySource, modificationStamp, u nit); 5332 Library targetLibrary = createLibrary2(librarySource, modificationStamp, u nit);
5405 _coreLibrary = _libraryMap[_coreLibrarySource]; 5333 _coreLibrary = _libraryMap[_coreLibrarySource];
5406 if (_coreLibrary == null) { 5334 if (_coreLibrary == null) {
5407 _coreLibrary = createLibrary(_coreLibrarySource); 5335 _coreLibrary = createLibrary(_coreLibrarySource);
5408 } 5336 }
5409 instrumentation.metric3("createLibrary", "complete"); 5337 instrumentation.metric3("createLibrary", "complete");
5410 computeLibraryDependencies2(targetLibrary, unit); 5338 computeLibraryDependencies2(targetLibrary, unit);
5411 _librariesInCycles = computeLibrariesInCycles(targetLibrary); 5339 resolvedLibraries = computeLibrariesInCycles(targetLibrary);
5412 buildElementModels(); 5340 buildElementModels();
5413 instrumentation.metric3("buildElementModels", "complete"); 5341 instrumentation.metric3("buildElementModels", "complete");
5414 LibraryElement coreElement = _coreLibrary.libraryElement; 5342 LibraryElement coreElement = _coreLibrary.libraryElement;
5415 if (coreElement == null) { 5343 if (coreElement == null) {
5416 throw new AnalysisException.con1("Could not resolve dart:core"); 5344 throw new AnalysisException.con1("Could not resolve dart:core");
5417 } 5345 }
5418 buildDirectiveModels(); 5346 buildDirectiveModels();
5419 instrumentation.metric3("buildDirectiveModels", "complete"); 5347 instrumentation.metric3("buildDirectiveModels", "complete");
5420 _typeProvider = new TypeProviderImpl(coreElement); 5348 _typeProvider = new TypeProviderImpl(coreElement);
5421 buildTypeHierarchies(); 5349 buildTypeHierarchies();
(...skipping 30 matching lines...) Expand all
5452 try { 5380 try {
5453 instrumentation.metric("fullAnalysis", fullAnalysis); 5381 instrumentation.metric("fullAnalysis", fullAnalysis);
5454 instrumentation.data3("fullName", librarySource.fullName); 5382 instrumentation.data3("fullName", librarySource.fullName);
5455 Library targetLibrary = createLibrary(librarySource); 5383 Library targetLibrary = createLibrary(librarySource);
5456 _coreLibrary = _libraryMap[_coreLibrarySource]; 5384 _coreLibrary = _libraryMap[_coreLibrarySource];
5457 if (_coreLibrary == null) { 5385 if (_coreLibrary == null) {
5458 _coreLibrary = createLibrary(_coreLibrarySource); 5386 _coreLibrary = createLibrary(_coreLibrarySource);
5459 } 5387 }
5460 instrumentation.metric3("createLibrary", "complete"); 5388 instrumentation.metric3("createLibrary", "complete");
5461 computeLibraryDependencies(targetLibrary); 5389 computeLibraryDependencies(targetLibrary);
5462 _librariesInCycles = computeLibrariesInCycles(targetLibrary); 5390 resolvedLibraries = computeLibrariesInCycles(targetLibrary);
5463 buildElementModels(); 5391 buildElementModels();
5464 instrumentation.metric3("buildElementModels", "complete"); 5392 instrumentation.metric3("buildElementModels", "complete");
5465 LibraryElement coreElement = _coreLibrary.libraryElement; 5393 LibraryElement coreElement = _coreLibrary.libraryElement;
5466 if (coreElement == null) { 5394 if (coreElement == null) {
5467 throw new AnalysisException.con1("Could not resolve dart:core"); 5395 throw new AnalysisException.con1("Could not resolve dart:core");
5468 } 5396 }
5469 buildDirectiveModels(); 5397 buildDirectiveModels();
5470 instrumentation.metric3("buildDirectiveModels", "complete"); 5398 instrumentation.metric3("buildDirectiveModels", "complete");
5471 _typeProvider = new TypeProviderImpl(coreElement); 5399 _typeProvider = new TypeProviderImpl(coreElement);
5472 buildTypeHierarchies(); 5400 buildTypeHierarchies();
5473 instrumentation.metric3("buildTypeHierarchies", "complete"); 5401 instrumentation.metric3("buildTypeHierarchies", "complete");
5474 resolveReferencesAndTypes(); 5402 resolveReferencesAndTypes();
5475 instrumentation.metric3("resolveReferencesAndTypes", "complete"); 5403 instrumentation.metric3("resolveReferencesAndTypes", "complete");
5476 performConstantEvaluation(); 5404 performConstantEvaluation();
5477 instrumentation.metric3("performConstantEvaluation", "complete"); 5405 instrumentation.metric3("performConstantEvaluation", "complete");
5478 if (fullAnalysis) { 5406 if (fullAnalysis) {
5479 runAdditionalAnalyses(); 5407 runAdditionalAnalyses();
5480 instrumentation.metric3("runAdditionalAnalyses", "complete"); 5408 instrumentation.metric3("runAdditionalAnalyses", "complete");
5481 } 5409 }
5482 instrumentation.metric2("librariesInCycles", _librariesInCycles.length); 5410 instrumentation.metric2("librariesInCycles", resolvedLibraries.length);
5483 for (Library lib in _librariesInCycles) { 5411 for (Library lib in resolvedLibraries) {
5484 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size", lib.compilationUnitSources.length); 5412 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size", lib.compilationUnitSources.length);
5485 } 5413 }
5486 return targetLibrary.libraryElement; 5414 return targetLibrary.libraryElement;
5487 } finally { 5415 } finally {
5488 instrumentation.log(); 5416 instrumentation.log();
5489 } 5417 }
5490 } 5418 }
5491 5419
5492 /** 5420 /**
5493 * Add a dependency to the given map from the referencing library to the refer enced library. 5421 * Add a dependency to the given map from the referencing library to the refer enced library.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
5570 } 5498 }
5571 5499
5572 /** 5500 /**
5573 * Every library now has a corresponding [LibraryElement], so it is now possib le to resolve 5501 * Every library now has a corresponding [LibraryElement], so it is now possib le to resolve
5574 * the import and export directives. 5502 * the import and export directives.
5575 * 5503 *
5576 * @throws AnalysisException if the defining compilation unit for any of the l ibraries could not 5504 * @throws AnalysisException if the defining compilation unit for any of the l ibraries could not
5577 * be accessed 5505 * be accessed
5578 */ 5506 */
5579 void buildDirectiveModels() { 5507 void buildDirectiveModels() {
5580 for (Library library in _librariesInCycles) { 5508 for (Library library in resolvedLibraries) {
5581 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>(); 5509 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>();
5582 List<ImportElement> imports = new List<ImportElement>(); 5510 List<ImportElement> imports = new List<ImportElement>();
5583 List<ExportElement> exports = new List<ExportElement>(); 5511 List<ExportElement> exports = new List<ExportElement>();
5584 for (Directive directive in library.definingCompilationUnit.directives) { 5512 for (Directive directive in library.definingCompilationUnit.directives) {
5585 if (directive is ImportDirective) { 5513 if (directive is ImportDirective) {
5586 ImportDirective importDirective = directive as ImportDirective; 5514 ImportDirective importDirective = directive as ImportDirective;
5587 Source importedSource = library.getSource(importDirective); 5515 Source importedSource = library.getSource(importDirective);
5588 if (importedSource != null) { 5516 if (importedSource != null) {
5589 Library importedLibrary = _libraryMap[importedSource]; 5517 Library importedLibrary = _libraryMap[importedSource];
5590 if (importedLibrary != null) { 5518 if (importedLibrary != null) {
(...skipping 12 matching lines...) Expand all
5603 prefix = new PrefixElementImpl(prefixNode); 5531 prefix = new PrefixElementImpl(prefixNode);
5604 nameToPrefixMap[prefixName] = prefix; 5532 nameToPrefixMap[prefixName] = prefix;
5605 } 5533 }
5606 importElement.prefix = prefix; 5534 importElement.prefix = prefix;
5607 prefixNode.staticElement = prefix; 5535 prefixNode.staticElement = prefix;
5608 } 5536 }
5609 directive.element = importElement; 5537 directive.element = importElement;
5610 imports.add(importElement); 5538 imports.add(importElement);
5611 if (doesCompilationUnitHavePartOfDirective(importedLibrary.getAST( importedSource))) { 5539 if (doesCompilationUnitHavePartOfDirective(importedLibrary.getAST( importedSource))) {
5612 StringLiteral uriLiteral = importDirective.uri; 5540 StringLiteral uriLiteral = importDirective.uri;
5613 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()])); 5541 errorListener.onError(new AnalysisError.con2(library.librarySour ce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LIB RARY, [uriLiteral.toSource()]));
5614 } 5542 }
5615 } 5543 }
5616 } 5544 }
5617 } else if (directive is ExportDirective) { 5545 } else if (directive is ExportDirective) {
5618 ExportDirective exportDirective = directive as ExportDirective; 5546 ExportDirective exportDirective = directive as ExportDirective;
5619 Source exportedSource = library.getSource(exportDirective); 5547 Source exportedSource = library.getSource(exportDirective);
5620 if (exportedSource != null) { 5548 if (exportedSource != null) {
5621 Library exportedLibrary = _libraryMap[exportedSource]; 5549 Library exportedLibrary = _libraryMap[exportedSource];
5622 if (exportedLibrary != null) { 5550 if (exportedLibrary != null) {
5623 ExportElementImpl exportElement = new ExportElementImpl(); 5551 ExportElementImpl exportElement = new ExportElementImpl();
5624 exportElement.uri = library.getUri(exportDirective); 5552 exportElement.uri = library.getUri(exportDirective);
5625 exportElement.combinators = buildCombinators(exportDirective); 5553 exportElement.combinators = buildCombinators(exportDirective);
5626 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment; 5554 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment;
5627 if (exportedLibraryElement != null) { 5555 if (exportedLibraryElement != null) {
5628 exportElement.exportedLibrary = exportedLibraryElement; 5556 exportElement.exportedLibrary = exportedLibraryElement;
5629 } 5557 }
5630 directive.element = exportElement; 5558 directive.element = exportElement;
5631 exports.add(exportElement); 5559 exports.add(exportElement);
5632 if (doesCompilationUnitHavePartOfDirective(exportedLibrary.getAST( exportedSource))) { 5560 if (doesCompilationUnitHavePartOfDirective(exportedLibrary.getAST( exportedSource))) {
5633 StringLiteral uriLiteral = exportDirective.uri; 5561 StringLiteral uriLiteral = exportDirective.uri;
5634 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LI BRARY, [uriLiteral.toSource()])); 5562 errorListener.onError(new AnalysisError.con2(library.librarySour ce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LIB RARY, [uriLiteral.toSource()]));
5635 } 5563 }
5636 } 5564 }
5637 } 5565 }
5638 } 5566 }
5639 } 5567 }
5640 Source librarySource = library.librarySource; 5568 Source librarySource = library.librarySource;
5641 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource) { 5569 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource) {
5642 ImportElementImpl importElement = new ImportElementImpl(); 5570 ImportElementImpl importElement = new ImportElementImpl();
5643 importElement.importedLibrary = _coreLibrary.libraryElement; 5571 importElement.importedLibrary = _coreLibrary.libraryElement;
5644 importElement.synthetic = true; 5572 importElement.synthetic = true;
5645 imports.add(importElement); 5573 imports.add(importElement);
5646 } 5574 }
5647 LibraryElementImpl libraryElement = library.libraryElement; 5575 LibraryElementImpl libraryElement = library.libraryElement;
5648 libraryElement.imports = new List.from(imports); 5576 libraryElement.imports = new List.from(imports);
5649 libraryElement.exports = new List.from(exports); 5577 libraryElement.exports = new List.from(exports);
5650 } 5578 }
5651 } 5579 }
5652 5580
5653 /** 5581 /**
5654 * Build element models for all of the libraries in the current cycle. 5582 * Build element models for all of the libraries in the current cycle.
5655 * 5583 *
5656 * @throws AnalysisException if any of the element models cannot be built 5584 * @throws AnalysisException if any of the element models cannot be built
5657 */ 5585 */
5658 void buildElementModels() { 5586 void buildElementModels() {
5659 for (Library library in _librariesInCycles) { 5587 for (Library library in resolvedLibraries) {
5660 LibraryElementBuilder builder = new LibraryElementBuilder(this); 5588 LibraryElementBuilder builder = new LibraryElementBuilder(this);
5661 LibraryElementImpl libraryElement = builder.buildLibrary(library); 5589 LibraryElementImpl libraryElement = builder.buildLibrary(library);
5662 library.libraryElement = libraryElement; 5590 library.libraryElement = libraryElement;
5663 } 5591 }
5664 } 5592 }
5665 5593
5666 /** 5594 /**
5667 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 5595 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
5668 * cycle. 5596 * cycle.
5669 * 5597 *
5670 * @throws AnalysisException if any of the type hierarchies could not be resol ved 5598 * @throws AnalysisException if any of the type hierarchies could not be resol ved
5671 */ 5599 */
5672 void buildTypeHierarchies() { 5600 void buildTypeHierarchies() {
5673 for (Library library in _librariesInCycles) { 5601 for (Library library in resolvedLibraries) {
5674 for (Source source in library.compilationUnitSources) { 5602 for (Source source in library.compilationUnitSources) {
5675 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(library, sour ce, _typeProvider); 5603 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(library, sour ce, _typeProvider);
5676 library.getAST(source).accept(visitor); 5604 library.getAST(source).accept(visitor);
5677 } 5605 }
5678 } 5606 }
5679 } 5607 }
5680 5608
5681 /** 5609 /**
5682 * Compute a dependency map of libraries reachable from the given library. A d ependency map is a 5610 * Compute a dependency map of libraries reachable from the given library. A d ependency map is a
5683 * table that maps individual libraries to a list of the libraries that either import or export 5611 * table that maps individual libraries to a list of the libraries that either import or export
(...skipping 28 matching lines...) Expand all
5712 5640
5713 /** 5641 /**
5714 * Recursively traverse the libraries reachable from the given library, creati ng instances of the 5642 * Recursively traverse the libraries reachable from the given library, creati ng instances of the
5715 * class [Library] to represent them, and record the references in the library objects. 5643 * class [Library] to represent them, and record the references in the library objects.
5716 * 5644 *
5717 * @param library the library to be processed to find libraries that have not yet been traversed 5645 * @param library the library to be processed to find libraries that have not yet been traversed
5718 * @throws AnalysisException if some portion of the library graph could not be traversed 5646 * @throws AnalysisException if some portion of the library graph could not be traversed
5719 */ 5647 */
5720 void computeLibraryDependencies(Library library) { 5648 void computeLibraryDependencies(Library library) {
5721 Source librarySource = library.librarySource; 5649 Source librarySource = library.librarySource;
5722 computeLibraryDependencies3(library, _analysisContext.computeImportedLibrari es(librarySource), _analysisContext.computeExportedLibraries(librarySource)); 5650 computeLibraryDependencies3(library, analysisContext.computeImportedLibrarie s(librarySource), analysisContext.computeExportedLibraries(librarySource));
5723 } 5651 }
5724 5652
5725 /** 5653 /**
5726 * Recursively traverse the libraries reachable from the given library, creati ng instances of the 5654 * Recursively traverse the libraries reachable from the given library, creati ng instances of the
5727 * class [Library] to represent them, and record the references in the library objects. 5655 * class [Library] to represent them, and record the references in the library objects.
5728 * 5656 *
5729 * @param library the library to be processed to find libraries that have not yet been traversed 5657 * @param library the library to be processed to find libraries that have not yet been traversed
5730 * @throws AnalysisException if some portion of the library graph could not be traversed 5658 * @throws AnalysisException if some portion of the library graph could not be traversed
5731 */ 5659 */
5732 void computeLibraryDependencies2(Library library, CompilationUnit unit) { 5660 void computeLibraryDependencies2(Library library, CompilationUnit unit) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
5805 5733
5806 /** 5734 /**
5807 * Create an object to represent the information about the library defined by the compilation unit 5735 * Create an object to represent the information about the library defined by the compilation unit
5808 * with the given source. 5736 * with the given source.
5809 * 5737 *
5810 * @param librarySource the source of the library's defining compilation unit 5738 * @param librarySource the source of the library's defining compilation unit
5811 * @return the library object that was created 5739 * @return the library object that was created
5812 * @throws AnalysisException if the library source is not valid 5740 * @throws AnalysisException if the library source is not valid
5813 */ 5741 */
5814 Library createLibrary(Source librarySource) { 5742 Library createLibrary(Source librarySource) {
5815 Library library = new Library(_analysisContext, _errorListener, librarySourc e); 5743 Library library = new Library(analysisContext, errorListener, librarySource) ;
5816 library.definingCompilationUnit; 5744 library.definingCompilationUnit;
5817 _libraryMap[librarySource] = library; 5745 _libraryMap[librarySource] = library;
5818 return library; 5746 return library;
5819 } 5747 }
5820 5748
5821 /** 5749 /**
5822 * Create an object to represent the information about the library defined by the compilation unit 5750 * Create an object to represent the information about the library defined by the compilation unit
5823 * with the given source. 5751 * with the given source.
5824 * 5752 *
5825 * @param librarySource the source of the library's defining compilation unit 5753 * @param librarySource the source of the library's defining compilation unit
5826 * @param modificationStamp the modification time of the source from which the compilation unit 5754 * @param modificationStamp the modification time of the source from which the compilation unit
5827 * was created 5755 * was created
5828 * @param unit the compilation unit that defines the library 5756 * @param unit the compilation unit that defines the library
5829 * @return the library object that was created 5757 * @return the library object that was created
5830 * @throws AnalysisException if the library source is not valid 5758 * @throws AnalysisException if the library source is not valid
5831 */ 5759 */
5832 Library createLibrary2(Source librarySource, int modificationStamp, Compilatio nUnit unit) { 5760 Library createLibrary2(Source librarySource, int modificationStamp, Compilatio nUnit unit) {
5833 Library library = new Library(_analysisContext, _errorListener, librarySourc e); 5761 Library library = new Library(analysisContext, errorListener, librarySource) ;
5834 library.setDefiningCompilationUnit(modificationStamp, unit); 5762 library.setDefiningCompilationUnit(modificationStamp, unit);
5835 _libraryMap[librarySource] = library; 5763 _libraryMap[librarySource] = library;
5836 return library; 5764 return library;
5837 } 5765 }
5838 5766
5839 /** 5767 /**
5840 * Create an object to represent the information about the library defined by the compilation unit 5768 * Create an object to represent the information about the library defined by the compilation unit
5841 * with the given source. Return the library object that was created, or `null ` if the 5769 * with the given source. Return the library object that was created, or `null ` if the
5842 * source is not valid. 5770 * source is not valid.
5843 * 5771 *
5844 * @param librarySource the source of the library's defining compilation unit 5772 * @param librarySource the source of the library's defining compilation unit
5845 * @return the library object that was created 5773 * @return the library object that was created
5846 */ 5774 */
5847 Library createLibraryOrNull(Source librarySource) { 5775 Library createLibraryOrNull(Source librarySource) {
5848 if (!librarySource.exists()) { 5776 if (!librarySource.exists()) {
5849 return null; 5777 return null;
5850 } 5778 }
5851 Library library = new Library(_analysisContext, _errorListener, librarySourc e); 5779 Library library = new Library(analysisContext, errorListener, librarySource) ;
5852 _libraryMap[librarySource] = library; 5780 _libraryMap[librarySource] = library;
5853 return library; 5781 return library;
5854 } 5782 }
5855 5783
5856 /** 5784 /**
5857 * Return `true` if and only if the passed [CompilationUnit] has a part-of dir ective. 5785 * Return `true` if and only if the passed [CompilationUnit] has a part-of dir ective.
5858 * 5786 *
5859 * @param node the [CompilationUnit] to test 5787 * @param node the [CompilationUnit] to test
5860 * @return `true` if and only if the passed [CompilationUnit] has a part-of di rective 5788 * @return `true` if and only if the passed [CompilationUnit] has a part-of di rective
5861 */ 5789 */
(...skipping 20 matching lines...) Expand all
5882 identifiers[i] = names[i].name; 5810 identifiers[i] = names[i].name;
5883 } 5811 }
5884 return identifiers; 5812 return identifiers;
5885 } 5813 }
5886 5814
5887 /** 5815 /**
5888 * Compute a value for all of the constants in the libraries being analyzed. 5816 * Compute a value for all of the constants in the libraries being analyzed.
5889 */ 5817 */
5890 void performConstantEvaluation() { 5818 void performConstantEvaluation() {
5891 ConstantValueComputer computer = new ConstantValueComputer(); 5819 ConstantValueComputer computer = new ConstantValueComputer();
5892 for (Library library in _librariesInCycles) { 5820 for (Library library in resolvedLibraries) {
5893 for (Source source in library.compilationUnitSources) { 5821 for (Source source in library.compilationUnitSources) {
5894 try { 5822 try {
5895 CompilationUnit unit = library.getAST(source); 5823 CompilationUnit unit = library.getAST(source);
5896 if (unit != null) { 5824 if (unit != null) {
5897 computer.add(unit); 5825 computer.add(unit);
5898 } 5826 }
5899 } on AnalysisException catch (exception) { 5827 } on AnalysisException catch (exception) {
5900 AnalysisEngine.instance.logger.logError2("Internal Error: Could not ac cess AST for ${source.fullName} during constant evaluation", exception); 5828 AnalysisEngine.instance.logger.logError2("Internal Error: Could not ac cess AST for ${source.fullName} during constant evaluation", exception);
5901 } 5829 }
5902 } 5830 }
5903 } 5831 }
5904 computer.computeValues(); 5832 computer.computeValues();
5905 } 5833 }
5906 5834
5907 /** 5835 /**
5908 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle. 5836 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle.
5909 * 5837 *
5910 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the 5838 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the
5911 * libraries could not have their types analyzed 5839 * libraries could not have their types analyzed
5912 */ 5840 */
5913 void resolveReferencesAndTypes() { 5841 void resolveReferencesAndTypes() {
5914 for (Library library in _librariesInCycles) { 5842 for (Library library in resolvedLibraries) {
5915 resolveReferencesAndTypes2(library); 5843 resolveReferencesAndTypes2(library);
5916 } 5844 }
5917 } 5845 }
5918 5846
5919 /** 5847 /**
5920 * Resolve the identifiers and perform type analysis in the given library. 5848 * Resolve the identifiers and perform type analysis in the given library.
5921 * 5849 *
5922 * @param library the library to be resolved 5850 * @param library the library to be resolved
5923 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 5851 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
5924 * the library cannot be analyzed 5852 * the library cannot be analyzed
(...skipping 21 matching lines...) Expand all
5946 Source resolveSource(Source librarySource, UriBasedDirective directive) { 5874 Source resolveSource(Source librarySource, UriBasedDirective directive) {
5947 StringLiteral uriLiteral = directive.uri; 5875 StringLiteral uriLiteral = directive.uri;
5948 if (uriLiteral is StringInterpolation) { 5876 if (uriLiteral is StringInterpolation) {
5949 return null; 5877 return null;
5950 } 5878 }
5951 String uriContent = uriLiteral.stringValue.trim(); 5879 String uriContent = uriLiteral.stringValue.trim();
5952 if (uriContent == null || uriContent.isEmpty) { 5880 if (uriContent == null || uriContent.isEmpty) {
5953 return null; 5881 return null;
5954 } 5882 }
5955 uriContent = Uri.encodeFull(uriContent); 5883 uriContent = Uri.encodeFull(uriContent);
5956 return _analysisContext.sourceFactory.resolveUri(librarySource, uriContent); 5884 return analysisContext.sourceFactory.resolveUri(librarySource, uriContent);
5957 } 5885 }
5958 5886
5959 /** 5887 /**
5960 * Run additional analyses, such as the [ConstantVerifier] and [ErrorVerifier] 5888 * Run additional analyses, such as the [ConstantVerifier] and [ErrorVerifier]
5961 * analysis in the current cycle. 5889 * analysis in the current cycle.
5962 * 5890 *
5963 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 5891 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
5964 * the library cannot be analyzed 5892 * the library cannot be analyzed
5965 */ 5893 */
5966 void runAdditionalAnalyses() { 5894 void runAdditionalAnalyses() {
5967 for (Library library in _librariesInCycles) { 5895 for (Library library in resolvedLibraries) {
5968 runAdditionalAnalyses2(library); 5896 runAdditionalAnalyses2(library);
5969 } 5897 }
5970 } 5898 }
5971 5899
5972 /** 5900 /**
5973 * Run additional analyses, such as the [ConstantVerifier] and [ErrorVerifier] 5901 * Run additional analyses, such as the [ConstantVerifier] and [ErrorVerifier]
5974 * analysis in the given library. 5902 * analysis in the given library.
5975 * 5903 *
5976 * @param library the library to have the extra analyses processes run 5904 * @param library the library to have the extra analyses processes run
5977 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 5905 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
5978 * the library cannot be analyzed 5906 * the library cannot be analyzed
5979 */ 5907 */
5980 void runAdditionalAnalyses2(Library library) { 5908 void runAdditionalAnalyses2(Library library) {
5981 for (Source source in library.compilationUnitSources) { 5909 for (Source source in library.compilationUnitSources) {
5982 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); 5910 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
5983 CompilationUnit unit = library.getAST(source); 5911 CompilationUnit unit = library.getAST(source);
5984 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _t ypeProvider); 5912 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _t ypeProvider);
5985 unit.accept(constantVerifier); 5913 unit.accept(constantVerifier);
5986 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib raryElement, _typeProvider, library.inheritanceManager); 5914 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib raryElement, _typeProvider, library.inheritanceManager);
5987 unit.accept(errorVerifier); 5915 unit.accept(errorVerifier);
5988 } 5916 }
5989 if (_enableHints) { 5917 if (_enableHints) {
5990 HintGenerator hintGenerator = new HintGenerator(library.compilationUnits, _analysisContext, _errorListener); 5918 HintGenerator hintGenerator = new HintGenerator(library.compilationUnits, analysisContext, errorListener);
5991 hintGenerator.generateForLibrary(); 5919 hintGenerator.generateForLibrary();
5992 } 5920 }
5993 } 5921 }
5994 } 5922 }
5995 /** 5923 /**
5996 * This class is a wrapper for an [AnalysisError] which can also be queried afte r resolution 5924 * This class is a wrapper for an [AnalysisError] which can also be queried afte r resolution
5997 * to find out if the error should actually be reported. In this case, these err ors are conditional 5925 * to find out if the error should actually be reported. In this case, these err ors are conditional
5998 * on the non-existence of an `@proxy` annotation. 5926 * on the non-existence of an `@proxy` annotation.
5999 * 5927 *
6000 * If we have other conditional error codes in the future, we should have this c lass implement some 5928 * If we have other conditional error codes in the future, we should have this c lass implement some
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6038 5966
6039 /** 5967 /**
6040 * The enclosing [ClassElement], this is what will determine if the error code should, or 5968 * The enclosing [ClassElement], this is what will determine if the error code should, or
6041 * should not, be generated on the source. 5969 * should not, be generated on the source.
6042 */ 5970 */
6043 Element _enclosingElement; 5971 Element _enclosingElement;
6044 5972
6045 /** 5973 /**
6046 * The conditional analysis error. 5974 * The conditional analysis error.
6047 */ 5975 */
6048 AnalysisError _analysisError; 5976 AnalysisError analysisError;
6049 5977
6050 /** 5978 /**
6051 * Instantiate a new ProxyConditionalErrorCode with some enclosing element and the conditional 5979 * Instantiate a new ProxyConditionalErrorCode with some enclosing element and the conditional
6052 * analysis error. 5980 * analysis error.
6053 * 5981 *
6054 * @param enclosingElement the enclosing element 5982 * @param enclosingElement the enclosing element
6055 * @param analysisError the conditional analysis error 5983 * @param analysisError the conditional analysis error
6056 */ 5984 */
6057 ProxyConditionalAnalysisError(Element enclosingElement, AnalysisError analysis Error) { 5985 ProxyConditionalAnalysisError(Element enclosingElement, AnalysisError analysis Error) {
6058 this._enclosingElement = enclosingElement; 5986 this._enclosingElement = enclosingElement;
6059 this._analysisError = analysisError; 5987 this.analysisError = analysisError;
6060 } 5988 }
6061 5989
6062 /** 5990 /**
6063 * Return the analysis error.
6064 *
6065 * @return the analysis error
6066 */
6067 AnalysisError get analysisError => _analysisError;
6068
6069 /**
6070 * Return `true` iff the enclosing class has the proxy annotation. 5991 * Return `true` iff the enclosing class has the proxy annotation.
6071 * 5992 *
6072 * @return `true` iff the enclosing class has the proxy annotation 5993 * @return `true` iff the enclosing class has the proxy annotation
6073 */ 5994 */
6074 bool shouldIncludeErrorCode() => !classHasProxyAnnotation(_enclosingElement); 5995 bool shouldIncludeErrorCode() => !classHasProxyAnnotation(_enclosingElement);
6075 } 5996 }
6076 /** 5997 /**
6077 * Instances of the class `ResolverVisitor` are used to resolve the nodes within a single 5998 * Instances of the class `ResolverVisitor` are used to resolve the nodes within a single
6078 * compilation unit. 5999 * compilation unit.
6079 * 6000 *
(...skipping 13 matching lines...) Expand all
6093 6014
6094 /** 6015 /**
6095 * The object used to compute the type associated with the current node. 6016 * The object used to compute the type associated with the current node.
6096 */ 6017 */
6097 StaticTypeAnalyzer _typeAnalyzer; 6018 StaticTypeAnalyzer _typeAnalyzer;
6098 6019
6099 /** 6020 /**
6100 * The class element representing the class containing the current node, or `n ull` if the 6021 * The class element representing the class containing the current node, or `n ull` if the
6101 * current node is not contained in a class. 6022 * current node is not contained in a class.
6102 */ 6023 */
6103 ClassElement _enclosingClass = null; 6024 ClassElement enclosingClass = null;
6104 6025
6105 /** 6026 /**
6106 * The element representing the function containing the current node, or `null ` if the 6027 * The element representing the function containing the current node, or `null ` if the
6107 * current node is not contained in a function. 6028 * current node is not contained in a function.
6108 */ 6029 */
6109 ExecutableElement _enclosingFunction = null; 6030 ExecutableElement enclosingFunction = null;
6110 6031
6111 /** 6032 /**
6112 * The object keeping track of which elements have had their types overridden. 6033 * The object keeping track of which elements have had their types overridden.
6113 */ 6034 */
6114 TypeOverrideManager _overrideManager = new TypeOverrideManager(); 6035 final TypeOverrideManager overrideManager = new TypeOverrideManager();
6115 6036
6116 /** 6037 /**
6117 * Proxy conditional error codes. 6038 * Proxy conditional error codes.
6118 */ 6039 */
6119 List<ProxyConditionalAnalysisError> _proxyConditionalAnalysisErrors = new List <ProxyConditionalAnalysisError>(); 6040 final List<ProxyConditionalAnalysisError> proxyConditionalAnalysisErrors = new List<ProxyConditionalAnalysisError>();
6120 6041
6121 /** 6042 /**
6122 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 6043 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
6123 * 6044 *
6124 * @param library the library containing the compilation unit being resolved 6045 * @param library the library containing the compilation unit being resolved
6125 * @param source the source representing the compilation unit being visited 6046 * @param source the source representing the compilation unit being visited
6126 * @param typeProvider the object used to access the types from the core libra ry 6047 * @param typeProvider the object used to access the types from the core libra ry
6127 */ 6048 */
6128 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider ) : super.con1(library, source, typeProvider) { 6049 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider ) : super.con1(library, source, typeProvider) {
6129 this._inheritanceManager = library.inheritanceManager; 6050 this._inheritanceManager = library.inheritanceManager;
6130 this._elementResolver = new ElementResolver(this); 6051 this._elementResolver = new ElementResolver(this);
6131 this._typeAnalyzer = new StaticTypeAnalyzer(this); 6052 this._typeAnalyzer = new StaticTypeAnalyzer(this);
6132 } 6053 }
6133 6054
6134 /** 6055 /**
6135 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 6056 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
6136 * 6057 *
6137 * @param definingLibrary the element for the library containing the compilati on unit being 6058 * @param definingLibrary the element for the library containing the compilati on unit being
6138 * visited 6059 * visited
6139 * @param source the source representing the compilation unit being visited 6060 * @param source the source representing the compilation unit being visited
6140 * @param typeProvider the object used to access the types from the core libra ry 6061 * @param typeProvider the object used to access the types from the core libra ry
6141 * @param errorListener the error listener that will be informed of any errors that are found 6062 * @param errorListener the error listener that will be informed of any errors that are found
6142 * during resolution 6063 * during resolution
6143 */ 6064 */
6144 ResolverVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvid er typeProvider, InheritanceManager inheritanceManager, AnalysisErrorListener er rorListener) : super.con2(definingLibrary, source, typeProvider, errorListener) { 6065 ResolverVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvid er typeProvider, InheritanceManager inheritanceManager, AnalysisErrorListener er rorListener) : super.con2(definingLibrary, source, typeProvider, errorListener) {
6145 this._inheritanceManager = inheritanceManager; 6066 this._inheritanceManager = inheritanceManager;
6146 this._elementResolver = new ElementResolver(this); 6067 this._elementResolver = new ElementResolver(this);
6147 this._typeAnalyzer = new StaticTypeAnalyzer(this); 6068 this._typeAnalyzer = new StaticTypeAnalyzer(this);
6148 } 6069 }
6149
6150 /**
6151 * Return the object keeping track of which elements have had their types over ridden.
6152 *
6153 * @return the object keeping track of which elements have had their types ove rridden
6154 */
6155 TypeOverrideManager get overrideManager => _overrideManager;
6156 List<ProxyConditionalAnalysisError> get proxyConditionalAnalysisErrors => _pro xyConditionalAnalysisErrors;
6157 Object visitAsExpression(AsExpression node) { 6070 Object visitAsExpression(AsExpression node) {
6158 super.visitAsExpression(node); 6071 super.visitAsExpression(node);
6159 override(node.expression, node.type.type); 6072 override(node.expression, node.type.type);
6160 return null; 6073 return null;
6161 } 6074 }
6162 Object visitAssertStatement(AssertStatement node) { 6075 Object visitAssertStatement(AssertStatement node) {
6163 super.visitAssertStatement(node); 6076 super.visitAssertStatement(node);
6164 propagateTrueState(node.condition); 6077 propagateTrueState(node.condition);
6165 return null; 6078 return null;
6166 } 6079 }
6167 Object visitBinaryExpression(BinaryExpression node) { 6080 Object visitBinaryExpression(BinaryExpression node) {
6168 sc.TokenType operatorType = node.operator.type; 6081 sc.TokenType operatorType = node.operator.type;
6169 Expression leftOperand = node.leftOperand; 6082 Expression leftOperand = node.leftOperand;
6170 Expression rightOperand = node.rightOperand; 6083 Expression rightOperand = node.rightOperand;
6171 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) { 6084 if (identical(operatorType, sc.TokenType.AMPERSAND_AMPERSAND)) {
6172 safelyVisit(leftOperand); 6085 safelyVisit(leftOperand);
6173 if (rightOperand != null) { 6086 if (rightOperand != null) {
6174 try { 6087 try {
6175 _overrideManager.enterScope(); 6088 overrideManager.enterScope();
6176 propagateTrueState(leftOperand); 6089 propagateTrueState(leftOperand);
6177 rightOperand.accept(this); 6090 rightOperand.accept(this);
6178 } finally { 6091 } finally {
6179 _overrideManager.exitScope(); 6092 overrideManager.exitScope();
6180 } 6093 }
6181 } 6094 }
6182 } else if (identical(operatorType, sc.TokenType.BAR_BAR)) { 6095 } else if (identical(operatorType, sc.TokenType.BAR_BAR)) {
6183 safelyVisit(leftOperand); 6096 safelyVisit(leftOperand);
6184 if (rightOperand != null) { 6097 if (rightOperand != null) {
6185 try { 6098 try {
6186 _overrideManager.enterScope(); 6099 overrideManager.enterScope();
6187 propagateFalseState(leftOperand); 6100 propagateFalseState(leftOperand);
6188 rightOperand.accept(this); 6101 rightOperand.accept(this);
6189 } finally { 6102 } finally {
6190 _overrideManager.exitScope(); 6103 overrideManager.exitScope();
6191 } 6104 }
6192 } 6105 }
6193 } else { 6106 } else {
6194 safelyVisit(leftOperand); 6107 safelyVisit(leftOperand);
6195 safelyVisit(rightOperand); 6108 safelyVisit(rightOperand);
6196 } 6109 }
6197 node.accept(_elementResolver); 6110 node.accept(_elementResolver);
6198 node.accept(_typeAnalyzer); 6111 node.accept(_typeAnalyzer);
6199 return null; 6112 return null;
6200 } 6113 }
6201 Object visitBreakStatement(BreakStatement node) { 6114 Object visitBreakStatement(BreakStatement node) {
6202 node.accept(_elementResolver); 6115 node.accept(_elementResolver);
6203 node.accept(_typeAnalyzer); 6116 node.accept(_typeAnalyzer);
6204 return null; 6117 return null;
6205 } 6118 }
6206 Object visitClassDeclaration(ClassDeclaration node) { 6119 Object visitClassDeclaration(ClassDeclaration node) {
6207 ClassElement outerType = _enclosingClass; 6120 ClassElement outerType = enclosingClass;
6208 try { 6121 try {
6209 _enclosingClass = node.element; 6122 enclosingClass = node.element;
6210 _typeAnalyzer.thisType = _enclosingClass == null ? null : _enclosingClass. type; 6123 _typeAnalyzer.thisType = enclosingClass == null ? null : enclosingClass.ty pe;
6211 super.visitClassDeclaration(node); 6124 super.visitClassDeclaration(node);
6212 } finally { 6125 } finally {
6213 _typeAnalyzer.thisType = outerType == null ? null : outerType.type; 6126 _typeAnalyzer.thisType = outerType == null ? null : outerType.type;
6214 _enclosingClass = outerType; 6127 enclosingClass = outerType;
6215 } 6128 }
6216 return null; 6129 return null;
6217 } 6130 }
6218 Object visitCommentReference(CommentReference node) { 6131 Object visitCommentReference(CommentReference node) {
6219 node.accept(_elementResolver); 6132 node.accept(_elementResolver);
6220 node.accept(_typeAnalyzer); 6133 node.accept(_typeAnalyzer);
6221 return null; 6134 return null;
6222 } 6135 }
6223 Object visitCompilationUnit(CompilationUnit node) { 6136 Object visitCompilationUnit(CompilationUnit node) {
6224 try { 6137 try {
6225 _overrideManager.enterScope(); 6138 overrideManager.enterScope();
6226 for (Directive directive in node.directives) { 6139 for (Directive directive in node.directives) {
6227 directive.accept(this); 6140 directive.accept(this);
6228 } 6141 }
6229 List<CompilationUnitMember> classes = new List<CompilationUnitMember>(); 6142 List<CompilationUnitMember> classes = new List<CompilationUnitMember>();
6230 for (CompilationUnitMember declaration in node.declarations) { 6143 for (CompilationUnitMember declaration in node.declarations) {
6231 if (declaration is ClassDeclaration) { 6144 if (declaration is ClassDeclaration) {
6232 classes.add(declaration); 6145 classes.add(declaration);
6233 } else { 6146 } else {
6234 declaration.accept(this); 6147 declaration.accept(this);
6235 } 6148 }
6236 } 6149 }
6237 for (CompilationUnitMember declaration in classes) { 6150 for (CompilationUnitMember declaration in classes) {
6238 declaration.accept(this); 6151 declaration.accept(this);
6239 } 6152 }
6240 } finally { 6153 } finally {
6241 _overrideManager.exitScope(); 6154 overrideManager.exitScope();
6242 } 6155 }
6243 node.accept(_elementResolver); 6156 node.accept(_elementResolver);
6244 node.accept(_typeAnalyzer); 6157 node.accept(_typeAnalyzer);
6245 return null; 6158 return null;
6246 } 6159 }
6247 Object visitConditionalExpression(ConditionalExpression node) { 6160 Object visitConditionalExpression(ConditionalExpression node) {
6248 Expression condition = node.condition; 6161 Expression condition = node.condition;
6249 safelyVisit(condition); 6162 safelyVisit(condition);
6250 Expression thenExpression = node.thenExpression; 6163 Expression thenExpression = node.thenExpression;
6251 if (thenExpression != null) { 6164 if (thenExpression != null) {
6252 try { 6165 try {
6253 _overrideManager.enterScope(); 6166 overrideManager.enterScope();
6254 propagateTrueState(condition); 6167 propagateTrueState(condition);
6255 thenExpression.accept(this); 6168 thenExpression.accept(this);
6256 } finally { 6169 } finally {
6257 _overrideManager.exitScope(); 6170 overrideManager.exitScope();
6258 } 6171 }
6259 } 6172 }
6260 Expression elseExpression = node.elseExpression; 6173 Expression elseExpression = node.elseExpression;
6261 if (elseExpression != null) { 6174 if (elseExpression != null) {
6262 try { 6175 try {
6263 _overrideManager.enterScope(); 6176 overrideManager.enterScope();
6264 propagateFalseState(condition); 6177 propagateFalseState(condition);
6265 elseExpression.accept(this); 6178 elseExpression.accept(this);
6266 } finally { 6179 } finally {
6267 _overrideManager.exitScope(); 6180 overrideManager.exitScope();
6268 } 6181 }
6269 } 6182 }
6270 node.accept(_elementResolver); 6183 node.accept(_elementResolver);
6271 node.accept(_typeAnalyzer); 6184 node.accept(_typeAnalyzer);
6272 bool thenIsAbrupt = isAbruptTermination(thenExpression); 6185 bool thenIsAbrupt = isAbruptTermination(thenExpression);
6273 bool elseIsAbrupt = isAbruptTermination(elseExpression); 6186 bool elseIsAbrupt = isAbruptTermination(elseExpression);
6274 if (elseIsAbrupt && !thenIsAbrupt) { 6187 if (elseIsAbrupt && !thenIsAbrupt) {
6275 propagateTrueState(condition); 6188 propagateTrueState(condition);
6276 propagateState(thenExpression); 6189 propagateState(thenExpression);
6277 } else if (thenIsAbrupt && !elseIsAbrupt) { 6190 } else if (thenIsAbrupt && !elseIsAbrupt) {
6278 propagateFalseState(condition); 6191 propagateFalseState(condition);
6279 propagateState(elseExpression); 6192 propagateState(elseExpression);
6280 } 6193 }
6281 return null; 6194 return null;
6282 } 6195 }
6283 Object visitConstructorDeclaration(ConstructorDeclaration node) { 6196 Object visitConstructorDeclaration(ConstructorDeclaration node) {
6284 ExecutableElement outerFunction = _enclosingFunction; 6197 ExecutableElement outerFunction = enclosingFunction;
6285 try { 6198 try {
6286 _enclosingFunction = node.element; 6199 enclosingFunction = node.element;
6287 super.visitConstructorDeclaration(node); 6200 super.visitConstructorDeclaration(node);
6288 } finally { 6201 } finally {
6289 _enclosingFunction = outerFunction; 6202 enclosingFunction = outerFunction;
6290 } 6203 }
6291 return null; 6204 return null;
6292 } 6205 }
6293 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { 6206 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
6294 safelyVisit(node.expression); 6207 safelyVisit(node.expression);
6295 node.accept(_elementResolver); 6208 node.accept(_elementResolver);
6296 node.accept(_typeAnalyzer); 6209 node.accept(_typeAnalyzer);
6297 return null; 6210 return null;
6298 } 6211 }
6299 Object visitConstructorName(ConstructorName node) { 6212 Object visitConstructorName(ConstructorName node) {
6300 node.accept(_elementResolver); 6213 node.accept(_elementResolver);
6301 node.accept(_typeAnalyzer); 6214 node.accept(_typeAnalyzer);
6302 return null; 6215 return null;
6303 } 6216 }
6304 Object visitContinueStatement(ContinueStatement node) { 6217 Object visitContinueStatement(ContinueStatement node) {
6305 node.accept(_elementResolver); 6218 node.accept(_elementResolver);
6306 node.accept(_typeAnalyzer); 6219 node.accept(_typeAnalyzer);
6307 return null; 6220 return null;
6308 } 6221 }
6309 Object visitDoStatement(DoStatement node) { 6222 Object visitDoStatement(DoStatement node) {
6310 try { 6223 try {
6311 _overrideManager.enterScope(); 6224 overrideManager.enterScope();
6312 super.visitDoStatement(node); 6225 super.visitDoStatement(node);
6313 } finally { 6226 } finally {
6314 _overrideManager.exitScope(); 6227 overrideManager.exitScope();
6315 } 6228 }
6316 return null; 6229 return null;
6317 } 6230 }
6318 Object visitFieldDeclaration(FieldDeclaration node) { 6231 Object visitFieldDeclaration(FieldDeclaration node) {
6319 try { 6232 try {
6320 _overrideManager.enterScope(); 6233 overrideManager.enterScope();
6321 super.visitFieldDeclaration(node); 6234 super.visitFieldDeclaration(node);
6322 } finally { 6235 } finally {
6323 Map<Element, Type2> overrides = _overrideManager.captureOverrides(node.fie lds); 6236 Map<Element, Type2> overrides = overrideManager.captureOverrides(node.fiel ds);
6324 _overrideManager.exitScope(); 6237 overrideManager.exitScope();
6325 _overrideManager.applyOverrides(overrides); 6238 overrideManager.applyOverrides(overrides);
6326 } 6239 }
6327 return null; 6240 return null;
6328 } 6241 }
6329 Object visitForEachStatement(ForEachStatement node) { 6242 Object visitForEachStatement(ForEachStatement node) {
6330 try { 6243 try {
6331 _overrideManager.enterScope(); 6244 overrideManager.enterScope();
6332 super.visitForEachStatement(node); 6245 super.visitForEachStatement(node);
6333 } finally { 6246 } finally {
6334 _overrideManager.exitScope(); 6247 overrideManager.exitScope();
6335 } 6248 }
6336 return null; 6249 return null;
6337 } 6250 }
6338 Object visitForStatement(ForStatement node) { 6251 Object visitForStatement(ForStatement node) {
6339 try { 6252 try {
6340 _overrideManager.enterScope(); 6253 overrideManager.enterScope();
6341 super.visitForStatement(node); 6254 super.visitForStatement(node);
6342 } finally { 6255 } finally {
6343 _overrideManager.exitScope(); 6256 overrideManager.exitScope();
6344 } 6257 }
6345 return null; 6258 return null;
6346 } 6259 }
6347 Object visitFunctionBody(FunctionBody node) { 6260 Object visitFunctionBody(FunctionBody node) {
6348 try { 6261 try {
6349 _overrideManager.enterScope(); 6262 overrideManager.enterScope();
6350 super.visitFunctionBody(node); 6263 super.visitFunctionBody(node);
6351 } finally { 6264 } finally {
6352 _overrideManager.exitScope(); 6265 overrideManager.exitScope();
6353 } 6266 }
6354 return null; 6267 return null;
6355 } 6268 }
6356 Object visitFunctionDeclaration(FunctionDeclaration node) { 6269 Object visitFunctionDeclaration(FunctionDeclaration node) {
6357 ExecutableElement outerFunction = _enclosingFunction; 6270 ExecutableElement outerFunction = enclosingFunction;
6358 try { 6271 try {
6359 SimpleIdentifier functionName = node.name; 6272 SimpleIdentifier functionName = node.name;
6360 _enclosingFunction = functionName.staticElement as ExecutableElement; 6273 enclosingFunction = functionName.staticElement as ExecutableElement;
6361 super.visitFunctionDeclaration(node); 6274 super.visitFunctionDeclaration(node);
6362 } finally { 6275 } finally {
6363 _enclosingFunction = outerFunction; 6276 enclosingFunction = outerFunction;
6364 } 6277 }
6365 return null; 6278 return null;
6366 } 6279 }
6367 Object visitFunctionExpression(FunctionExpression node) { 6280 Object visitFunctionExpression(FunctionExpression node) {
6368 ExecutableElement outerFunction = _enclosingFunction; 6281 ExecutableElement outerFunction = enclosingFunction;
6369 try { 6282 try {
6370 _enclosingFunction = node.element; 6283 enclosingFunction = node.element;
6371 _overrideManager.enterScope(); 6284 overrideManager.enterScope();
6372 super.visitFunctionExpression(node); 6285 super.visitFunctionExpression(node);
6373 } finally { 6286 } finally {
6374 _overrideManager.exitScope(); 6287 overrideManager.exitScope();
6375 _enclosingFunction = outerFunction; 6288 enclosingFunction = outerFunction;
6376 } 6289 }
6377 return null; 6290 return null;
6378 } 6291 }
6379 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 6292 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
6380 safelyVisit(node.function); 6293 safelyVisit(node.function);
6381 node.accept(_elementResolver); 6294 node.accept(_elementResolver);
6382 inferFunctionExpressionsParametersTypes(node.argumentList); 6295 inferFunctionExpressionsParametersTypes(node.argumentList);
6383 safelyVisit(node.argumentList); 6296 safelyVisit(node.argumentList);
6384 node.accept(_typeAnalyzer); 6297 node.accept(_typeAnalyzer);
6385 return null; 6298 return null;
6386 } 6299 }
6387 Object visitHideCombinator(HideCombinator node) => null; 6300 Object visitHideCombinator(HideCombinator node) => null;
6388 Object visitIfStatement(IfStatement node) { 6301 Object visitIfStatement(IfStatement node) {
6389 Expression condition = node.condition; 6302 Expression condition = node.condition;
6390 safelyVisit(condition); 6303 safelyVisit(condition);
6391 Map<Element, Type2> thenOverrides = null; 6304 Map<Element, Type2> thenOverrides = null;
6392 Statement thenStatement = node.thenStatement; 6305 Statement thenStatement = node.thenStatement;
6393 if (thenStatement != null) { 6306 if (thenStatement != null) {
6394 try { 6307 try {
6395 _overrideManager.enterScope(); 6308 overrideManager.enterScope();
6396 propagateTrueState(condition); 6309 propagateTrueState(condition);
6397 visitStatementInScope(thenStatement); 6310 visitStatementInScope(thenStatement);
6398 } finally { 6311 } finally {
6399 thenOverrides = _overrideManager.captureLocalOverrides(); 6312 thenOverrides = overrideManager.captureLocalOverrides();
6400 _overrideManager.exitScope(); 6313 overrideManager.exitScope();
6401 } 6314 }
6402 } 6315 }
6403 Map<Element, Type2> elseOverrides = null; 6316 Map<Element, Type2> elseOverrides = null;
6404 Statement elseStatement = node.elseStatement; 6317 Statement elseStatement = node.elseStatement;
6405 if (elseStatement != null) { 6318 if (elseStatement != null) {
6406 try { 6319 try {
6407 _overrideManager.enterScope(); 6320 overrideManager.enterScope();
6408 propagateFalseState(condition); 6321 propagateFalseState(condition);
6409 visitStatementInScope(elseStatement); 6322 visitStatementInScope(elseStatement);
6410 } finally { 6323 } finally {
6411 elseOverrides = _overrideManager.captureLocalOverrides(); 6324 elseOverrides = overrideManager.captureLocalOverrides();
6412 _overrideManager.exitScope(); 6325 overrideManager.exitScope();
6413 } 6326 }
6414 } 6327 }
6415 node.accept(_elementResolver); 6328 node.accept(_elementResolver);
6416 node.accept(_typeAnalyzer); 6329 node.accept(_typeAnalyzer);
6417 bool thenIsAbrupt = isAbruptTermination2(thenStatement); 6330 bool thenIsAbrupt = isAbruptTermination2(thenStatement);
6418 bool elseIsAbrupt = isAbruptTermination2(elseStatement); 6331 bool elseIsAbrupt = isAbruptTermination2(elseStatement);
6419 if (elseIsAbrupt && !thenIsAbrupt) { 6332 if (elseIsAbrupt && !thenIsAbrupt) {
6420 propagateTrueState(condition); 6333 propagateTrueState(condition);
6421 if (thenOverrides != null) { 6334 if (thenOverrides != null) {
6422 _overrideManager.applyOverrides(thenOverrides); 6335 overrideManager.applyOverrides(thenOverrides);
6423 } 6336 }
6424 } else if (thenIsAbrupt && !elseIsAbrupt) { 6337 } else if (thenIsAbrupt && !elseIsAbrupt) {
6425 propagateFalseState(condition); 6338 propagateFalseState(condition);
6426 if (elseOverrides != null) { 6339 if (elseOverrides != null) {
6427 _overrideManager.applyOverrides(elseOverrides); 6340 overrideManager.applyOverrides(elseOverrides);
6428 } 6341 }
6429 } 6342 }
6430 return null; 6343 return null;
6431 } 6344 }
6432 Object visitLabel(Label node) => null; 6345 Object visitLabel(Label node) => null;
6433 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 6346 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
6434 Object visitMethodDeclaration(MethodDeclaration node) { 6347 Object visitMethodDeclaration(MethodDeclaration node) {
6435 ExecutableElement outerFunction = _enclosingFunction; 6348 ExecutableElement outerFunction = enclosingFunction;
6436 try { 6349 try {
6437 _enclosingFunction = node.element; 6350 enclosingFunction = node.element;
6438 super.visitMethodDeclaration(node); 6351 super.visitMethodDeclaration(node);
6439 } finally { 6352 } finally {
6440 _enclosingFunction = outerFunction; 6353 enclosingFunction = outerFunction;
6441 } 6354 }
6442 return null; 6355 return null;
6443 } 6356 }
6444 Object visitMethodInvocation(MethodInvocation node) { 6357 Object visitMethodInvocation(MethodInvocation node) {
6445 safelyVisit(node.target); 6358 safelyVisit(node.target);
6446 node.accept(_elementResolver); 6359 node.accept(_elementResolver);
6447 inferFunctionExpressionsParametersTypes(node.argumentList); 6360 inferFunctionExpressionsParametersTypes(node.argumentList);
6448 safelyVisit(node.argumentList); 6361 safelyVisit(node.argumentList);
6449 node.accept(_typeAnalyzer); 6362 node.accept(_typeAnalyzer);
6450 return null; 6363 return null;
(...skipping 24 matching lines...) Expand all
6475 } 6388 }
6476 Object visitShowCombinator(ShowCombinator node) => null; 6389 Object visitShowCombinator(ShowCombinator node) => null;
6477 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 6390 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
6478 safelyVisit(node.argumentList); 6391 safelyVisit(node.argumentList);
6479 node.accept(_elementResolver); 6392 node.accept(_elementResolver);
6480 node.accept(_typeAnalyzer); 6393 node.accept(_typeAnalyzer);
6481 return null; 6394 return null;
6482 } 6395 }
6483 Object visitSwitchCase(SwitchCase node) { 6396 Object visitSwitchCase(SwitchCase node) {
6484 try { 6397 try {
6485 _overrideManager.enterScope(); 6398 overrideManager.enterScope();
6486 super.visitSwitchCase(node); 6399 super.visitSwitchCase(node);
6487 } finally { 6400 } finally {
6488 _overrideManager.exitScope(); 6401 overrideManager.exitScope();
6489 } 6402 }
6490 return null; 6403 return null;
6491 } 6404 }
6492 Object visitSwitchDefault(SwitchDefault node) { 6405 Object visitSwitchDefault(SwitchDefault node) {
6493 try { 6406 try {
6494 _overrideManager.enterScope(); 6407 overrideManager.enterScope();
6495 super.visitSwitchDefault(node); 6408 super.visitSwitchDefault(node);
6496 } finally { 6409 } finally {
6497 _overrideManager.exitScope(); 6410 overrideManager.exitScope();
6498 } 6411 }
6499 return null; 6412 return null;
6500 } 6413 }
6501 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 6414 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
6502 try { 6415 try {
6503 _overrideManager.enterScope(); 6416 overrideManager.enterScope();
6504 super.visitTopLevelVariableDeclaration(node); 6417 super.visitTopLevelVariableDeclaration(node);
6505 } finally { 6418 } finally {
6506 Map<Element, Type2> overrides = _overrideManager.captureOverrides(node.var iables); 6419 Map<Element, Type2> overrides = overrideManager.captureOverrides(node.vari ables);
6507 _overrideManager.exitScope(); 6420 overrideManager.exitScope();
6508 _overrideManager.applyOverrides(overrides); 6421 overrideManager.applyOverrides(overrides);
6509 } 6422 }
6510 return null; 6423 return null;
6511 } 6424 }
6512 Object visitTypeName(TypeName node) => null; 6425 Object visitTypeName(TypeName node) => null;
6513 Object visitWhileStatement(WhileStatement node) { 6426 Object visitWhileStatement(WhileStatement node) {
6514 Expression condition = node.condition; 6427 Expression condition = node.condition;
6515 safelyVisit(condition); 6428 safelyVisit(condition);
6516 Statement body = node.body; 6429 Statement body = node.body;
6517 if (body != null) { 6430 if (body != null) {
6518 try { 6431 try {
6519 _overrideManager.enterScope(); 6432 overrideManager.enterScope();
6520 propagateTrueState(condition); 6433 propagateTrueState(condition);
6521 visitStatementInScope(body); 6434 visitStatementInScope(body);
6522 } finally { 6435 } finally {
6523 _overrideManager.exitScope(); 6436 overrideManager.exitScope();
6524 } 6437 }
6525 } 6438 }
6526 node.accept(_elementResolver); 6439 node.accept(_elementResolver);
6527 node.accept(_typeAnalyzer); 6440 node.accept(_typeAnalyzer);
6528 return null; 6441 return null;
6529 } 6442 }
6530 6443
6531 /** 6444 /**
6532 * Return the class element representing the class containing the current node , or `null` if
6533 * the current node is not contained in a class.
6534 *
6535 * @return the class element representing the class containing the current nod e
6536 */
6537 ClassElement get enclosingClass => _enclosingClass;
6538
6539 /**
6540 * Return the element representing the function containing the current node, o r `null` if
6541 * the current node is not contained in a function.
6542 *
6543 * @return the element representing the function containing the current node
6544 */
6545 ExecutableElement get enclosingFunction => _enclosingFunction;
6546
6547 /**
6548 * Return the propagated element associated with the given expression whose ty pe can be 6445 * Return the propagated element associated with the given expression whose ty pe can be
6549 * overridden, or `null` if there is no element whose type can be overridden. 6446 * overridden, or `null` if there is no element whose type can be overridden.
6550 * 6447 *
6551 * @param expression the expression with which the element is associated 6448 * @param expression the expression with which the element is associated
6552 * @return the element associated with the given expression 6449 * @return the element associated with the given expression
6553 */ 6450 */
6554 VariableElement getOverridablePropagatedElement(Expression expression) { 6451 VariableElement getOverridablePropagatedElement(Expression expression) {
6555 Element element = null; 6452 Element element = null;
6556 if (expression is SimpleIdentifier) { 6453 if (expression is SimpleIdentifier) {
6557 element = ((expression as SimpleIdentifier)).propagatedElement; 6454 element = ((expression as SimpleIdentifier)).propagatedElement;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
6621 return; 6518 return;
6622 } 6519 }
6623 if (element is PropertyInducingElement) { 6520 if (element is PropertyInducingElement) {
6624 PropertyInducingElement variable = element as PropertyInducingElement; 6521 PropertyInducingElement variable = element as PropertyInducingElement;
6625 if (!variable.isConst && !variable.isFinal) { 6522 if (!variable.isConst && !variable.isFinal) {
6626 return; 6523 return;
6627 } 6524 }
6628 } 6525 }
6629 Type2 currentType = getBestType(element); 6526 Type2 currentType = getBestType(element);
6630 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { 6527 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) {
6631 _overrideManager.setType(element, potentialType); 6528 overrideManager.setType(element, potentialType);
6632 } 6529 }
6633 } 6530 }
6634 6531
6635 /** 6532 /**
6636 * Report a conditional analysis error with the given error code and arguments . 6533 * Report a conditional analysis error with the given error code and arguments .
6637 * 6534 *
6638 * @param enclosingElement the enclosing element 6535 * @param enclosingElement the enclosing element
6639 * @param errorCode the error code of the error to be reported 6536 * @param errorCode the error code of the error to be reported
6640 * @param node the node specifying the location of the error 6537 * @param node the node specifying the location of the error
6641 * @param arguments the arguments to the error, used to compose the error mess age 6538 * @param arguments the arguments to the error, used to compose the error mess age
6642 */ 6539 */
6643 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC ode errorCode, ASTNode node, List<Object> arguments) { 6540 void reportErrorProxyConditionalAnalysisError(Element enclosingElement, ErrorC ode errorCode, ASTNode node, List<Object> arguments) {
6644 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, node.offset, node.length, errorCode, arguments))); 6541 proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclosi ngElement, new AnalysisError.con2(source, node.offset, node.length, errorCode, a rguments)));
6645 } 6542 }
6646 6543
6647 /** 6544 /**
6648 * Report a conditional analysis error with the given error code and arguments . 6545 * Report a conditional analysis error with the given error code and arguments .
6649 * 6546 *
6650 * @param enclosingElement the enclosing element 6547 * @param enclosingElement the enclosing element
6651 * @param errorCode the error code of the error to be reported 6548 * @param errorCode the error code of the error to be reported
6652 * @param offset the offset of the location of the error 6549 * @param offset the offset of the location of the error
6653 * @param length the length of the location of the error 6550 * @param length the length of the location of the error
6654 * @param arguments the arguments to the error, used to compose the error mess age 6551 * @param arguments the arguments to the error, used to compose the error mess age
6655 */ 6552 */
6656 void reportErrorProxyConditionalAnalysisError2(Element enclosingElement, Error Code errorCode, int offset, int length, List<Object> arguments) { 6553 void reportErrorProxyConditionalAnalysisError2(Element enclosingElement, Error Code errorCode, int offset, int length, List<Object> arguments) {
6657 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, offset, length, errorCode, arguments) )); 6554 proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclosi ngElement, new AnalysisError.con2(source, offset, length, errorCode, arguments)) );
6658 } 6555 }
6659 6556
6660 /** 6557 /**
6661 * Report a conditional analysis error with the given error code and arguments . 6558 * Report a conditional analysis error with the given error code and arguments .
6662 * 6559 *
6663 * @param enclosingElement the enclosing element 6560 * @param enclosingElement the enclosing element
6664 * @param errorCode the error code of the error to be reported 6561 * @param errorCode the error code of the error to be reported
6665 * @param token the token specifying the location of the error 6562 * @param token the token specifying the location of the error
6666 * @param arguments the arguments to the error, used to compose the error mess age 6563 * @param arguments the arguments to the error, used to compose the error mess age
6667 */ 6564 */
6668 void reportErrorProxyConditionalAnalysisError3(Element enclosingElement, Error Code errorCode, sc.Token token, List<Object> arguments) { 6565 void reportErrorProxyConditionalAnalysisError3(Element enclosingElement, Error Code errorCode, sc.Token token, List<Object> arguments) {
6669 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, token.offset, token.length, errorCode , arguments))); 6566 proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclosi ngElement, new AnalysisError.con2(source, token.offset, token.length, errorCode, arguments)));
6670 } 6567 }
6671 void visitForEachStatementInScope(ForEachStatement node) { 6568 void visitForEachStatementInScope(ForEachStatement node) {
6672 Expression iterator = node.iterator; 6569 Expression iterator = node.iterator;
6673 safelyVisit(iterator); 6570 safelyVisit(iterator);
6674 DeclaredIdentifier loopVariable = node.loopVariable; 6571 DeclaredIdentifier loopVariable = node.loopVariable;
6675 safelyVisit(loopVariable); 6572 safelyVisit(loopVariable);
6676 Statement body = node.body; 6573 Statement body = node.body;
6677 if (body != null) { 6574 if (body != null) {
6678 try { 6575 try {
6679 _overrideManager.enterScope(); 6576 overrideManager.enterScope();
6680 if (loopVariable != null && iterator != null) { 6577 if (loopVariable != null && iterator != null) {
6681 LocalVariableElement loopElement = loopVariable.element; 6578 LocalVariableElement loopElement = loopVariable.element;
6682 if (loopElement != null) { 6579 if (loopElement != null) {
6683 Type2 iteratorElementType = getIteratorElementType(iterator); 6580 Type2 iteratorElementType = getIteratorElementType(iterator);
6684 override2(loopElement, iteratorElementType); 6581 override2(loopElement, iteratorElementType);
6685 recordPropagatedType(loopVariable.identifier, iteratorElementType); 6582 recordPropagatedType(loopVariable.identifier, iteratorElementType);
6686 } 6583 }
6687 } 6584 }
6688 visitStatementInScope(body); 6585 visitStatementInScope(body);
6689 } finally { 6586 } finally {
6690 _overrideManager.exitScope(); 6587 overrideManager.exitScope();
6691 } 6588 }
6692 } 6589 }
6693 node.accept(_elementResolver); 6590 node.accept(_elementResolver);
6694 node.accept(_typeAnalyzer); 6591 node.accept(_typeAnalyzer);
6695 } 6592 }
6696 void visitForStatementInScope(ForStatement node) { 6593 void visitForStatementInScope(ForStatement node) {
6697 safelyVisit(node.variables); 6594 safelyVisit(node.variables);
6698 safelyVisit(node.initialization); 6595 safelyVisit(node.initialization);
6699 safelyVisit(node.condition); 6596 safelyVisit(node.condition);
6700 _overrideManager.enterScope(); 6597 overrideManager.enterScope();
6701 try { 6598 try {
6702 propagateTrueState(node.condition); 6599 propagateTrueState(node.condition);
6703 visitStatementInScope(node.body); 6600 visitStatementInScope(node.body);
6704 node.updaters.accept(this); 6601 node.updaters.accept(this);
6705 } finally { 6602 } finally {
6706 _overrideManager.exitScope(); 6603 overrideManager.exitScope();
6707 } 6604 }
6708 } 6605 }
6709 6606
6710 /** 6607 /**
6711 * Return the best type information available for the given element. If the ty pe of the element 6608 * Return the best type information available for the given element. If the ty pe of the element
6712 * has been overridden, then return the overriding type. Otherwise, return the static type. 6609 * has been overridden, then return the overriding type. Otherwise, return the static type.
6713 * 6610 *
6714 * @param element the element for which type information is to be returned 6611 * @param element the element for which type information is to be returned
6715 * @return the best type information available for the given element 6612 * @return the best type information available for the given element
6716 */ 6613 */
6717 Type2 getBestType(Element element) { 6614 Type2 getBestType(Element element) {
6718 Type2 bestType = _overrideManager.getType(element); 6615 Type2 bestType = overrideManager.getType(element);
6719 if (bestType == null) { 6616 if (bestType == null) {
6720 if (element is LocalVariableElement) { 6617 if (element is LocalVariableElement) {
6721 bestType = ((element as LocalVariableElement)).type; 6618 bestType = ((element as LocalVariableElement)).type;
6722 } else if (element is ParameterElement) { 6619 } else if (element is ParameterElement) {
6723 bestType = ((element as ParameterElement)).type; 6620 bestType = ((element as ParameterElement)).type;
6724 } 6621 }
6725 } 6622 }
6726 return bestType; 6623 return bestType;
6727 } 6624 }
6728 6625
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6770 FunctionType expectedClosureType = mayByFunctionType as FunctionType; 6667 FunctionType expectedClosureType = mayByFunctionType as FunctionType;
6771 closure.propagatedType = expectedClosureType; 6668 closure.propagatedType = expectedClosureType;
6772 NodeList<FormalParameter> parameters = closure.parameters.parameters; 6669 NodeList<FormalParameter> parameters = closure.parameters.parameters;
6773 List<ParameterElement> expectedParameters = expectedClosureType.parameters; 6670 List<ParameterElement> expectedParameters = expectedClosureType.parameters;
6774 for (int i = 0; i < parameters.length && i < expectedParameters.length; i++) { 6671 for (int i = 0; i < parameters.length && i < expectedParameters.length; i++) {
6775 FormalParameter parameter = parameters[i]; 6672 FormalParameter parameter = parameters[i];
6776 ParameterElement element = parameter.element; 6673 ParameterElement element = parameter.element;
6777 Type2 currentType = getBestType(element); 6674 Type2 currentType = getBestType(element);
6778 Type2 expectedType = expectedParameters[i].type; 6675 Type2 expectedType = expectedParameters[i].type;
6779 if (currentType == null || expectedType.isMoreSpecificThan(currentType)) { 6676 if (currentType == null || expectedType.isMoreSpecificThan(currentType)) {
6780 _overrideManager.setType(element, expectedType); 6677 overrideManager.setType(element, expectedType);
6781 } 6678 }
6782 } 6679 }
6783 } 6680 }
6784 6681
6785 /** 6682 /**
6786 * Try to infer types of parameters of the [FunctionExpression] arguments. 6683 * Try to infer types of parameters of the [FunctionExpression] arguments.
6787 */ 6684 */
6788 void inferFunctionExpressionsParametersTypes(ArgumentList argumentList) { 6685 void inferFunctionExpressionsParametersTypes(ArgumentList argumentList) {
6789 for (Expression argument in argumentList.arguments) { 6686 for (Expression argument in argumentList.arguments) {
6790 ParameterElement parameter = argument.propagatedParameterElement; 6687 ParameterElement parameter = argument.propagatedParameterElement;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
6905 * @param expression the node whose type is to be recorded 6802 * @param expression the node whose type is to be recorded
6906 * @param type the propagated type of the node 6803 * @param type the propagated type of the node
6907 */ 6804 */
6908 void recordPropagatedType(Expression expression, Type2 type) { 6805 void recordPropagatedType(Expression expression, Type2 type) {
6909 if (type != null && !type.isDynamic) { 6806 if (type != null && !type.isDynamic) {
6910 expression.propagatedType = type; 6807 expression.propagatedType = type;
6911 } 6808 }
6912 } 6809 }
6913 get elementResolver_J2DAccessor => _elementResolver; 6810 get elementResolver_J2DAccessor => _elementResolver;
6914 set elementResolver_J2DAccessor(__v) => _elementResolver = __v; 6811 set elementResolver_J2DAccessor(__v) => _elementResolver = __v;
6915 get labelScope_J2DAccessor => _labelScope; 6812 get labelScope_J2DAccessor => labelScope;
6916 set labelScope_J2DAccessor(__v) => _labelScope = __v; 6813 set labelScope_J2DAccessor(__v) => labelScope = __v;
6917 get nameScope_J2DAccessor => _nameScope; 6814 get nameScope_J2DAccessor => nameScope;
6918 set nameScope_J2DAccessor(__v) => _nameScope = __v; 6815 set nameScope_J2DAccessor(__v) => nameScope = __v;
6919 get typeAnalyzer_J2DAccessor => _typeAnalyzer; 6816 get typeAnalyzer_J2DAccessor => _typeAnalyzer;
6920 set typeAnalyzer_J2DAccessor(__v) => _typeAnalyzer = __v; 6817 set typeAnalyzer_J2DAccessor(__v) => _typeAnalyzer = __v;
6921 get enclosingClass_J2DAccessor => _enclosingClass; 6818 get enclosingClass_J2DAccessor => enclosingClass;
6922 set enclosingClass_J2DAccessor(__v) => _enclosingClass = __v; 6819 set enclosingClass_J2DAccessor(__v) => enclosingClass = __v;
6923 } 6820 }
6924 /** 6821 /**
6925 * The abstract class `ScopedVisitor` maintains name and label scopes as an AST structure is 6822 * The abstract class `ScopedVisitor` maintains name and label scopes as an AST structure is
6926 * being visited. 6823 * being visited.
6927 * 6824 *
6928 * @coverage dart.engine.resolver 6825 * @coverage dart.engine.resolver
6929 */ 6826 */
6930 abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> { 6827 abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
6931 6828
6932 /** 6829 /**
6933 * The element for the library containing the compilation unit being visited. 6830 * The element for the library containing the compilation unit being visited.
6934 */ 6831 */
6935 LibraryElement _definingLibrary; 6832 LibraryElement definingLibrary;
6936 6833
6937 /** 6834 /**
6938 * The source representing the compilation unit being visited. 6835 * The source representing the compilation unit being visited.
6939 */ 6836 */
6940 Source _source; 6837 Source source;
6941 6838
6942 /** 6839 /**
6943 * The error listener that will be informed of any errors that are found durin g resolution. 6840 * The error listener that will be informed of any errors that are found durin g resolution.
6944 */ 6841 */
6945 AnalysisErrorListener _errorListener; 6842 AnalysisErrorListener _errorListener;
6946 6843
6947 /** 6844 /**
6948 * The scope used to resolve identifiers. 6845 * The scope used to resolve identifiers.
6949 */ 6846 */
6950 Scope _nameScope; 6847 Scope nameScope;
6951 6848
6952 /** 6849 /**
6953 * The object used to access the types from the core library. 6850 * The object used to access the types from the core library.
6954 */ 6851 */
6955 TypeProvider _typeProvider; 6852 TypeProvider typeProvider;
6956 6853
6957 /** 6854 /**
6958 * The scope used to resolve labels for `break` and `continue` statements, or 6855 * The scope used to resolve labels for `break` and `continue` statements, or
6959 * `null` if no labels have been defined in the current context. 6856 * `null` if no labels have been defined in the current context.
6960 */ 6857 */
6961 LabelScope _labelScope; 6858 LabelScope labelScope;
6962 6859
6963 /** 6860 /**
6964 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 6861 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
6965 * 6862 *
6966 * @param library the library containing the compilation unit being resolved 6863 * @param library the library containing the compilation unit being resolved
6967 * @param source the source representing the compilation unit being visited 6864 * @param source the source representing the compilation unit being visited
6968 * @param typeProvider the object used to access the types from the core libra ry 6865 * @param typeProvider the object used to access the types from the core libra ry
6969 */ 6866 */
6970 ScopedVisitor.con1(Library library, Source source, TypeProvider typeProvider) { 6867 ScopedVisitor.con1(Library library, Source source, TypeProvider typeProvider) {
6971 this._definingLibrary = library.libraryElement; 6868 this.definingLibrary = library.libraryElement;
6972 this._source = source; 6869 this.source = source;
6973 LibraryScope libraryScope = library.libraryScope; 6870 LibraryScope libraryScope = library.libraryScope;
6974 this._errorListener = libraryScope.errorListener; 6871 this._errorListener = libraryScope.errorListener;
6975 this._nameScope = libraryScope; 6872 this.nameScope = libraryScope;
6976 this._typeProvider = typeProvider; 6873 this.typeProvider = typeProvider;
6977 } 6874 }
6978 6875
6979 /** 6876 /**
6980 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 6877 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
6981 * 6878 *
6982 * @param definingLibrary the element for the library containing the compilati on unit being 6879 * @param definingLibrary the element for the library containing the compilati on unit being
6983 * visited 6880 * visited
6984 * @param source the source representing the compilation unit being visited 6881 * @param source the source representing the compilation unit being visited
6985 * @param typeProvider the object used to access the types from the core libra ry 6882 * @param typeProvider the object used to access the types from the core libra ry
6986 * @param errorListener the error listener that will be informed of any errors that are found 6883 * @param errorListener the error listener that will be informed of any errors that are found
6987 * during resolution 6884 * during resolution
6988 */ 6885 */
6989 ScopedVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) { 6886 ScopedVisitor.con2(LibraryElement definingLibrary, Source source, TypeProvider typeProvider, AnalysisErrorListener errorListener) {
6990 this._definingLibrary = definingLibrary; 6887 this.definingLibrary = definingLibrary;
6991 this._source = source; 6888 this.source = source;
6992 this._errorListener = errorListener; 6889 this._errorListener = errorListener;
6993 this._nameScope = new LibraryScope(definingLibrary, errorListener); 6890 this.nameScope = new LibraryScope(definingLibrary, errorListener);
6994 this._typeProvider = typeProvider; 6891 this.typeProvider = typeProvider;
6995 } 6892 }
6996 6893
6997 /** 6894 /**
6998 * Return the library element for the library containing the compilation unit being resolved.
6999 *
7000 * @return the library element for the library containing the compilation unit being resolved
7001 */
7002 LibraryElement get definingLibrary => _definingLibrary;
7003
7004 /**
7005 * Return the object used to access the types from the core library.
7006 *
7007 * @return the object used to access the types from the core library
7008 */
7009 TypeProvider get typeProvider => _typeProvider;
7010
7011 /**
7012 * Report an error with the given analysis error. 6895 * Report an error with the given analysis error.
7013 * 6896 *
7014 * @param errorCode analysis error 6897 * @param errorCode analysis error
7015 */ 6898 */
7016 void reportError(AnalysisError analysisError) { 6899 void reportError(AnalysisError analysisError) {
7017 _errorListener.onError(analysisError); 6900 _errorListener.onError(analysisError);
7018 } 6901 }
7019 Object visitBlock(Block node) { 6902 Object visitBlock(Block node) {
7020 Scope outerScope = _nameScope; 6903 Scope outerScope = nameScope;
7021 try { 6904 try {
7022 EnclosedScope enclosedScope = new EnclosedScope(_nameScope); 6905 EnclosedScope enclosedScope = new EnclosedScope(nameScope);
7023 hideNamesDefinedInBlock(enclosedScope, node); 6906 hideNamesDefinedInBlock(enclosedScope, node);
7024 _nameScope = enclosedScope; 6907 nameScope = enclosedScope;
7025 super.visitBlock(node); 6908 super.visitBlock(node);
7026 } finally { 6909 } finally {
7027 _nameScope = outerScope; 6910 nameScope = outerScope;
7028 } 6911 }
7029 return null; 6912 return null;
7030 } 6913 }
7031 Object visitCatchClause(CatchClause node) { 6914 Object visitCatchClause(CatchClause node) {
7032 SimpleIdentifier exception = node.exceptionParameter; 6915 SimpleIdentifier exception = node.exceptionParameter;
7033 if (exception != null) { 6916 if (exception != null) {
7034 Scope outerScope = _nameScope; 6917 Scope outerScope = nameScope;
7035 try { 6918 try {
7036 _nameScope = new EnclosedScope(_nameScope); 6919 nameScope = new EnclosedScope(nameScope);
7037 _nameScope.define(exception.staticElement); 6920 nameScope.define(exception.staticElement);
7038 SimpleIdentifier stackTrace = node.stackTraceParameter; 6921 SimpleIdentifier stackTrace = node.stackTraceParameter;
7039 if (stackTrace != null) { 6922 if (stackTrace != null) {
7040 _nameScope.define(stackTrace.staticElement); 6923 nameScope.define(stackTrace.staticElement);
7041 } 6924 }
7042 super.visitCatchClause(node); 6925 super.visitCatchClause(node);
7043 } finally { 6926 } finally {
7044 _nameScope = outerScope; 6927 nameScope = outerScope;
7045 } 6928 }
7046 } else { 6929 } else {
7047 super.visitCatchClause(node); 6930 super.visitCatchClause(node);
7048 } 6931 }
7049 return null; 6932 return null;
7050 } 6933 }
7051 Object visitClassDeclaration(ClassDeclaration node) { 6934 Object visitClassDeclaration(ClassDeclaration node) {
7052 Scope outerScope = _nameScope; 6935 Scope outerScope = nameScope;
7053 try { 6936 try {
7054 _nameScope = new ClassScope(_nameScope, node.element); 6937 nameScope = new ClassScope(nameScope, node.element);
7055 super.visitClassDeclaration(node); 6938 super.visitClassDeclaration(node);
7056 } finally { 6939 } finally {
7057 _nameScope = outerScope; 6940 nameScope = outerScope;
7058 } 6941 }
7059 return null; 6942 return null;
7060 } 6943 }
7061 Object visitClassTypeAlias(ClassTypeAlias node) { 6944 Object visitClassTypeAlias(ClassTypeAlias node) {
7062 Scope outerScope = _nameScope; 6945 Scope outerScope = nameScope;
7063 try { 6946 try {
7064 _nameScope = new ClassScope(_nameScope, node.element); 6947 nameScope = new ClassScope(nameScope, node.element);
7065 super.visitClassTypeAlias(node); 6948 super.visitClassTypeAlias(node);
7066 } finally { 6949 } finally {
7067 _nameScope = outerScope; 6950 nameScope = outerScope;
7068 } 6951 }
7069 return null; 6952 return null;
7070 } 6953 }
7071 Object visitConstructorDeclaration(ConstructorDeclaration node) { 6954 Object visitConstructorDeclaration(ConstructorDeclaration node) {
7072 Scope outerScope = _nameScope; 6955 Scope outerScope = nameScope;
7073 try { 6956 try {
7074 _nameScope = new FunctionScope(_nameScope, node.element); 6957 nameScope = new FunctionScope(nameScope, node.element);
7075 super.visitConstructorDeclaration(node); 6958 super.visitConstructorDeclaration(node);
7076 } finally { 6959 } finally {
7077 _nameScope = outerScope; 6960 nameScope = outerScope;
7078 } 6961 }
7079 return null; 6962 return null;
7080 } 6963 }
7081 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 6964 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
7082 VariableElement element = node.element; 6965 VariableElement element = node.element;
7083 if (element != null) { 6966 if (element != null) {
7084 _nameScope.define(element); 6967 nameScope.define(element);
7085 } 6968 }
7086 super.visitDeclaredIdentifier(node); 6969 super.visitDeclaredIdentifier(node);
7087 return null; 6970 return null;
7088 } 6971 }
7089 Object visitDoStatement(DoStatement node) { 6972 Object visitDoStatement(DoStatement node) {
7090 LabelScope outerLabelScope = _labelScope; 6973 LabelScope outerLabelScope = labelScope;
7091 try { 6974 try {
7092 _labelScope = new LabelScope.con1(_labelScope, false, false); 6975 labelScope = new LabelScope.con1(labelScope, false, false);
7093 visitStatementInScope(node.body); 6976 visitStatementInScope(node.body);
7094 safelyVisit(node.condition); 6977 safelyVisit(node.condition);
7095 } finally { 6978 } finally {
7096 _labelScope = outerLabelScope; 6979 labelScope = outerLabelScope;
7097 } 6980 }
7098 return null; 6981 return null;
7099 } 6982 }
7100 Object visitForEachStatement(ForEachStatement node) { 6983 Object visitForEachStatement(ForEachStatement node) {
7101 Scope outerNameScope = _nameScope; 6984 Scope outerNameScope = nameScope;
7102 LabelScope outerLabelScope = _labelScope; 6985 LabelScope outerLabelScope = labelScope;
7103 try { 6986 try {
7104 _nameScope = new EnclosedScope(_nameScope); 6987 nameScope = new EnclosedScope(nameScope);
7105 _labelScope = new LabelScope.con1(outerLabelScope, false, false); 6988 labelScope = new LabelScope.con1(outerLabelScope, false, false);
7106 visitForEachStatementInScope(node); 6989 visitForEachStatementInScope(node);
7107 } finally { 6990 } finally {
7108 _labelScope = outerLabelScope; 6991 labelScope = outerLabelScope;
7109 _nameScope = outerNameScope; 6992 nameScope = outerNameScope;
7110 } 6993 }
7111 return null; 6994 return null;
7112 } 6995 }
7113 Object visitForStatement(ForStatement node) { 6996 Object visitForStatement(ForStatement node) {
7114 Scope outerNameScope = _nameScope; 6997 Scope outerNameScope = nameScope;
7115 LabelScope outerLabelScope = _labelScope; 6998 LabelScope outerLabelScope = labelScope;
7116 try { 6999 try {
7117 _nameScope = new EnclosedScope(_nameScope); 7000 nameScope = new EnclosedScope(nameScope);
7118 _labelScope = new LabelScope.con1(outerLabelScope, false, false); 7001 labelScope = new LabelScope.con1(outerLabelScope, false, false);
7119 visitForStatementInScope(node); 7002 visitForStatementInScope(node);
7120 } finally { 7003 } finally {
7121 _labelScope = outerLabelScope; 7004 labelScope = outerLabelScope;
7122 _nameScope = outerNameScope; 7005 nameScope = outerNameScope;
7123 } 7006 }
7124 return null; 7007 return null;
7125 } 7008 }
7126 Object visitFunctionDeclaration(FunctionDeclaration node) { 7009 Object visitFunctionDeclaration(FunctionDeclaration node) {
7127 ExecutableElement function = node.element; 7010 ExecutableElement function = node.element;
7128 Scope outerScope = _nameScope; 7011 Scope outerScope = nameScope;
7129 try { 7012 try {
7130 _nameScope = new FunctionScope(_nameScope, function); 7013 nameScope = new FunctionScope(nameScope, function);
7131 super.visitFunctionDeclaration(node); 7014 super.visitFunctionDeclaration(node);
7132 } finally { 7015 } finally {
7133 _nameScope = outerScope; 7016 nameScope = outerScope;
7134 } 7017 }
7135 if (function.enclosingElement is! CompilationUnitElement) { 7018 if (function.enclosingElement is! CompilationUnitElement) {
7136 _nameScope.define(function); 7019 nameScope.define(function);
7137 } 7020 }
7138 return null; 7021 return null;
7139 } 7022 }
7140 Object visitFunctionExpression(FunctionExpression node) { 7023 Object visitFunctionExpression(FunctionExpression node) {
7141 if (node.parent is FunctionDeclaration) { 7024 if (node.parent is FunctionDeclaration) {
7142 super.visitFunctionExpression(node); 7025 super.visitFunctionExpression(node);
7143 } else { 7026 } else {
7144 Scope outerScope = _nameScope; 7027 Scope outerScope = nameScope;
7145 try { 7028 try {
7146 ExecutableElement functionElement = node.element; 7029 ExecutableElement functionElement = node.element;
7147 if (functionElement == null) { 7030 if (functionElement == null) {
7148 } else { 7031 } else {
7149 _nameScope = new FunctionScope(_nameScope, functionElement); 7032 nameScope = new FunctionScope(nameScope, functionElement);
7150 } 7033 }
7151 super.visitFunctionExpression(node); 7034 super.visitFunctionExpression(node);
7152 } finally { 7035 } finally {
7153 _nameScope = outerScope; 7036 nameScope = outerScope;
7154 } 7037 }
7155 } 7038 }
7156 return null; 7039 return null;
7157 } 7040 }
7158 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 7041 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
7159 Scope outerScope = _nameScope; 7042 Scope outerScope = nameScope;
7160 try { 7043 try {
7161 _nameScope = new FunctionTypeScope(_nameScope, node.element); 7044 nameScope = new FunctionTypeScope(nameScope, node.element);
7162 super.visitFunctionTypeAlias(node); 7045 super.visitFunctionTypeAlias(node);
7163 } finally { 7046 } finally {
7164 _nameScope = outerScope; 7047 nameScope = outerScope;
7165 } 7048 }
7166 return null; 7049 return null;
7167 } 7050 }
7168 Object visitIfStatement(IfStatement node) { 7051 Object visitIfStatement(IfStatement node) {
7169 safelyVisit(node.condition); 7052 safelyVisit(node.condition);
7170 visitStatementInScope(node.thenStatement); 7053 visitStatementInScope(node.thenStatement);
7171 visitStatementInScope(node.elseStatement); 7054 visitStatementInScope(node.elseStatement);
7172 return null; 7055 return null;
7173 } 7056 }
7174 Object visitLabeledStatement(LabeledStatement node) { 7057 Object visitLabeledStatement(LabeledStatement node) {
7175 LabelScope outerScope = addScopesFor(node.labels); 7058 LabelScope outerScope = addScopesFor(node.labels);
7176 try { 7059 try {
7177 super.visitLabeledStatement(node); 7060 super.visitLabeledStatement(node);
7178 } finally { 7061 } finally {
7179 _labelScope = outerScope; 7062 labelScope = outerScope;
7180 } 7063 }
7181 return null; 7064 return null;
7182 } 7065 }
7183 Object visitMethodDeclaration(MethodDeclaration node) { 7066 Object visitMethodDeclaration(MethodDeclaration node) {
7184 Scope outerScope = _nameScope; 7067 Scope outerScope = nameScope;
7185 try { 7068 try {
7186 _nameScope = new FunctionScope(_nameScope, node.element); 7069 nameScope = new FunctionScope(nameScope, node.element);
7187 super.visitMethodDeclaration(node); 7070 super.visitMethodDeclaration(node);
7188 } finally { 7071 } finally {
7189 _nameScope = outerScope; 7072 nameScope = outerScope;
7190 } 7073 }
7191 return null; 7074 return null;
7192 } 7075 }
7193 Object visitSwitchCase(SwitchCase node) { 7076 Object visitSwitchCase(SwitchCase node) {
7194 node.expression.accept(this); 7077 node.expression.accept(this);
7195 Scope outerNameScope = _nameScope; 7078 Scope outerNameScope = nameScope;
7196 try { 7079 try {
7197 _nameScope = new EnclosedScope(_nameScope); 7080 nameScope = new EnclosedScope(nameScope);
7198 node.statements.accept(this); 7081 node.statements.accept(this);
7199 } finally { 7082 } finally {
7200 _nameScope = outerNameScope; 7083 nameScope = outerNameScope;
7201 } 7084 }
7202 return null; 7085 return null;
7203 } 7086 }
7204 Object visitSwitchDefault(SwitchDefault node) { 7087 Object visitSwitchDefault(SwitchDefault node) {
7205 Scope outerNameScope = _nameScope; 7088 Scope outerNameScope = nameScope;
7206 try { 7089 try {
7207 _nameScope = new EnclosedScope(_nameScope); 7090 nameScope = new EnclosedScope(nameScope);
7208 node.statements.accept(this); 7091 node.statements.accept(this);
7209 } finally { 7092 } finally {
7210 _nameScope = outerNameScope; 7093 nameScope = outerNameScope;
7211 } 7094 }
7212 return null; 7095 return null;
7213 } 7096 }
7214 Object visitSwitchStatement(SwitchStatement node) { 7097 Object visitSwitchStatement(SwitchStatement node) {
7215 LabelScope outerScope = _labelScope; 7098 LabelScope outerScope = labelScope;
7216 try { 7099 try {
7217 _labelScope = new LabelScope.con1(outerScope, true, false); 7100 labelScope = new LabelScope.con1(outerScope, true, false);
7218 for (SwitchMember member in node.members) { 7101 for (SwitchMember member in node.members) {
7219 for (Label label in member.labels) { 7102 for (Label label in member.labels) {
7220 SimpleIdentifier labelName = label.label; 7103 SimpleIdentifier labelName = label.label;
7221 LabelElement labelElement = labelName.staticElement as LabelElement; 7104 LabelElement labelElement = labelName.staticElement as LabelElement;
7222 _labelScope = new LabelScope.con2(_labelScope, labelName.name, labelEl ement); 7105 labelScope = new LabelScope.con2(labelScope, labelName.name, labelElem ent);
7223 } 7106 }
7224 } 7107 }
7225 super.visitSwitchStatement(node); 7108 super.visitSwitchStatement(node);
7226 } finally { 7109 } finally {
7227 _labelScope = outerScope; 7110 labelScope = outerScope;
7228 } 7111 }
7229 return null; 7112 return null;
7230 } 7113 }
7231 Object visitVariableDeclaration(VariableDeclaration node) { 7114 Object visitVariableDeclaration(VariableDeclaration node) {
7232 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) { 7115 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) {
7233 VariableElement element = node.element; 7116 VariableElement element = node.element;
7234 if (element != null) { 7117 if (element != null) {
7235 _nameScope.define(element); 7118 nameScope.define(element);
7236 } 7119 }
7237 } 7120 }
7238 super.visitVariableDeclaration(node); 7121 super.visitVariableDeclaration(node);
7239 return null; 7122 return null;
7240 } 7123 }
7241 Object visitWhileStatement(WhileStatement node) { 7124 Object visitWhileStatement(WhileStatement node) {
7242 LabelScope outerScope = _labelScope; 7125 LabelScope outerScope = labelScope;
7243 try { 7126 try {
7244 _labelScope = new LabelScope.con1(outerScope, false, false); 7127 labelScope = new LabelScope.con1(outerScope, false, false);
7245 safelyVisit(node.condition); 7128 safelyVisit(node.condition);
7246 visitStatementInScope(node.body); 7129 visitStatementInScope(node.body);
7247 } finally { 7130 } finally {
7248 _labelScope = outerScope; 7131 labelScope = outerScope;
7249 } 7132 }
7250 return null; 7133 return null;
7251 } 7134 }
7252 7135
7253 /** 7136 /**
7254 * Return the label scope in which the current node is being resolved.
7255 *
7256 * @return the label scope in which the current node is being resolved
7257 */
7258 LabelScope get labelScope => _labelScope;
7259
7260 /**
7261 * Return the name scope in which the current node is being resolved.
7262 *
7263 * @return the name scope in which the current node is being resolved
7264 */
7265 Scope get nameScope => _nameScope;
7266
7267 /**
7268 * Return the source.
7269 *
7270 * @return the source
7271 */
7272 Source get source => _source;
7273
7274 /**
7275 * Report an error with the given error code and arguments. 7137 * Report an error with the given error code and arguments.
7276 * 7138 *
7277 * @param errorCode the error code of the error to be reported 7139 * @param errorCode the error code of the error to be reported
7278 * @param node the node specifying the location of the error 7140 * @param node the node specifying the location of the error
7279 * @param arguments the arguments to the error, used to compose the error mess age 7141 * @param arguments the arguments to the error, used to compose the error mess age
7280 */ 7142 */
7281 void reportError5(ErrorCode errorCode, ASTNode node, List<Object> arguments) { 7143 void reportError5(ErrorCode errorCode, ASTNode node, List<Object> arguments) {
7282 _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.len gth, errorCode, arguments)); 7144 _errorListener.onError(new AnalysisError.con2(source, node.offset, node.leng th, errorCode, arguments));
7283 } 7145 }
7284 7146
7285 /** 7147 /**
7286 * Report an error with the given error code and arguments. 7148 * Report an error with the given error code and arguments.
7287 * 7149 *
7288 * @param errorCode the error code of the error to be reported 7150 * @param errorCode the error code of the error to be reported
7289 * @param offset the offset of the location of the error 7151 * @param offset the offset of the location of the error
7290 * @param length the length of the location of the error 7152 * @param length the length of the location of the error
7291 * @param arguments the arguments to the error, used to compose the error mess age 7153 * @param arguments the arguments to the error, used to compose the error mess age
7292 */ 7154 */
7293 void reportError6(ErrorCode errorCode, int offset, int length, List<Object> ar guments) { 7155 void reportError6(ErrorCode errorCode, int offset, int length, List<Object> ar guments) {
7294 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error Code, arguments)); 7156 _errorListener.onError(new AnalysisError.con2(source, offset, length, errorC ode, arguments));
7295 } 7157 }
7296 7158
7297 /** 7159 /**
7298 * Report an error with the given error code and arguments. 7160 * Report an error with the given error code and arguments.
7299 * 7161 *
7300 * @param errorCode the error code of the error to be reported 7162 * @param errorCode the error code of the error to be reported
7301 * @param token the token specifying the location of the error 7163 * @param token the token specifying the location of the error
7302 * @param arguments the arguments to the error, used to compose the error mess age 7164 * @param arguments the arguments to the error, used to compose the error mess age
7303 */ 7165 */
7304 void reportError7(ErrorCode errorCode, sc.Token token, List<Object> arguments) { 7166 void reportError7(ErrorCode errorCode, sc.Token token, List<Object> arguments) {
7305 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l ength, errorCode, arguments)); 7167 _errorListener.onError(new AnalysisError.con2(source, token.offset, token.le ngth, errorCode, arguments));
7306 } 7168 }
7307 7169
7308 /** 7170 /**
7309 * Visit the given AST node if it is not null. 7171 * Visit the given AST node if it is not null.
7310 * 7172 *
7311 * @param node the node to be visited 7173 * @param node the node to be visited
7312 */ 7174 */
7313 void safelyVisit(ASTNode node) { 7175 void safelyVisit(ASTNode node) {
7314 if (node != null) { 7176 if (node != null) {
7315 node.accept(this); 7177 node.accept(this);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7347 /** 7209 /**
7348 * Visit the given statement after it's scope has been created. This is used b y ResolverVisitor to 7210 * Visit the given statement after it's scope has been created. This is used b y ResolverVisitor to
7349 * correctly visit the 'then' and 'else' statements of an 'if' statement. 7211 * correctly visit the 'then' and 'else' statements of an 'if' statement.
7350 * 7212 *
7351 * @param node the statement to be visited 7213 * @param node the statement to be visited
7352 */ 7214 */
7353 void visitStatementInScope(Statement node) { 7215 void visitStatementInScope(Statement node) {
7354 if (node is Block) { 7216 if (node is Block) {
7355 visitBlock(node as Block); 7217 visitBlock(node as Block);
7356 } else if (node != null) { 7218 } else if (node != null) {
7357 Scope outerNameScope = _nameScope; 7219 Scope outerNameScope = nameScope;
7358 try { 7220 try {
7359 _nameScope = new EnclosedScope(_nameScope); 7221 nameScope = new EnclosedScope(nameScope);
7360 node.accept(this); 7222 node.accept(this);
7361 } finally { 7223 } finally {
7362 _nameScope = outerNameScope; 7224 nameScope = outerNameScope;
7363 } 7225 }
7364 } 7226 }
7365 } 7227 }
7366 7228
7367 /** 7229 /**
7368 * Add scopes for each of the given labels. 7230 * Add scopes for each of the given labels.
7369 * 7231 *
7370 * @param labels the labels for which new scopes are to be added 7232 * @param labels the labels for which new scopes are to be added
7371 * @return the scope that was in effect before the new scopes were added 7233 * @return the scope that was in effect before the new scopes were added
7372 */ 7234 */
7373 LabelScope addScopesFor(NodeList<Label> labels) { 7235 LabelScope addScopesFor(NodeList<Label> labels) {
7374 LabelScope outerScope = _labelScope; 7236 LabelScope outerScope = labelScope;
7375 for (Label label in labels) { 7237 for (Label label in labels) {
7376 SimpleIdentifier labelNameNode = label.label; 7238 SimpleIdentifier labelNameNode = label.label;
7377 String labelName = labelNameNode.name; 7239 String labelName = labelNameNode.name;
7378 LabelElement labelElement = labelNameNode.staticElement as LabelElement; 7240 LabelElement labelElement = labelNameNode.staticElement as LabelElement;
7379 _labelScope = new LabelScope.con2(_labelScope, labelName, labelElement); 7241 labelScope = new LabelScope.con2(labelScope, labelName, labelElement);
7380 } 7242 }
7381 return outerScope; 7243 return outerScope;
7382 } 7244 }
7383 7245
7384 /** 7246 /**
7385 * Marks the local declarations of the given [Block] hidden in the enclosing s cope. 7247 * Marks the local declarations of the given [Block] hidden in the enclosing s cope.
7386 * According to the scoping rules name is hidden if block defines it, but name is defined after 7248 * According to the scoping rules name is hidden if block defines it, but name is defined after
7387 * its declaration statement. 7249 * its declaration statement.
7388 */ 7250 */
7389 void hideNamesDefinedInBlock(EnclosedScope scope, Block block) { 7251 void hideNamesDefinedInBlock(EnclosedScope scope, Block block) {
(...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after
10300 * Instances of the class `EnclosedScope` implement a scope that is lexically en closed in 10162 * Instances of the class `EnclosedScope` implement a scope that is lexically en closed in
10301 * another scope. 10163 * another scope.
10302 * 10164 *
10303 * @coverage dart.engine.resolver 10165 * @coverage dart.engine.resolver
10304 */ 10166 */
10305 class EnclosedScope extends Scope { 10167 class EnclosedScope extends Scope {
10306 10168
10307 /** 10169 /**
10308 * The scope in which this scope is lexically enclosed. 10170 * The scope in which this scope is lexically enclosed.
10309 */ 10171 */
10310 Scope _enclosingScope; 10172 Scope enclosingScope;
10311 10173
10312 /** 10174 /**
10313 * A set of names that will be defined in this scope, but right now are not de fined. However 10175 * A set of names that will be defined in this scope, but right now are not de fined. However
10314 * according to the scoping rules these names are hidden, even if they were de fined in an outer 10176 * according to the scoping rules these names are hidden, even if they were de fined in an outer
10315 * scope. 10177 * scope.
10316 */ 10178 */
10317 Set<String> _hiddenNames = new Set<String>(); 10179 Set<String> _hiddenNames = new Set<String>();
10318 10180
10319 /** 10181 /**
10320 * Initialize a newly created scope enclosed within another scope. 10182 * Initialize a newly created scope enclosed within another scope.
10321 * 10183 *
10322 * @param enclosingScope the scope in which this scope is lexically enclosed 10184 * @param enclosingScope the scope in which this scope is lexically enclosed
10323 */ 10185 */
10324 EnclosedScope(Scope enclosingScope) { 10186 EnclosedScope(Scope enclosingScope) {
10325 this._enclosingScope = enclosingScope; 10187 this.enclosingScope = enclosingScope;
10326 } 10188 }
10327 LibraryElement get definingLibrary => _enclosingScope.definingLibrary; 10189 LibraryElement get definingLibrary => enclosingScope.definingLibrary;
10328 AnalysisErrorListener get errorListener => _enclosingScope.errorListener; 10190 AnalysisErrorListener get errorListener => enclosingScope.errorListener;
10329 10191
10330 /** 10192 /**
10331 * Hides the name of the given element in this scope. If there is already an e lement with the 10193 * Hides the name of the given element in this scope. If there is already an e lement with the
10332 * given name defined in an outer scope, then it will become unavailable. 10194 * given name defined in an outer scope, then it will become unavailable.
10333 * 10195 *
10334 * @param element the element to be hidden in this scope 10196 * @param element the element to be hidden in this scope
10335 */ 10197 */
10336 void hide(Element element) { 10198 void hide(Element element) {
10337 if (element != null) { 10199 if (element != null) {
10338 String name = element.name; 10200 String name = element.name;
10339 if (name != null && !name.isEmpty) { 10201 if (name != null && !name.isEmpty) {
10340 javaSetAdd(_hiddenNames, name); 10202 javaSetAdd(_hiddenNames, name);
10341 } 10203 }
10342 } 10204 }
10343 } 10205 }
10344
10345 /**
10346 * Return the scope in which this scope is lexically enclosed.
10347 *
10348 * @return the scope in which this scope is lexically enclosed
10349 */
10350 Scope get enclosingScope => _enclosingScope;
10351 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) { 10206 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) {
10352 Element element = localLookup(name, referencingLibrary); 10207 Element element = localLookup(name, referencingLibrary);
10353 if (element != null) { 10208 if (element != null) {
10354 return element; 10209 return element;
10355 } 10210 }
10356 if (_hiddenNames.contains(name)) { 10211 if (_hiddenNames.contains(name)) {
10357 return null; 10212 return null;
10358 } 10213 }
10359 return _enclosingScope.lookup3(identifier, name, referencingLibrary); 10214 return enclosingScope.lookup3(identifier, name, referencingLibrary);
10360 } 10215 }
10361 } 10216 }
10362 /** 10217 /**
10363 * Instances of the class `FunctionScope` implement the scope defined by a funct ion. 10218 * Instances of the class `FunctionScope` implement the scope defined by a funct ion.
10364 * 10219 *
10365 * @coverage dart.engine.resolver 10220 * @coverage dart.engine.resolver
10366 */ 10221 */
10367 class FunctionScope extends EnclosedScope { 10222 class FunctionScope extends EnclosedScope {
10368 10223
10369 /** 10224 /**
(...skipping 5291 matching lines...) Expand 10 before | Expand all | Expand 10 after
15661 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag e, String correction) : super(name, ordinal) { 15516 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag e, String correction) : super(name, ordinal) {
15662 this._type = type; 15517 this._type = type;
15663 this._message = message; 15518 this._message = message;
15664 this.correction9 = correction; 15519 this.correction9 = correction;
15665 } 15520 }
15666 String get correction => correction9; 15521 String get correction => correction9;
15667 ErrorSeverity get errorSeverity => _type.severity; 15522 ErrorSeverity get errorSeverity => _type.severity;
15668 String get message => _message; 15523 String get message => _message;
15669 ErrorType get type => _type; 15524 ErrorType get type => _type;
15670 } 15525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698