Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.analyzer.ast_builder; | 5 library fasta.analyzer.ast_builder; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; | 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; |
| 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; | 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; |
| 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; | 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 toAnalyzerToken(beginToken), | 763 toAnalyzerToken(beginToken), |
| 764 parameters, | 764 parameters, |
| 765 toAnalyzerToken(leftDelimiter), | 765 toAnalyzerToken(leftDelimiter), |
| 766 toAnalyzerToken(rightDelimiter), | 766 toAnalyzerToken(rightDelimiter), |
| 767 toAnalyzerToken(endToken))); | 767 toAnalyzerToken(endToken))); |
| 768 } | 768 } |
| 769 | 769 |
| 770 void handleCatchBlock(Token onKeyword, Token catchKeyword) { | 770 void handleCatchBlock(Token onKeyword, Token catchKeyword) { |
| 771 debugEvent("CatchBlock"); | 771 debugEvent("CatchBlock"); |
| 772 Block body = pop(); | 772 Block body = pop(); |
| 773 FormalParameterList catchParameters = popIfNotNull(catchKeyword); | 773 FormalParameterList catchParameterList = popIfNotNull(catchKeyword); |
| 774 if (catchKeyword != null) { | |
| 775 exitLocalScope(); | |
|
Paul Berry
2017/03/14 19:30:06
It's not obvious to me why it's safe to drop the c
scheglov
2017/03/14 19:34:42
No, this is an intentional change.
There is no cor
Paul Berry
2017/03/14 19:39:01
Ok, thanks for clarifying.
| |
| 776 } | |
| 777 TypeAnnotation type = popIfNotNull(onKeyword); | 774 TypeAnnotation type = popIfNotNull(onKeyword); |
| 778 SimpleIdentifier exception; | 775 SimpleIdentifier exception; |
| 779 SimpleIdentifier stackTrace; | 776 SimpleIdentifier stackTrace; |
| 780 if (catchParameters != null) { | 777 if (catchParameterList != null) { |
| 778 List<FormalParameter> catchParameters = catchParameterList.parameters; | |
| 781 if (catchParameters.length > 0) { | 779 if (catchParameters.length > 0) { |
| 782 exception = catchParameters.parameters[0].identifier; | 780 exception = catchParameters[0].identifier; |
| 783 } | 781 } |
| 784 if (catchParameters.length > 1) { | 782 if (catchParameters.length > 1) { |
| 785 stackTrace = catchParameters.parameters[1].identifier; | 783 stackTrace = catchParameters[1].identifier; |
| 786 } | 784 } |
| 787 } | 785 } |
| 788 BeginGroupToken leftParenthesis = catchKeyword.next; | |
| 789 push(ast.catchClause( | 786 push(ast.catchClause( |
| 790 toAnalyzerToken(onKeyword), | 787 toAnalyzerToken(onKeyword), |
| 791 type, | 788 type, |
| 792 toAnalyzerToken(catchKeyword), | 789 toAnalyzerToken(catchKeyword), |
| 793 toAnalyzerToken(leftParenthesis), | 790 catchParameterList?.leftParenthesis, |
| 794 exception, | 791 exception, |
| 795 null, | 792 null, |
| 796 stackTrace, | 793 stackTrace, |
| 797 toAnalyzerToken(leftParenthesis.endGroup), | 794 catchParameterList?.rightParenthesis, |
| 798 body)); | 795 body)); |
| 799 } | 796 } |
| 800 | 797 |
| 798 @override | |
| 799 void handleFinallyBlock(Token finallyKeyword) { | |
| 800 debugEvent("FinallyBlock"); | |
| 801 // The finally block is popped in "endTryStatement". | |
| 802 } | |
| 803 | |
| 801 void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { | 804 void endTryStatement(int catchCount, Token tryKeyword, Token finallyKeyword) { |
| 802 Block finallyBlock = popIfNotNull(finallyKeyword); | 805 Block finallyBlock = popIfNotNull(finallyKeyword); |
| 803 List<CatchClause> catchClauses = popList(catchCount); | 806 List<CatchClause> catchClauses = popList(catchCount); |
| 804 Block body = pop(); | 807 Block body = pop(); |
| 805 push(ast.tryStatement(toAnalyzerToken(tryKeyword), body, catchClauses, | 808 push(ast.tryStatement(toAnalyzerToken(tryKeyword), body, catchClauses, |
| 806 toAnalyzerToken(finallyKeyword), finallyBlock)); | 809 toAnalyzerToken(finallyKeyword), finallyBlock)); |
| 807 } | 810 } |
| 808 | 811 |
| 809 void handleNoExpression(Token token) { | 812 void handleNoExpression(Token token) { |
| 810 debugEvent("NoExpression"); | 813 debugEvent("NoExpression"); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1610 } else if (identical('static', s)) { | 1613 } else if (identical('static', s)) { |
| 1611 staticKeyword = token; | 1614 staticKeyword = token; |
| 1612 } else if (identical('var', s)) { | 1615 } else if (identical('var', s)) { |
| 1613 finalConstOrVarKeyword = token; | 1616 finalConstOrVarKeyword = token; |
| 1614 } else { | 1617 } else { |
| 1615 internalError('Unhandled modifier: $s'); | 1618 internalError('Unhandled modifier: $s'); |
| 1616 } | 1619 } |
| 1617 } | 1620 } |
| 1618 } | 1621 } |
| 1619 } | 1622 } |
| OLD | NEW |