| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/protocol/protocol_generated.dart' | 7 import 'package:analysis_server/protocol/protocol_generated.dart' |
| 8 hide Element, ElementKind; | 8 hide Element, ElementKind; |
| 9 import 'package:analysis_server/src/provisional/edit/utilities/change_builder_co
re.dart'; | 9 import 'package:analysis_server/src/provisional/edit/utilities/change_builder_co
re.dart'; |
| 10 import 'package:analysis_server/src/provisional/edit/utilities/change_builder_da
rt.dart'; | 10 import 'package:analysis_server/src/provisional/edit/utilities/change_builder_da
rt.dart'; |
| 11 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; | 11 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; |
| 12 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| 12 import 'package:analysis_server/src/services/correction/util.dart'; | 13 import 'package:analysis_server/src/services/correction/util.dart'; |
| 13 import 'package:analysis_server/src/utilities/change_builder_core.dart'; | 14 import 'package:analysis_server/src/utilities/change_builder_core.dart'; |
| 14 import 'package:analyzer/dart/ast/ast.dart'; | 15 import 'package:analyzer/dart/ast/ast.dart'; |
| 15 import 'package:analyzer/dart/ast/token.dart'; | 16 import 'package:analyzer/dart/ast/token.dart'; |
| 16 import 'package:analyzer/dart/element/element.dart'; | 17 import 'package:analyzer/dart/element/element.dart'; |
| 17 import 'package:analyzer/dart/element/type.dart'; | 18 import 'package:analyzer/dart/element/type.dart'; |
| 18 import 'package:analyzer/src/dart/analysis/driver.dart'; | 19 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 19 import 'package:analyzer/src/generated/resolver.dart'; | 20 import 'package:analyzer/src/generated/resolver.dart'; |
| 20 import 'package:analyzer/src/generated/source.dart'; | 21 import 'package:analyzer/src/generated/source.dart'; |
| 21 import 'package:analyzer/src/generated/utilities_dart.dart'; | 22 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 type.isDynamic || | 662 type.isDynamic || |
| 662 type is InterfaceType && type.element == futureType.element) { | 663 type is InterfaceType && type.element == futureType.element) { |
| 663 return; | 664 return; |
| 664 } | 665 } |
| 665 // prepare code for the types | 666 // prepare code for the types |
| 666 String futureTypeCode = utils.getTypeSource(futureType, librariesToImport); | 667 String futureTypeCode = utils.getTypeSource(futureType, librariesToImport); |
| 667 String nodeCode = utils.getNodeText(typeAnnotation); | 668 String nodeCode = utils.getNodeText(typeAnnotation); |
| 668 // wrap the existing type with Future | 669 // wrap the existing type with Future |
| 669 String returnTypeCode = | 670 String returnTypeCode = |
| 670 nodeCode == 'void' ? futureTypeCode : '$futureTypeCode<$nodeCode>'; | 671 nodeCode == 'void' ? futureTypeCode : '$futureTypeCode<$nodeCode>'; |
| 671 addReplacement(typeAnnotation.offset, typeAnnotation.length, | 672 addReplacement(rangeNode(typeAnnotation), (EditBuilder builder) { |
| 672 (EditBuilder builder) { | |
| 673 builder.write(returnTypeCode); | 673 builder.write(returnTypeCode); |
| 674 }); | 674 }); |
| 675 } | 675 } |
| 676 | 676 |
| 677 /** | 677 /** |
| 678 * Create an edit to replace the return type of the innermost function | 678 * Create an edit to replace the return type of the innermost function |
| 679 * containing the given [node] with the type `Future`. The [typeProvider] is | 679 * containing the given [node] with the type `Future`. The [typeProvider] is |
| 680 * used to check the current return type, because if it is already `Future` no | 680 * used to check the current return type, because if it is already `Future` no |
| 681 * edit will be added. | 681 * edit will be added. |
| 682 */ | 682 */ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 void _addSuperTypesAsSuggestions(DartType type, Set<DartType> alreadyAdded) { | 718 void _addSuperTypesAsSuggestions(DartType type, Set<DartType> alreadyAdded) { |
| 719 if (type is InterfaceType && alreadyAdded.add(type)) { | 719 if (type is InterfaceType && alreadyAdded.add(type)) { |
| 720 addSuggestion(LinkedEditSuggestionKind.TYPE, type.displayName); | 720 addSuggestion(LinkedEditSuggestionKind.TYPE, type.displayName); |
| 721 _addSuperTypesAsSuggestions(type.superclass, alreadyAdded); | 721 _addSuperTypesAsSuggestions(type.superclass, alreadyAdded); |
| 722 for (InterfaceType interfaceType in type.interfaces) { | 722 for (InterfaceType interfaceType in type.interfaces) { |
| 723 _addSuperTypesAsSuggestions(interfaceType, alreadyAdded); | 723 _addSuperTypesAsSuggestions(interfaceType, alreadyAdded); |
| 724 } | 724 } |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 } | 727 } |
| OLD | NEW |