| 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 | 3 |
| 4 library engine.resolver; | 4 library engine.resolver; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
| 9 import 'source.dart'; | 9 import 'source.dart'; |
| 10 import 'error.dart'; | 10 import 'error.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * Instances of the class {@code CompilationUnitBuilder} build an element model
for a single | 22 * Instances of the class {@code CompilationUnitBuilder} build an element model
for a single |
| 23 * compilation unit. | 23 * compilation unit. |
| 24 * @coverage dart.engine.resolver | 24 * @coverage dart.engine.resolver |
| 25 */ | 25 */ |
| 26 class CompilationUnitBuilder { | 26 class CompilationUnitBuilder { |
| 27 /** | 27 /** |
| 28 * The analysis context in which the element model will be built. | 28 * The analysis context in which the element model will be built. |
| 29 */ | 29 */ |
| 30 AnalysisContextImpl _analysisContext; | 30 AnalysisContextImpl _analysisContext; |
| 31 /** | 31 /** |
| 32 * The listener to which errors will be reported. | |
| 33 */ | |
| 34 AnalysisErrorListener _errorListener; | |
| 35 /** | |
| 36 * Initialize a newly created compilation unit element builder. | 32 * Initialize a newly created compilation unit element builder. |
| 37 * @param analysisContext the analysis context in which the element model will
be built | 33 * @param analysisContext the analysis context in which the element model will
be built |
| 38 * @param errorListener the listener to which errors will be reported | |
| 39 */ | 34 */ |
| 40 CompilationUnitBuilder(AnalysisContextImpl analysisContext, AnalysisErrorListe
ner errorListener) { | 35 CompilationUnitBuilder(AnalysisContextImpl analysisContext) { |
| 41 this._analysisContext = analysisContext; | 36 this._analysisContext = analysisContext; |
| 42 this._errorListener = errorListener; | |
| 43 } | 37 } |
| 44 /** | 38 /** |
| 45 * Build the compilation unit element for the given source. | 39 * Build the compilation unit element for the given source. |
| 46 * @param source the source describing the compilation unit | 40 * @param source the source describing the compilation unit |
| 47 * @return the compilation unit element that was built | 41 * @return the compilation unit element that was built |
| 48 * @throws AnalysisException if the analysis could not be performed | 42 * @throws AnalysisException if the analysis could not be performed |
| 49 */ | 43 */ |
| 50 CompilationUnitElementImpl buildCompilationUnit(Source source) => buildCompila
tionUnit2(source, _analysisContext.parse3(source, _errorListener)); | 44 CompilationUnitElementImpl buildCompilationUnit(Source source) => buildCompila
tionUnit2(source, _analysisContext.parseCompilationUnit(source)); |
| 51 /** | 45 /** |
| 52 * Build the compilation unit element for the given source. | 46 * Build the compilation unit element for the given source. |
| 53 * @param source the source describing the compilation unit | 47 * @param source the source describing the compilation unit |
| 54 * @param unit the AST structure representing the compilation unit | 48 * @param unit the AST structure representing the compilation unit |
| 55 * @return the compilation unit element that was built | 49 * @return the compilation unit element that was built |
| 56 * @throws AnalysisException if the analysis could not be performed | 50 * @throws AnalysisException if the analysis could not be performed |
| 57 */ | 51 */ |
| 58 CompilationUnitElementImpl buildCompilationUnit2(Source source15, CompilationU
nit unit) { | 52 CompilationUnitElementImpl buildCompilationUnit2(Source source13, CompilationU
nit unit) { |
| 53 if (unit == null) { |
| 54 return null; |
| 55 } |
| 59 ElementHolder holder = new ElementHolder(); | 56 ElementHolder holder = new ElementHolder(); |
| 60 ElementBuilder builder = new ElementBuilder(holder); | 57 ElementBuilder builder = new ElementBuilder(holder); |
| 61 unit.accept(builder); | 58 unit.accept(builder); |
| 62 CompilationUnitElementImpl element = new CompilationUnitElementImpl(source15
.shortName); | 59 CompilationUnitElementImpl element = new CompilationUnitElementImpl(source13
.shortName); |
| 63 element.accessors = holder.accessors; | 60 element.accessors = holder.accessors; |
| 64 element.functions = holder.functions; | 61 element.functions = holder.functions; |
| 65 element.source = source15; | 62 element.source = source13; |
| 66 element.typeAliases = holder.typeAliases; | 63 element.typeAliases = holder.typeAliases; |
| 67 element.types = holder.types; | 64 element.types = holder.types; |
| 68 element.topLevelVariables = holder.topLevelVariables; | 65 element.topLevelVariables = holder.topLevelVariables; |
| 69 unit.element = element; | 66 unit.element = element; |
| 70 return element; | 67 return element; |
| 71 } | 68 } |
| 72 } | 69 } |
| 73 /** | 70 /** |
| 74 * Instances of the class {@code ElementBuilder} traverse an AST structure and b
uild the element | 71 * Instances of the class {@code ElementBuilder} traverse an AST structure and b
uild the element |
| 75 * model representing the AST structure. | 72 * model representing the AST structure. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (returnType4 != null) { | 178 if (returnType4 != null) { |
| 182 element.nameOffset = returnType4.offset; | 179 element.nameOffset = returnType4.offset; |
| 183 } | 180 } |
| 184 } else { | 181 } else { |
| 185 constructorName.element = element; | 182 constructorName.element = element; |
| 186 } | 183 } |
| 187 return null; | 184 return null; |
| 188 } | 185 } |
| 189 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 186 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 190 SimpleIdentifier variableName = node.identifier; | 187 SimpleIdentifier variableName = node.identifier; |
| 191 sc.Token keyword27 = node.keyword; | 188 sc.Token keyword28 = node.keyword; |
| 192 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName
); | 189 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName
); |
| 193 ForEachStatement statement = node.parent as ForEachStatement; | 190 ForEachStatement statement = node.parent as ForEachStatement; |
| 194 int declarationEnd = node.offset + node.length; | 191 int declarationEnd = node.offset + node.length; |
| 195 int statementEnd = statement.offset + statement.length; | 192 int statementEnd = statement.offset + statement.length; |
| 196 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); | 193 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); |
| 197 element.const3 = matches(keyword27, sc.Keyword.CONST); | 194 element.const3 = matches(keyword28, sc.Keyword.CONST); |
| 198 element.final2 = matches(keyword27, sc.Keyword.FINAL); | 195 element.final2 = matches(keyword28, sc.Keyword.FINAL); |
| 199 _currentHolder.addLocalVariable(element); | 196 _currentHolder.addLocalVariable(element); |
| 200 variableName.element = element; | 197 variableName.element = element; |
| 201 return super.visitDeclaredIdentifier(node); | 198 return super.visitDeclaredIdentifier(node); |
| 202 } | 199 } |
| 203 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 200 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 204 ElementHolder holder = new ElementHolder(); | 201 ElementHolder holder = new ElementHolder(); |
| 205 visit(holder, node.defaultValue); | 202 visit(holder, node.defaultValue); |
| 206 FunctionElementImpl initializer = new FunctionElementImpl(); | 203 FunctionElementImpl initializer = new FunctionElementImpl(); |
| 207 initializer.functions = holder.functions; | 204 initializer.functions = holder.functions; |
| 208 initializer.labels = holder.labels; | 205 initializer.labels = holder.labels; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 Object visitTypeParameter(TypeParameter node) { | 475 Object visitTypeParameter(TypeParameter node) { |
| 479 SimpleIdentifier parameterName = node.name; | 476 SimpleIdentifier parameterName = node.name; |
| 480 TypeVariableElementImpl element = new TypeVariableElementImpl(parameterName)
; | 477 TypeVariableElementImpl element = new TypeVariableElementImpl(parameterName)
; |
| 481 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); | 478 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); |
| 482 element.type = type; | 479 element.type = type; |
| 483 _currentHolder.addTypeVariable(element); | 480 _currentHolder.addTypeVariable(element); |
| 484 parameterName.element = element; | 481 parameterName.element = element; |
| 485 return super.visitTypeParameter(node); | 482 return super.visitTypeParameter(node); |
| 486 } | 483 } |
| 487 Object visitVariableDeclaration(VariableDeclaration node) { | 484 Object visitVariableDeclaration(VariableDeclaration node) { |
| 488 sc.Token keyword28 = ((node.parent as VariableDeclarationList)).keyword; | 485 sc.Token keyword29 = ((node.parent as VariableDeclarationList)).keyword; |
| 489 bool isConst = matches(keyword28, sc.Keyword.CONST); | 486 bool isConst = matches(keyword29, sc.Keyword.CONST); |
| 490 bool isFinal = matches(keyword28, sc.Keyword.FINAL); | 487 bool isFinal = matches(keyword29, sc.Keyword.FINAL); |
| 491 bool hasInitializer = node.initializer != null; | 488 bool hasInitializer = node.initializer != null; |
| 492 VariableElementImpl element; | 489 VariableElementImpl element; |
| 493 if (_inFieldContext) { | 490 if (_inFieldContext) { |
| 494 SimpleIdentifier fieldName = node.name; | 491 SimpleIdentifier fieldName = node.name; |
| 495 FieldElementImpl field; | 492 FieldElementImpl field; |
| 496 if (isConst && hasInitializer) { | 493 if (isConst && hasInitializer) { |
| 497 field = new ConstFieldElementImpl(fieldName); | 494 field = new ConstFieldElementImpl(fieldName); |
| 498 } else { | 495 } else { |
| 499 field = new FieldElementImpl.con1(fieldName); | 496 field = new FieldElementImpl.con1(fieldName); |
| 500 } | 497 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 parent13 = parent13.parent; | 589 parent13 = parent13.parent; |
| 593 } | 590 } |
| 594 return null; | 591 return null; |
| 595 } | 592 } |
| 596 /** | 593 /** |
| 597 * Return {@code true} if the given token is a token for the given keyword. | 594 * Return {@code true} if the given token is a token for the given keyword. |
| 598 * @param token the token being tested | 595 * @param token the token being tested |
| 599 * @param keyword the keyword being tested for | 596 * @param keyword the keyword being tested for |
| 600 * @return {@code true} if the given token is a token for the given keyword | 597 * @return {@code true} if the given token is a token for the given keyword |
| 601 */ | 598 */ |
| 602 bool matches(sc.Token token, sc.Keyword keyword36) => token != null && identic
al(token.type, sc.TokenType.KEYWORD) && identical(((token as sc.KeywordToken)).k
eyword, keyword36); | 599 bool matches(sc.Token token, sc.Keyword keyword37) => token != null && identic
al(token.type, sc.TokenType.KEYWORD) && identical(((token as sc.KeywordToken)).k
eyword, keyword37); |
| 603 /** | 600 /** |
| 604 * Make the given holder be the current holder while visiting the given node. | 601 * Make the given holder be the current holder while visiting the given node. |
| 605 * @param holder the holder that will gather elements that are built while vis
iting the children | 602 * @param holder the holder that will gather elements that are built while vis
iting the children |
| 606 * @param node the node to be visited | 603 * @param node the node to be visited |
| 607 */ | 604 */ |
| 608 void visit(ElementHolder holder, ASTNode node) { | 605 void visit(ElementHolder holder, ASTNode node) { |
| 609 if (node != null) { | 606 if (node != null) { |
| 610 ElementHolder previousHolder = _currentHolder; | 607 ElementHolder previousHolder = _currentHolder; |
| 611 _currentHolder = holder; | 608 _currentHolder = holder; |
| 612 try { | 609 try { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 */ | 737 */ |
| 741 HtmlUnitBuilder(AnalysisContextImpl context) { | 738 HtmlUnitBuilder(AnalysisContextImpl context) { |
| 742 this._context = context; | 739 this._context = context; |
| 743 } | 740 } |
| 744 /** | 741 /** |
| 745 * Build the HTML element for the given source. | 742 * Build the HTML element for the given source. |
| 746 * @param source the source describing the compilation unit | 743 * @param source the source describing the compilation unit |
| 747 * @return the HTML element that was built | 744 * @return the HTML element that was built |
| 748 * @throws AnalysisException if the analysis could not be performed | 745 * @throws AnalysisException if the analysis could not be performed |
| 749 */ | 746 */ |
| 750 HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, _
context.parseHtml(source).htmlUnit); | 747 HtmlElementImpl buildHtmlElement(Source source) => buildHtmlElement2(source, _
context.parseHtmlUnit(source)); |
| 751 /** | 748 /** |
| 752 * Build the HTML element for the given source. | 749 * Build the HTML element for the given source. |
| 753 * @param source the source describing the compilation unit | 750 * @param source the source describing the compilation unit |
| 754 * @param unit the AST structure representing the HTML | 751 * @param unit the AST structure representing the HTML |
| 755 * @throws AnalysisException if the analysis could not be performed | 752 * @throws AnalysisException if the analysis could not be performed |
| 756 */ | 753 */ |
| 757 HtmlElementImpl buildHtmlElement2(Source source16, ht.HtmlUnit unit) { | 754 HtmlElementImpl buildHtmlElement2(Source source14, ht.HtmlUnit unit) { |
| 758 HtmlElementImpl result = new HtmlElementImpl(_context, source16.shortName); | 755 HtmlElementImpl result = new HtmlElementImpl(_context, source14.shortName); |
| 759 result.source = source16; | 756 result.source = source14; |
| 760 _htmlElement = result; | 757 _htmlElement = result; |
| 761 unit.accept(this); | 758 unit.accept(this); |
| 762 _htmlElement = null; | 759 _htmlElement = null; |
| 763 unit.element = result; | 760 unit.element = result; |
| 764 return result; | 761 return result; |
| 765 } | 762 } |
| 766 Object visitHtmlUnit(ht.HtmlUnit node) { | 763 Object visitHtmlUnit(ht.HtmlUnit node) { |
| 767 _scripts = new List<HtmlScriptElement>(); | 764 _scripts = new List<HtmlScriptElement>(); |
| 768 node.visitChildren(this); | 765 node.visitChildren(this); |
| 769 _htmlElement.scripts = new List.from(_scripts); | 766 _htmlElement.scripts = new List.from(_scripts); |
| 770 _scripts = null; | 767 _scripts = null; |
| 771 return null; | 768 return null; |
| 772 } | 769 } |
| 773 Object visitXmlAttributeNode(ht.XmlAttributeNode node) => null; | 770 Object visitXmlAttributeNode(ht.XmlAttributeNode node) => null; |
| 774 Object visitXmlTagNode(ht.XmlTagNode node) { | 771 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 775 if (isScriptNode(node)) { | 772 if (isScriptNode(node)) { |
| 776 Source htmlSource = _htmlElement.source; | 773 Source htmlSource = _htmlElement.source; |
| 777 String scriptSourcePath = getScriptSourcePath(node); | 774 String scriptSourcePath = getScriptSourcePath(node); |
| 778 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath
== null) { | 775 if (identical(node.attributeEnd.type, ht.TokenType.GT) && scriptSourcePath
== null) { |
| 779 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl
(node); | 776 EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl
(node); |
| 780 String contents = node.content; | 777 String contents = node.content; |
| 781 AnalysisErrorListener errorListener = new AnalysisErrorListener_2(); | 778 AnalysisErrorListener errorListener = new AnalysisErrorListener_2(); |
| 782 sc.StringScanner scanner = new sc.StringScanner(null, contents, errorLis
tener); | 779 sc.StringScanner scanner = new sc.StringScanner(null, contents, errorLis
tener); |
| 783 sc.Token firstToken = scanner.tokenize(); | 780 sc.Token firstToken = scanner.tokenize(); |
| 784 List<int> lineStarts2 = scanner.lineStarts; | 781 List<int> lineStarts2 = scanner.lineStarts; |
| 785 Parser parser = new Parser(null, errorListener); | 782 Parser parser = new Parser(null, errorListener); |
| 786 CompilationUnit unit = parser.parseCompilationUnit(firstToken); | 783 CompilationUnit unit = parser.parseCompilationUnit(firstToken); |
| 787 try { | 784 try { |
| 788 CompilationUnitBuilder builder = new CompilationUnitBuilder(_context,
errorListener); | 785 CompilationUnitBuilder builder = new CompilationUnitBuilder(_context); |
| 789 CompilationUnitElementImpl elem = builder.buildCompilationUnit2(htmlSo
urce, unit); | 786 CompilationUnitElementImpl elem = builder.buildCompilationUnit2(htmlSo
urce, unit); |
| 790 LibraryElementImpl library = new LibraryElementImpl(_context, null); | 787 LibraryElementImpl library = new LibraryElementImpl(_context, null); |
| 791 library.definingCompilationUnit = elem; | 788 library.definingCompilationUnit = elem; |
| 792 script.scriptLibrary = library; | 789 script.scriptLibrary = library; |
| 793 } on AnalysisException catch (e) { | 790 } on AnalysisException catch (e) { |
| 794 print(e); | 791 print(e); |
| 795 } | 792 } |
| 796 _scripts.add(script); | 793 _scripts.add(script); |
| 797 } else { | 794 } else { |
| 798 ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl
(node); | 795 ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl
(node); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 } | 982 } |
| 986 Object visitContinueStatement(ContinueStatement node) { | 983 Object visitContinueStatement(ContinueStatement node) { |
| 987 SimpleIdentifier labelNode = node.label; | 984 SimpleIdentifier labelNode = node.label; |
| 988 LabelElementImpl labelElement = lookupLabel(node, labelNode); | 985 LabelElementImpl labelElement = lookupLabel(node, labelNode); |
| 989 if (labelElement != null && labelElement.isOnSwitchStatement()) { | 986 if (labelElement != null && labelElement.isOnSwitchStatement()) { |
| 990 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod
e, []); | 987 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod
e, []); |
| 991 } | 988 } |
| 992 return null; | 989 return null; |
| 993 } | 990 } |
| 994 Object visitExportDirective(ExportDirective node) { | 991 Object visitExportDirective(ExportDirective node) { |
| 995 Element element22 = node.element; | 992 Element element26 = node.element; |
| 996 if (element22 is ExportElement) { | 993 if (element26 is ExportElement) { |
| 997 resolveCombinators(((element22 as ExportElement)).exportedLibrary, node.co
mbinators); | 994 resolveCombinators(((element26 as ExportElement)).exportedLibrary, node.co
mbinators); |
| 998 } | 995 } |
| 999 return null; | 996 return null; |
| 1000 } | 997 } |
| 1001 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
null; | 998 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) =>
null; |
| 1002 Object visitImportDirective(ImportDirective node) { | 999 Object visitImportDirective(ImportDirective node) { |
| 1003 SimpleIdentifier prefixNode = node.prefix; | 1000 SimpleIdentifier prefixNode = node.prefix; |
| 1004 if (prefixNode != null) { | 1001 if (prefixNode != null) { |
| 1005 String prefixName = prefixNode.name; | 1002 String prefixName = prefixNode.name; |
| 1006 for (PrefixElement prefixElement in _resolver.definingLibrary.prefixes) { | 1003 for (PrefixElement prefixElement in _resolver.definingLibrary.prefixes) { |
| 1007 if (prefixElement.name == prefixName) { | 1004 if (prefixElement.name == prefixName) { |
| 1008 recordResolution(prefixNode, prefixElement); | 1005 recordResolution(prefixNode, prefixElement); |
| 1009 break; | 1006 break; |
| 1010 } | 1007 } |
| 1011 } | 1008 } |
| 1012 } | 1009 } |
| 1013 Element element23 = node.element; | 1010 Element element27 = node.element; |
| 1014 if (element23 is ImportElement) { | 1011 if (element27 is ImportElement) { |
| 1015 resolveCombinators(((element23 as ImportElement)).importedLibrary, node.co
mbinators); | 1012 resolveCombinators(((element27 as ImportElement)).importedLibrary, node.co
mbinators); |
| 1016 } | 1013 } |
| 1017 return null; | 1014 return null; |
| 1018 } | 1015 } |
| 1019 Object visitIndexExpression(IndexExpression node) { | 1016 Object visitIndexExpression(IndexExpression node) { |
| 1020 Type2 arrayType = getType(node.realTarget); | 1017 Type2 arrayType = getType(node.realTarget); |
| 1021 if (arrayType == null || arrayType.isDynamic()) { | 1018 if (arrayType == null || arrayType.isDynamic()) { |
| 1022 return null; | 1019 return null; |
| 1023 } | 1020 } |
| 1024 Element arrayTypeElement = arrayType.element; | 1021 Element arrayTypeElement = arrayType.element; |
| 1025 String operator; | 1022 String operator; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 } | 1079 } |
| 1083 } | 1080 } |
| 1084 if (element == null && target is SuperExpression) { | 1081 if (element == null && target is SuperExpression) { |
| 1085 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, me
thodName2, [methodName2.name, targetType.element.name]); | 1082 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, me
thodName2, [methodName2.name, targetType.element.name]); |
| 1086 return null; | 1083 return null; |
| 1087 } | 1084 } |
| 1088 } else if (target is SimpleIdentifier) { | 1085 } else if (target is SimpleIdentifier) { |
| 1089 Element targetElement = ((target as SimpleIdentifier)).element; | 1086 Element targetElement = ((target as SimpleIdentifier)).element; |
| 1090 if (targetElement is PrefixElement) { | 1087 if (targetElement is PrefixElement) { |
| 1091 String name9 = "${((target as SimpleIdentifier)).name}.${methodName2}"
; | 1088 String name9 = "${((target as SimpleIdentifier)).name}.${methodName2}"
; |
| 1092 Identifier functionName = new Identifier_4(name9); | 1089 Identifier functionName = new Identifier_5(name9); |
| 1093 element = _resolver.nameScope.lookup(functionName, _resolver.definingL
ibrary); | 1090 element = _resolver.nameScope.lookup(functionName, _resolver.definingL
ibrary); |
| 1094 } else { | 1091 } else { |
| 1095 return null; | 1092 return null; |
| 1096 } | 1093 } |
| 1097 } else { | 1094 } else { |
| 1098 return null; | 1095 return null; |
| 1099 } | 1096 } |
| 1100 } | 1097 } |
| 1101 ExecutableElement invokedMethod = null; | 1098 ExecutableElement invokedMethod = null; |
| 1102 if (element is ExecutableElement) { | 1099 if (element is ExecutableElement) { |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 break; | 1692 break; |
| 1696 } | 1693 } |
| 1697 AnalysisEngine.instance.logger.logError("Failed to map ${operator.lexeme} to
it's corresponding operator"); | 1694 AnalysisEngine.instance.logger.logError("Failed to map ${operator.lexeme} to
it's corresponding operator"); |
| 1698 return operator; | 1695 return operator; |
| 1699 } | 1696 } |
| 1700 /** | 1697 /** |
| 1701 * Record the fact that the given AST node was resolved to the given element. | 1698 * Record the fact that the given AST node was resolved to the given element. |
| 1702 * @param node the AST node that was resolved | 1699 * @param node the AST node that was resolved |
| 1703 * @param element the element to which the AST node was resolved | 1700 * @param element the element to which the AST node was resolved |
| 1704 */ | 1701 */ |
| 1705 void recordResolution(SimpleIdentifier node, Element element52) { | 1702 void recordResolution(SimpleIdentifier node, Element element58) { |
| 1706 if (element52 != null) { | 1703 if (element58 != null) { |
| 1707 node.element = element52; | 1704 node.element = element58; |
| 1708 } | 1705 } |
| 1709 } | 1706 } |
| 1710 /** | 1707 /** |
| 1711 * Report the {@link StaticTypeWarningCode}s <code>UNDEFINED_SETTER</code> and | 1708 * Report the {@link StaticTypeWarningCode}s <code>UNDEFINED_SETTER</code> and |
| 1712 * <code>UNDEFINED_GETTER</code>. | 1709 * <code>UNDEFINED_GETTER</code>. |
| 1713 * @param node the prefixed identifier that gives the context to determine if
the error on the | 1710 * @param node the prefixed identifier that gives the context to determine if
the error on the |
| 1714 * undefined identifier is a getter or a setter | 1711 * undefined identifier is a getter or a setter |
| 1715 * @param identifier the identifier in the passed prefix identifier | 1712 * @param identifier the identifier in the passed prefix identifier |
| 1716 * @param typeName the name of the type of the left hand side of the passed pr
efixed identifier | 1713 * @param typeName the name of the type of the left hand side of the passed pr
efixed identifier |
| 1717 */ | 1714 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 } | 1764 } |
| 1768 } | 1765 } |
| 1769 } | 1766 } |
| 1770 /** | 1767 /** |
| 1771 * If the given element is a type variable, resolve it to the class that shoul
d be used when | 1768 * If the given element is a type variable, resolve it to the class that shoul
d be used when |
| 1772 * looking up members. Otherwise, return the original element. | 1769 * looking up members. Otherwise, return the original element. |
| 1773 * @param element the element that is to be resolved if it is a type variable | 1770 * @param element the element that is to be resolved if it is a type variable |
| 1774 * @return the class that should be used in place of the argument if it is a t
ype variable, or the | 1771 * @return the class that should be used in place of the argument if it is a t
ype variable, or the |
| 1775 * original argument if it isn't a type variable | 1772 * original argument if it isn't a type variable |
| 1776 */ | 1773 */ |
| 1777 Element resolveTypeVariable(Element element53) { | 1774 Element resolveTypeVariable(Element element59) { |
| 1778 if (element53 is TypeVariableElement) { | 1775 if (element59 is TypeVariableElement) { |
| 1779 Type2 bound4 = ((element53 as TypeVariableElement)).bound; | 1776 Type2 bound4 = ((element59 as TypeVariableElement)).bound; |
| 1780 if (bound4 == null) { | 1777 if (bound4 == null) { |
| 1781 return _resolver.typeProvider.objectType.element; | 1778 return _resolver.typeProvider.objectType.element; |
| 1782 } | 1779 } |
| 1783 return bound4.element; | 1780 return bound4.element; |
| 1784 } | 1781 } |
| 1785 return element53; | 1782 return element59; |
| 1786 } | 1783 } |
| 1787 } | 1784 } |
| 1788 class Identifier_4 extends Identifier { | 1785 class Identifier_5 extends Identifier { |
| 1789 String name9; | 1786 String name9; |
| 1790 Identifier_4(this.name9) : super(); | 1787 Identifier_5(this.name9) : super(); |
| 1791 accept(ASTVisitor visitor) => null; | 1788 accept(ASTVisitor visitor) => null; |
| 1792 sc.Token get beginToken => null; | 1789 sc.Token get beginToken => null; |
| 1793 Element get element => null; | 1790 Element get element => null; |
| 1794 sc.Token get endToken => null; | 1791 sc.Token get endToken => null; |
| 1795 String get name => name9; | 1792 String get name => name9; |
| 1796 void visitChildren(ASTVisitor<Object> visitor) { | 1793 void visitChildren(ASTVisitor<Object> visitor) { |
| 1797 } | 1794 } |
| 1798 } | 1795 } |
| 1799 /** | 1796 /** |
| 1800 * Instances of the class {@code Library} represent the data about a single libr
ary during the | 1797 * Instances of the class {@code Library} represent the data about a single libr
ary during the |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 /** | 1840 /** |
| 1844 * Initialize a newly created data holder that can maintain the data associate
d with a library. | 1841 * Initialize a newly created data holder that can maintain the data associate
d with a library. |
| 1845 * @param analysisContext the analysis context in which this library is being
analyzed | 1842 * @param analysisContext the analysis context in which this library is being
analyzed |
| 1846 * @param errorListener the listener to which analysis errors will be reported | 1843 * @param errorListener the listener to which analysis errors will be reported |
| 1847 * @param librarySource the source specifying the defining compilation unit of
this library | 1844 * @param librarySource the source specifying the defining compilation unit of
this library |
| 1848 */ | 1845 */ |
| 1849 Library(AnalysisContextImpl analysisContext, AnalysisErrorListener errorListen
er, Source librarySource) { | 1846 Library(AnalysisContextImpl analysisContext, AnalysisErrorListener errorListen
er, Source librarySource) { |
| 1850 this._analysisContext = analysisContext; | 1847 this._analysisContext = analysisContext; |
| 1851 this._errorListener = errorListener; | 1848 this._errorListener = errorListener; |
| 1852 this._librarySource = librarySource; | 1849 this._librarySource = librarySource; |
| 1853 this._libraryElement = analysisContext.getLibraryElementOrNull(librarySource
) as LibraryElementImpl; | 1850 this._libraryElement = analysisContext.getLibraryElement(librarySource) as L
ibraryElementImpl; |
| 1854 } | 1851 } |
| 1855 /** | 1852 /** |
| 1856 * Record that the given library is exported from this library. | 1853 * Record that the given library is exported from this library. |
| 1857 * @param importLibrary the library that is exported from this library | 1854 * @param importLibrary the library that is exported from this library |
| 1858 */ | 1855 */ |
| 1859 void addExport(ExportDirective directive, Library exportLibrary) { | 1856 void addExport(ExportDirective directive, Library exportLibrary) { |
| 1860 _exportedLibraries[directive] = exportLibrary; | 1857 _exportedLibraries[directive] = exportLibrary; |
| 1861 } | 1858 } |
| 1862 /** | 1859 /** |
| 1863 * Record that the given library is imported into this library. | 1860 * Record that the given library is imported into this library. |
| 1864 * @param importLibrary the library that is imported into this library | 1861 * @param importLibrary the library that is imported into this library |
| 1865 */ | 1862 */ |
| 1866 void addImport(ImportDirective directive, Library importLibrary) { | 1863 void addImport(ImportDirective directive, Library importLibrary) { |
| 1867 _importedLibraries[directive] = importLibrary; | 1864 _importedLibraries[directive] = importLibrary; |
| 1868 } | 1865 } |
| 1869 /** | 1866 /** |
| 1870 * Return the AST structure associated with the given source. | 1867 * Return the AST structure associated with the given source. |
| 1871 * @param source the source representing the compilation unit whose AST is to
be returned | 1868 * @param source the source representing the compilation unit whose AST is to
be returned |
| 1872 * @return the AST structure associated with the given source | 1869 * @return the AST structure associated with the given source |
| 1873 * @throws AnalysisException if an AST structure could not be created for the
compilation unit | 1870 * @throws AnalysisException if an AST structure could not be created for the
compilation unit |
| 1874 */ | 1871 */ |
| 1875 CompilationUnit getAST(Source source) { | 1872 CompilationUnit getAST(Source source) { |
| 1876 CompilationUnit unit = _astMap[source]; | 1873 CompilationUnit unit = _astMap[source]; |
| 1877 if (unit == null) { | 1874 if (unit == null) { |
| 1878 unit = _analysisContext.parse3(source, _errorListener); | 1875 unit = _analysisContext.parseCompilationUnit(source); |
| 1879 _astMap[source] = unit; | 1876 _astMap[source] = unit; |
| 1880 } | 1877 } |
| 1881 return unit; | 1878 return unit; |
| 1882 } | 1879 } |
| 1883 /** | 1880 /** |
| 1884 * Return a collection containing the sources for the compilation units in thi
s library. | 1881 * Return a collection containing the sources for the compilation units in thi
s library. |
| 1885 * @return the sources for the compilation units in this library | 1882 * @return the sources for the compilation units in this library |
| 1886 */ | 1883 */ |
| 1887 Set<Source> get compilationUnitSources => _astMap.keys.toSet(); | 1884 Set<Source> get compilationUnitSources => _astMap.keys.toSet(); |
| 1888 /** | 1885 /** |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 libraries.addAll(_importedLibraries.values); | 1934 libraries.addAll(_importedLibraries.values); |
| 1938 libraries.addAll(_exportedLibraries.values); | 1935 libraries.addAll(_exportedLibraries.values); |
| 1939 return new List.from(libraries); | 1936 return new List.from(libraries); |
| 1940 } | 1937 } |
| 1941 /** | 1938 /** |
| 1942 * Return the library element representing this library, creating it if necess
ary. | 1939 * Return the library element representing this library, creating it if necess
ary. |
| 1943 * @return the library element representing this library | 1940 * @return the library element representing this library |
| 1944 */ | 1941 */ |
| 1945 LibraryElementImpl get libraryElement { | 1942 LibraryElementImpl get libraryElement { |
| 1946 if (_libraryElement == null) { | 1943 if (_libraryElement == null) { |
| 1947 _libraryElement = _analysisContext.getLibraryElement(_librarySource) as Li
braryElementImpl; | 1944 try { |
| 1945 _libraryElement = _analysisContext.computeLibraryElement(_librarySource)
as LibraryElementImpl; |
| 1946 } on AnalysisException catch (exception) { |
| 1947 AnalysisEngine.instance.logger.logError2("Could not compute ilbrary elem
ent for ${_librarySource.fullName}", exception); |
| 1948 } |
| 1948 } | 1949 } |
| 1949 return _libraryElement; | 1950 return _libraryElement; |
| 1950 } | 1951 } |
| 1951 /** | 1952 /** |
| 1952 * Return the library scope used when resolving elements within this library's
compilation units. | 1953 * Return the library scope used when resolving elements within this library's
compilation units. |
| 1953 * @return the library scope used when resolving elements within this library'
s compilation units | 1954 * @return the library scope used when resolving elements within this library'
s compilation units |
| 1954 */ | 1955 */ |
| 1955 LibraryScope get libraryScope { | 1956 LibraryScope get libraryScope { |
| 1956 if (_libraryScope == null) { | 1957 if (_libraryScope == null) { |
| 1957 _libraryScope = new LibraryScope(_libraryElement, _errorListener); | 1958 _libraryScope = new LibraryScope(_libraryElement, _errorListener); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 this._analysisContext = resolver.analysisContext; | 2067 this._analysisContext = resolver.analysisContext; |
| 2067 this._errorListener = resolver.errorListener; | 2068 this._errorListener = resolver.errorListener; |
| 2068 } | 2069 } |
| 2069 /** | 2070 /** |
| 2070 * Build the library element for the given library. | 2071 * Build the library element for the given library. |
| 2071 * @param library the library for which an element model is to be built | 2072 * @param library the library for which an element model is to be built |
| 2072 * @return the library element that was built | 2073 * @return the library element that was built |
| 2073 * @throws AnalysisException if the analysis could not be performed | 2074 * @throws AnalysisException if the analysis could not be performed |
| 2074 */ | 2075 */ |
| 2075 LibraryElementImpl buildLibrary(Library library) { | 2076 LibraryElementImpl buildLibrary(Library library) { |
| 2076 CompilationUnitBuilder builder = new CompilationUnitBuilder(_analysisContext
, _errorListener); | 2077 CompilationUnitBuilder builder = new CompilationUnitBuilder(_analysisContext
); |
| 2077 Source librarySource2 = library.librarySource; | 2078 Source librarySource2 = library.librarySource; |
| 2078 CompilationUnit definingCompilationUnit3 = library.definingCompilationUnit; | 2079 CompilationUnit definingCompilationUnit3 = library.definingCompilationUnit; |
| 2079 CompilationUnitElementImpl definingCompilationUnitElement = builder.buildCom
pilationUnit2(librarySource2, definingCompilationUnit3); | 2080 CompilationUnitElementImpl definingCompilationUnitElement = builder.buildCom
pilationUnit2(librarySource2, definingCompilationUnit3); |
| 2080 NodeList<Directive> directives3 = definingCompilationUnit3.directives; | 2081 NodeList<Directive> directives3 = definingCompilationUnit3.directives; |
| 2081 LibraryIdentifier libraryNameNode = null; | 2082 LibraryIdentifier libraryNameNode = null; |
| 2082 bool hasPartDirective = false; | 2083 bool hasPartDirective = false; |
| 2083 FunctionElement entryPoint = findEntryPoint(definingCompilationUnitElement); | 2084 FunctionElement entryPoint = findEntryPoint(definingCompilationUnitElement); |
| 2084 List<Directive> directivesToResolve = new List<Directive>(); | 2085 List<Directive> directivesToResolve = new List<Directive>(); |
| 2085 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat
ionUnitElementImpl>(); | 2086 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat
ionUnitElementImpl>(); |
| 2086 for (Directive directive in directives3) { | 2087 for (Directive directive in directives3) { |
| 2087 if (directive is LibraryDirective) { | 2088 if (directive is LibraryDirective) { |
| 2088 if (libraryNameNode == null) { | 2089 if (libraryNameNode == null) { |
| 2089 libraryNameNode = ((directive as LibraryDirective)).name; | 2090 libraryNameNode = ((directive as LibraryDirective)).name; |
| 2090 directivesToResolve.add(directive); | 2091 directivesToResolve.add(directive); |
| 2091 } | 2092 } |
| 2092 } else if (directive is PartDirective) { | 2093 } else if (directive is PartDirective) { |
| 2093 hasPartDirective = true; | 2094 hasPartDirective = true; |
| 2094 StringLiteral partUri = ((directive as PartDirective)).uri; | 2095 StringLiteral partUri = ((directive as PartDirective)).uri; |
| 2095 Source partSource = library.getSource(partUri); | 2096 Source partSource = library.getSource(partUri); |
| 2096 if (partSource != null) { | 2097 if (partSource != null && partSource.exists()) { |
| 2097 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou
rce); | 2098 CompilationUnitElementImpl part = builder.buildCompilationUnit(partSou
rce); |
| 2098 String partLibraryName = getPartLibraryName(library, partSource, direc
tivesToResolve); | 2099 String partLibraryName = getPartLibraryName(library, partSource, direc
tivesToResolve); |
| 2099 if (partLibraryName == null) { | 2100 if (partLibraryName == null) { |
| 2100 _errorListener.onError(new AnalysisError.con2(librarySource2, partUr
i.offset, partUri.length, ResolverErrorCode.MISSING_PART_OF_DIRECTIVE, [])); | 2101 _errorListener.onError(new AnalysisError.con2(librarySource2, partUr
i.offset, partUri.length, ResolverErrorCode.MISSING_PART_OF_DIRECTIVE, [])); |
| 2101 } else if (libraryNameNode == null) { | 2102 } else if (libraryNameNode == null) { |
| 2102 } else if (libraryNameNode.name != partLibraryName) { | 2103 } else if (libraryNameNode.name != partLibraryName) { |
| 2103 _errorListener.onError(new AnalysisError.con2(librarySource2, partUr
i.offset, partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [libraryN
ameNode.name, partLibraryName])); | 2104 _errorListener.onError(new AnalysisError.con2(librarySource2, partUr
i.offset, partUri.length, StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [libraryN
ameNode.name, partLibraryName])); |
| 2104 } | 2105 } |
| 2105 if (entryPoint == null) { | 2106 if (entryPoint == null) { |
| 2106 entryPoint = findEntryPoint(part); | 2107 entryPoint = findEntryPoint(part); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 */ | 2176 */ |
| 2176 AnalysisContextImpl _analysisContext; | 2177 AnalysisContextImpl _analysisContext; |
| 2177 /** | 2178 /** |
| 2178 * The listener to which analysis errors will be reported, this error listener
is either | 2179 * The listener to which analysis errors will be reported, this error listener
is either |
| 2179 * references {@link #recordingErrorListener}, or it unions the passed{@link A
nalysisErrorListener} with the {@link #recordingErrorListener}. | 2180 * references {@link #recordingErrorListener}, or it unions the passed{@link A
nalysisErrorListener} with the {@link #recordingErrorListener}. |
| 2180 */ | 2181 */ |
| 2181 AnalysisErrorListener _errorListener; | 2182 AnalysisErrorListener _errorListener; |
| 2182 /** | 2183 /** |
| 2183 * This error listener is used by the resolver to be able to call the listener
and get back the | 2184 * This error listener is used by the resolver to be able to call the listener
and get back the |
| 2184 * set of errors for each {@link Source}. | 2185 * set of errors for each {@link Source}. |
| 2185 * @see #recordErrors() | 2186 * @see #recordResults() |
| 2186 */ | 2187 */ |
| 2187 RecordingErrorListener _recordingErrorListener; | 2188 RecordingErrorListener _recordingErrorListener; |
| 2188 /** | 2189 /** |
| 2189 * A source object representing the core library (dart:core). | 2190 * A source object representing the core library (dart:core). |
| 2190 */ | 2191 */ |
| 2191 Source _coreLibrarySource; | 2192 Source _coreLibrarySource; |
| 2192 /** | 2193 /** |
| 2193 * The object representing the core library. | 2194 * The object representing the core library. |
| 2194 */ | 2195 */ |
| 2195 Library _coreLibrary; | 2196 Library _coreLibrary; |
| 2196 /** | 2197 /** |
| 2197 * The object used to access the types from the core library. | 2198 * The object used to access the types from the core library. |
| 2198 */ | 2199 */ |
| 2199 TypeProvider _typeProvider; | 2200 TypeProvider _typeProvider; |
| 2200 /** | 2201 /** |
| 2201 * A table mapping library sources to the information being maintained for tho
se libraries. | 2202 * A table mapping library sources to the information being maintained for tho
se libraries. |
| 2202 */ | 2203 */ |
| 2203 Map<Source, Library> _libraryMap = new Map<Source, Library>(); | 2204 Map<Source, Library> _libraryMap = new Map<Source, Library>(); |
| 2204 /** | 2205 /** |
| 2205 * A collection containing the libraries that are being resolved together. | 2206 * A collection containing the libraries that are being resolved together. |
| 2206 */ | 2207 */ |
| 2207 Set<Library> _librariesInCycles; | 2208 Set<Library> _librariesInCycles; |
| 2208 /** | 2209 /** |
| 2209 * Initialize a newly created library resolver to resolve libraries within the
given context. | 2210 * Initialize a newly created library resolver to resolve libraries within the
given context. |
| 2210 * @param analysisContext the analysis context in which the library is being a
nalyzed | 2211 * @param analysisContext the analysis context in which the library is being a
nalyzed |
| 2211 */ | 2212 */ |
| 2212 LibraryResolver.con1(AnalysisContextImpl analysisContext) { | 2213 LibraryResolver.con1(AnalysisContextImpl analysisContext) { |
| 2213 _jtd_constructor_239_impl(analysisContext); | 2214 _jtd_constructor_243_impl(analysisContext); |
| 2214 } | 2215 } |
| 2215 _jtd_constructor_239_impl(AnalysisContextImpl analysisContext) { | 2216 _jtd_constructor_243_impl(AnalysisContextImpl analysisContext) { |
| 2216 _jtd_constructor_240_impl(analysisContext, null); | 2217 _jtd_constructor_244_impl(analysisContext, null); |
| 2217 } | 2218 } |
| 2218 /** | 2219 /** |
| 2219 * Initialize a newly created library resolver to resolve libraries within the
given context. | 2220 * Initialize a newly created library resolver to resolve libraries within the
given context. |
| 2220 * @param analysisContext the analysis context in which the library is being a
nalyzed | 2221 * @param analysisContext the analysis context in which the library is being a
nalyzed |
| 2221 * @param errorListener the listener to which analysis errors will be reported | 2222 * @param errorListener the listener to which analysis errors will be reported |
| 2222 */ | 2223 */ |
| 2223 LibraryResolver.con2(AnalysisContextImpl analysisContext2, AnalysisErrorListen
er additionalAnalysisErrorListener) { | 2224 LibraryResolver.con2(AnalysisContextImpl analysisContext2, AnalysisErrorListen
er additionalAnalysisErrorListener) { |
| 2224 _jtd_constructor_240_impl(analysisContext2, additionalAnalysisErrorListener)
; | 2225 _jtd_constructor_244_impl(analysisContext2, additionalAnalysisErrorListener)
; |
| 2225 } | 2226 } |
| 2226 _jtd_constructor_240_impl(AnalysisContextImpl analysisContext2, AnalysisErrorL
istener additionalAnalysisErrorListener) { | 2227 _jtd_constructor_244_impl(AnalysisContextImpl analysisContext2, AnalysisErrorL
istener additionalAnalysisErrorListener) { |
| 2227 this._analysisContext = analysisContext2; | 2228 this._analysisContext = analysisContext2; |
| 2228 this._recordingErrorListener = new RecordingErrorListener(); | 2229 this._recordingErrorListener = new RecordingErrorListener(); |
| 2229 if (additionalAnalysisErrorListener == null) { | 2230 if (additionalAnalysisErrorListener == null) { |
| 2230 this._errorListener = _recordingErrorListener; | 2231 this._errorListener = _recordingErrorListener; |
| 2231 } else { | 2232 } else { |
| 2232 this._errorListener = new AnalysisErrorListener_5(this, additionalAnalysis
ErrorListener); | 2233 this._errorListener = new AnalysisErrorListener_6(this, additionalAnalysis
ErrorListener); |
| 2233 } | 2234 } |
| 2234 _coreLibrarySource = analysisContext2.sourceFactory.forUri(LibraryElementBui
lder.CORE_LIBRARY_URI); | 2235 _coreLibrarySource = analysisContext2.sourceFactory.forUri(LibraryElementBui
lder.CORE_LIBRARY_URI); |
| 2235 } | 2236 } |
| 2236 /** | 2237 /** |
| 2237 * Return the analysis context in which the libraries are being analyzed. | 2238 * Return the analysis context in which the libraries are being analyzed. |
| 2238 * @return the analysis context in which the libraries are being analyzed | 2239 * @return the analysis context in which the libraries are being analyzed |
| 2239 */ | 2240 */ |
| 2240 AnalysisContextImpl get analysisContext => _analysisContext; | 2241 AnalysisContextImpl get analysisContext => _analysisContext; |
| 2241 /** | 2242 /** |
| 2242 * Return the listener to which analysis errors will be reported. | 2243 * Return the listener to which analysis errors will be reported. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2264 computeLibraryDependencies(targetLibrary); | 2265 computeLibraryDependencies(targetLibrary); |
| 2265 _librariesInCycles = computeLibrariesInCycles(targetLibrary); | 2266 _librariesInCycles = computeLibrariesInCycles(targetLibrary); |
| 2266 buildElementModels(); | 2267 buildElementModels(); |
| 2267 buildDirectiveModels(); | 2268 buildDirectiveModels(); |
| 2268 _typeProvider = new TypeProviderImpl(_coreLibrary.libraryElement); | 2269 _typeProvider = new TypeProviderImpl(_coreLibrary.libraryElement); |
| 2269 buildTypeHierarchies(); | 2270 buildTypeHierarchies(); |
| 2270 resolveReferencesAndTypes(); | 2271 resolveReferencesAndTypes(); |
| 2271 if (fullAnalysis) { | 2272 if (fullAnalysis) { |
| 2272 runAdditionalAnalyses(); | 2273 runAdditionalAnalyses(); |
| 2273 } | 2274 } |
| 2274 recordLibraryElements(); | 2275 recordResults(); |
| 2275 recordErrors(); | |
| 2276 return targetLibrary.libraryElement; | 2276 return targetLibrary.libraryElement; |
| 2277 } | 2277 } |
| 2278 /** | 2278 /** |
| 2279 * Add a dependency to the given map from the referencing library to the refer
enced library. | 2279 * Add a dependency to the given map from the referencing library to the refer
enced library. |
| 2280 * @param dependencyMap the map to which the dependency is to be added | 2280 * @param dependencyMap the map to which the dependency is to be added |
| 2281 * @param referencingLibrary the library that references the referenced librar
y | 2281 * @param referencingLibrary the library that references the referenced librar
y |
| 2282 * @param referencedLibrary the library referenced by the referencing library | 2282 * @param referencedLibrary the library referenced by the referencing library |
| 2283 */ | 2283 */ |
| 2284 void addDependencyToMap(Map<Library, List<Library>> dependencyMap, Library ref
erencingLibrary, Library referencedLibrary) { | 2284 void addDependencyToMap(Map<Library, List<Library>> dependencyMap, Library ref
erencingLibrary, Library referencedLibrary) { |
| 2285 List<Library> dependentLibraries = dependencyMap[referencedLibrary]; | 2285 List<Library> dependentLibraries = dependencyMap[referencedLibrary]; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2531 return library; | 2531 return library; |
| 2532 } | 2532 } |
| 2533 /** | 2533 /** |
| 2534 * Create an object to represent the information about the library defined by
the compilation unit | 2534 * Create an object to represent the information about the library defined by
the compilation unit |
| 2535 * with the given source. Return the library object that was created, or {@cod
e null} if the | 2535 * with the given source. Return the library object that was created, or {@cod
e null} if the |
| 2536 * source is not valid. | 2536 * source is not valid. |
| 2537 * @param librarySource the source of the library's defining compilation unit | 2537 * @param librarySource the source of the library's defining compilation unit |
| 2538 * @return the library object that was created | 2538 * @return the library object that was created |
| 2539 */ | 2539 */ |
| 2540 Library createLibraryOrNull(Source librarySource) { | 2540 Library createLibraryOrNull(Source librarySource) { |
| 2541 if (!librarySource.exists()) { |
| 2542 return null; |
| 2543 } |
| 2541 Library library = new Library(_analysisContext, _errorListener, librarySourc
e); | 2544 Library library = new Library(_analysisContext, _errorListener, librarySourc
e); |
| 2542 try { | 2545 try { |
| 2543 library.definingCompilationUnit; | 2546 library.definingCompilationUnit; |
| 2544 } on AnalysisException catch (exception) { | 2547 } on AnalysisException catch (exception) { |
| 2545 return null; | 2548 return null; |
| 2546 } | 2549 } |
| 2547 _libraryMap[librarySource] = library; | 2550 _libraryMap[librarySource] = library; |
| 2548 return library; | 2551 return library; |
| 2549 } | 2552 } |
| 2550 /** | 2553 /** |
| 2551 * Return an array containing the lexical identifiers associated with the node
s in the given list. | 2554 * Return an array containing the lexical identifiers associated with the node
s in the given list. |
| 2552 * @param names the AST nodes representing the identifiers | 2555 * @param names the AST nodes representing the identifiers |
| 2553 * @return the lexical identifiers associated with the nodes in the list | 2556 * @return the lexical identifiers associated with the nodes in the list |
| 2554 */ | 2557 */ |
| 2555 List<String> getIdentifiers(NodeList<SimpleIdentifier> names) { | 2558 List<String> getIdentifiers(NodeList<SimpleIdentifier> names) { |
| 2556 int count = names.length; | 2559 int count = names.length; |
| 2557 List<String> identifiers = new List<String>(count); | 2560 List<String> identifiers = new List<String>(count); |
| 2558 for (int i = 0; i < count; i++) { | 2561 for (int i = 0; i < count; i++) { |
| 2559 identifiers[i] = names[i].name; | 2562 identifiers[i] = names[i].name; |
| 2560 } | 2563 } |
| 2561 return identifiers; | 2564 return identifiers; |
| 2562 } | 2565 } |
| 2563 /** | 2566 /** |
| 2564 * For each library, loop through the set of all {@link CompilationUnit}s reco
rding the set of | 2567 * Record the results of resolution with the analysis context. This includes r
ecording |
| 2565 * resolution errors on each unit. | 2568 * <ul> |
| 2569 * <li>the resolved AST associated with each compilation unit,</li> |
| 2570 * <li>the set of resolution errors produced for each compilation unit, and</l
i> |
| 2571 * <li>the element models produced for each library.</li> |
| 2572 * </ul> |
| 2566 */ | 2573 */ |
| 2567 void recordErrors() { | 2574 void recordResults() { |
| 2568 for (Library library in _librariesInCycles) { | |
| 2569 try { | |
| 2570 CompilationUnit definingUnit = library.definingCompilationUnit; | |
| 2571 definingUnit.resolutionErrors = _recordingErrorListener.getErrors2(libra
ry.librarySource); | |
| 2572 } on AnalysisException catch (e) { | |
| 2573 throw new AnalysisException(); | |
| 2574 } | |
| 2575 Set<Source> sources = library.compilationUnitSources; | |
| 2576 for (Source source in sources) { | |
| 2577 try { | |
| 2578 CompilationUnit unit = library.getAST(source); | |
| 2579 unit.resolutionErrors = _recordingErrorListener.getErrors2(source); | |
| 2580 } on JavaException catch (e) { | |
| 2581 throw new AnalysisException(); | |
| 2582 } | |
| 2583 } | |
| 2584 } | |
| 2585 } | |
| 2586 /** | |
| 2587 * As the final step in the process, record the resolved element models with t
he analysis context. | |
| 2588 */ | |
| 2589 void recordLibraryElements() { | |
| 2590 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); | 2575 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); |
| 2591 for (Library library in _librariesInCycles) { | 2576 for (Library library in _librariesInCycles) { |
| 2577 recordResults2(library.librarySource, library.definingCompilationUnit); |
| 2578 for (Source source in library.compilationUnitSources) { |
| 2579 recordResults2(source, library.getAST(source)); |
| 2580 } |
| 2592 elementMap[library.librarySource] = library.libraryElement; | 2581 elementMap[library.librarySource] = library.libraryElement; |
| 2593 } | 2582 } |
| 2594 _analysisContext.recordLibraryElements(elementMap); | 2583 _analysisContext.recordLibraryElements(elementMap); |
| 2595 } | 2584 } |
| 2585 void recordResults2(Source source, CompilationUnit unit) { |
| 2586 List<AnalysisError> errors = _recordingErrorListener.getErrors2(source); |
| 2587 unit.resolutionErrors = errors; |
| 2588 _analysisContext.recordResolvedCompilationUnit(source, unit); |
| 2589 _analysisContext.recordResolutionErrors(source, errors, unit.lineInfo); |
| 2590 } |
| 2596 /** | 2591 /** |
| 2597 * Resolve the identifiers and perform type analysis in the libraries in the c
urrent cycle. | 2592 * Resolve the identifiers and perform type analysis in the libraries in the c
urrent cycle. |
| 2598 * @throws AnalysisException if any of the identifiers could not be resolved o
r if any of the | 2593 * @throws AnalysisException if any of the identifiers could not be resolved o
r if any of the |
| 2599 * libraries could not have their types analyzed | 2594 * libraries could not have their types analyzed |
| 2600 */ | 2595 */ |
| 2601 void resolveReferencesAndTypes() { | 2596 void resolveReferencesAndTypes() { |
| 2602 for (Library library in _librariesInCycles) { | 2597 for (Library library in _librariesInCycles) { |
| 2603 resolveReferencesAndTypes2(library); | 2598 resolveReferencesAndTypes2(library); |
| 2604 } | 2599 } |
| 2605 } | 2600 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2635 for (Source source in library.compilationUnitSources) { | 2630 for (Source source in library.compilationUnitSources) { |
| 2636 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); | 2631 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
| 2637 CompilationUnit unit = library.getAST(source); | 2632 CompilationUnit unit = library.getAST(source); |
| 2638 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib
raryElement, _typeProvider); | 2633 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib
raryElement, _typeProvider); |
| 2639 unit.accept(errorVerifier); | 2634 unit.accept(errorVerifier); |
| 2640 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter); | 2635 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter); |
| 2641 unit.accept(constantVerifier); | 2636 unit.accept(constantVerifier); |
| 2642 } | 2637 } |
| 2643 } | 2638 } |
| 2644 } | 2639 } |
| 2645 class AnalysisErrorListener_5 implements AnalysisErrorListener { | 2640 class AnalysisErrorListener_6 implements AnalysisErrorListener { |
| 2646 final LibraryResolver LibraryResolver_this; | 2641 final LibraryResolver LibraryResolver_this; |
| 2647 AnalysisErrorListener additionalAnalysisErrorListener; | 2642 AnalysisErrorListener additionalAnalysisErrorListener; |
| 2648 AnalysisErrorListener_5(this.LibraryResolver_this, this.additionalAnalysisErro
rListener); | 2643 AnalysisErrorListener_6(this.LibraryResolver_this, this.additionalAnalysisErro
rListener); |
| 2649 void onError(AnalysisError error) { | 2644 void onError(AnalysisError error) { |
| 2650 additionalAnalysisErrorListener.onError(error); | 2645 additionalAnalysisErrorListener.onError(error); |
| 2651 LibraryResolver_this._recordingErrorListener.onError(error); | 2646 LibraryResolver_this._recordingErrorListener.onError(error); |
| 2652 } | 2647 } |
| 2653 } | 2648 } |
| 2654 /** | 2649 /** |
| 2655 * Instances of the class {@code ResolverVisitor} are used to resolve the nodes
within a single | 2650 * Instances of the class {@code ResolverVisitor} are used to resolve the nodes
within a single |
| 2656 * compilation unit. | 2651 * compilation unit. |
| 2657 * @coverage dart.engine.resolver | 2652 * @coverage dart.engine.resolver |
| 2658 */ | 2653 */ |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3020 } | 3015 } |
| 3021 try { | 3016 try { |
| 3022 super.visitSwitchStatement(node); | 3017 super.visitSwitchStatement(node); |
| 3023 } finally { | 3018 } finally { |
| 3024 _labelScope = outerScope; | 3019 _labelScope = outerScope; |
| 3025 } | 3020 } |
| 3026 return null; | 3021 return null; |
| 3027 } | 3022 } |
| 3028 Object visitVariableDeclaration(VariableDeclaration node) { | 3023 Object visitVariableDeclaration(VariableDeclaration node) { |
| 3029 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent
is! FieldDeclaration) { | 3024 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent
is! FieldDeclaration) { |
| 3030 VariableElement element24 = node.element; | 3025 VariableElement element28 = node.element; |
| 3031 if (element24 != null) { | 3026 if (element28 != null) { |
| 3032 _nameScope.define(element24); | 3027 _nameScope.define(element28); |
| 3033 } | 3028 } |
| 3034 } | 3029 } |
| 3035 super.visitVariableDeclaration(node); | 3030 super.visitVariableDeclaration(node); |
| 3036 return null; | 3031 return null; |
| 3037 } | 3032 } |
| 3038 Object visitWhileStatement(WhileStatement node) { | 3033 Object visitWhileStatement(WhileStatement node) { |
| 3039 LabelScope outerScope = _labelScope; | 3034 LabelScope outerScope = _labelScope; |
| 3040 _labelScope = new LabelScope.con1(outerScope, false, false); | 3035 _labelScope = new LabelScope.con1(outerScope, false, false); |
| 3041 try { | 3036 try { |
| 3042 super.visitWhileStatement(node); | 3037 super.visitWhileStatement(node); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3478 * <p> | 3473 * <p> |
| 3479 * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i)
{var r = a[i]; a[i] | 3474 * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i)
{var r = a[i]; a[i] |
| 3480 * = r - 1; return r}(e1, e2)</i></blockquote> | 3475 * = r - 1; return r}(e1, e2)</i></blockquote> |
| 3481 */ | 3476 */ |
| 3482 Object visitPostfixExpression(PostfixExpression node) => recordType(node, getT
ype(node.operand)); | 3477 Object visitPostfixExpression(PostfixExpression node) => recordType(node, getT
ype(node.operand)); |
| 3483 /** | 3478 /** |
| 3484 * See {@link #visitSimpleIdentifier(SimpleIdentifier)}. | 3479 * See {@link #visitSimpleIdentifier(SimpleIdentifier)}. |
| 3485 */ | 3480 */ |
| 3486 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 3481 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 3487 SimpleIdentifier prefixedIdentifier = node.identifier; | 3482 SimpleIdentifier prefixedIdentifier = node.identifier; |
| 3488 Element element25 = prefixedIdentifier.element; | 3483 Element element29 = prefixedIdentifier.element; |
| 3489 if (element25 is VariableElement) { | 3484 if (element29 is VariableElement) { |
| 3490 Type2 variableType = ((element25 as VariableElement)).type; | 3485 Type2 variableType = ((element29 as VariableElement)).type; |
| 3491 recordType(prefixedIdentifier, variableType); | 3486 recordType(prefixedIdentifier, variableType); |
| 3492 return recordType(node, variableType); | 3487 return recordType(node, variableType); |
| 3493 } else if (element25 is PropertyAccessorElement) { | 3488 } else if (element29 is PropertyAccessorElement) { |
| 3494 Type2 propertyType = getType2((element25 as PropertyAccessorElement)); | 3489 Type2 propertyType = getType2((element29 as PropertyAccessorElement)); |
| 3495 recordType(prefixedIdentifier, propertyType); | 3490 recordType(prefixedIdentifier, propertyType); |
| 3496 return recordType(node, propertyType); | 3491 return recordType(node, propertyType); |
| 3497 } else if (element25 is MethodElement) { | 3492 } else if (element29 is MethodElement) { |
| 3498 Type2 returnType = ((element25 as MethodElement)).type; | 3493 Type2 returnType = ((element29 as MethodElement)).type; |
| 3499 recordType(prefixedIdentifier, returnType); | 3494 recordType(prefixedIdentifier, returnType); |
| 3500 return recordType(node, returnType); | 3495 return recordType(node, returnType); |
| 3501 } else { | 3496 } else { |
| 3502 } | 3497 } |
| 3503 recordType(prefixedIdentifier, _dynamicType); | 3498 recordType(prefixedIdentifier, _dynamicType); |
| 3504 return recordType(node, _dynamicType); | 3499 return recordType(node, _dynamicType); |
| 3505 } | 3500 } |
| 3506 /** | 3501 /** |
| 3507 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u
</i> of the form | 3502 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u
</i> of the form |
| 3508 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>.
An expression of the | 3503 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>.
An expression of the |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3553 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it
exists or dynamic | 3548 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it
exists or dynamic |
| 3554 * otherwise. | 3549 * otherwise. |
| 3555 * <p> | 3550 * <p> |
| 3556 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m
</i> is an | 3551 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m
</i> is an |
| 3557 * identifier ... | 3552 * identifier ... |
| 3558 * <p> | 3553 * <p> |
| 3559 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> | 3554 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block
quote> |
| 3560 */ | 3555 */ |
| 3561 Object visitPropertyAccess(PropertyAccess node) { | 3556 Object visitPropertyAccess(PropertyAccess node) { |
| 3562 SimpleIdentifier propertyName2 = node.propertyName; | 3557 SimpleIdentifier propertyName2 = node.propertyName; |
| 3563 Element element26 = propertyName2.element; | 3558 Element element30 = propertyName2.element; |
| 3564 if (element26 is MethodElement) { | 3559 if (element30 is MethodElement) { |
| 3565 FunctionType type15 = ((element26 as MethodElement)).type; | 3560 FunctionType type15 = ((element30 as MethodElement)).type; |
| 3566 recordType(propertyName2, type15); | 3561 recordType(propertyName2, type15); |
| 3567 return recordType(node, type15); | 3562 return recordType(node, type15); |
| 3568 } else if (element26 is PropertyAccessorElement) { | 3563 } else if (element30 is PropertyAccessorElement) { |
| 3569 Type2 propertyType = getType2((element26 as PropertyAccessorElement)); | 3564 Type2 propertyType = getType2((element30 as PropertyAccessorElement)); |
| 3570 recordType(propertyName2, propertyType); | 3565 recordType(propertyName2, propertyType); |
| 3571 return recordType(node, propertyType); | 3566 return recordType(node, propertyType); |
| 3572 } else { | 3567 } else { |
| 3573 } | 3568 } |
| 3574 recordType(propertyName2, _dynamicType); | 3569 recordType(propertyName2, _dynamicType); |
| 3575 return recordType(node, _dynamicType); | 3570 return recordType(node, _dynamicType); |
| 3576 } | 3571 } |
| 3577 /** | 3572 /** |
| 3573 * The Dart Language Specification, 12.9: <blockquote>The static type of a ret
hrow expression is |
| 3574 * bottom.</blockquote> |
| 3575 */ |
| 3576 Object visitRethrowExpression(RethrowExpression node) => recordType(node, _typ
eProvider.bottomType); |
| 3577 /** |
| 3578 * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identi
fier expression | 3578 * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identi
fier expression |
| 3579 * <i>e</i> of the form <i>id</i> proceeds as follows: | 3579 * <i>e</i> of the form <i>id</i> proceeds as follows: |
| 3580 * <p> | 3580 * <p> |
| 3581 * Let <i>d</i> be the innermost declaration in the enclosing lexical scope wh
ose name is | 3581 * Let <i>d</i> be the innermost declaration in the enclosing lexical scope wh
ose name is |
| 3582 * <i>id</i>. If no such declaration exists in the lexical scope, let <i>d</i>
be the declaration | 3582 * <i>id</i>. If no such declaration exists in the lexical scope, let <i>d</i>
be the declaration |
| 3583 * of the inherited member named <i>id</i> if it exists. | 3583 * of the inherited member named <i>id</i> if it exists. |
| 3584 * <ul> | 3584 * <ul> |
| 3585 * <li>If <i>d</i> is a class or type alias <i>T</i>, the value of <i>e</i> is
the unique instance | 3585 * <li>If <i>d</i> is a class or type alias <i>T</i>, the value of <i>e</i> is
the unique instance |
| 3586 * of class {@code Type} reifying <i>T</i>. | 3586 * of class {@code Type} reifying <i>T</i>. |
| 3587 * <li>If <i>d</i> is a type parameter <i>T</i>, then the value of <i>e</i> is
the value of the | 3587 * <li>If <i>d</i> is a type parameter <i>T</i>, then the value of <i>e</i> is
the value of the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3610 * <li>If <i>d</i> is the declaration of a top level getter, then <i>e</i> is
equivalent to the | 3610 * <li>If <i>d</i> is the declaration of a top level getter, then <i>e</i> is
equivalent to the |
| 3611 * getter invocation <i>id</i>. | 3611 * getter invocation <i>id</i>. |
| 3612 * <li>Otherwise, if <i>e</i> occurs inside a top level or static function (be
it function, | 3612 * <li>Otherwise, if <i>e</i> occurs inside a top level or static function (be
it function, |
| 3613 * method, getter, or setter) or variable initializer, evaluation of e causes
a NoSuchMethodError | 3613 * method, getter, or setter) or variable initializer, evaluation of e causes
a NoSuchMethodError |
| 3614 * to be thrown. | 3614 * to be thrown. |
| 3615 * <li>Otherwise <i>e</i> is equivalent to the property extraction <i>this.id<
/i>. | 3615 * <li>Otherwise <i>e</i> is equivalent to the property extraction <i>this.id<
/i>. |
| 3616 * </ul> | 3616 * </ul> |
| 3617 * </blockquote> | 3617 * </blockquote> |
| 3618 */ | 3618 */ |
| 3619 Object visitSimpleIdentifier(SimpleIdentifier node) { | 3619 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 3620 Element element27 = node.element; | 3620 Element element31 = node.element; |
| 3621 if (element27 == null) { | 3621 if (element31 == null) { |
| 3622 return recordType(node, _dynamicType); | 3622 return recordType(node, _dynamicType); |
| 3623 } else if (element27 is ClassElement) { | 3623 } else if (element31 is ClassElement) { |
| 3624 if (isNotTypeLiteral(node)) { | 3624 if (isNotTypeLiteral(node)) { |
| 3625 return recordType(node, ((element27 as ClassElement)).type); | 3625 return recordType(node, ((element31 as ClassElement)).type); |
| 3626 } | 3626 } |
| 3627 return recordType(node, _typeProvider.typeType); | 3627 return recordType(node, _typeProvider.typeType); |
| 3628 } else if (element27 is TypeVariableElement) { | 3628 } else if (element31 is TypeVariableElement) { |
| 3629 return recordType(node, ((element27 as TypeVariableElement)).type); | 3629 return recordType(node, ((element31 as TypeVariableElement)).type); |
| 3630 } else if (element27 is FunctionTypeAliasElement) { | 3630 } else if (element31 is FunctionTypeAliasElement) { |
| 3631 return recordType(node, ((element27 as FunctionTypeAliasElement)).type); | 3631 return recordType(node, ((element31 as FunctionTypeAliasElement)).type); |
| 3632 } else if (element27 is VariableElement) { | 3632 } else if (element31 is VariableElement) { |
| 3633 return recordType(node, ((element27 as VariableElement)).type); | 3633 return recordType(node, ((element31 as VariableElement)).type); |
| 3634 } else if (element27 is MethodElement) { | 3634 } else if (element31 is MethodElement) { |
| 3635 return recordType(node, ((element27 as MethodElement)).type); | 3635 return recordType(node, ((element31 as MethodElement)).type); |
| 3636 } else if (element27 is PropertyAccessorElement) { | 3636 } else if (element31 is PropertyAccessorElement) { |
| 3637 return recordType(node, getType2((element27 as PropertyAccessorElement))); | 3637 return recordType(node, getType2((element31 as PropertyAccessorElement))); |
| 3638 } else if (element27 is ExecutableElement) { | 3638 } else if (element31 is ExecutableElement) { |
| 3639 return recordType(node, ((element27 as ExecutableElement)).type); | 3639 return recordType(node, ((element31 as ExecutableElement)).type); |
| 3640 } else if (element27 is PrefixElement) { | 3640 } else if (element31 is PrefixElement) { |
| 3641 return null; | 3641 return null; |
| 3642 } else { | 3642 } else { |
| 3643 return recordType(node, _dynamicType); | 3643 return recordType(node, _dynamicType); |
| 3644 } | 3644 } |
| 3645 } | 3645 } |
| 3646 /** | 3646 /** |
| 3647 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is{@code String}.</blockquote> | 3647 * The Dart Language Specification, 12.5: <blockquote>The static type of a str
ing literal is{@code String}.</blockquote> |
| 3648 */ | 3648 */ |
| 3649 Object visitSimpleStringLiteral(SimpleStringLiteral node) => recordType(node,
_typeProvider.stringType); | 3649 Object visitSimpleStringLiteral(SimpleStringLiteral node) => recordType(node,
_typeProvider.stringType); |
| 3650 /** | 3650 /** |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4084 SimpleIdentifier exception = node.exceptionParameter; | 4084 SimpleIdentifier exception = node.exceptionParameter; |
| 4085 if (exception != null) { | 4085 if (exception != null) { |
| 4086 TypeName exceptionTypeName = node.exceptionType; | 4086 TypeName exceptionTypeName = node.exceptionType; |
| 4087 Type2 exceptionType; | 4087 Type2 exceptionType; |
| 4088 if (exceptionTypeName == null) { | 4088 if (exceptionTypeName == null) { |
| 4089 exceptionType = typeProvider.objectType; | 4089 exceptionType = typeProvider.objectType; |
| 4090 } else { | 4090 } else { |
| 4091 exceptionType = getType4(exceptionTypeName); | 4091 exceptionType = getType4(exceptionTypeName); |
| 4092 } | 4092 } |
| 4093 recordType(exception, exceptionType); | 4093 recordType(exception, exceptionType); |
| 4094 Element element28 = exception.element; | 4094 Element element32 = exception.element; |
| 4095 if (element28 is VariableElementImpl) { | 4095 if (element32 is VariableElementImpl) { |
| 4096 ((element28 as VariableElementImpl)).type = exceptionType; | 4096 ((element32 as VariableElementImpl)).type = exceptionType; |
| 4097 } else { | 4097 } else { |
| 4098 } | 4098 } |
| 4099 } | 4099 } |
| 4100 SimpleIdentifier stackTrace = node.stackTraceParameter; | 4100 SimpleIdentifier stackTrace = node.stackTraceParameter; |
| 4101 if (stackTrace != null) { | 4101 if (stackTrace != null) { |
| 4102 recordType(stackTrace, typeProvider.stackTraceType); | 4102 recordType(stackTrace, typeProvider.stackTraceType); |
| 4103 } | 4103 } |
| 4104 return null; | 4104 return null; |
| 4105 } | 4105 } |
| 4106 Object visitClassDeclaration(ClassDeclaration node) { | 4106 Object visitClassDeclaration(ClassDeclaration node) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4134 superclassType = typeProvider.objectType; | 4134 superclassType = typeProvider.objectType; |
| 4135 } | 4135 } |
| 4136 if (classElement != null && superclassType != null) { | 4136 if (classElement != null && superclassType != null) { |
| 4137 classElement.supertype = superclassType; | 4137 classElement.supertype = superclassType; |
| 4138 } | 4138 } |
| 4139 resolve(classElement, node.withClause, node.implementsClause); | 4139 resolve(classElement, node.withClause, node.implementsClause); |
| 4140 return null; | 4140 return null; |
| 4141 } | 4141 } |
| 4142 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 4142 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 4143 super.visitConstructorDeclaration(node); | 4143 super.visitConstructorDeclaration(node); |
| 4144 ExecutableElementImpl element29 = node.element as ExecutableElementImpl; | 4144 ExecutableElementImpl element33 = node.element as ExecutableElementImpl; |
| 4145 FunctionTypeImpl type = new FunctionTypeImpl.con1(element29); | 4145 FunctionTypeImpl type = new FunctionTypeImpl.con1(element33); |
| 4146 setTypeInformation(type, null, element29.parameters); | 4146 setTypeInformation(type, null, element33.parameters); |
| 4147 type.returnType = ((element29.enclosingElement as ClassElement)).type; | 4147 type.returnType = ((element33.enclosingElement as ClassElement)).type; |
| 4148 element29.type = type; | 4148 element33.type = type; |
| 4149 return null; | 4149 return null; |
| 4150 } | 4150 } |
| 4151 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 4151 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 4152 super.visitDeclaredIdentifier(node); | 4152 super.visitDeclaredIdentifier(node); |
| 4153 Type2 declaredType; | 4153 Type2 declaredType; |
| 4154 TypeName typeName = node.type; | 4154 TypeName typeName = node.type; |
| 4155 if (typeName == null) { | 4155 if (typeName == null) { |
| 4156 declaredType = _dynamicType; | 4156 declaredType = _dynamicType; |
| 4157 } else { | 4157 } else { |
| 4158 declaredType = getType4(typeName); | 4158 declaredType = getType4(typeName); |
| 4159 } | 4159 } |
| 4160 LocalVariableElementImpl element30 = node.element as LocalVariableElementImp
l; | 4160 LocalVariableElementImpl element34 = node.element as LocalVariableElementImp
l; |
| 4161 element30.type = declaredType; | 4161 element34.type = declaredType; |
| 4162 return null; | 4162 return null; |
| 4163 } | 4163 } |
| 4164 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 4164 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 4165 super.visitDefaultFormalParameter(node); | 4165 super.visitDefaultFormalParameter(node); |
| 4166 return null; | 4166 return null; |
| 4167 } | 4167 } |
| 4168 Object visitFieldFormalParameter(FieldFormalParameter node) { | 4168 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 4169 super.visitFieldFormalParameter(node); | 4169 super.visitFieldFormalParameter(node); |
| 4170 Element element31 = node.identifier.element; | 4170 Element element35 = node.identifier.element; |
| 4171 if (element31 is ParameterElementImpl) { | 4171 if (element35 is ParameterElementImpl) { |
| 4172 ParameterElementImpl parameter = element31 as ParameterElementImpl; | 4172 ParameterElementImpl parameter = element35 as ParameterElementImpl; |
| 4173 Type2 type; | 4173 Type2 type; |
| 4174 TypeName typeName = node.type; | 4174 TypeName typeName = node.type; |
| 4175 if (typeName == null) { | 4175 if (typeName == null) { |
| 4176 type = _dynamicType; | 4176 type = _dynamicType; |
| 4177 } else { | 4177 } else { |
| 4178 type = getType4(typeName); | 4178 type = getType4(typeName); |
| 4179 } | 4179 } |
| 4180 parameter.type = type; | 4180 parameter.type = type; |
| 4181 } else { | 4181 } else { |
| 4182 } | 4182 } |
| 4183 return null; | 4183 return null; |
| 4184 } | 4184 } |
| 4185 Object visitFunctionDeclaration(FunctionDeclaration node) { | 4185 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 4186 super.visitFunctionDeclaration(node); | 4186 super.visitFunctionDeclaration(node); |
| 4187 ExecutableElementImpl element32 = node.element as ExecutableElementImpl; | 4187 ExecutableElementImpl element36 = node.element as ExecutableElementImpl; |
| 4188 FunctionTypeImpl type = new FunctionTypeImpl.con1(element32); | 4188 FunctionTypeImpl type = new FunctionTypeImpl.con1(element36); |
| 4189 setTypeInformation(type, node.returnType, element32.parameters); | 4189 setTypeInformation(type, node.returnType, element36.parameters); |
| 4190 element32.type = type; | 4190 element36.type = type; |
| 4191 return null; | 4191 return null; |
| 4192 } | 4192 } |
| 4193 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 4193 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 4194 super.visitFunctionTypeAlias(node); | 4194 super.visitFunctionTypeAlias(node); |
| 4195 FunctionTypeAliasElementImpl element33 = node.element as FunctionTypeAliasEl
ementImpl; | 4195 FunctionTypeAliasElementImpl element37 = node.element as FunctionTypeAliasEl
ementImpl; |
| 4196 FunctionTypeImpl type18 = element33.type as FunctionTypeImpl; | 4196 FunctionTypeImpl type18 = element37.type as FunctionTypeImpl; |
| 4197 setTypeInformation(type18, node.returnType, element33.parameters); | 4197 setTypeInformation(type18, node.returnType, element37.parameters); |
| 4198 return null; | 4198 return null; |
| 4199 } | 4199 } |
| 4200 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 4200 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 4201 super.visitFunctionTypedFormalParameter(node); | 4201 super.visitFunctionTypedFormalParameter(node); |
| 4202 ParameterElementImpl element34 = node.identifier.element as ParameterElement
Impl; | 4202 ParameterElementImpl element38 = node.identifier.element as ParameterElement
Impl; |
| 4203 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement
)); | 4203 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement
)); |
| 4204 setTypeInformation(type, node.returnType, getElements(node.parameters)); | 4204 setTypeInformation(type, node.returnType, getElements(node.parameters)); |
| 4205 element34.type = type; | 4205 element38.type = type; |
| 4206 return null; | 4206 return null; |
| 4207 } | 4207 } |
| 4208 Object visitMethodDeclaration(MethodDeclaration node) { | 4208 Object visitMethodDeclaration(MethodDeclaration node) { |
| 4209 super.visitMethodDeclaration(node); | 4209 super.visitMethodDeclaration(node); |
| 4210 ExecutableElementImpl element35 = node.element as ExecutableElementImpl; | 4210 ExecutableElementImpl element39 = node.element as ExecutableElementImpl; |
| 4211 FunctionTypeImpl type = new FunctionTypeImpl.con1(element35); | 4211 FunctionTypeImpl type = new FunctionTypeImpl.con1(element39); |
| 4212 setTypeInformation(type, node.returnType, element35.parameters); | 4212 setTypeInformation(type, node.returnType, element39.parameters); |
| 4213 element35.type = type; | 4213 element39.type = type; |
| 4214 if (element35 is PropertyAccessorElementImpl) { | 4214 if (element39 is PropertyAccessorElementImpl) { |
| 4215 PropertyAccessorElementImpl accessor = element35 as PropertyAccessorElemen
tImpl; | 4215 PropertyAccessorElementImpl accessor = element39 as PropertyAccessorElemen
tImpl; |
| 4216 PropertyInducingElementImpl variable5 = accessor.variable as PropertyInduc
ingElementImpl; | 4216 PropertyInducingElementImpl variable5 = accessor.variable as PropertyInduc
ingElementImpl; |
| 4217 if (accessor.isGetter()) { | 4217 if (accessor.isGetter()) { |
| 4218 variable5.type = type.returnType; | 4218 variable5.type = type.returnType; |
| 4219 } else if (variable5.type == null) { | 4219 } else if (variable5.type == null) { |
| 4220 List<Type2> parameterTypes = type.normalParameterTypes; | 4220 List<Type2> parameterTypes = type.normalParameterTypes; |
| 4221 if (parameterTypes != null && parameterTypes.length > 0) { | 4221 if (parameterTypes != null && parameterTypes.length > 0) { |
| 4222 variable5.type = parameterTypes[0]; | 4222 variable5.type = parameterTypes[0]; |
| 4223 } | 4223 } |
| 4224 } | 4224 } |
| 4225 } | 4225 } |
| 4226 return null; | 4226 return null; |
| 4227 } | 4227 } |
| 4228 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 4228 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 4229 super.visitSimpleFormalParameter(node); | 4229 super.visitSimpleFormalParameter(node); |
| 4230 Type2 declaredType; | 4230 Type2 declaredType; |
| 4231 TypeName typeName = node.type; | 4231 TypeName typeName = node.type; |
| 4232 if (typeName == null) { | 4232 if (typeName == null) { |
| 4233 declaredType = _dynamicType; | 4233 declaredType = _dynamicType; |
| 4234 } else { | 4234 } else { |
| 4235 declaredType = getType4(typeName); | 4235 declaredType = getType4(typeName); |
| 4236 } | 4236 } |
| 4237 Element element36 = node.identifier.element; | 4237 Element element40 = node.identifier.element; |
| 4238 if (element36 is ParameterElement) { | 4238 if (element40 is ParameterElement) { |
| 4239 ((element36 as ParameterElementImpl)).type = declaredType; | 4239 ((element40 as ParameterElementImpl)).type = declaredType; |
| 4240 } else { | 4240 } else { |
| 4241 } | 4241 } |
| 4242 return null; | 4242 return null; |
| 4243 } | 4243 } |
| 4244 Object visitTypeName(TypeName node) { | 4244 Object visitTypeName(TypeName node) { |
| 4245 super.visitTypeName(node); | 4245 super.visitTypeName(node); |
| 4246 Identifier typeName = node.name; | 4246 Identifier typeName = node.name; |
| 4247 TypeArgumentList argumentList = node.typeArguments; | 4247 TypeArgumentList argumentList = node.typeArguments; |
| 4248 Element element = nameScope.lookup(typeName, definingLibrary); | 4248 Element element = nameScope.lookup(typeName, definingLibrary); |
| 4249 if (element == null) { | 4249 if (element == null) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4352 } | 4352 } |
| 4353 Object visitVariableDeclaration(VariableDeclaration node) { | 4353 Object visitVariableDeclaration(VariableDeclaration node) { |
| 4354 super.visitVariableDeclaration(node); | 4354 super.visitVariableDeclaration(node); |
| 4355 Type2 declaredType; | 4355 Type2 declaredType; |
| 4356 TypeName typeName = ((node.parent as VariableDeclarationList)).type; | 4356 TypeName typeName = ((node.parent as VariableDeclarationList)).type; |
| 4357 if (typeName == null) { | 4357 if (typeName == null) { |
| 4358 declaredType = _dynamicType; | 4358 declaredType = _dynamicType; |
| 4359 } else { | 4359 } else { |
| 4360 declaredType = getType4(typeName); | 4360 declaredType = getType4(typeName); |
| 4361 } | 4361 } |
| 4362 Element element37 = node.name.element; | 4362 Element element41 = node.name.element; |
| 4363 if (element37 is VariableElement) { | 4363 if (element41 is VariableElement) { |
| 4364 ((element37 as VariableElementImpl)).type = declaredType; | 4364 ((element41 as VariableElementImpl)).type = declaredType; |
| 4365 if (element37 is FieldElement) { | 4365 if (element41 is FieldElement) { |
| 4366 FieldElement field = element37 as FieldElement; | 4366 FieldElement field = element41 as FieldElement; |
| 4367 PropertyAccessorElementImpl getter5 = field.getter as PropertyAccessorEl
ementImpl; | 4367 PropertyAccessorElementImpl getter5 = field.getter as PropertyAccessorEl
ementImpl; |
| 4368 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter5); | 4368 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter5); |
| 4369 getterType.returnType = declaredType; | 4369 getterType.returnType = declaredType; |
| 4370 getter5.type = getterType; | 4370 getter5.type = getterType; |
| 4371 PropertyAccessorElementImpl setter4 = field.setter as PropertyAccessorEl
ementImpl; | 4371 PropertyAccessorElementImpl setter4 = field.setter as PropertyAccessorEl
ementImpl; |
| 4372 if (setter4 != null) { | 4372 if (setter4 != null) { |
| 4373 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter4); | 4373 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter4); |
| 4374 setterType.returnType = VoidTypeImpl.instance; | 4374 setterType.returnType = VoidTypeImpl.instance; |
| 4375 setterType.normalParameterTypes = <Type2> [declaredType]; | 4375 setterType.normalParameterTypes = <Type2> [declaredType]; |
| 4376 setter4.type = setterType; | 4376 setter4.type = setterType; |
| 4377 } | 4377 } |
| 4378 } | 4378 } |
| 4379 } else { | 4379 } else { |
| 4380 } | 4380 } |
| 4381 return null; | 4381 return null; |
| 4382 } | 4382 } |
| 4383 /** | 4383 /** |
| 4384 * Return the class element that represents the class whose name was provided. | 4384 * Return the class element that represents the class whose name was provided. |
| 4385 * @param identifier the name from the declaration of a class | 4385 * @param identifier the name from the declaration of a class |
| 4386 * @return the class element that represents the class | 4386 * @return the class element that represents the class |
| 4387 */ | 4387 */ |
| 4388 ClassElementImpl getClassElement(SimpleIdentifier identifier) { | 4388 ClassElementImpl getClassElement(SimpleIdentifier identifier) { |
| 4389 if (identifier == null) { | 4389 if (identifier == null) { |
| 4390 return null; | 4390 return null; |
| 4391 } | 4391 } |
| 4392 Element element38 = identifier.element; | 4392 Element element42 = identifier.element; |
| 4393 if (element38 is! ClassElementImpl) { | 4393 if (element42 is! ClassElementImpl) { |
| 4394 return null; | 4394 return null; |
| 4395 } | 4395 } |
| 4396 return element38 as ClassElementImpl; | 4396 return element42 as ClassElementImpl; |
| 4397 } | 4397 } |
| 4398 /** | 4398 /** |
| 4399 * Return an array containing all of the elements associated with the paramete
rs in the given | 4399 * Return an array containing all of the elements associated with the paramete
rs in the given |
| 4400 * list. | 4400 * list. |
| 4401 * @param parameterList the list of parameters whose elements are to be return
ed | 4401 * @param parameterList the list of parameters whose elements are to be return
ed |
| 4402 * @return the elements associated with the parameters | 4402 * @return the elements associated with the parameters |
| 4403 */ | 4403 */ |
| 4404 List<ParameterElement> getElements(FormalParameterList parameterList) { | 4404 List<ParameterElement> getElements(FormalParameterList parameterList) { |
| 4405 List<ParameterElement> elements = new List<ParameterElement>(); | 4405 List<ParameterElement> elements = new List<ParameterElement>(); |
| 4406 for (FormalParameter parameter in parameterList.parameters) { | 4406 for (FormalParameter parameter in parameterList.parameters) { |
| 4407 ParameterElement element39 = parameter.identifier.element as ParameterElem
ent; | 4407 ParameterElement element43 = parameter.identifier.element as ParameterElem
ent; |
| 4408 if (element39 != null) { | 4408 if (element43 != null) { |
| 4409 elements.add(element39); | 4409 elements.add(element43); |
| 4410 } | 4410 } |
| 4411 } | 4411 } |
| 4412 return new List.from(elements); | 4412 return new List.from(elements); |
| 4413 } | 4413 } |
| 4414 /** | 4414 /** |
| 4415 * The number of type arguments in the given type name does not match the numb
er of parameters in | 4415 * The number of type arguments in the given type name does not match the numb
er of parameters in |
| 4416 * the corresponding class element. Return the error code that should be used
to report this | 4416 * the corresponding class element. Return the error code that should be used
to report this |
| 4417 * error. | 4417 * error. |
| 4418 * @param node the type name with the wrong number of type arguments | 4418 * @param node the type name with the wrong number of type arguments |
| 4419 * @return the error code that should be used to report that the wrong number
of type arguments | 4419 * @return the error code that should be used to report that the wrong number
of type arguments |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4555 List<InterfaceType> resolveTypes(NodeList<TypeName> typeNames, ErrorCode undef
inedError, ErrorCode nonTypeError, ErrorCode nonInterfaceType) { | 4555 List<InterfaceType> resolveTypes(NodeList<TypeName> typeNames, ErrorCode undef
inedError, ErrorCode nonTypeError, ErrorCode nonInterfaceType) { |
| 4556 List<InterfaceType> types = new List<InterfaceType>(); | 4556 List<InterfaceType> types = new List<InterfaceType>(); |
| 4557 for (TypeName typeName in typeNames) { | 4557 for (TypeName typeName in typeNames) { |
| 4558 InterfaceType type = resolveType(typeName, undefinedError, nonTypeError, n
onInterfaceType); | 4558 InterfaceType type = resolveType(typeName, undefinedError, nonTypeError, n
onInterfaceType); |
| 4559 if (type != null) { | 4559 if (type != null) { |
| 4560 types.add(type); | 4560 types.add(type); |
| 4561 } | 4561 } |
| 4562 } | 4562 } |
| 4563 return new List.from(types); | 4563 return new List.from(types); |
| 4564 } | 4564 } |
| 4565 void setElement(Identifier typeName, Element element54) { | 4565 void setElement(Identifier typeName, Element element60) { |
| 4566 if (element54 != null) { | 4566 if (element60 != null) { |
| 4567 if (typeName is SimpleIdentifier) { | 4567 if (typeName is SimpleIdentifier) { |
| 4568 ((typeName as SimpleIdentifier)).element = element54; | 4568 ((typeName as SimpleIdentifier)).element = element60; |
| 4569 } else if (typeName is PrefixedIdentifier) { | 4569 } else if (typeName is PrefixedIdentifier) { |
| 4570 PrefixedIdentifier identifier = typeName as PrefixedIdentifier; | 4570 PrefixedIdentifier identifier = typeName as PrefixedIdentifier; |
| 4571 identifier.identifier.element = element54; | 4571 identifier.identifier.element = element60; |
| 4572 SimpleIdentifier prefix9 = identifier.prefix; | 4572 SimpleIdentifier prefix9 = identifier.prefix; |
| 4573 Element prefixElement = nameScope.lookup(prefix9, definingLibrary); | 4573 Element prefixElement = nameScope.lookup(prefix9, definingLibrary); |
| 4574 if (prefixElement != null) { | 4574 if (prefixElement != null) { |
| 4575 prefix9.element = prefixElement; | 4575 prefix9.element = prefixElement; |
| 4576 } | 4576 } |
| 4577 } | 4577 } |
| 4578 } | 4578 } |
| 4579 } | 4579 } |
| 4580 /** | 4580 /** |
| 4581 * Set the return type and parameter type information for the given function t
ype based on the | 4581 * Set the return type and parameter type information for the given function t
ype based on the |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4767 * The label element returned for scopes that can be the target of an unlabele
d {@code break} or{@code continue}. | 4767 * The label element returned for scopes that can be the target of an unlabele
d {@code break} or{@code continue}. |
| 4768 */ | 4768 */ |
| 4769 static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier.full(ne
w sc.StringToken(sc.TokenType.IDENTIFIER, "", 0)); | 4769 static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier.full(ne
w sc.StringToken(sc.TokenType.IDENTIFIER, "", 0)); |
| 4770 /** | 4770 /** |
| 4771 * Initialize a newly created scope to represent the potential target of an un
labeled{@code break} or {@code continue}. | 4771 * Initialize a newly created scope to represent the potential target of an un
labeled{@code break} or {@code continue}. |
| 4772 * @param outerScope the label scope enclosing the new label scope | 4772 * @param outerScope the label scope enclosing the new label scope |
| 4773 * @param onSwitchStatement {@code true} if this label is associated with a {@
code switch}statement | 4773 * @param onSwitchStatement {@code true} if this label is associated with a {@
code switch}statement |
| 4774 * @param onSwitchMember {@code true} if this label is associated with a {@cod
e switch} member | 4774 * @param onSwitchMember {@code true} if this label is associated with a {@cod
e switch} member |
| 4775 */ | 4775 */ |
| 4776 LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMe
mber) { | 4776 LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMe
mber) { |
| 4777 _jtd_constructor_250_impl(outerScope, onSwitchStatement, onSwitchMember); | 4777 _jtd_constructor_254_impl(outerScope, onSwitchStatement, onSwitchMember); |
| 4778 } | 4778 } |
| 4779 _jtd_constructor_250_impl(LabelScope outerScope, bool onSwitchStatement, bool
onSwitchMember) { | 4779 _jtd_constructor_254_impl(LabelScope outerScope, bool onSwitchStatement, bool
onSwitchMember) { |
| 4780 _jtd_constructor_251_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMP
TY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember)); | 4780 _jtd_constructor_255_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMP
TY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember)); |
| 4781 } | 4781 } |
| 4782 /** | 4782 /** |
| 4783 * Initialize a newly created scope to represent the given label. | 4783 * Initialize a newly created scope to represent the given label. |
| 4784 * @param outerScope the label scope enclosing the new label scope | 4784 * @param outerScope the label scope enclosing the new label scope |
| 4785 * @param label the label defined in this scope | 4785 * @param label the label defined in this scope |
| 4786 * @param element the element to which the label resolves | 4786 * @param element the element to which the label resolves |
| 4787 */ | 4787 */ |
| 4788 LabelScope.con2(LabelScope outerScope2, String label4, LabelElement element19)
{ | 4788 LabelScope.con2(LabelScope outerScope2, String label4, LabelElement element21)
{ |
| 4789 _jtd_constructor_251_impl(outerScope2, label4, element19); | 4789 _jtd_constructor_255_impl(outerScope2, label4, element21); |
| 4790 } | 4790 } |
| 4791 _jtd_constructor_251_impl(LabelScope outerScope2, String label4, LabelElement
element19) { | 4791 _jtd_constructor_255_impl(LabelScope outerScope2, String label4, LabelElement
element21) { |
| 4792 this._outerScope = outerScope2; | 4792 this._outerScope = outerScope2; |
| 4793 this._label = label4; | 4793 this._label = label4; |
| 4794 this._element = element19; | 4794 this._element = element21; |
| 4795 } | 4795 } |
| 4796 /** | 4796 /** |
| 4797 * Return the label element corresponding to the given label, or {@code null}
if the given label | 4797 * Return the label element corresponding to the given label, or {@code null}
if the given label |
| 4798 * is not defined in this scope. | 4798 * is not defined in this scope. |
| 4799 * @param targetLabel the label being looked up | 4799 * @param targetLabel the label being looked up |
| 4800 * @return the label element corresponding to the given label | 4800 * @return the label element corresponding to the given label |
| 4801 */ | 4801 */ |
| 4802 LabelElement lookup(SimpleIdentifier targetLabel) => lookup2(targetLabel.name)
; | 4802 LabelElement lookup(SimpleIdentifier targetLabel) => lookup2(targetLabel.name)
; |
| 4803 /** | 4803 /** |
| 4804 * Return the label element corresponding to the given label, or {@code null}
if the given label | 4804 * Return the label element corresponding to the given label, or {@code null}
if the given label |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5030 for (MapEntry<String, Element> entry in getMapEntrySet(newNames)) { | 5030 for (MapEntry<String, Element> entry in getMapEntrySet(newNames)) { |
| 5031 definedNames[entry.getKey()] = entry.getValue(); | 5031 definedNames[entry.getKey()] = entry.getValue(); |
| 5032 } | 5032 } |
| 5033 } | 5033 } |
| 5034 /** | 5034 /** |
| 5035 * Add all of the names in the given namespace to the given mapping table. | 5035 * Add all of the names in the given namespace to the given mapping table. |
| 5036 * @param definedNames the mapping table to which the names in the given names
pace are to be added | 5036 * @param definedNames the mapping table to which the names in the given names
pace are to be added |
| 5037 * @param namespace the namespace containing the names to be added to this nam
espace | 5037 * @param namespace the namespace containing the names to be added to this nam
espace |
| 5038 */ | 5038 */ |
| 5039 void addAll2(Map<String, Element> definedNames2, Namespace namespace) { | 5039 void addAll2(Map<String, Element> definedNames2, Namespace namespace) { |
| 5040 addAll(definedNames2, namespace.definedNames); | 5040 if (namespace != null) { |
| 5041 addAll(definedNames2, namespace.definedNames); |
| 5042 } |
| 5041 } | 5043 } |
| 5042 /** | 5044 /** |
| 5043 * Add the given element to the given mapping table if it has a publicly visib
le name. | 5045 * Add the given element to the given mapping table if it has a publicly visib
le name. |
| 5044 * @param definedNames the mapping table to which the public name is to be add
ed | 5046 * @param definedNames the mapping table to which the public name is to be add
ed |
| 5045 * @param element the element to be added | 5047 * @param element the element to be added |
| 5046 */ | 5048 */ |
| 5047 void addIfPublic(Map<String, Element> definedNames, Element element) { | 5049 void addIfPublic(Map<String, Element> definedNames, Element element) { |
| 5048 String name19 = element.name; | 5050 String name19 = element.name; |
| 5049 if (name19 != null && !Scope.isPrivateName(name19)) { | 5051 if (name19 != null && !Scope.isPrivateName(name19)) { |
| 5050 definedNames[name19] = element; | 5052 definedNames[name19] = element; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5352 Object visitSwitchCase(SwitchCase node) { | 5354 Object visitSwitchCase(SwitchCase node) { |
| 5353 super.visitSwitchCase(node); | 5355 super.visitSwitchCase(node); |
| 5354 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION)
; | 5356 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION)
; |
| 5355 return null; | 5357 return null; |
| 5356 } | 5358 } |
| 5357 Object visitVariableDeclaration(VariableDeclaration node) { | 5359 Object visitVariableDeclaration(VariableDeclaration node) { |
| 5358 super.visitVariableDeclaration(node); | 5360 super.visitVariableDeclaration(node); |
| 5359 Expression initializer4 = node.initializer; | 5361 Expression initializer4 = node.initializer; |
| 5360 if (initializer4 != null && node.isConst()) { | 5362 if (initializer4 != null && node.isConst()) { |
| 5361 EvaluationResultImpl result = validate(initializer4, CompileTimeErrorCode.
CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE); | 5363 EvaluationResultImpl result = validate(initializer4, CompileTimeErrorCode.
CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE); |
| 5362 VariableElementImpl element45 = node.element as VariableElementImpl; | 5364 VariableElementImpl element49 = node.element as VariableElementImpl; |
| 5363 element45.evaluationResult = result; | 5365 element49.evaluationResult = result; |
| 5364 } | 5366 } |
| 5365 return null; | 5367 return null; |
| 5366 } | 5368 } |
| 5367 /** | 5369 /** |
| 5368 * Validate that the given expression is a compile time constant. Return the v
alue of the compile | 5370 * Validate that the given expression is a compile time constant. Return the v
alue of the compile |
| 5369 * time constant, or {@code null} if the expression is not a compile time cons
tant. | 5371 * time constant, or {@code null} if the expression is not a compile time cons
tant. |
| 5370 * @param expression the expression to be validated | 5372 * @param expression the expression to be validated |
| 5371 * @param errorCode the error code to be used if the expression is not a compi
le time constant | 5373 * @param errorCode the error code to be used if the expression is not a compi
le time constant |
| 5372 * @return the value of the compile time constant | 5374 * @return the value of the compile time constant |
| 5373 */ | 5375 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5393 if (parameters15 == null) { | 5395 if (parameters15 == null) { |
| 5394 return; | 5396 return; |
| 5395 } | 5397 } |
| 5396 for (FormalParameter parameter in parameters15.parameters) { | 5398 for (FormalParameter parameter in parameters15.parameters) { |
| 5397 if (parameter is DefaultFormalParameter) { | 5399 if (parameter is DefaultFormalParameter) { |
| 5398 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara
meter; | 5400 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara
meter; |
| 5399 Expression defaultValue2 = defaultParameter.defaultValue; | 5401 Expression defaultValue2 = defaultParameter.defaultValue; |
| 5400 if (defaultValue2 != null) { | 5402 if (defaultValue2 != null) { |
| 5401 EvaluationResultImpl result = validate(defaultValue2, CompileTimeError
Code.NON_CONSTANT_DEFAULT_VALUE); | 5403 EvaluationResultImpl result = validate(defaultValue2, CompileTimeError
Code.NON_CONSTANT_DEFAULT_VALUE); |
| 5402 if (defaultParameter.isConst()) { | 5404 if (defaultParameter.isConst()) { |
| 5403 VariableElementImpl element46 = parameter.element as VariableElement
Impl; | 5405 VariableElementImpl element50 = parameter.element as VariableElement
Impl; |
| 5404 element46.evaluationResult = result; | 5406 element50.evaluationResult = result; |
| 5405 } | 5407 } |
| 5406 } | 5408 } |
| 5407 } | 5409 } |
| 5408 } | 5410 } |
| 5409 } | 5411 } |
| 5410 } | 5412 } |
| 5411 /** | 5413 /** |
| 5412 * Instances of the class {@code ErrorVerifier} traverse an AST structure lookin
g for additional | 5414 * Instances of the class {@code ErrorVerifier} traverse an AST structure lookin
g for additional |
| 5413 * errors and warnings not covered by the parser and resolver. | 5415 * errors and warnings not covered by the parser and resolver. |
| 5414 * @coverage dart.engine.resolver | 5416 * @coverage dart.engine.resolver |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5429 /** | 5431 /** |
| 5430 * The object providing access to the types defined by the language. | 5432 * The object providing access to the types defined by the language. |
| 5431 */ | 5433 */ |
| 5432 TypeProvider _typeProvider; | 5434 TypeProvider _typeProvider; |
| 5433 /** | 5435 /** |
| 5434 * This is set to <code>true</code> iff the visitor is currently visiting chil
dren nodes of a{@link ConstructorDeclaration} and the constructor is 'const'. | 5436 * This is set to <code>true</code> iff the visitor is currently visiting chil
dren nodes of a{@link ConstructorDeclaration} and the constructor is 'const'. |
| 5435 * @see #visitConstructorDeclaration(ConstructorDeclaration) | 5437 * @see #visitConstructorDeclaration(ConstructorDeclaration) |
| 5436 */ | 5438 */ |
| 5437 bool _isEnclosingConstructorConst = false; | 5439 bool _isEnclosingConstructorConst = false; |
| 5438 /** | 5440 /** |
| 5439 * The method or function that we are currently visiting, or {@code null} if w
e are not inside a | 5441 * This is set to <code>true</code> iff the visitor is currently visiting chil
dren nodes of a{@link CatchClause}. |
| 5440 * method or function. | 5442 * @see #visitCatchClause(CatchClause) |
| 5443 */ |
| 5444 bool _isInCatchClause = false; |
| 5445 /** |
| 5446 * The method or function that we are currently visiting, or <code>null</code>
if we are not |
| 5447 * inside a method or function. |
| 5441 */ | 5448 */ |
| 5442 ExecutableElement _currentFunction; | 5449 ExecutableElement _currentFunction; |
| 5443 /** | 5450 /** |
| 5444 * A list of types used by the {@link CompileTimeErrorCode#EXTENDS_DISALLOWED_
CLASS} and{@link CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS} error codes. | 5451 * A list of types used by the {@link CompileTimeErrorCode#EXTENDS_DISALLOWED_
CLASS} and{@link CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS} error codes. |
| 5445 */ | 5452 */ |
| 5446 List<InterfaceType> _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT; | 5453 List<InterfaceType> _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT; |
| 5447 ErrorVerifier(ErrorReporter errorReporter, LibraryElement currentLibrary, Type
Provider typeProvider) { | 5454 ErrorVerifier(ErrorReporter errorReporter, LibraryElement currentLibrary, Type
Provider typeProvider) { |
| 5448 this._errorReporter = errorReporter; | 5455 this._errorReporter = errorReporter; |
| 5449 this._currentLibrary = currentLibrary; | 5456 this._currentLibrary = currentLibrary; |
| 5450 this._typeProvider = typeProvider; | 5457 this._typeProvider = typeProvider; |
| 5451 _isEnclosingConstructorConst = false; | 5458 _isEnclosingConstructorConst = false; |
| 5459 _isInCatchClause = false; |
| 5452 _dynamicType = typeProvider.dynamicType; | 5460 _dynamicType = typeProvider.dynamicType; |
| 5453 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [typeProvider.num
Type, typeProvider.intType, typeProvider.doubleType, typeProvider.boolType, type
Provider.stringType]; | 5461 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [typeProvider.num
Type, typeProvider.intType, typeProvider.doubleType, typeProvider.boolType, type
Provider.stringType]; |
| 5454 } | 5462 } |
| 5455 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | 5463 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 5456 checkForArgumentDefinitionTestNonParameter(node); | 5464 checkForArgumentDefinitionTestNonParameter(node); |
| 5457 return super.visitArgumentDefinitionTest(node); | 5465 return super.visitArgumentDefinitionTest(node); |
| 5458 } | 5466 } |
| 5459 Object visitAssertStatement(AssertStatement node) { | 5467 Object visitAssertStatement(AssertStatement node) { |
| 5460 checkForNonBoolExpression(node); | 5468 checkForNonBoolExpression(node); |
| 5461 return super.visitAssertStatement(node); | 5469 return super.visitAssertStatement(node); |
| 5462 } | 5470 } |
| 5463 Object visitAssignmentExpression(AssignmentExpression node) { | 5471 Object visitAssignmentExpression(AssignmentExpression node) { |
| 5464 checkForInvalidAssignment(node); | 5472 checkForInvalidAssignment(node); |
| 5465 return super.visitAssignmentExpression(node); | 5473 return super.visitAssignmentExpression(node); |
| 5466 } | 5474 } |
| 5475 Object visitCatchClause(CatchClause node) { |
| 5476 bool previousIsInCatchClause = _isInCatchClause; |
| 5477 try { |
| 5478 _isInCatchClause = true; |
| 5479 return super.visitCatchClause(node); |
| 5480 } finally { |
| 5481 _isInCatchClause = previousIsInCatchClause; |
| 5482 } |
| 5483 } |
| 5467 Object visitClassDeclaration(ClassDeclaration node) { | 5484 Object visitClassDeclaration(ClassDeclaration node) { |
| 5468 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE
NTIFIER_AS_TYPE_NAME); | 5485 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE
NTIFIER_AS_TYPE_NAME); |
| 5469 return super.visitClassDeclaration(node); | 5486 return super.visitClassDeclaration(node); |
| 5470 } | 5487 } |
| 5471 Object visitClassTypeAlias(ClassTypeAlias node) { | 5488 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 5472 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE
NTIFIER_AS_TYPEDEF_NAME); | 5489 checkForBuiltInIdentifierAsName(node.name, CompileTimeErrorCode.BUILT_IN_IDE
NTIFIER_AS_TYPEDEF_NAME); |
| 5473 return super.visitClassTypeAlias(node); | 5490 return super.visitClassTypeAlias(node); |
| 5474 } | 5491 } |
| 5475 Object visitConditionalExpression(ConditionalExpression node) { | 5492 Object visitConditionalExpression(ConditionalExpression node) { |
| 5476 checkForNonBoolCondition(node.condition); | 5493 checkForNonBoolCondition(node.condition); |
| 5477 return super.visitConditionalExpression(node); | 5494 return super.visitConditionalExpression(node); |
| 5478 } | 5495 } |
| 5479 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 5496 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 5480 ExecutableElement previousFunction = _currentFunction; | 5497 ExecutableElement previousFunction = _currentFunction; |
| 5481 try { | 5498 try { |
| 5482 _currentFunction = node.element; | 5499 _currentFunction = node.element; |
| 5483 _isEnclosingConstructorConst = node.constKeyword != null; | 5500 _isEnclosingConstructorConst = node.constKeyword != null; |
| 5484 checkForConstConstructorWithNonFinalField(node); | 5501 checkForConstConstructorWithNonFinalField(node); |
| 5485 checkForConflictingConstructorNameAndMember(node); | 5502 checkForConflictingConstructorNameAndMember(node); |
| 5486 return super.visitConstructorDeclaration(node); | 5503 return super.visitConstructorDeclaration(node); |
| 5487 } finally { | 5504 } finally { |
| 5488 _isEnclosingConstructorConst = false; | 5505 _isEnclosingConstructorConst = false; |
| 5489 _currentFunction = previousFunction; | 5506 _currentFunction = previousFunction; |
| 5490 } | 5507 } |
| 5491 } | 5508 } |
| 5509 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 5510 checkForFieldInitializedInInitializerAndDeclaration(node); |
| 5511 checkForFieldInitializedInParameterAndInitializer(node); |
| 5512 return super.visitConstructorFieldInitializer(node); |
| 5513 } |
| 5492 Object visitDoStatement(DoStatement node) { | 5514 Object visitDoStatement(DoStatement node) { |
| 5493 checkForNonBoolCondition(node.condition); | 5515 checkForNonBoolCondition(node.condition); |
| 5494 return super.visitDoStatement(node); | 5516 return super.visitDoStatement(node); |
| 5495 } | 5517 } |
| 5496 Object visitExtendsClause(ExtendsClause node) { | 5518 Object visitExtendsClause(ExtendsClause node) { |
| 5497 checkForExtendsDisallowedClass(node); | 5519 checkForExtendsDisallowedClass(node); |
| 5498 return super.visitExtendsClause(node); | 5520 return super.visitExtendsClause(node); |
| 5499 } | 5521 } |
| 5500 Object visitFieldFormalParameter(FieldFormalParameter node) { | 5522 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 5501 checkForConstFormalParameter(node); | 5523 checkForConstFormalParameter(node); |
| 5524 checkForFieldInitializerOutsideConstructor(node); |
| 5502 return super.visitFieldFormalParameter(node); | 5525 return super.visitFieldFormalParameter(node); |
| 5503 } | 5526 } |
| 5504 Object visitFunctionDeclaration(FunctionDeclaration node) { | 5527 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 5505 ExecutableElement previousFunction = _currentFunction; | 5528 ExecutableElement previousFunction = _currentFunction; |
| 5506 try { | 5529 try { |
| 5507 _currentFunction = node.element; | 5530 _currentFunction = node.element; |
| 5508 return super.visitFunctionDeclaration(node); | 5531 return super.visitFunctionDeclaration(node); |
| 5509 } finally { | 5532 } finally { |
| 5510 _currentFunction = previousFunction; | 5533 _currentFunction = previousFunction; |
| 5511 } | 5534 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5546 } | 5569 } |
| 5547 Object visitMethodDeclaration(MethodDeclaration node) { | 5570 Object visitMethodDeclaration(MethodDeclaration node) { |
| 5548 ExecutableElement previousFunction = _currentFunction; | 5571 ExecutableElement previousFunction = _currentFunction; |
| 5549 try { | 5572 try { |
| 5550 _currentFunction = node.element; | 5573 _currentFunction = node.element; |
| 5551 return super.visitMethodDeclaration(node); | 5574 return super.visitMethodDeclaration(node); |
| 5552 } finally { | 5575 } finally { |
| 5553 _currentFunction = previousFunction; | 5576 _currentFunction = previousFunction; |
| 5554 } | 5577 } |
| 5555 } | 5578 } |
| 5579 Object visitRethrowExpression(RethrowExpression node) { |
| 5580 checkForRethrowOutsideCatch(node); |
| 5581 return super.visitRethrowExpression(node); |
| 5582 } |
| 5556 Object visitReturnStatement(ReturnStatement node) { | 5583 Object visitReturnStatement(ReturnStatement node) { |
| 5557 checkForReturnOfInvalidType(node); | 5584 checkForReturnOfInvalidType(node); |
| 5558 return super.visitReturnStatement(node); | 5585 return super.visitReturnStatement(node); |
| 5559 } | 5586 } |
| 5560 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 5587 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 5561 checkForConstFormalParameter(node); | 5588 checkForConstFormalParameter(node); |
| 5562 return super.visitSimpleFormalParameter(node); | 5589 return super.visitSimpleFormalParameter(node); |
| 5563 } | 5590 } |
| 5564 Object visitSwitchStatement(SwitchStatement node) { | 5591 Object visitSwitchStatement(SwitchStatement node) { |
| 5565 checkForCaseExpressionTypeImplementsEquals(node); | 5592 checkForCaseExpressionTypeImplementsEquals(node); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5582 return super.visitWhileStatement(node); | 5609 return super.visitWhileStatement(node); |
| 5583 } | 5610 } |
| 5584 /** | 5611 /** |
| 5585 * This verifies that the passed argument definition test identifier is a para
meter. | 5612 * This verifies that the passed argument definition test identifier is a para
meter. |
| 5586 * @param node the {@link ArgumentDefinitionTest} to evaluate | 5613 * @param node the {@link ArgumentDefinitionTest} to evaluate |
| 5587 * @return return <code>true</code> if and only if an error code is generated
on the passed node | 5614 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5588 * @see CompileTimeErrorCode#ARGUMENT_DEFINITION_TEST_NON_PARAMETER | 5615 * @see CompileTimeErrorCode#ARGUMENT_DEFINITION_TEST_NON_PARAMETER |
| 5589 */ | 5616 */ |
| 5590 bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) { | 5617 bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) { |
| 5591 SimpleIdentifier identifier14 = node.identifier; | 5618 SimpleIdentifier identifier14 = node.identifier; |
| 5592 Element element47 = identifier14.element; | 5619 Element element51 = identifier14.element; |
| 5593 if (element47 != null && element47 is! ParameterElement) { | 5620 if (element51 != null && element51 is! ParameterElement) { |
| 5594 _errorReporter.reportError(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_N
ON_PARAMETER, identifier14, [identifier14.name]); | 5621 _errorReporter.reportError(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_N
ON_PARAMETER, identifier14, [identifier14.name]); |
| 5595 return true; | 5622 return true; |
| 5596 } | 5623 } |
| 5597 return false; | 5624 return false; |
| 5598 } | 5625 } |
| 5599 /** | 5626 /** |
| 5600 * This verifies that the passed identifier is not a keyword, and generates th
e passed error code | 5627 * This verifies that the passed identifier is not a keyword, and generates th
e passed error code |
| 5601 * on the identifier if it is a keyword. | 5628 * on the identifier if it is a keyword. |
| 5602 * @param identifier the identifier to check to ensure that it is not a keywor
d | 5629 * @param identifier the identifier to check to ensure that it is not a keywor
d |
| 5603 * @param errorCode if the passed identifier is a keyword then this error code
is created on the | 5630 * @param errorCode if the passed identifier is a keyword then this error code
is created on the |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5642 * This verifies that the passed switch statement does not have a case express
ion with the | 5669 * This verifies that the passed switch statement does not have a case express
ion with the |
| 5643 * operator '==' overridden. | 5670 * operator '==' overridden. |
| 5644 * @param node the switch statement to evaluate | 5671 * @param node the switch statement to evaluate |
| 5645 * @return return <code>true</code> if and only if an error code is generated
on the passed node | 5672 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5646 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS | 5673 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS |
| 5647 */ | 5674 */ |
| 5648 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node) { | 5675 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node) { |
| 5649 Expression expression16 = node.expression; | 5676 Expression expression16 = node.expression; |
| 5650 Type2 type = expression16.staticType; | 5677 Type2 type = expression16.staticType; |
| 5651 if (type != null && type != _typeProvider.intType && type != _typeProvider.s
tringType) { | 5678 if (type != null && type != _typeProvider.intType && type != _typeProvider.s
tringType) { |
| 5652 Element element48 = type.element; | 5679 Element element52 = type.element; |
| 5653 if (element48 is ClassElement) { | 5680 if (element52 is ClassElement) { |
| 5654 ClassElement classElement = element48 as ClassElement; | 5681 ClassElement classElement = element52 as ClassElement; |
| 5655 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); | 5682 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); |
| 5656 if (method != null && method.enclosingElement.type != _typeProvider.obje
ctType) { | 5683 if (method != null && method.enclosingElement.type != _typeProvider.obje
ctType) { |
| 5657 _errorReporter.reportError(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_I
MPLEMENTS_EQUALS, expression16, [element48.name]); | 5684 _errorReporter.reportError(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_I
MPLEMENTS_EQUALS, expression16, [element52.name]); |
| 5658 return true; | 5685 return true; |
| 5659 } | 5686 } |
| 5660 } | 5687 } |
| 5661 } | 5688 } |
| 5662 return false; | 5689 return false; |
| 5663 } | 5690 } |
| 5664 bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node)
{ | 5691 bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node)
{ |
| 5665 ConstructorElement constructorElement = node.element; | 5692 ConstructorElement constructorElement = node.element; |
| 5666 SimpleIdentifier constructorName = node.name; | 5693 SimpleIdentifier constructorName = node.name; |
| 5667 if (constructorName != null && constructorElement != null && !constructorNam
e.isSynthetic()) { | 5694 if (constructorName != null && constructorElement != null && !constructorNam
e.isSynthetic()) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5740 * class. | 5767 * class. |
| 5741 * @param node the instance creation expression to evaluate | 5768 * @param node the instance creation expression to evaluate |
| 5742 * @param typeName the {@link TypeName} of the {@link ConstructorName} from th
e{@link InstanceCreationExpression}, this is the AST node that the error is atta
ched to | 5769 * @param typeName the {@link TypeName} of the {@link ConstructorName} from th
e{@link InstanceCreationExpression}, this is the AST node that the error is atta
ched to |
| 5743 * @param type the type being constructed with this {@link InstanceCreationExp
ression} | 5770 * @param type the type being constructed with this {@link InstanceCreationExp
ression} |
| 5744 * @return return <code>true</code> if and only if an error code is generated
on the passed node | 5771 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5745 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS | 5772 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS |
| 5746 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS | 5773 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS |
| 5747 */ | 5774 */ |
| 5748 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type
Name typeName, InterfaceType type) { | 5775 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type
Name typeName, InterfaceType type) { |
| 5749 if (type.element.isAbstract()) { | 5776 if (type.element.isAbstract()) { |
| 5750 ConstructorElement element49 = node.element; | 5777 ConstructorElement element53 = node.element; |
| 5751 if (element49 != null && !element49.isFactory()) { | 5778 if (element53 != null && !element53.isFactory()) { |
| 5752 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO
NST)) { | 5779 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO
NST)) { |
| 5753 _errorReporter.reportError(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS
, typeName, []); | 5780 _errorReporter.reportError(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS
, typeName, []); |
| 5754 } else { | 5781 } else { |
| 5755 _errorReporter.reportError(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS,
typeName, []); | 5782 _errorReporter.reportError(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS,
typeName, []); |
| 5756 } | 5783 } |
| 5757 return true; | 5784 return true; |
| 5758 } | 5785 } |
| 5759 } | 5786 } |
| 5760 return false; | 5787 return false; |
| 5761 } | 5788 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5829 } | 5856 } |
| 5830 } | 5857 } |
| 5831 } | 5858 } |
| 5832 _errorReporter.reportError(errorCode, typeName, [disallowedType.name]); | 5859 _errorReporter.reportError(errorCode, typeName, [disallowedType.name]); |
| 5833 return true; | 5860 return true; |
| 5834 } | 5861 } |
| 5835 } | 5862 } |
| 5836 return false; | 5863 return false; |
| 5837 } | 5864 } |
| 5838 /** | 5865 /** |
| 5866 * This verifies that the passed constructor field initializer is not also a f
inal variable that |
| 5867 * already included an initialization. |
| 5868 * @param node the constructor field initializer to test |
| 5869 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5870 * @see CompileTimeErrorCode#FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION |
| 5871 */ |
| 5872 bool checkForFieldInitializedInInitializerAndDeclaration(ConstructorFieldIniti
alizer node) { |
| 5873 SimpleIdentifier identifier = node.fieldName; |
| 5874 Element element54 = identifier.element; |
| 5875 if (element54 is PropertyAccessorElement) { |
| 5876 PropertyAccessorElement propertyAccessorElement = element54 as PropertyAcc
essorElement; |
| 5877 PropertyInducingElement propertyInducingElement = propertyAccessorElement.
variable; |
| 5878 if (propertyInducingElement.initializer != null && (propertyInducingElemen
t.isFinal() || propertyInducingElement.isConst())) { |
| 5879 _errorReporter.reportError(CompileTimeErrorCode.FIELD_INITIALIZED_IN_INI
TIALIZER_AND_DECLARATION, node, []); |
| 5880 return true; |
| 5881 } |
| 5882 } |
| 5883 return false; |
| 5884 } |
| 5885 /** |
| 5886 * This verifies that the passed constructor field initializer is not also a f
ield formal |
| 5887 * parameter in the constructor declaration. |
| 5888 * @param node the constructor field initializer to test |
| 5889 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5890 * @see CompileTimeErrorCode#FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER |
| 5891 */ |
| 5892 bool checkForFieldInitializedInParameterAndInitializer(ConstructorFieldInitial
izer node) { |
| 5893 SimpleIdentifier identifier = node.fieldName; |
| 5894 Element element55 = identifier.element; |
| 5895 ASTNode parent18 = node.parent; |
| 5896 if (element55 != null && parent18 is ConstructorDeclaration) { |
| 5897 ConstructorDeclaration constructorDeclaration = parent18 as ConstructorDec
laration; |
| 5898 NodeList<FormalParameter> formalParameters = constructorDeclaration.parame
ters.parameters; |
| 5899 for (FormalParameter formalParameter in formalParameters) { |
| 5900 if (formalParameter is FieldFormalParameter) { |
| 5901 FieldFormalParameter fieldFormalParameter = formalParameter as FieldFo
rmalParameter; |
| 5902 if (fieldFormalParameter.identifier.name == element55.name) { |
| 5903 _errorReporter.reportError(CompileTimeErrorCode.FIELD_INITIALIZED_IN
_PARAMETER_AND_INITIALIZER, node, []); |
| 5904 return true; |
| 5905 } |
| 5906 } |
| 5907 } |
| 5908 } |
| 5909 return false; |
| 5910 } |
| 5911 /** |
| 5912 * This verifies that the passed field formal parameter is in a constructor de
claration. |
| 5913 * @param node the field formal parameter to test |
| 5914 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5915 * @see CompileTimeErrorCode#FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR |
| 5916 */ |
| 5917 bool checkForFieldInitializerOutsideConstructor(FieldFormalParameter node) { |
| 5918 ASTNode parent19 = node.parent; |
| 5919 if (parent19 != null) { |
| 5920 ASTNode grandparent = parent19.parent; |
| 5921 if (grandparent != null && grandparent is! ConstructorDeclaration && grand
parent.parent is! ConstructorDeclaration) { |
| 5922 _errorReporter.reportError(CompileTimeErrorCode.FIELD_INITIALIZER_OUTSID
E_CONSTRUCTOR, node, []); |
| 5923 return true; |
| 5924 } |
| 5925 } |
| 5926 return false; |
| 5927 } |
| 5928 /** |
| 5839 * This verifies that the passed implements clause does not implement classes
such as 'num' or | 5929 * This verifies that the passed implements clause does not implement classes
such as 'num' or |
| 5840 * 'String'. | 5930 * 'String'. |
| 5841 * @param node the implements clause to test | 5931 * @param node the implements clause to test |
| 5842 * @return return <code>true</code> if and only if an error code is generated
on the passed node | 5932 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5843 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS | 5933 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS |
| 5844 */ | 5934 */ |
| 5845 bool checkForImplementsDisallowedClass(ImplementsClause implementsClause) { | 5935 bool checkForImplementsDisallowedClass(ImplementsClause implementsClause) { |
| 5846 bool result = false; | 5936 bool result = false; |
| 5847 for (TypeName type in implementsClause.interfaces) { | 5937 for (TypeName type in implementsClause.interfaces) { |
| 5848 result = javaBooleanOr(result, checkForExtendsOrImplementsDisallowedClass(
type, CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS)); | 5938 result = javaBooleanOr(result, checkForExtendsOrImplementsDisallowedClass(
type, CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5899 } else if (type is FunctionType) { | 5989 } else if (type is FunctionType) { |
| 5900 FunctionType functionType = type as FunctionType; | 5990 FunctionType functionType = type as FunctionType; |
| 5901 if (functionType.typeArguments.length == 0 && !functionType.returnType.isA
ssignableTo(_typeProvider.boolType)) { | 5991 if (functionType.typeArguments.length == 0 && !functionType.returnType.isA
ssignableTo(_typeProvider.boolType)) { |
| 5902 _errorReporter.reportError(StaticTypeWarningCode.NON_BOOL_EXPRESSION, ex
pression, []); | 5992 _errorReporter.reportError(StaticTypeWarningCode.NON_BOOL_EXPRESSION, ex
pression, []); |
| 5903 return true; | 5993 return true; |
| 5904 } | 5994 } |
| 5905 } | 5995 } |
| 5906 return false; | 5996 return false; |
| 5907 } | 5997 } |
| 5908 /** | 5998 /** |
| 5999 * This checks that the rethrow is inside of a catch clause. |
| 6000 * @param node the rethrow expression to evaluate |
| 6001 * @return <code>true</code> if and only if an error code is generated on the
passed node |
| 6002 * @see CompileTimeErrorCode#RETHROW_OUTSIDE_CATCH |
| 6003 */ |
| 6004 bool checkForRethrowOutsideCatch(RethrowExpression node) { |
| 6005 if (!_isInCatchClause) { |
| 6006 _errorReporter.reportError(CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, nod
e, []); |
| 6007 return true; |
| 6008 } |
| 6009 return false; |
| 6010 } |
| 6011 /** |
| 5909 * This checks that the return type matches the type of the declared return ty
pe in the enclosing | 6012 * This checks that the return type matches the type of the declared return ty
pe in the enclosing |
| 5910 * method or function. | 6013 * method or function. |
| 5911 * @param node the return statement to evaluate | 6014 * @param node the return statement to evaluate |
| 5912 * @return return <code>true</code> if and only if an error code is generated
on the passed node | 6015 * @return return <code>true</code> if and only if an error code is generated
on the passed node |
| 5913 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE | 6016 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE |
| 5914 */ | 6017 */ |
| 5915 bool checkForReturnOfInvalidType(ReturnStatement node) { | 6018 bool checkForReturnOfInvalidType(ReturnStatement node) { |
| 5916 FunctionType functionType = _currentFunction == null ? null : _currentFuncti
on.type; | 6019 FunctionType functionType = _currentFunction == null ? null : _currentFuncti
on.type; |
| 5917 Type2 expectedReturnType = functionType == null ? null : functionType.return
Type; | 6020 Type2 expectedReturnType = functionType == null ? null : functionType.return
Type; |
| 5918 Expression returnExpression = node.expression; | 6021 Expression returnExpression = node.expression; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5997 ResolverErrorCode(this.__name, this.__ordinal, ErrorType type, String message)
{ | 6100 ResolverErrorCode(this.__name, this.__ordinal, ErrorType type, String message)
{ |
| 5998 this._type = type; | 6101 this._type = type; |
| 5999 this._message = message; | 6102 this._message = message; |
| 6000 } | 6103 } |
| 6001 ErrorSeverity get errorSeverity => _type.severity; | 6104 ErrorSeverity get errorSeverity => _type.severity; |
| 6002 String get message => _message; | 6105 String get message => _message; |
| 6003 ErrorType get type => _type; | 6106 ErrorType get type => _type; |
| 6004 bool needsRecompilation() => true; | 6107 bool needsRecompilation() => true; |
| 6005 String toString() => __name; | 6108 String toString() => __name; |
| 6006 } | 6109 } |
| OLD | NEW |