| OLD | NEW |
| 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 15 matching lines...) Expand all Loading... |
| 26 class CompilationUnitBuilder { | 26 class CompilationUnitBuilder { |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Build the compilation unit element for the given source. | 29 * Build the compilation unit element for the given source. |
| 30 * | 30 * |
| 31 * @param source the source describing the compilation unit | 31 * @param source the source describing the compilation unit |
| 32 * @param unit the AST structure representing the compilation unit | 32 * @param unit the AST structure representing the compilation unit |
| 33 * @return the compilation unit element that was built | 33 * @return the compilation unit element that was built |
| 34 * @throws AnalysisException if the analysis could not be performed | 34 * @throws AnalysisException if the analysis could not be performed |
| 35 */ | 35 */ |
| 36 CompilationUnitElementImpl buildCompilationUnit(Source source2, CompilationUni
t unit) { | 36 CompilationUnitElementImpl buildCompilationUnit(Source source, CompilationUnit
unit) { |
| 37 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st
art(); | 37 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st
art(); |
| 38 if (unit == null) { | 38 if (unit == null) { |
| 39 return null; | 39 return null; |
| 40 } | 40 } |
| 41 ElementHolder holder = new ElementHolder(); | 41 ElementHolder holder = new ElementHolder(); |
| 42 ElementBuilder builder = new ElementBuilder(holder); | 42 ElementBuilder builder = new ElementBuilder(holder); |
| 43 unit.accept(builder); | 43 unit.accept(builder); |
| 44 CompilationUnitElementImpl element = new CompilationUnitElementImpl(source2.
shortName); | 44 CompilationUnitElementImpl element = new CompilationUnitElementImpl(source.s
hortName); |
| 45 element.accessors = holder.accessors; | 45 element.accessors = holder.accessors; |
| 46 element.functions = holder.functions; | 46 element.functions = holder.functions; |
| 47 element.source = source2; | 47 element.source = source; |
| 48 element.typeAliases = holder.typeAliases; | 48 element.typeAliases = holder.typeAliases; |
| 49 element.types = holder.types; | 49 element.types = holder.types; |
| 50 element.topLevelVariables = holder.topLevelVariables; | 50 element.topLevelVariables = holder.topLevelVariables; |
| 51 unit.element = element; | 51 unit.element = element; |
| 52 timeCounter.stop(); | 52 timeCounter.stop(); |
| 53 return element; | 53 return element; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 /** | 56 /** |
| 57 * Instances of the class `ElementBuilder` traverse an AST structure and build t
he element | 57 * Instances of the class `ElementBuilder` traverse an AST structure and build t
he element |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 return null; | 686 return null; |
| 687 } | 687 } |
| 688 | 688 |
| 689 /** | 689 /** |
| 690 * Return `true` if the given token is a token for the given keyword. | 690 * Return `true` if the given token is a token for the given keyword. |
| 691 * | 691 * |
| 692 * @param token the token being tested | 692 * @param token the token being tested |
| 693 * @param keyword the keyword being tested for | 693 * @param keyword the keyword being tested for |
| 694 * @return `true` if the given token is a token for the given keyword | 694 * @return `true` if the given token is a token for the given keyword |
| 695 */ | 695 */ |
| 696 bool matches(sc.Token token, sc.Keyword keyword2) => token != null && identica
l(token.type, sc.TokenType.KEYWORD) && identical(((token as sc.KeywordToken)).ke
yword, keyword2); | 696 bool matches(sc.Token token, sc.Keyword keyword) => token != null && identical
(token.type, sc.TokenType.KEYWORD) && identical(((token as sc.KeywordToken)).key
word, keyword); |
| 697 | 697 |
| 698 /** | 698 /** |
| 699 * Sets the visible source range for formal parameter. | 699 * Sets the visible source range for formal parameter. |
| 700 */ | 700 */ |
| 701 void setParameterVisibleRange(FormalParameter node, ParameterElementImpl eleme
nt) { | 701 void setParameterVisibleRange(FormalParameter node, ParameterElementImpl eleme
nt) { |
| 702 FunctionBody body = getFunctionBody(node); | 702 FunctionBody body = getFunctionBody(node); |
| 703 if (body != null) { | 703 if (body != null) { |
| 704 element.setVisibleRange(body.offset, body.length); | 704 element.setVisibleRange(body.offset, body.length); |
| 705 } | 705 } |
| 706 } | 706 } |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 | 1110 |
| 1111 /** | 1111 /** |
| 1112 * Build the HTML element for the given source. | 1112 * Build the HTML element for the given source. |
| 1113 * | 1113 * |
| 1114 * @param source the source describing the compilation unit | 1114 * @param source the source describing the compilation unit |
| 1115 * @param modificationStamp the modification time of the source for which an e
lement is being | 1115 * @param modificationStamp the modification time of the source for which an e
lement is being |
| 1116 * built | 1116 * built |
| 1117 * @param unit the AST structure representing the HTML | 1117 * @param unit the AST structure representing the HTML |
| 1118 * @throws AnalysisException if the analysis could not be performed | 1118 * @throws AnalysisException if the analysis could not be performed |
| 1119 */ | 1119 */ |
| 1120 HtmlElementImpl buildHtmlElement2(Source source2, int modificationStamp2, ht.H
tmlUnit unit) { | 1120 HtmlElementImpl buildHtmlElement2(Source source, int modificationStamp, ht.Htm
lUnit unit) { |
| 1121 this._modificationStamp = modificationStamp2; | 1121 this._modificationStamp = modificationStamp; |
| 1122 _lineInfo = _context.computeLineInfo(source2); | 1122 _lineInfo = _context.computeLineInfo(source); |
| 1123 HtmlElementImpl result = new HtmlElementImpl(_context, source2.shortName); | 1123 HtmlElementImpl result = new HtmlElementImpl(_context, source.shortName); |
| 1124 result.source = source2; | 1124 result.source = source; |
| 1125 _htmlElement = result; | 1125 _htmlElement = result; |
| 1126 unit.accept(this); | 1126 unit.accept(this); |
| 1127 _htmlElement = null; | 1127 _htmlElement = null; |
| 1128 unit.element = result; | 1128 unit.element = result; |
| 1129 return result; | 1129 return result; |
| 1130 } | 1130 } |
| 1131 Object visitHtmlUnit(ht.HtmlUnit node) { | 1131 Object visitHtmlUnit(ht.HtmlUnit node) { |
| 1132 _parentNodes = new List<ht.XmlTagNode>(); | 1132 _parentNodes = new List<ht.XmlTagNode>(); |
| 1133 _scripts = new List<HtmlScriptElement>(); | 1133 _scripts = new List<HtmlScriptElement>(); |
| 1134 try { | 1134 try { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 * Instances of the class `BestPracticesVerifier` traverse an AST structure look
ing for | 1289 * Instances of the class `BestPracticesVerifier` traverse an AST structure look
ing for |
| 1290 * violations of Dart best practices. | 1290 * violations of Dart best practices. |
| 1291 * | 1291 * |
| 1292 * @coverage dart.engine.resolver | 1292 * @coverage dart.engine.resolver |
| 1293 */ | 1293 */ |
| 1294 class BestPracticesVerifier extends RecursiveASTVisitor<Object> { | 1294 class BestPracticesVerifier extends RecursiveASTVisitor<Object> { |
| 1295 static String _GETTER = "getter"; | 1295 static String _GETTER = "getter"; |
| 1296 static String _HASHCODE_GETTER_NAME = "hashCode"; | 1296 static String _HASHCODE_GETTER_NAME = "hashCode"; |
| 1297 static String _METHOD = "method"; | 1297 static String _METHOD = "method"; |
| 1298 static String _NULL_TYPE_NAME = "Null"; | 1298 static String _NULL_TYPE_NAME = "Null"; |
| 1299 static String _OBJECT_TYPE_NAME = "Object"; | |
| 1300 static String _SETTER = "setter"; | 1299 static String _SETTER = "setter"; |
| 1301 static String _TO_INT_METHOD_NAME = "toInt"; | 1300 static String _TO_INT_METHOD_NAME = "toInt"; |
| 1302 | 1301 |
| 1303 /** | 1302 /** |
| 1304 * Given a parenthesized expression, this returns the parent (or recursively g
rand-parent) of the | 1303 * Given a parenthesized expression, this returns the parent (or recursively g
rand-parent) of the |
| 1305 * expression that is a parenthesized expression, but whose parent is not a pa
renthesized | 1304 * expression that is a parenthesized expression, but whose parent is not a pa
renthesized |
| 1306 * expression. | 1305 * expression. |
| 1307 * | 1306 * |
| 1308 * For example given the code `(((e)))`: `(e) -> (((e)))`. | 1307 * For example given the code `(((e)))`: `(e) -> (((e)))`. |
| 1309 * | 1308 * |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 if (node.notOperator == null) { | 1386 if (node.notOperator == null) { |
| 1388 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node,
[]); | 1387 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node,
[]); |
| 1389 } else { | 1388 } else { |
| 1390 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node,
[]); | 1389 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node,
[]); |
| 1391 } | 1390 } |
| 1392 return true; | 1391 return true; |
| 1393 } | 1392 } |
| 1394 Element rhsElement = rhsType.element; | 1393 Element rhsElement = rhsType.element; |
| 1395 LibraryElement libraryElement = rhsElement != null ? rhsElement.library : nu
ll; | 1394 LibraryElement libraryElement = rhsElement != null ? rhsElement.library : nu
ll; |
| 1396 if (libraryElement != null && libraryElement.isDartCore) { | 1395 if (libraryElement != null && libraryElement.isDartCore) { |
| 1397 if ((rhsType.isObject && rhsNameStr == _OBJECT_TYPE_NAME) || (expression i
s NullLiteral && rhsNameStr == _NULL_TYPE_NAME)) { | 1396 if (rhsType.isObject || (expression is NullLiteral && rhsNameStr == _NULL_
TYPE_NAME)) { |
| 1398 if (node.notOperator == null) { | 1397 if (node.notOperator == null) { |
| 1399 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node
, []); | 1398 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node
, []); |
| 1400 } else { | 1399 } else { |
| 1401 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, nod
e, []); | 1400 _errorReporter.reportError2(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, nod
e, []); |
| 1402 } | 1401 } |
| 1403 return true; | 1402 return true; |
| 1404 } else if (rhsNameStr == _NULL_TYPE_NAME) { | 1403 } else if (rhsNameStr == _NULL_TYPE_NAME) { |
| 1405 if (node.notOperator == null) { | 1404 if (node.notOperator == null) { |
| 1406 _errorReporter.reportError2(HintCode.TYPE_CHECK_IS_NULL, node, []); | 1405 _errorReporter.reportError2(HintCode.TYPE_CHECK_IS_NULL, node, []); |
| 1407 } else { | 1406 } else { |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 2069 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 2071 SimpleIdentifier prefixIdentifier = node.prefix; | 2070 SimpleIdentifier prefixIdentifier = node.prefix; |
| 2072 Element element = prefixIdentifier.staticElement; | 2071 Element element = prefixIdentifier.staticElement; |
| 2073 if (element is PrefixElement) { | 2072 if (element is PrefixElement) { |
| 2074 _unusedImports.remove(_prefixElementMap[element]); | 2073 _unusedImports.remove(_prefixElementMap[element]); |
| 2075 return null; | 2074 return null; |
| 2076 } | 2075 } |
| 2077 return visitIdentifier(element, prefixIdentifier.name); | 2076 return visitIdentifier(element, prefixIdentifier.name); |
| 2078 } | 2077 } |
| 2079 Object visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node.st
aticElement, node.name); | 2078 Object visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node.st
aticElement, node.name); |
| 2080 void set inDefiningCompilationUnit(bool inDefiningCompilationUnit2) { | 2079 void set inDefiningCompilationUnit(bool inDefiningCompilationUnit) { |
| 2081 this._inDefiningCompilationUnit = inDefiningCompilationUnit2; | 2080 this._inDefiningCompilationUnit = inDefiningCompilationUnit; |
| 2082 } | 2081 } |
| 2083 | 2082 |
| 2084 /** | 2083 /** |
| 2085 * Recursively add any exported library elements into the [libraryMap]. | 2084 * Recursively add any exported library elements into the [libraryMap]. |
| 2086 */ | 2085 */ |
| 2087 void addAdditionalLibrariesForExports(LibraryElement library, ImportDirective
importDirective, List<LibraryElement> exportPath) { | 2086 void addAdditionalLibrariesForExports(LibraryElement library, ImportDirective
importDirective, List<LibraryElement> exportPath) { |
| 2088 if (exportPath.contains(library)) { | 2087 if (exportPath.contains(library)) { |
| 2089 return; | 2088 return; |
| 2090 } | 2089 } |
| 2091 exportPath.add(library); | 2090 exportPath.add(library); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 */ | 2369 */ |
| 2371 ParameterElement _enclosingParameter; | 2370 ParameterElement _enclosingParameter; |
| 2372 | 2371 |
| 2373 /** | 2372 /** |
| 2374 * Resolve the declarations within the given compilation unit to the elements
rooted at the given | 2373 * Resolve the declarations within the given compilation unit to the elements
rooted at the given |
| 2375 * element. | 2374 * element. |
| 2376 * | 2375 * |
| 2377 * @param unit the compilation unit to be resolved | 2376 * @param unit the compilation unit to be resolved |
| 2378 * @param element the root of the element model used to resolve the AST nodes | 2377 * @param element the root of the element model used to resolve the AST nodes |
| 2379 */ | 2378 */ |
| 2380 void resolve(CompilationUnit unit, CompilationUnitElement element2) { | 2379 void resolve(CompilationUnit unit, CompilationUnitElement element) { |
| 2381 _enclosingUnit = element2; | 2380 _enclosingUnit = element; |
| 2382 unit.element = element2; | 2381 unit.element = element; |
| 2383 unit.accept(this); | 2382 unit.accept(this); |
| 2384 } | 2383 } |
| 2385 Object visitCatchClause(CatchClause node) { | 2384 Object visitCatchClause(CatchClause node) { |
| 2386 SimpleIdentifier exceptionParameter = node.exceptionParameter; | 2385 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 2387 if (exceptionParameter != null) { | 2386 if (exceptionParameter != null) { |
| 2388 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; | 2387 List<LocalVariableElement> localVariables = _enclosingExecutable.localVari
ables; |
| 2389 find3(localVariables, exceptionParameter); | 2388 find3(localVariables, exceptionParameter); |
| 2390 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; | 2389 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; |
| 2391 if (stackTraceParameter != null) { | 2390 if (stackTraceParameter != null) { |
| 2392 find3(localVariables, stackTraceParameter); | 2391 find3(localVariables, stackTraceParameter); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 | 2729 |
| 2731 /** | 2730 /** |
| 2732 * Return the export element from the given array whose library has the given
source, or | 2731 * Return the export element from the given array whose library has the given
source, or |
| 2733 * `null` if there is no such export. | 2732 * `null` if there is no such export. |
| 2734 * | 2733 * |
| 2735 * @param exports the export elements being searched | 2734 * @param exports the export elements being searched |
| 2736 * @param source the source of the library associated with the export element
to being searched | 2735 * @param source the source of the library associated with the export element
to being searched |
| 2737 * for | 2736 * for |
| 2738 * @return the export element whose library has the given source | 2737 * @return the export element whose library has the given source |
| 2739 */ | 2738 */ |
| 2740 ExportElement find5(List<ExportElement> exports, Source source2) { | 2739 ExportElement find5(List<ExportElement> exports, Source source) { |
| 2741 for (ExportElement export in exports) { | 2740 for (ExportElement export in exports) { |
| 2742 if (export.exportedLibrary.source == source2) { | 2741 if (export.exportedLibrary.source == source) { |
| 2743 return export; | 2742 return export; |
| 2744 } | 2743 } |
| 2745 } | 2744 } |
| 2746 return null; | 2745 return null; |
| 2747 } | 2746 } |
| 2748 | 2747 |
| 2749 /** | 2748 /** |
| 2750 * Return the import element from the given array whose library has the given
source and that has | 2749 * Return the import element from the given array whose library has the given
source and that has |
| 2751 * the given prefix, or `null` if there is no such import. | 2750 * the given prefix, or `null` if there is no such import. |
| 2752 * | 2751 * |
| 2753 * @param imports the import elements being searched | 2752 * @param imports the import elements being searched |
| 2754 * @param source the source of the library associated with the import element
to being searched | 2753 * @param source the source of the library associated with the import element
to being searched |
| 2755 * for | 2754 * for |
| 2756 * @param prefix the prefix with which the library was imported | 2755 * @param prefix the prefix with which the library was imported |
| 2757 * @return the import element whose library has the given source and prefix | 2756 * @return the import element whose library has the given source and prefix |
| 2758 */ | 2757 */ |
| 2759 ImportElement find6(List<ImportElement> imports, Source source2, SimpleIdentif
ier prefix2) { | 2758 ImportElement find6(List<ImportElement> imports, Source source, SimpleIdentifi
er prefix) { |
| 2760 for (ImportElement element in imports) { | 2759 for (ImportElement element in imports) { |
| 2761 if (element.importedLibrary.source == source2) { | 2760 if (element.importedLibrary.source == source) { |
| 2762 PrefixElement prefixElement = element.prefix; | 2761 PrefixElement prefixElement = element.prefix; |
| 2763 if (prefix2 == null) { | 2762 if (prefix == null) { |
| 2764 if (prefixElement == null) { | 2763 if (prefixElement == null) { |
| 2765 return element; | 2764 return element; |
| 2766 } | 2765 } |
| 2767 } else { | 2766 } else { |
| 2768 if (prefixElement != null && prefix2.name == prefixElement.displayName
) { | 2767 if (prefixElement != null && prefix.name == prefixElement.displayName)
{ |
| 2769 return element; | 2768 return element; |
| 2770 } | 2769 } |
| 2771 } | 2770 } |
| 2772 } | 2771 } |
| 2773 } | 2772 } |
| 2774 return null; | 2773 return null; |
| 2775 } | 2774 } |
| 2776 | 2775 |
| 2777 /** | 2776 /** |
| 2778 * Search the most closely enclosing list of parameters for a parameter with t
he given name. | 2777 * Search the most closely enclosing list of parameters for a parameter with t
he given name. |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3739 | 3738 |
| 3740 /** | 3739 /** |
| 3741 * Given a list of arguments and the element that will be invoked using those
argument, compute | 3740 * Given a list of arguments and the element that will be invoked using those
argument, compute |
| 3742 * the list of parameters that correspond to the list of arguments. Return the
parameters that | 3741 * the list of parameters that correspond to the list of arguments. Return the
parameters that |
| 3743 * correspond to the arguments, or `null` if no correspondence could be comput
ed. | 3742 * correspond to the arguments, or `null` if no correspondence could be comput
ed. |
| 3744 * | 3743 * |
| 3745 * @param argumentList the list of arguments being passed to the element | 3744 * @param argumentList the list of arguments being passed to the element |
| 3746 * @param executableElement the element that will be invoked with the argument
s | 3745 * @param executableElement the element that will be invoked with the argument
s |
| 3747 * @return the parameters that correspond to the arguments | 3746 * @return the parameters that correspond to the arguments |
| 3748 */ | 3747 */ |
| 3749 List<ParameterElement> computeCorrespondingParameters(ArgumentList argumentLis
t, Element element2) { | 3748 List<ParameterElement> computeCorrespondingParameters(ArgumentList argumentLis
t, Element element) { |
| 3750 if (element2 is PropertyAccessorElement) { | 3749 if (element is PropertyAccessorElement) { |
| 3751 FunctionType getterType = ((element2 as PropertyAccessorElement)).type; | 3750 FunctionType getterType = ((element as PropertyAccessorElement)).type; |
| 3752 if (getterType != null) { | 3751 if (getterType != null) { |
| 3753 Type2 getterReturnType = getterType.returnType; | 3752 Type2 getterReturnType = getterType.returnType; |
| 3754 if (getterReturnType is InterfaceType) { | 3753 if (getterReturnType is InterfaceType) { |
| 3755 MethodElement callMethod = ((getterReturnType as InterfaceType)).lookU
pMethod(CALL_METHOD_NAME, _resolver.definingLibrary); | 3754 MethodElement callMethod = ((getterReturnType as InterfaceType)).lookU
pMethod(CALL_METHOD_NAME, _resolver.definingLibrary); |
| 3756 if (callMethod != null) { | 3755 if (callMethod != null) { |
| 3757 return resolveArgumentsToParameters(false, argumentList, callMethod)
; | 3756 return resolveArgumentsToParameters(false, argumentList, callMethod)
; |
| 3758 } | 3757 } |
| 3759 } else if (getterReturnType is FunctionType) { | 3758 } else if (getterReturnType is FunctionType) { |
| 3760 Element functionElement = ((getterReturnType as FunctionType)).element
; | 3759 Element functionElement = ((getterReturnType as FunctionType)).element
; |
| 3761 if (functionElement is ExecutableElement) { | 3760 if (functionElement is ExecutableElement) { |
| 3762 return resolveArgumentsToParameters(false, argumentList, functionEle
ment as ExecutableElement); | 3761 return resolveArgumentsToParameters(false, argumentList, functionEle
ment as ExecutableElement); |
| 3763 } | 3762 } |
| 3764 } | 3763 } |
| 3765 } | 3764 } |
| 3766 } else if (element2 is ExecutableElement) { | 3765 } else if (element is ExecutableElement) { |
| 3767 return resolveArgumentsToParameters(false, argumentList, element2 as Execu
tableElement); | 3766 return resolveArgumentsToParameters(false, argumentList, element as Execut
ableElement); |
| 3768 } else if (element2 is VariableElement) { | 3767 } else if (element is VariableElement) { |
| 3769 VariableElement variable = element2 as VariableElement; | 3768 VariableElement variable = element as VariableElement; |
| 3770 Type2 type = variable.type; | 3769 Type2 type = variable.type; |
| 3771 if (type is FunctionType) { | 3770 if (type is FunctionType) { |
| 3772 FunctionType functionType = type as FunctionType; | 3771 FunctionType functionType = type as FunctionType; |
| 3773 List<ParameterElement> parameters = functionType.parameters; | 3772 List<ParameterElement> parameters = functionType.parameters; |
| 3774 return resolveArgumentsToParameters2(false, argumentList, parameters); | 3773 return resolveArgumentsToParameters2(false, argumentList, parameters); |
| 3775 } else if (type is InterfaceType) { | 3774 } else if (type is InterfaceType) { |
| 3776 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(CALL_M
ETHOD_NAME, _resolver.definingLibrary); | 3775 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(CALL_M
ETHOD_NAME, _resolver.definingLibrary); |
| 3777 if (callMethod != null) { | 3776 if (callMethod != null) { |
| 3778 List<ParameterElement> parameters = callMethod.parameters; | 3777 List<ParameterElement> parameters = callMethod.parameters; |
| 3779 return resolveArgumentsToParameters2(false, argumentList, parameters); | 3778 return resolveArgumentsToParameters2(false, argumentList, parameters); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4336 | 4335 |
| 4337 /** | 4336 /** |
| 4338 * Validates that the given [Element] is the constant variable; or resolves it
as a | 4337 * Validates that the given [Element] is the constant variable; or resolves it
as a |
| 4339 * constructor invocation. | 4338 * constructor invocation. |
| 4340 * | 4339 * |
| 4341 * @param annotation the [Annotation] to resolve | 4340 * @param annotation the [Annotation] to resolve |
| 4342 * @param element the current known [Element] of the annotation, or [ClassElem
ent] | 4341 * @param element the current known [Element] of the annotation, or [ClassElem
ent] |
| 4343 * @param nameNode the name of the invoked constructor, may be `null` if unnam
ed constructor | 4342 * @param nameNode the name of the invoked constructor, may be `null` if unnam
ed constructor |
| 4344 * or not a constructor invocation | 4343 * or not a constructor invocation |
| 4345 */ | 4344 */ |
| 4346 void resolveAnnotationElement(Annotation annotation, Element element2, SimpleI
dentifier nameNode) { | 4345 void resolveAnnotationElement(Annotation annotation, Element element, SimpleId
entifier nameNode) { |
| 4347 if (element2 is PropertyAccessorElement) { | 4346 if (element is PropertyAccessorElement) { |
| 4348 PropertyAccessorElement accessorElement = element2 as PropertyAccessorElem
ent; | 4347 PropertyAccessorElement accessorElement = element as PropertyAccessorEleme
nt; |
| 4349 if (!accessorElement.isSynthetic) { | 4348 if (!accessorElement.isSynthetic) { |
| 4350 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); | 4349 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
| 4351 return; | 4350 return; |
| 4352 } | 4351 } |
| 4353 VariableElement variableElement = accessorElement.variable; | 4352 VariableElement variableElement = accessorElement.variable; |
| 4354 if (!variableElement.isConst) { | 4353 if (!variableElement.isConst) { |
| 4355 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); | 4354 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
| 4356 } | 4355 } |
| 4357 return; | 4356 return; |
| 4358 } | 4357 } |
| 4359 if (element2 is ClassElement) { | 4358 if (element is ClassElement) { |
| 4360 if (nameNode == null) { | 4359 if (nameNode == null) { |
| 4361 nameNode = annotation.constructorName; | 4360 nameNode = annotation.constructorName; |
| 4362 } | 4361 } |
| 4363 String name = nameNode != null ? nameNode.name : null; | 4362 String name = nameNode != null ? nameNode.name : null; |
| 4364 ConstructorElement constructor; | 4363 ConstructorElement constructor; |
| 4365 { | 4364 { |
| 4366 InterfaceType interfaceType = new InterfaceTypeImpl.con1(element2 as Cla
ssElement); | 4365 InterfaceType interfaceType = new InterfaceTypeImpl.con1(element as Clas
sElement); |
| 4367 LibraryElement definingLibrary = _resolver.definingLibrary; | 4366 LibraryElement definingLibrary = _resolver.definingLibrary; |
| 4368 constructor = interfaceType.lookUpConstructor(name, definingLibrary); | 4367 constructor = interfaceType.lookUpConstructor(name, definingLibrary); |
| 4369 } | 4368 } |
| 4370 if (constructor == null) { | 4369 if (constructor == null) { |
| 4371 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); | 4370 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotati
on, []); |
| 4372 return; | 4371 return; |
| 4373 } | 4372 } |
| 4374 annotation.element = constructor; | 4373 annotation.element = constructor; |
| 4375 if (nameNode != null) { | 4374 if (nameNode != null) { |
| 4376 nameNode.staticElement = constructor; | 4375 nameNode.staticElement = constructor; |
| 4377 } | 4376 } |
| 4378 resolveAnnotationConstructorInvocationArguments(annotation, constructor); | 4377 resolveAnnotationConstructorInvocationArguments(annotation, constructor); |
| 4379 return; | 4378 return; |
| 4380 } | 4379 } |
| 4381 if (element2 != null) { | 4380 if (element != null) { |
| 4382 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotation
, []); | 4381 _resolver.reportError5(CompileTimeErrorCode.INVALID_ANNOTATION, annotation
, []); |
| 4383 } | 4382 } |
| 4384 } | 4383 } |
| 4385 | 4384 |
| 4386 /** | 4385 /** |
| 4387 * Given a list of arguments and the element that will be invoked using those
argument, compute | 4386 * Given a list of arguments and the element that will be invoked using those
argument, compute |
| 4388 * the list of parameters that correspond to the list of arguments. Return the
parameters that | 4387 * the list of parameters that correspond to the list of arguments. Return the
parameters that |
| 4389 * correspond to the arguments, or `null` if no correspondence could be comput
ed. | 4388 * correspond to the arguments, or `null` if no correspondence could be comput
ed. |
| 4390 * | 4389 * |
| 4391 * @param reportError if `true` then compile-time error should be reported; if
`false` | 4390 * @param reportError if `true` then compile-time error should be reported; if
`false` |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4899 return null; | 4898 return null; |
| 4900 } | 4899 } |
| 4901 return substituteTypeArgumentsInMemberFromInheritance(iteratorMember.type, m
emberName, interfaceType); | 4900 return substituteTypeArgumentsInMemberFromInheritance(iteratorMember.type, m
emberName, interfaceType); |
| 4902 } | 4901 } |
| 4903 | 4902 |
| 4904 /** | 4903 /** |
| 4905 * Set the new library element context. | 4904 * Set the new library element context. |
| 4906 * | 4905 * |
| 4907 * @param library the new library element | 4906 * @param library the new library element |
| 4908 */ | 4907 */ |
| 4909 void set libraryElement(LibraryElement library2) { | 4908 void set libraryElement(LibraryElement library) { |
| 4910 this._library = library2; | 4909 this._library = library; |
| 4911 } | 4910 } |
| 4912 | 4911 |
| 4913 /** | 4912 /** |
| 4914 * This method takes some inherited [FunctionType], and resolves all the param
eterized types | 4913 * This method takes some inherited [FunctionType], and resolves all the param
eterized types |
| 4915 * in the function type, dependent on the class in which it is being overridde
n. | 4914 * in the function type, dependent on the class in which it is being overridde
n. |
| 4916 * | 4915 * |
| 4917 * @param baseFunctionType the function type that is being overridden | 4916 * @param baseFunctionType the function type that is being overridden |
| 4918 * @param memberName the name of the member, this is used to lookup the inheri
tance path of the | 4917 * @param memberName the name of the member, this is used to lookup the inheri
tance path of the |
| 4919 * override | 4918 * override |
| 4920 * @param definingType the type that is overriding the member | 4919 * @param definingType the type that is overriding the member |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5527 */ | 5526 */ |
| 5528 void setDefiningCompilationUnit(int modificationStamp, CompilationUnit unit) { | 5527 void setDefiningCompilationUnit(int modificationStamp, CompilationUnit unit) { |
| 5529 _astMap[librarySource] = new ResolvableCompilationUnit(modificationStamp, un
it); | 5528 _astMap[librarySource] = new ResolvableCompilationUnit(modificationStamp, un
it); |
| 5530 } | 5529 } |
| 5531 | 5530 |
| 5532 /** | 5531 /** |
| 5533 * Set the libraries that are exported by this library to be those in the give
n array. | 5532 * Set the libraries that are exported by this library to be those in the give
n array. |
| 5534 * | 5533 * |
| 5535 * @param exportedLibraries the libraries that are exported by this library | 5534 * @param exportedLibraries the libraries that are exported by this library |
| 5536 */ | 5535 */ |
| 5537 void set exportedLibraries(List<Library> exportedLibraries2) { | 5536 void set exportedLibraries(List<Library> exportedLibraries) { |
| 5538 this.exports = exportedLibraries2; | 5537 this.exports = exportedLibraries; |
| 5539 } | 5538 } |
| 5540 | 5539 |
| 5541 /** | 5540 /** |
| 5542 * Set the libraries that are imported into this library to be those in the gi
ven array. | 5541 * Set the libraries that are imported into this library to be those in the gi
ven array. |
| 5543 * | 5542 * |
| 5544 * @param importedLibraries the libraries that are imported into this library | 5543 * @param importedLibraries the libraries that are imported into this library |
| 5545 */ | 5544 */ |
| 5546 void set importedLibraries(List<Library> importedLibraries2) { | 5545 void set importedLibraries(List<Library> importedLibraries) { |
| 5547 this.imports = importedLibraries2; | 5546 this.imports = importedLibraries; |
| 5548 } | 5547 } |
| 5549 | 5548 |
| 5550 /** | 5549 /** |
| 5551 * Set the library element representing this library to the given library elem
ent. | 5550 * Set the library element representing this library to the given library elem
ent. |
| 5552 * | 5551 * |
| 5553 * @param libraryElement the library element representing this library | 5552 * @param libraryElement the library element representing this library |
| 5554 */ | 5553 */ |
| 5555 void set libraryElement(LibraryElementImpl libraryElement2) { | 5554 void set libraryElement(LibraryElementImpl libraryElement) { |
| 5556 this._libraryElement = libraryElement2; | 5555 this._libraryElement = libraryElement; |
| 5557 if (_inheritanceManager != null) { | 5556 if (_inheritanceManager != null) { |
| 5558 _inheritanceManager.libraryElement = libraryElement2; | 5557 _inheritanceManager.libraryElement = libraryElement; |
| 5559 } | 5558 } |
| 5560 } | 5559 } |
| 5561 String toString() => librarySource.shortName; | 5560 String toString() => librarySource.shortName; |
| 5562 } | 5561 } |
| 5563 /** | 5562 /** |
| 5564 * Instances of the class `LibraryElementBuilder` build an element model for a s
ingle library. | 5563 * Instances of the class `LibraryElementBuilder` build an element model for a s
ingle library. |
| 5565 * | 5564 * |
| 5566 * @coverage dart.engine.resolver | 5565 * @coverage dart.engine.resolver |
| 5567 */ | 5566 */ |
| 5568 class LibraryElementBuilder { | 5567 class LibraryElementBuilder { |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6437 * The name of the meta library name, from the meta pub package. | 6436 * The name of the meta library name, from the meta pub package. |
| 6438 */ | 6437 */ |
| 6439 static String _META_LIBRARY_NAME = "meta"; | 6438 static String _META_LIBRARY_NAME = "meta"; |
| 6440 | 6439 |
| 6441 /** | 6440 /** |
| 6442 * Return `true` if the given element represents a class that has the proxy an
notation. | 6441 * Return `true` if the given element represents a class that has the proxy an
notation. |
| 6443 * | 6442 * |
| 6444 * @param element the class being tested | 6443 * @param element the class being tested |
| 6445 * @return `true` if the given element represents a class that has the proxy a
nnotation | 6444 * @return `true` if the given element represents a class that has the proxy a
nnotation |
| 6446 */ | 6445 */ |
| 6447 static bool classHasProxyAnnotation(Element element2) { | 6446 static bool classHasProxyAnnotation(Element element) { |
| 6448 if (element2 is ClassElement) { | 6447 if (element is ClassElement) { |
| 6449 ClassElement classElement = element2 as ClassElement; | 6448 ClassElement classElement = element as ClassElement; |
| 6450 List<ElementAnnotation> annotations = classElement.metadata; | 6449 List<ElementAnnotation> annotations = classElement.metadata; |
| 6451 for (ElementAnnotation annotation in annotations) { | 6450 for (ElementAnnotation annotation in annotations) { |
| 6452 Element elementAnnotation = annotation.element; | 6451 Element elementAnnotation = annotation.element; |
| 6453 if (elementAnnotation != null) { | 6452 if (elementAnnotation != null) { |
| 6454 LibraryElement lib = elementAnnotation.library; | 6453 LibraryElement lib = elementAnnotation.library; |
| 6455 if (elementAnnotation.name == _PROXY_ANNOTATION_NAME && lib != null &&
lib.name == _META_LIBRARY_NAME) { | 6454 if (elementAnnotation.name == _PROXY_ANNOTATION_NAME && lib != null &&
lib.name == _META_LIBRARY_NAME) { |
| 6456 return true; | 6455 return true; |
| 6457 } | 6456 } |
| 6458 } | 6457 } |
| 6459 } | 6458 } |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7200 } | 7199 } |
| 7201 } | 7200 } |
| 7202 | 7201 |
| 7203 /** | 7202 /** |
| 7204 * Return `true` if the given expression terminates abruptly (that is, if any
expression | 7203 * Return `true` if the given expression terminates abruptly (that is, if any
expression |
| 7205 * following the given expression will not be reached). | 7204 * following the given expression will not be reached). |
| 7206 * | 7205 * |
| 7207 * @param expression the expression being tested | 7206 * @param expression the expression being tested |
| 7208 * @return `true` if the given expression terminates abruptly | 7207 * @return `true` if the given expression terminates abruptly |
| 7209 */ | 7208 */ |
| 7210 bool isAbruptTermination(Expression expression2) { | 7209 bool isAbruptTermination(Expression expression) { |
| 7211 while (expression2 is ParenthesizedExpression) { | 7210 while (expression is ParenthesizedExpression) { |
| 7212 expression2 = ((expression2 as ParenthesizedExpression)).expression; | 7211 expression = ((expression as ParenthesizedExpression)).expression; |
| 7213 } | 7212 } |
| 7214 return expression2 is ThrowExpression || expression2 is RethrowExpression; | 7213 return expression is ThrowExpression || expression is RethrowExpression; |
| 7215 } | 7214 } |
| 7216 | 7215 |
| 7217 /** | 7216 /** |
| 7218 * Return `true` if the given statement terminates abruptly (that is, if any s
tatement | 7217 * Return `true` if the given statement terminates abruptly (that is, if any s
tatement |
| 7219 * following the given statement will not be reached). | 7218 * following the given statement will not be reached). |
| 7220 * | 7219 * |
| 7221 * @param statement the statement being tested | 7220 * @param statement the statement being tested |
| 7222 * @return `true` if the given statement terminates abruptly | 7221 * @return `true` if the given statement terminates abruptly |
| 7223 */ | 7222 */ |
| 7224 bool isAbruptTermination2(Statement statement) { | 7223 bool isAbruptTermination2(Statement statement) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7492 try { | 7491 try { |
| 7493 nameScope = new EnclosedScope(nameScope); | 7492 nameScope = new EnclosedScope(nameScope); |
| 7494 labelScope = new LabelScope.con1(outerLabelScope, false, false); | 7493 labelScope = new LabelScope.con1(outerLabelScope, false, false); |
| 7495 visitForEachStatementInScope(node); | 7494 visitForEachStatementInScope(node); |
| 7496 } finally { | 7495 } finally { |
| 7497 labelScope = outerLabelScope; | 7496 labelScope = outerLabelScope; |
| 7498 nameScope = outerNameScope; | 7497 nameScope = outerNameScope; |
| 7499 } | 7498 } |
| 7500 return null; | 7499 return null; |
| 7501 } | 7500 } |
| 7501 Object visitFormalParameterList(FormalParameterList node) { |
| 7502 super.visitFormalParameterList(node); |
| 7503 if (nameScope is FunctionScope) { |
| 7504 ((nameScope as FunctionScope)).defineParameters(); |
| 7505 } |
| 7506 if (nameScope is FunctionTypeScope) { |
| 7507 ((nameScope as FunctionTypeScope)).defineParameters(); |
| 7508 } |
| 7509 return null; |
| 7510 } |
| 7502 Object visitForStatement(ForStatement node) { | 7511 Object visitForStatement(ForStatement node) { |
| 7503 Scope outerNameScope = nameScope; | 7512 Scope outerNameScope = nameScope; |
| 7504 LabelScope outerLabelScope = labelScope; | 7513 LabelScope outerLabelScope = labelScope; |
| 7505 try { | 7514 try { |
| 7506 nameScope = new EnclosedScope(nameScope); | 7515 nameScope = new EnclosedScope(nameScope); |
| 7507 labelScope = new LabelScope.con1(outerLabelScope, false, false); | 7516 labelScope = new LabelScope.con1(outerLabelScope, false, false); |
| 7508 visitForStatementInScope(node); | 7517 visitForStatementInScope(node); |
| 7509 } finally { | 7518 } finally { |
| 7510 labelScope = outerLabelScope; | 7519 labelScope = outerLabelScope; |
| 7511 nameScope = outerNameScope; | 7520 nameScope = outerNameScope; |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7901 _typeProvider = resolver.typeProvider; | 7910 _typeProvider = resolver.typeProvider; |
| 7902 _dynamicType = _typeProvider.dynamicType; | 7911 _dynamicType = _typeProvider.dynamicType; |
| 7903 _overrideManager = resolver.overrideManager; | 7912 _overrideManager = resolver.overrideManager; |
| 7904 } | 7913 } |
| 7905 | 7914 |
| 7906 /** | 7915 /** |
| 7907 * Set the type of the class being analyzed to the given type. | 7916 * Set the type of the class being analyzed to the given type. |
| 7908 * | 7917 * |
| 7909 * @param thisType the type representing the class containing the nodes being
analyzed | 7918 * @param thisType the type representing the class containing the nodes being
analyzed |
| 7910 */ | 7919 */ |
| 7911 void set thisType(InterfaceType thisType2) { | 7920 void set thisType(InterfaceType thisType) { |
| 7912 this._thisType = thisType2; | 7921 this._thisType = thisType; |
| 7913 } | 7922 } |
| 7914 | 7923 |
| 7915 /** | 7924 /** |
| 7916 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is | 7925 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is |
| 7917 * `String`.</blockquote> | 7926 * `String`.</blockquote> |
| 7918 */ | 7927 */ |
| 7919 Object visitAdjacentStrings(AdjacentStrings node) { | 7928 Object visitAdjacentStrings(AdjacentStrings node) { |
| 7920 recordStaticType(node, _typeProvider.stringType); | 7929 recordStaticType(node, _typeProvider.stringType); |
| 7921 return null; | 7930 return null; |
| 7922 } | 7931 } |
| (...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10031 Object visitSuperExpression(SuperExpression node) { | 10040 Object visitSuperExpression(SuperExpression node) { |
| 10032 _hasReferenceToSuper = true; | 10041 _hasReferenceToSuper = true; |
| 10033 return super.visitSuperExpression(node); | 10042 return super.visitSuperExpression(node); |
| 10034 } | 10043 } |
| 10035 Object visitTypeName(TypeName node) { | 10044 Object visitTypeName(TypeName node) { |
| 10036 super.visitTypeName(node); | 10045 super.visitTypeName(node); |
| 10037 Identifier typeName = node.name; | 10046 Identifier typeName = node.name; |
| 10038 TypeArgumentList argumentList = node.typeArguments; | 10047 TypeArgumentList argumentList = node.typeArguments; |
| 10039 Element element = nameScope.lookup(typeName, definingLibrary); | 10048 Element element = nameScope.lookup(typeName, definingLibrary); |
| 10040 if (element == null) { | 10049 if (element == null) { |
| 10041 if (typeName.name == _dynamicType.name) { | 10050 if (typeName.name == this._dynamicType.name) { |
| 10042 setElement(typeName, _dynamicType.element); | 10051 setElement(typeName, this._dynamicType.element); |
| 10043 if (argumentList != null) { | 10052 if (argumentList != null) { |
| 10044 } | 10053 } |
| 10045 typeName.staticType = _dynamicType; | 10054 typeName.staticType = this._dynamicType; |
| 10046 node.type = _dynamicType; | 10055 node.type = this._dynamicType; |
| 10047 return null; | 10056 return null; |
| 10048 } | 10057 } |
| 10049 VoidTypeImpl voidType = VoidTypeImpl.instance; | 10058 VoidTypeImpl voidType = VoidTypeImpl.instance; |
| 10050 if (typeName.name == voidType.name) { | 10059 if (typeName.name == voidType.name) { |
| 10051 if (argumentList != null) { | 10060 if (argumentList != null) { |
| 10052 } | 10061 } |
| 10053 typeName.staticType = voidType; | 10062 typeName.staticType = voidType; |
| 10054 node.type = voidType; | 10063 node.type = voidType; |
| 10055 return null; | 10064 return null; |
| 10056 } | 10065 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10112 reportError5(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, typeName,
[typeName.name]); | 10121 reportError5(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, typeName,
[typeName.name]); |
| 10113 } else { | 10122 } else { |
| 10114 reportError5(StaticWarningCode.UNDEFINED_CLASS, typeName, [typeName.name
]); | 10123 reportError5(StaticWarningCode.UNDEFINED_CLASS, typeName, [typeName.name
]); |
| 10115 } | 10124 } |
| 10116 elementValid = false; | 10125 elementValid = false; |
| 10117 } | 10126 } |
| 10118 if (!elementValid) { | 10127 if (!elementValid) { |
| 10119 if (element is MultiplyDefinedElement) { | 10128 if (element is MultiplyDefinedElement) { |
| 10120 setElement(typeName, element); | 10129 setElement(typeName, element); |
| 10121 } else { | 10130 } else { |
| 10122 setElement(typeName, _dynamicType.element); | 10131 setElement(typeName, this._dynamicType.element); |
| 10123 } | 10132 } |
| 10124 typeName.staticType = _dynamicType; | 10133 typeName.staticType = this._dynamicType; |
| 10125 node.type = _dynamicType; | 10134 node.type = this._dynamicType; |
| 10126 return null; | 10135 return null; |
| 10127 } | 10136 } |
| 10128 Type2 type = null; | 10137 Type2 type = null; |
| 10129 if (element is ClassElement) { | 10138 if (element is ClassElement) { |
| 10130 setElement(typeName, element); | 10139 setElement(typeName, element); |
| 10131 type = ((element as ClassElement)).type; | 10140 type = ((element as ClassElement)).type; |
| 10132 } else if (element is FunctionTypeAliasElement) { | 10141 } else if (element is FunctionTypeAliasElement) { |
| 10133 setElement(typeName, element); | 10142 setElement(typeName, element); |
| 10134 type = ((element as FunctionTypeAliasElement)).type; | 10143 type = ((element as FunctionTypeAliasElement)).type; |
| 10135 } else if (element is TypeParameterElement) { | 10144 } else if (element is TypeParameterElement) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 10157 } else { | 10166 } else { |
| 10158 ASTNode parent = typeName.parent; | 10167 ASTNode parent = typeName.parent; |
| 10159 while (parent is TypeName) { | 10168 while (parent is TypeName) { |
| 10160 parent = parent.parent; | 10169 parent = parent.parent; |
| 10161 } | 10170 } |
| 10162 if (parent is ExtendsClause || parent is ImplementsClause || parent is W
ithClause || parent is ClassTypeAlias) { | 10171 if (parent is ExtendsClause || parent is ImplementsClause || parent is W
ithClause || parent is ClassTypeAlias) { |
| 10163 } else { | 10172 } else { |
| 10164 reportError5(StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]); | 10173 reportError5(StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]); |
| 10165 } | 10174 } |
| 10166 } | 10175 } |
| 10167 setElement(typeName, _dynamicType.element); | 10176 setElement(typeName, this._dynamicType.element); |
| 10168 typeName.staticType = _dynamicType; | 10177 typeName.staticType = this._dynamicType; |
| 10169 node.type = _dynamicType; | 10178 node.type = this._dynamicType; |
| 10170 return null; | 10179 return null; |
| 10171 } | 10180 } |
| 10172 if (argumentList != null) { | 10181 if (argumentList != null) { |
| 10173 NodeList<TypeName> arguments = argumentList.arguments; | 10182 NodeList<TypeName> arguments = argumentList.arguments; |
| 10174 int argumentCount = arguments.length; | 10183 int argumentCount = arguments.length; |
| 10175 List<Type2> parameters = getTypeArguments(type); | 10184 List<Type2> parameters = getTypeArguments(type); |
| 10176 int parameterCount = parameters.length; | 10185 int parameterCount = parameters.length; |
| 10177 int count = Math.min(argumentCount, parameterCount); | 10186 int count = Math.min(argumentCount, parameterCount); |
| 10178 List<Type2> typeArguments = new List<Type2>(); | 10187 List<Type2> typeArguments = new List<Type2>(); |
| 10179 for (int i = 0; i < count; i++) { | 10188 for (int i = 0; i < count; i++) { |
| 10180 Type2 argumentType = getType3(arguments[i]); | 10189 Type2 argumentType = getType3(arguments[i]); |
| 10181 if (argumentType != null) { | 10190 if (argumentType != null) { |
| 10182 typeArguments.add(argumentType); | 10191 typeArguments.add(argumentType); |
| 10183 } | 10192 } |
| 10184 } | 10193 } |
| 10185 if (argumentCount != parameterCount) { | 10194 if (argumentCount != parameterCount) { |
| 10186 reportError5(getInvalidTypeParametersErrorCode(node), node, [typeName.na
me, parameterCount, argumentCount]); | 10195 reportError5(getInvalidTypeParametersErrorCode(node), node, [typeName.na
me, parameterCount, argumentCount]); |
| 10187 } | 10196 } |
| 10188 argumentCount = typeArguments.length; | 10197 argumentCount = typeArguments.length; |
| 10189 if (argumentCount < parameterCount) { | 10198 if (argumentCount < parameterCount) { |
| 10190 for (int i = argumentCount; i < parameterCount; i++) { | 10199 for (int i = argumentCount; i < parameterCount; i++) { |
| 10191 typeArguments.add(_dynamicType); | 10200 typeArguments.add(this._dynamicType); |
| 10192 } | 10201 } |
| 10193 } | 10202 } |
| 10194 if (type is InterfaceTypeImpl) { | 10203 if (type is InterfaceTypeImpl) { |
| 10195 InterfaceTypeImpl interfaceType = type as InterfaceTypeImpl; | 10204 InterfaceTypeImpl interfaceType = type as InterfaceTypeImpl; |
| 10196 type = interfaceType.substitute4(new List.from(typeArguments)); | 10205 type = interfaceType.substitute4(new List.from(typeArguments)); |
| 10197 } else if (type is FunctionTypeImpl) { | 10206 } else if (type is FunctionTypeImpl) { |
| 10198 FunctionTypeImpl functionType = type as FunctionTypeImpl; | 10207 FunctionTypeImpl functionType = type as FunctionTypeImpl; |
| 10199 type = functionType.substitute3(new List.from(typeArguments)); | 10208 type = functionType.substitute3(new List.from(typeArguments)); |
| 10200 } else { | 10209 } else { |
| 10201 } | 10210 } |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10601 } | 10610 } |
| 10602 | 10611 |
| 10603 /** | 10612 /** |
| 10604 * Given a parameter element, create a function type based on the given return
type and parameter | 10613 * Given a parameter element, create a function type based on the given return
type and parameter |
| 10605 * list and associate the created type with the element. | 10614 * list and associate the created type with the element. |
| 10606 * | 10615 * |
| 10607 * @param element the parameter element whose type is to be set | 10616 * @param element the parameter element whose type is to be set |
| 10608 * @param returnType the (possibly `null`) return type of the function | 10617 * @param returnType the (possibly `null`) return type of the function |
| 10609 * @param parameterList the list of parameters to the function | 10618 * @param parameterList the list of parameters to the function |
| 10610 */ | 10619 */ |
| 10611 void setFunctionTypedParameterType(ParameterElementImpl element, TypeName retu
rnType2, FormalParameterList parameterList) { | 10620 void setFunctionTypedParameterType(ParameterElementImpl element, TypeName retu
rnType, FormalParameterList parameterList) { |
| 10612 List<ParameterElement> parameters = getElements(parameterList); | 10621 List<ParameterElement> parameters = getElements(parameterList); |
| 10613 FunctionTypeAliasElementImpl aliasElement = new FunctionTypeAliasElementImpl
(null); | 10622 FunctionTypeAliasElementImpl aliasElement = new FunctionTypeAliasElementImpl
(null); |
| 10614 aliasElement.synthetic = true; | 10623 aliasElement.synthetic = true; |
| 10615 aliasElement.shareParameters(parameters); | 10624 aliasElement.shareParameters(parameters); |
| 10616 aliasElement.returnType = computeReturnType(returnType2); | 10625 aliasElement.returnType = computeReturnType(returnType); |
| 10617 FunctionTypeImpl type = new FunctionTypeImpl.con2(aliasElement); | 10626 FunctionTypeImpl type = new FunctionTypeImpl.con2(aliasElement); |
| 10618 ClassElement definingClass = element.getAncestor(ClassElement); | 10627 ClassElement definingClass = element.getAncestor(ClassElement); |
| 10619 if (definingClass != null) { | 10628 if (definingClass != null) { |
| 10620 aliasElement.shareTypeParameters(definingClass.typeParameters); | 10629 aliasElement.shareTypeParameters(definingClass.typeParameters); |
| 10621 type.typeArguments = definingClass.type.typeArguments; | 10630 type.typeArguments = definingClass.type.typeArguments; |
| 10622 } else { | 10631 } else { |
| 10623 FunctionTypeAliasElement alias = element.getAncestor(FunctionTypeAliasElem
ent); | 10632 FunctionTypeAliasElement alias = element.getAncestor(FunctionTypeAliasElem
ent); |
| 10624 while (alias != null && alias.isSynthetic) { | 10633 while (alias != null && alias.isSynthetic) { |
| 10625 alias = alias.getAncestor(FunctionTypeAliasElement); | 10634 alias = alias.getAncestor(FunctionTypeAliasElement); |
| 10626 } | 10635 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10743 } | 10752 } |
| 10744 return enclosingScope.lookup3(identifier, name, referencingLibrary); | 10753 return enclosingScope.lookup3(identifier, name, referencingLibrary); |
| 10745 } | 10754 } |
| 10746 } | 10755 } |
| 10747 /** | 10756 /** |
| 10748 * Instances of the class `FunctionScope` implement the scope defined by a funct
ion. | 10757 * Instances of the class `FunctionScope` implement the scope defined by a funct
ion. |
| 10749 * | 10758 * |
| 10750 * @coverage dart.engine.resolver | 10759 * @coverage dart.engine.resolver |
| 10751 */ | 10760 */ |
| 10752 class FunctionScope extends EnclosedScope { | 10761 class FunctionScope extends EnclosedScope { |
| 10762 ExecutableElement _functionElement; |
| 10763 bool _parametersDefined = false; |
| 10753 | 10764 |
| 10754 /** | 10765 /** |
| 10755 * Initialize a newly created scope enclosed within another scope. | 10766 * Initialize a newly created scope enclosed within another scope. |
| 10756 * | 10767 * |
| 10757 * @param enclosingScope the scope in which this scope is lexically enclosed | 10768 * @param enclosingScope the scope in which this scope is lexically enclosed |
| 10758 * @param functionElement the element representing the type represented by thi
s scope | 10769 * @param functionElement the element representing the type represented by thi
s scope |
| 10759 */ | 10770 */ |
| 10760 FunctionScope(Scope enclosingScope, ExecutableElement functionElement) : super
(new EnclosedScope(enclosingScope)) { | 10771 FunctionScope(Scope enclosingScope, ExecutableElement functionElement) : super
(new EnclosedScope(enclosingScope)) { |
| 10761 defineParameters(functionElement); | 10772 this._functionElement = functionElement; |
| 10762 } | 10773 } |
| 10763 | 10774 |
| 10764 /** | 10775 /** |
| 10765 * Define the parameters for the given function in the scope that encloses thi
s function. | 10776 * Define the parameters for the given function in the scope that encloses thi
s function. |
| 10766 * | |
| 10767 * @param functionElement the element representing the function represented by
this scope | |
| 10768 */ | 10777 */ |
| 10769 void defineParameters(ExecutableElement functionElement) { | 10778 void defineParameters() { |
| 10779 if (_parametersDefined) { |
| 10780 return; |
| 10781 } |
| 10782 _parametersDefined = true; |
| 10770 Scope parameterScope = enclosingScope; | 10783 Scope parameterScope = enclosingScope; |
| 10771 if (functionElement.enclosingElement is ExecutableElement) { | 10784 if (_functionElement.enclosingElement is ExecutableElement) { |
| 10772 String name = functionElement.name; | 10785 String name = _functionElement.name; |
| 10773 if (name != null && !name.isEmpty) { | 10786 if (name != null && !name.isEmpty) { |
| 10774 parameterScope.define(functionElement); | 10787 parameterScope.define(_functionElement); |
| 10775 } | 10788 } |
| 10776 } | 10789 } |
| 10777 for (ParameterElement parameter in functionElement.parameters) { | 10790 for (ParameterElement parameter in _functionElement.parameters) { |
| 10778 if (!parameter.isInitializingFormal) { | 10791 if (!parameter.isInitializingFormal) { |
| 10779 parameterScope.define(parameter); | 10792 parameterScope.define(parameter); |
| 10780 } | 10793 } |
| 10781 } | 10794 } |
| 10782 } | 10795 } |
| 10783 } | 10796 } |
| 10784 /** | 10797 /** |
| 10785 * Instances of the class `FunctionTypeScope` implement the scope defined by a f
unction type | 10798 * Instances of the class `FunctionTypeScope` implement the scope defined by a f
unction type |
| 10786 * alias. | 10799 * alias. |
| 10787 * | 10800 * |
| 10788 * @coverage dart.engine.resolver | 10801 * @coverage dart.engine.resolver |
| 10789 */ | 10802 */ |
| 10790 class FunctionTypeScope extends EnclosedScope { | 10803 class FunctionTypeScope extends EnclosedScope { |
| 10804 FunctionTypeAliasElement _typeElement; |
| 10805 bool _parametersDefined = false; |
| 10791 | 10806 |
| 10792 /** | 10807 /** |
| 10793 * Initialize a newly created scope enclosed within another scope. | 10808 * Initialize a newly created scope enclosed within another scope. |
| 10794 * | 10809 * |
| 10795 * @param enclosingScope the scope in which this scope is lexically enclosed | 10810 * @param enclosingScope the scope in which this scope is lexically enclosed |
| 10796 * @param typeElement the element representing the type alias represented by t
his scope | 10811 * @param typeElement the element representing the type alias represented by t
his scope |
| 10797 */ | 10812 */ |
| 10798 FunctionTypeScope(Scope enclosingScope, FunctionTypeAliasElement typeElement)
: super(new EnclosedScope(enclosingScope)) { | 10813 FunctionTypeScope(Scope enclosingScope, FunctionTypeAliasElement typeElement)
: super(new EnclosedScope(enclosingScope)) { |
| 10799 defineTypeParameters(typeElement); | 10814 this._typeElement = typeElement; |
| 10800 defineParameters(typeElement); | 10815 defineTypeParameters(); |
| 10801 } | 10816 } |
| 10802 | 10817 |
| 10803 /** | 10818 /** |
| 10804 * Define the parameters for the function type alias. | 10819 * Define the parameters for the function type alias. |
| 10805 * | 10820 * |
| 10806 * @param typeElement the element representing the type represented by this sc
ope | 10821 * @param typeElement the element representing the type represented by this sc
ope |
| 10807 */ | 10822 */ |
| 10808 void defineParameters(FunctionTypeAliasElement typeElement) { | 10823 void defineParameters() { |
| 10809 for (ParameterElement parameter in typeElement.parameters) { | 10824 if (_parametersDefined) { |
| 10825 return; |
| 10826 } |
| 10827 _parametersDefined = true; |
| 10828 for (ParameterElement parameter in _typeElement.parameters) { |
| 10810 define(parameter); | 10829 define(parameter); |
| 10811 } | 10830 } |
| 10812 } | 10831 } |
| 10813 | 10832 |
| 10814 /** | 10833 /** |
| 10815 * Define the type parameters for the function type alias. | 10834 * Define the type parameters for the function type alias. |
| 10816 * | 10835 * |
| 10817 * @param typeElement the element representing the type represented by this sc
ope | 10836 * @param typeElement the element representing the type represented by this sc
ope |
| 10818 */ | 10837 */ |
| 10819 void defineTypeParameters(FunctionTypeAliasElement typeElement) { | 10838 void defineTypeParameters() { |
| 10820 Scope typeParameterScope = enclosingScope; | 10839 Scope typeParameterScope = enclosingScope; |
| 10821 for (TypeParameterElement typeParameter in typeElement.typeParameters) { | 10840 for (TypeParameterElement typeParameter in _typeElement.typeParameters) { |
| 10822 typeParameterScope.define(typeParameter); | 10841 typeParameterScope.define(typeParameter); |
| 10823 } | 10842 } |
| 10824 } | 10843 } |
| 10825 } | 10844 } |
| 10826 /** | 10845 /** |
| 10827 * Instances of the class `LabelScope` represent a scope in which a single label
is defined. | 10846 * Instances of the class `LabelScope` represent a scope in which a single label
is defined. |
| 10828 * | 10847 * |
| 10829 * @coverage dart.engine.resolver | 10848 * @coverage dart.engine.resolver |
| 10830 */ | 10849 */ |
| 10831 class LabelScope { | 10850 class LabelScope { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10972 String libName1 = "", libName2 = ""; | 10991 String libName1 = "", libName2 = ""; |
| 10973 List<Element> conflictingMembers = ((foundElement as MultiplyDefinedElemen
tImpl)).conflictingElements; | 10992 List<Element> conflictingMembers = ((foundElement as MultiplyDefinedElemen
tImpl)).conflictingElements; |
| 10974 LibraryElement enclosingLibrary = conflictingMembers[0].getAncestor(Librar
yElement); | 10993 LibraryElement enclosingLibrary = conflictingMembers[0].getAncestor(Librar
yElement); |
| 10975 if (enclosingLibrary != null) { | 10994 if (enclosingLibrary != null) { |
| 10976 libName1 = enclosingLibrary.definingCompilationUnit.displayName; | 10995 libName1 = enclosingLibrary.definingCompilationUnit.displayName; |
| 10977 } | 10996 } |
| 10978 enclosingLibrary = conflictingMembers[1].getAncestor(LibraryElement); | 10997 enclosingLibrary = conflictingMembers[1].getAncestor(LibraryElement); |
| 10979 if (enclosingLibrary != null) { | 10998 if (enclosingLibrary != null) { |
| 10980 libName2 = enclosingLibrary.definingCompilationUnit.displayName; | 10999 libName2 = enclosingLibrary.definingCompilationUnit.displayName; |
| 10981 } | 11000 } |
| 10982 _errorListener.onError(new AnalysisError.con2(source2, identifier.offset,
identifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltName, libName1,
libName2])); | 11001 _errorListener.onError(new AnalysisError.con2(source, identifier.offset, i
dentifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltName, libName1, l
ibName2])); |
| 10983 return foundElement; | 11002 return foundElement; |
| 10984 } | 11003 } |
| 10985 if (foundElement != null) { | 11004 if (foundElement != null) { |
| 10986 defineWithoutChecking2(name, foundElement); | 11005 defineWithoutChecking2(name, foundElement); |
| 10987 } | 11006 } |
| 10988 return foundElement; | 11007 return foundElement; |
| 10989 } | 11008 } |
| 10990 | 11009 |
| 10991 /** | 11010 /** |
| 10992 * Create all of the namespaces associated with the libraries imported into th
is library. The | 11011 * Create all of the namespaces associated with the libraries imported into th
is library. The |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11050 } | 11069 } |
| 11051 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 11070 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 11052 if (existing is PrefixElement) { | 11071 if (existing is PrefixElement) { |
| 11053 int offset = duplicate.nameOffset; | 11072 int offset = duplicate.nameOffset; |
| 11054 if (duplicate is PropertyAccessorElement) { | 11073 if (duplicate is PropertyAccessorElement) { |
| 11055 PropertyAccessorElement accessor = duplicate as PropertyAccessorElement; | 11074 PropertyAccessorElement accessor = duplicate as PropertyAccessorElement; |
| 11056 if (accessor.isSynthetic) { | 11075 if (accessor.isSynthetic) { |
| 11057 offset = accessor.variable.nameOffset; | 11076 offset = accessor.variable.nameOffset; |
| 11058 } | 11077 } |
| 11059 } | 11078 } |
| 11060 return new AnalysisError.con2(source2, offset, duplicate.displayName.lengt
h, CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [existing.display
Name]); | 11079 return new AnalysisError.con2(source, offset, duplicate.displayName.length
, CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [existing.displayN
ame]); |
| 11061 } | 11080 } |
| 11062 return super.getErrorForDuplicate(existing, duplicate); | 11081 return super.getErrorForDuplicate(existing, duplicate); |
| 11063 } | 11082 } |
| 11064 | 11083 |
| 11065 /** | 11084 /** |
| 11066 * Add to this scope all of the public top-level names that are defined in the
given compilation | 11085 * Add to this scope all of the public top-level names that are defined in the
given compilation |
| 11067 * unit. | 11086 * unit. |
| 11068 * | 11087 * |
| 11069 * @param compilationUnit the compilation unit defining the top-level names to
be added to this | 11088 * @param compilationUnit the compilation unit defining the top-level names to
be added to this |
| 11070 * scope | 11089 * scope |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11220 definedNames[entry.getKey()] = entry.getValue(); | 11239 definedNames[entry.getKey()] = entry.getValue(); |
| 11221 } | 11240 } |
| 11222 } | 11241 } |
| 11223 | 11242 |
| 11224 /** | 11243 /** |
| 11225 * Add all of the names in the given namespace to the given mapping table. | 11244 * Add all of the names in the given namespace to the given mapping table. |
| 11226 * | 11245 * |
| 11227 * @param definedNames the mapping table to which the names in the given names
pace are to be added | 11246 * @param definedNames the mapping table to which the names in the given names
pace are to be added |
| 11228 * @param namespace the namespace containing the names to be added to this nam
espace | 11247 * @param namespace the namespace containing the names to be added to this nam
espace |
| 11229 */ | 11248 */ |
| 11230 void addAll2(Map<String, Element> definedNames2, Namespace namespace) { | 11249 void addAll2(Map<String, Element> definedNames, Namespace namespace) { |
| 11231 if (namespace != null) { | 11250 if (namespace != null) { |
| 11232 addAll(definedNames2, namespace.definedNames); | 11251 addAll(definedNames, namespace.definedNames); |
| 11233 } | 11252 } |
| 11234 } | 11253 } |
| 11235 | 11254 |
| 11236 /** | 11255 /** |
| 11237 * Add the given element to the given mapping table if it has a publicly visib
le name. | 11256 * Add the given element to the given mapping table if it has a publicly visib
le name. |
| 11238 * | 11257 * |
| 11239 * @param definedNames the mapping table to which the public name is to be add
ed | 11258 * @param definedNames the mapping table to which the public name is to be add
ed |
| 11240 * @param element the element to be added | 11259 * @param element the element to be added |
| 11241 */ | 11260 */ |
| 11242 void addIfPublic(Map<String, Element> definedNames, Element element) { | 11261 void addIfPublic(Map<String, Element> definedNames, Element element) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11470 * Return the error code to be used when reporting that a name being defined l
ocally conflicts | 11489 * Return the error code to be used when reporting that a name being defined l
ocally conflicts |
| 11471 * with another element of the same name in the local scope. | 11490 * with another element of the same name in the local scope. |
| 11472 * | 11491 * |
| 11473 * @param existing the first element to be declared with the conflicting name | 11492 * @param existing the first element to be declared with the conflicting name |
| 11474 * @param duplicate another element declared with the conflicting name | 11493 * @param duplicate another element declared with the conflicting name |
| 11475 * @return the error code used to report duplicate names within a scope | 11494 * @return the error code used to report duplicate names within a scope |
| 11476 */ | 11495 */ |
| 11477 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { | 11496 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { |
| 11478 Source source = duplicate.source; | 11497 Source source = duplicate.source; |
| 11479 if (source == null) { | 11498 if (source == null) { |
| 11480 source = source2; | 11499 source = this.source; |
| 11481 } | 11500 } |
| 11482 return new AnalysisError.con2(source, duplicate.nameOffset, duplicate.displa
yName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName])
; | 11501 return new AnalysisError.con2(source, duplicate.nameOffset, duplicate.displa
yName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION, [existing.displayName])
; |
| 11483 } | 11502 } |
| 11484 | 11503 |
| 11485 /** | 11504 /** |
| 11486 * Return the listener that is to be informed when an error is encountered. | 11505 * Return the listener that is to be informed when an error is encountered. |
| 11487 * | 11506 * |
| 11488 * @return the listener that is to be informed when an error is encountered | 11507 * @return the listener that is to be informed when an error is encountered |
| 11489 */ | 11508 */ |
| 11490 AnalysisErrorListener get errorListener; | 11509 AnalysisErrorListener get errorListener; |
| 11491 | 11510 |
| 11492 /** | 11511 /** |
| 11493 * Return the source object representing the compilation unit with which error
s related to this | 11512 * Return the source object representing the compilation unit with which error
s related to this |
| 11494 * scope should be associated. | 11513 * scope should be associated. |
| 11495 * | 11514 * |
| 11496 * @return the source object with which errors should be associated | 11515 * @return the source object with which errors should be associated |
| 11497 */ | 11516 */ |
| 11498 Source get source2 => definingLibrary.definingCompilationUnit.source; | 11517 Source get source => definingLibrary.definingCompilationUnit.source; |
| 11499 | 11518 |
| 11500 /** | 11519 /** |
| 11501 * Return the element with which the given name is associated, or `null` if th
e name is not | 11520 * Return the element with which the given name is associated, or `null` if th
e name is not |
| 11502 * defined within this scope. This method only returns elements that are direc
tly defined within | 11521 * defined within this scope. This method only returns elements that are direc
tly defined within |
| 11503 * this scope, not elements that are defined in an enclosing scope. | 11522 * this scope, not elements that are defined in an enclosing scope. |
| 11504 * | 11523 * |
| 11505 * @param name the name associated with the element to be returned | 11524 * @param name the name associated with the element to be returned |
| 11506 * @param referencingLibrary the library that contains the reference to the na
me, used to | 11525 * @param referencingLibrary the library that contains the reference to the na
me, used to |
| 11507 * implement library-level privacy | 11526 * implement library-level privacy |
| 11508 * @return the element with which the given name is associated | 11527 * @return the element with which the given name is associated |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11693 return null; | 11712 return null; |
| 11694 } | 11713 } |
| 11695 | 11714 |
| 11696 /** | 11715 /** |
| 11697 * If the given result represents one or more errors, report those errors. Exc
ept for special | 11716 * If the given result represents one or more errors, report those errors. Exc
ept for special |
| 11698 * cases, use the given error code rather than the one reported in the error. | 11717 * cases, use the given error code rather than the one reported in the error. |
| 11699 * | 11718 * |
| 11700 * @param result the result containing any errors that need to be reported | 11719 * @param result the result containing any errors that need to be reported |
| 11701 * @param errorCode the error code to be used if the result represents an erro
r | 11720 * @param errorCode the error code to be used if the result represents an erro
r |
| 11702 */ | 11721 */ |
| 11703 void reportErrors(EvaluationResultImpl result, ErrorCode errorCode2) { | 11722 void reportErrors(EvaluationResultImpl result, ErrorCode errorCode) { |
| 11704 if (result is ErrorResult) { | 11723 if (result is ErrorResult) { |
| 11705 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) { | 11724 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) { |
| 11706 ErrorCode dataErrorCode = data.errorCode; | 11725 ErrorCode dataErrorCode = data.errorCode; |
| 11707 if (identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCE
PTION) || identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE)
|| identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRIN
G) || identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) || ide
ntical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) || identical(dat
aErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM)) { | 11726 if (identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCE
PTION) || identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE)
|| identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRIN
G) || identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) || ide
ntical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) || identical(dat
aErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM)) { |
| 11708 _errorReporter.reportError2(dataErrorCode, data.node, []); | 11727 _errorReporter.reportError2(dataErrorCode, data.node, []); |
| 11709 } else { | 11728 } else { |
| 11710 _errorReporter.reportError2(errorCode2, data.node, []); | 11729 _errorReporter.reportError2(errorCode, data.node, []); |
| 11711 } | 11730 } |
| 11712 } | 11731 } |
| 11713 } | 11732 } |
| 11714 } | 11733 } |
| 11715 | 11734 |
| 11716 /** | 11735 /** |
| 11717 * Validate that the given expression is a compile time constant. Return the v
alue of the compile | 11736 * Validate that the given expression is a compile time constant. Return the v
alue of the compile |
| 11718 * time constant, or `null` if the expression is not a compile time constant. | 11737 * time constant, or `null` if the expression is not a compile time constant. |
| 11719 * | 11738 * |
| 11720 * @param expression the expression to be validated | 11739 * @param expression the expression to be validated |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11757 } | 11776 } |
| 11758 validateConstantArguments(argumentList); | 11777 validateConstantArguments(argumentList); |
| 11759 } | 11778 } |
| 11760 | 11779 |
| 11761 /** | 11780 /** |
| 11762 * Validate that the default value associated with each of the parameters in t
he given list is a | 11781 * Validate that the default value associated with each of the parameters in t
he given list is a |
| 11763 * compile time constant. | 11782 * compile time constant. |
| 11764 * | 11783 * |
| 11765 * @param parameters the list of parameters to be validated | 11784 * @param parameters the list of parameters to be validated |
| 11766 */ | 11785 */ |
| 11767 void validateDefaultValues(FormalParameterList parameters2) { | 11786 void validateDefaultValues(FormalParameterList parameters) { |
| 11768 if (parameters2 == null) { | 11787 if (parameters == null) { |
| 11769 return; | 11788 return; |
| 11770 } | 11789 } |
| 11771 for (FormalParameter parameter in parameters2.parameters) { | 11790 for (FormalParameter parameter in parameters.parameters) { |
| 11772 if (parameter is DefaultFormalParameter) { | 11791 if (parameter is DefaultFormalParameter) { |
| 11773 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara
meter; | 11792 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara
meter; |
| 11774 Expression defaultValue = defaultParameter.defaultValue; | 11793 Expression defaultValue = defaultParameter.defaultValue; |
| 11775 if (defaultValue != null) { | 11794 if (defaultValue != null) { |
| 11776 EvaluationResultImpl result = validate(defaultValue, CompileTimeErrorC
ode.NON_CONSTANT_DEFAULT_VALUE); | 11795 EvaluationResultImpl result = validate(defaultValue, CompileTimeErrorC
ode.NON_CONSTANT_DEFAULT_VALUE); |
| 11777 VariableElementImpl element = parameter.element as VariableElementImpl
; | 11796 VariableElementImpl element = parameter.element as VariableElementImpl
; |
| 11778 element.evaluationResult = result; | 11797 element.evaluationResult = result; |
| 11779 } | 11798 } |
| 11780 } | 11799 } |
| 11781 } | 11800 } |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12646 * @see CompileTimeErrorCode#INVALID_OVERRIDE_POSITIONAL | 12665 * @see CompileTimeErrorCode#INVALID_OVERRIDE_POSITIONAL |
| 12647 * @see CompileTimeErrorCode#INVALID_OVERRIDE_NAMED | 12666 * @see CompileTimeErrorCode#INVALID_OVERRIDE_NAMED |
| 12648 * @see StaticWarningCode#INVALID_GETTER_OVERRIDE_RETURN_TYPE | 12667 * @see StaticWarningCode#INVALID_GETTER_OVERRIDE_RETURN_TYPE |
| 12649 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_RETURN_TYPE | 12668 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_RETURN_TYPE |
| 12650 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE | 12669 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE |
| 12651 * @see StaticWarningCode#INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE | 12670 * @see StaticWarningCode#INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE |
| 12652 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE | 12671 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE |
| 12653 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE | 12672 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE |
| 12654 * @see StaticWarningCode#INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES | 12673 * @see StaticWarningCode#INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES |
| 12655 */ | 12674 */ |
| 12656 bool checkForAllInvalidOverrideErrorCodes(ExecutableElement executableElement,
List<ParameterElement> parameters2, List<ASTNode> parameterLocations, SimpleIde
ntifier errorNameTarget) { | 12675 bool checkForAllInvalidOverrideErrorCodes(ExecutableElement executableElement,
List<ParameterElement> parameters, List<ASTNode> parameterLocations, SimpleIden
tifier errorNameTarget) { |
| 12657 String executableElementName = executableElement.name; | 12676 String executableElementName = executableElement.name; |
| 12658 ExecutableElement overriddenExecutable = _inheritanceManager.lookupInheritan
ce(_enclosingClass, executableElementName); | 12677 ExecutableElement overriddenExecutable = _inheritanceManager.lookupInheritan
ce(_enclosingClass, executableElementName); |
| 12659 bool isGetter = false; | 12678 bool isGetter = false; |
| 12660 bool isSetter = false; | 12679 bool isSetter = false; |
| 12661 if (executableElement is PropertyAccessorElement) { | 12680 if (executableElement is PropertyAccessorElement) { |
| 12662 PropertyAccessorElement accessorElement = executableElement as PropertyAcc
essorElement; | 12681 PropertyAccessorElement accessorElement = executableElement as PropertyAcc
essorElement; |
| 12663 isGetter = accessorElement.isGetter; | 12682 isGetter = accessorElement.isGetter; |
| 12664 isSetter = accessorElement.isSetter; | 12683 isSetter = accessorElement.isSetter; |
| 12665 } | 12684 } |
| 12666 if (overriddenExecutable == null) { | 12685 if (overriddenExecutable == null) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12766 JavaIterator<MapEntry<String, Type2>> overriddenNamedPTIterator = new JavaIt
erator(getMapEntrySet(overriddenNamedPT)); | 12785 JavaIterator<MapEntry<String, Type2>> overriddenNamedPTIterator = new JavaIt
erator(getMapEntrySet(overriddenNamedPT)); |
| 12767 while (overriddenNamedPTIterator.hasNext) { | 12786 while (overriddenNamedPTIterator.hasNext) { |
| 12768 MapEntry<String, Type2> overriddenNamedPTEntry = overriddenNamedPTIterator
.next(); | 12787 MapEntry<String, Type2> overriddenNamedPTEntry = overriddenNamedPTIterator
.next(); |
| 12769 Type2 overridingType = overridingNamedPT[overriddenNamedPTEntry.getKey()]; | 12788 Type2 overridingType = overridingNamedPT[overriddenNamedPTEntry.getKey()]; |
| 12770 if (overridingType == null) { | 12789 if (overridingType == null) { |
| 12771 continue; | 12790 continue; |
| 12772 } | 12791 } |
| 12773 if (!overriddenNamedPTEntry.getValue().isAssignableTo(overridingType)) { | 12792 if (!overriddenNamedPTEntry.getValue().isAssignableTo(overridingType)) { |
| 12774 ParameterElement parameterToSelect = null; | 12793 ParameterElement parameterToSelect = null; |
| 12775 ASTNode parameterLocationToSelect = null; | 12794 ASTNode parameterLocationToSelect = null; |
| 12776 for (int i = 0; i < parameters2.length; i++) { | 12795 for (int i = 0; i < parameters.length; i++) { |
| 12777 ParameterElement parameter = parameters2[i]; | 12796 ParameterElement parameter = parameters[i]; |
| 12778 if (identical(parameter.parameterKind, ParameterKind.NAMED) && overrid
denNamedPTEntry.getKey() == parameter.name) { | 12797 if (identical(parameter.parameterKind, ParameterKind.NAMED) && overrid
denNamedPTEntry.getKey() == parameter.name) { |
| 12779 parameterToSelect = parameter; | 12798 parameterToSelect = parameter; |
| 12780 parameterLocationToSelect = parameterLocations[i]; | 12799 parameterLocationToSelect = parameterLocations[i]; |
| 12781 break; | 12800 break; |
| 12782 } | 12801 } |
| 12783 } | 12802 } |
| 12784 if (parameterToSelect != null) { | 12803 if (parameterToSelect != null) { |
| 12785 _errorReporter.reportError2(StaticWarningCode.INVALID_METHOD_OVERRIDE_
NAMED_PARAM_TYPE, parameterLocationToSelect, [ | 12804 _errorReporter.reportError2(StaticWarningCode.INVALID_METHOD_OVERRIDE_
NAMED_PARAM_TYPE, parameterLocationToSelect, [ |
| 12786 overridingType.displayName, | 12805 overridingType.displayName, |
| 12787 overriddenNamedPTEntry.getValue().displayName, | 12806 overriddenNamedPTEntry.getValue().displayName, |
| 12788 overriddenExecutable.enclosingElement.displayName]); | 12807 overriddenExecutable.enclosingElement.displayName]); |
| 12789 return true; | 12808 return true; |
| 12790 } | 12809 } |
| 12791 } | 12810 } |
| 12792 } | 12811 } |
| 12793 bool foundError = false; | 12812 bool foundError = false; |
| 12794 List<ASTNode> formalParameters = new List<ASTNode>(); | 12813 List<ASTNode> formalParameters = new List<ASTNode>(); |
| 12795 List<ParameterElementImpl> parameterElts = new List<ParameterElementImpl>(); | 12814 List<ParameterElementImpl> parameterElts = new List<ParameterElementImpl>(); |
| 12796 List<ParameterElementImpl> overriddenParameterElts = new List<ParameterEleme
ntImpl>(); | 12815 List<ParameterElementImpl> overriddenParameterElts = new List<ParameterEleme
ntImpl>(); |
| 12797 List<ParameterElement> overriddenPEs = overriddenExecutable.parameters; | 12816 List<ParameterElement> overriddenPEs = overriddenExecutable.parameters; |
| 12798 for (int i = 0; i < parameters2.length; i++) { | 12817 for (int i = 0; i < parameters.length; i++) { |
| 12799 ParameterElement parameter = parameters2[i]; | 12818 ParameterElement parameter = parameters[i]; |
| 12800 if (parameter.parameterKind.isOptional) { | 12819 if (parameter.parameterKind.isOptional) { |
| 12801 formalParameters.add(parameterLocations[i]); | 12820 formalParameters.add(parameterLocations[i]); |
| 12802 parameterElts.add(parameter as ParameterElementImpl); | 12821 parameterElts.add(parameter as ParameterElementImpl); |
| 12803 } | 12822 } |
| 12804 } | 12823 } |
| 12805 for (ParameterElement parameterElt in overriddenPEs) { | 12824 for (ParameterElement parameterElt in overriddenPEs) { |
| 12806 if (parameterElt.parameterKind.isOptional) { | 12825 if (parameterElt.parameterKind.isOptional) { |
| 12807 if (parameterElt is ParameterElementImpl) { | 12826 if (parameterElt is ParameterElementImpl) { |
| 12808 overriddenParameterElts.add(parameterElt as ParameterElementImpl); | 12827 overriddenParameterElts.add(parameterElt as ParameterElementImpl); |
| 12809 } else if (parameterElt is ParameterMember) { | 12828 } else if (parameterElt is ParameterMember) { |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13341 | 13360 |
| 13342 /** | 13361 /** |
| 13343 * This verifies that the passed switch statement does not have a case express
ion with the | 13362 * This verifies that the passed switch statement does not have a case express
ion with the |
| 13344 * operator '==' overridden. | 13363 * operator '==' overridden. |
| 13345 * | 13364 * |
| 13346 * @param node the switch statement to evaluate | 13365 * @param node the switch statement to evaluate |
| 13347 * @param type the common type of all 'case' expressions | 13366 * @param type the common type of all 'case' expressions |
| 13348 * @return `true` if and only if an error code is generated on the passed node | 13367 * @return `true` if and only if an error code is generated on the passed node |
| 13349 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS | 13368 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS |
| 13350 */ | 13369 */ |
| 13351 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node, Type2 ty
pe2) { | 13370 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node, Type2 ty
pe) { |
| 13352 if (type2 == null || type2 == _typeProvider.intType || type2 == _typeProvide
r.stringType) { | 13371 if (type == null || type == _typeProvider.intType || type == _typeProvider.s
tringType) { |
| 13353 return false; | 13372 return false; |
| 13354 } | 13373 } |
| 13355 Element element = type2.element; | 13374 Element element = type.element; |
| 13356 if (element is! ClassElement) { | 13375 if (element is! ClassElement) { |
| 13357 return false; | 13376 return false; |
| 13358 } | 13377 } |
| 13359 ClassElement classElement = element as ClassElement; | 13378 ClassElement classElement = element as ClassElement; |
| 13360 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); | 13379 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); |
| 13361 if (method == null || method.enclosingElement.type.isObject) { | 13380 if (method == null || method.enclosingElement.type.isObject) { |
| 13362 return false; | 13381 return false; |
| 13363 } | 13382 } |
| 13364 _errorReporter.reportError4(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEM
ENTS_EQUALS, node.keyword, [element.displayName]); | 13383 _errorReporter.reportError4(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEM
ENTS_EQUALS, node.keyword, [element.displayName]); |
| 13365 return true; | 13384 return true; |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14349 | 14368 |
| 14350 /** | 14369 /** |
| 14351 * This checks that if the given "target" is not a type reference then the "na
me" is reference to | 14370 * This checks that if the given "target" is not a type reference then the "na
me" is reference to |
| 14352 * an instance member. | 14371 * an instance member. |
| 14353 * | 14372 * |
| 14354 * @param target the target of the name access to evaluate | 14373 * @param target the target of the name access to evaluate |
| 14355 * @param name the accessed name to evaluate | 14374 * @param name the accessed name to evaluate |
| 14356 * @return `true` if and only if an error code is generated on the passed node | 14375 * @return `true` if and only if an error code is generated on the passed node |
| 14357 * @see StaticTypeWarningCode#INSTANCE_ACCESS_TO_STATIC_MEMBER | 14376 * @see StaticTypeWarningCode#INSTANCE_ACCESS_TO_STATIC_MEMBER |
| 14358 */ | 14377 */ |
| 14359 bool checkForInstanceAccessToStaticMember(Expression target, SimpleIdentifier
name2) { | 14378 bool checkForInstanceAccessToStaticMember(Expression target, SimpleIdentifier
name) { |
| 14360 if (target == null) { | 14379 if (target == null) { |
| 14361 return false; | 14380 return false; |
| 14362 } | 14381 } |
| 14363 if (_isInComment) { | 14382 if (_isInComment) { |
| 14364 return false; | 14383 return false; |
| 14365 } | 14384 } |
| 14366 Element element = name2.staticElement; | 14385 Element element = name.staticElement; |
| 14367 if (element is! ExecutableElement) { | 14386 if (element is! ExecutableElement) { |
| 14368 return false; | 14387 return false; |
| 14369 } | 14388 } |
| 14370 ExecutableElement executableElement = element as ExecutableElement; | 14389 ExecutableElement executableElement = element as ExecutableElement; |
| 14371 if (executableElement.enclosingElement is! ClassElement) { | 14390 if (executableElement.enclosingElement is! ClassElement) { |
| 14372 return false; | 14391 return false; |
| 14373 } | 14392 } |
| 14374 if (!executableElement.isStatic) { | 14393 if (!executableElement.isStatic) { |
| 14375 return false; | 14394 return false; |
| 14376 } | 14395 } |
| 14377 if (isTypeReference(target)) { | 14396 if (isTypeReference(target)) { |
| 14378 return false; | 14397 return false; |
| 14379 } | 14398 } |
| 14380 _errorReporter.reportError2(StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_
MEMBER, name2, [name2.name]); | 14399 _errorReporter.reportError2(StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_
MEMBER, name, [name.name]); |
| 14381 return true; | 14400 return true; |
| 14382 } | 14401 } |
| 14383 | 14402 |
| 14384 /** | 14403 /** |
| 14385 * This verifies that an 'int' can be assigned to the parameter corresponding
to the given | 14404 * This verifies that an 'int' can be assigned to the parameter corresponding
to the given |
| 14386 * expression. This is used for prefix and postfix expressions where the argum
ent value is | 14405 * expression. This is used for prefix and postfix expressions where the argum
ent value is |
| 14387 * implicit. | 14406 * implicit. |
| 14388 * | 14407 * |
| 14389 * @param argument the expression to which the operator is being applied | 14408 * @param argument the expression to which the operator is being applied |
| 14390 * @return `true` if and only if an error code is generated on the passed node | 14409 * @return `true` if and only if an error code is generated on the passed node |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15365 | 15384 |
| 15366 /** | 15385 /** |
| 15367 * This checks that if the given "target" is the type reference then the "name
" is not the | 15386 * This checks that if the given "target" is the type reference then the "name
" is not the |
| 15368 * reference to a instance member. | 15387 * reference to a instance member. |
| 15369 * | 15388 * |
| 15370 * @param target the target of the name access to evaluate | 15389 * @param target the target of the name access to evaluate |
| 15371 * @param name the accessed name to evaluate | 15390 * @param name the accessed name to evaluate |
| 15372 * @return `true` if and only if an error code is generated on the passed node | 15391 * @return `true` if and only if an error code is generated on the passed node |
| 15373 * @see StaticWarningCode#STATIC_ACCESS_TO_INSTANCE_MEMBER | 15392 * @see StaticWarningCode#STATIC_ACCESS_TO_INSTANCE_MEMBER |
| 15374 */ | 15393 */ |
| 15375 bool checkForStaticAccessToInstanceMember(Expression target, SimpleIdentifier
name2) { | 15394 bool checkForStaticAccessToInstanceMember(Expression target, SimpleIdentifier
name) { |
| 15376 Element element = name2.staticElement; | 15395 Element element = name.staticElement; |
| 15377 if (element is! ExecutableElement) { | 15396 if (element is! ExecutableElement) { |
| 15378 return false; | 15397 return false; |
| 15379 } | 15398 } |
| 15380 ExecutableElement memberElement = element as ExecutableElement; | 15399 ExecutableElement memberElement = element as ExecutableElement; |
| 15381 if (memberElement.isStatic) { | 15400 if (memberElement.isStatic) { |
| 15382 return false; | 15401 return false; |
| 15383 } | 15402 } |
| 15384 if (!isTypeReference(target)) { | 15403 if (!isTypeReference(target)) { |
| 15385 return false; | 15404 return false; |
| 15386 } | 15405 } |
| 15387 _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMB
ER, name2, [name2.name]); | 15406 _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMB
ER, name, [name.name]); |
| 15388 return true; | 15407 return true; |
| 15389 } | 15408 } |
| 15390 | 15409 |
| 15391 /** | 15410 /** |
| 15392 * This checks that the type of the passed 'switch' expression is assignable t
o the type of the | 15411 * This checks that the type of the passed 'switch' expression is assignable t
o the type of the |
| 15393 * 'case' members. | 15412 * 'case' members. |
| 15394 * | 15413 * |
| 15395 * @param node the 'switch' statement to evaluate | 15414 * @param node the 'switch' statement to evaluate |
| 15396 * @return `true` if and only if an error code is generated on the passed node | 15415 * @return `true` if and only if an error code is generated on the passed node |
| 15397 * @see StaticWarningCode#SWITCH_EXPRESSION_NOT_ASSIGNABLE | 15416 * @see StaticWarningCode#SWITCH_EXPRESSION_NOT_ASSIGNABLE |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15566 } | 15585 } |
| 15567 | 15586 |
| 15568 /** | 15587 /** |
| 15569 * This checks that if the given name is a reference to a static member it is
defined in the | 15588 * This checks that if the given name is a reference to a static member it is
defined in the |
| 15570 * enclosing class rather than in a superclass. | 15589 * enclosing class rather than in a superclass. |
| 15571 * | 15590 * |
| 15572 * @param name the name to be evaluated | 15591 * @param name the name to be evaluated |
| 15573 * @return `true` if and only if an error code is generated on the passed node | 15592 * @return `true` if and only if an error code is generated on the passed node |
| 15574 * @see StaticTypeWarningCode#UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER | 15593 * @see StaticTypeWarningCode#UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER |
| 15575 */ | 15594 */ |
| 15576 bool checkForUnqualifiedReferenceToNonLocalStaticMember(SimpleIdentifier name2
) { | 15595 bool checkForUnqualifiedReferenceToNonLocalStaticMember(SimpleIdentifier name)
{ |
| 15577 Element element = name2.staticElement; | 15596 Element element = name.staticElement; |
| 15578 if (element == null || element is TypeParameterElement) { | 15597 if (element == null || element is TypeParameterElement) { |
| 15579 return false; | 15598 return false; |
| 15580 } | 15599 } |
| 15581 Element enclosingElement = element.enclosingElement; | 15600 Element enclosingElement = element.enclosingElement; |
| 15582 if (enclosingElement is! ClassElement) { | 15601 if (enclosingElement is! ClassElement) { |
| 15583 return false; | 15602 return false; |
| 15584 } | 15603 } |
| 15585 if ((element is MethodElement && !((element as MethodElement)).isStatic) ||
(element is PropertyAccessorElement && !((element as PropertyAccessorElement)).i
sStatic)) { | 15604 if ((element is MethodElement && !((element as MethodElement)).isStatic) ||
(element is PropertyAccessorElement && !((element as PropertyAccessorElement)).i
sStatic)) { |
| 15586 return false; | 15605 return false; |
| 15587 } | 15606 } |
| 15588 if (identical(enclosingElement, _enclosingClass)) { | 15607 if (identical(enclosingElement, _enclosingClass)) { |
| 15589 return false; | 15608 return false; |
| 15590 } | 15609 } |
| 15591 _errorReporter.reportError2(StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_N
ON_LOCAL_STATIC_MEMBER, name2, [name2.name]); | 15610 _errorReporter.reportError2(StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_N
ON_LOCAL_STATIC_MEMBER, name, [name.name]); |
| 15592 return true; | 15611 return true; |
| 15593 } | 15612 } |
| 15594 | 15613 |
| 15595 /** | 15614 /** |
| 15596 * This verifies the passed operator-method declaration, has correct number of
parameters. | 15615 * This verifies the passed operator-method declaration, has correct number of
parameters. |
| 15597 * | 15616 * |
| 15598 * This method assumes that the method declaration was tested to be an operato
r declaration before | 15617 * This method assumes that the method declaration was tested to be an operato
r declaration before |
| 15599 * being called. | 15618 * being called. |
| 15600 * | 15619 * |
| 15601 * @param node the method declaration to evaluate | 15620 * @param node the method declaration to evaluate |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16077 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { | 16096 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { |
| 16078 this._type = type; | 16097 this._type = type; |
| 16079 this._message = message; | 16098 this._message = message; |
| 16080 this.correction9 = correction; | 16099 this.correction9 = correction; |
| 16081 } | 16100 } |
| 16082 String get correction => correction9; | 16101 String get correction => correction9; |
| 16083 ErrorSeverity get errorSeverity => _type.severity; | 16102 ErrorSeverity get errorSeverity => _type.severity; |
| 16084 String get message => _message; | 16103 String get message => _message; |
| 16085 ErrorType get type => _type; | 16104 ErrorType get type => _type; |
| 16086 } | 16105 } |
| OLD | NEW |