| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 services.src.refactoring.extract_method; | 5 library services.src.refactoring.extract_method; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; | 9 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 10 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; | 10 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1100 |
| 1101 class _ReturnTypeComputer extends RecursiveAstVisitor { | 1101 class _ReturnTypeComputer extends RecursiveAstVisitor { |
| 1102 DartType returnType; | 1102 DartType returnType; |
| 1103 | 1103 |
| 1104 @override | 1104 @override |
| 1105 visitBlockFunctionBody(BlockFunctionBody node) { | 1105 visitBlockFunctionBody(BlockFunctionBody node) { |
| 1106 } | 1106 } |
| 1107 | 1107 |
| 1108 @override | 1108 @override |
| 1109 visitReturnStatement(ReturnStatement node) { | 1109 visitReturnStatement(ReturnStatement node) { |
| 1110 // prepare expression |
| 1110 Expression expression = node.expression; | 1111 Expression expression = node.expression; |
| 1111 if (expression != null) { | 1112 if (expression == null) { |
| 1112 DartType type = expression.bestType; | 1113 return; |
| 1113 if (returnType == null) { | 1114 } |
| 1114 returnType = type; | 1115 // prepare type |
| 1116 DartType type = expression.bestType; |
| 1117 if (type.isBottom) { |
| 1118 return; |
| 1119 } |
| 1120 // combine types |
| 1121 if (returnType == null) { |
| 1122 returnType = type; |
| 1123 } else { |
| 1124 if (returnType is InterfaceType && type is InterfaceType) { |
| 1125 returnType = InterfaceType.getSmartLeastUpperBound(returnType, type); |
| 1115 } else { | 1126 } else { |
| 1116 if (returnType is InterfaceType && type is InterfaceType) { | 1127 returnType = returnType.getLeastUpperBound(type); |
| 1117 returnType = InterfaceType.getSmartLeastUpperBound(returnType, type); | |
| 1118 } else { | |
| 1119 returnType = returnType.getLeastUpperBound(type); | |
| 1120 } | |
| 1121 } | 1128 } |
| 1122 } | 1129 } |
| 1123 } | 1130 } |
| 1124 } | 1131 } |
| 1125 | 1132 |
| 1126 | 1133 |
| 1127 /** | 1134 /** |
| 1128 * Generalized version of some source, in which references to the specific | 1135 * Generalized version of some source, in which references to the specific |
| 1129 * variables are replaced with pattern variables, with back mapping from the | 1136 * variables are replaced with pattern variables, with back mapping from the |
| 1130 * pattern to the original variable names. | 1137 * pattern to the original variable names. |
| 1131 */ | 1138 */ |
| 1132 class _SourcePattern { | 1139 class _SourcePattern { |
| 1133 String patternSource; | 1140 String patternSource; |
| 1134 Map<String, String> originalToPatternNames = {}; | 1141 Map<String, String> originalToPatternNames = {}; |
| 1135 } | 1142 } |
| OLD | NEW |