| 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 analysis_server.src.services.correction.fix_internal; | 5 library analysis_server.src.services.correction.fix_internal; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/edit/fix/fix_core.dart'; | 9 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 10 import 'package:analysis_server/edit/fix/fix_dart.dart'; | 10 import 'package:analysis_server/edit/fix/fix_dart.dart'; |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 void _addFix_createImportUri() { | 915 void _addFix_createImportUri() { |
| 916 if (node is SimpleStringLiteral && node.parent is ImportDirective) { | 916 if (node is SimpleStringLiteral && node.parent is ImportDirective) { |
| 917 ImportDirective importDirective = node.parent; | 917 ImportDirective importDirective = node.parent; |
| 918 Source source = importDirective.source; | 918 Source source = importDirective.source; |
| 919 if (source != null) { | 919 if (source != null) { |
| 920 String file = source.fullName; | 920 String file = source.fullName; |
| 921 if (isAbsolute(file)) { | 921 if (isAbsolute(file)) { |
| 922 String libName = removeEnd(source.shortName, '.dart'); | 922 String libName = removeEnd(source.shortName, '.dart'); |
| 923 libName = libName.replaceAll('_', '.'); | 923 libName = libName.replaceAll('_', '.'); |
| 924 SourceEdit edit = new SourceEdit(0, 0, 'library $libName;$eol$eol'); | 924 SourceEdit edit = new SourceEdit(0, 0, 'library $libName;$eol$eol'); |
| 925 change.addEdit(file, -1, edit); | |
| 926 doSourceChange_addSourceEdit(change, context, source, edit); | 925 doSourceChange_addSourceEdit(change, context, source, edit); |
| 927 } | 926 } |
| 928 _addFix(DartFixKind.CREATE_FILE, [file]); | 927 _addFix(DartFixKind.CREATE_FILE, [file]); |
| 929 } | 928 } |
| 930 } | 929 } |
| 931 } | 930 } |
| 932 | 931 |
| 933 void _addFix_createLocalVariable() { | 932 void _addFix_createLocalVariable() { |
| 934 if (node is! SimpleIdentifier) { | 933 if (node is! SimpleIdentifier) { |
| 935 return; | 934 return; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 } | 1119 } |
| 1121 | 1120 |
| 1122 void _addFix_createPartUri() { | 1121 void _addFix_createPartUri() { |
| 1123 if (node is SimpleStringLiteral && node.parent is PartDirective) { | 1122 if (node is SimpleStringLiteral && node.parent is PartDirective) { |
| 1124 PartDirective partDirective = node.parent; | 1123 PartDirective partDirective = node.parent; |
| 1125 Source source = partDirective.source; | 1124 Source source = partDirective.source; |
| 1126 if (source != null) { | 1125 if (source != null) { |
| 1127 String file = source.fullName; | 1126 String file = source.fullName; |
| 1128 String libName = unitLibraryElement.name; | 1127 String libName = unitLibraryElement.name; |
| 1129 SourceEdit edit = new SourceEdit(0, 0, 'part of $libName;$eol$eol'); | 1128 SourceEdit edit = new SourceEdit(0, 0, 'part of $libName;$eol$eol'); |
| 1130 change.addEdit(file, -1, edit); | |
| 1131 doSourceChange_addSourceEdit(change, context, source, edit); | 1129 doSourceChange_addSourceEdit(change, context, source, edit); |
| 1132 _addFix(DartFixKind.CREATE_FILE, [file]); | 1130 _addFix(DartFixKind.CREATE_FILE, [file]); |
| 1133 } | 1131 } |
| 1134 } | 1132 } |
| 1135 } | 1133 } |
| 1136 | 1134 |
| 1137 void _addFix_illegalAsyncReturnType() { | 1135 void _addFix_illegalAsyncReturnType() { |
| 1138 InterfaceType futureType = context.typeProvider.futureType; | 1136 InterfaceType futureType = context.typeProvider.futureType; |
| 1139 String futureTypeCode = utils.getTypeSource(futureType, librariesToImport); | 1137 String futureTypeCode = utils.getTypeSource(futureType, librariesToImport); |
| 1140 // prepare the existing type | 1138 // prepare the existing type |
| (...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 /** | 2538 /** |
| 2541 * Describes the location for a newly created [FieldDeclaration]. | 2539 * Describes the location for a newly created [FieldDeclaration]. |
| 2542 */ | 2540 */ |
| 2543 class _FieldLocation { | 2541 class _FieldLocation { |
| 2544 final String prefix; | 2542 final String prefix; |
| 2545 final int offset; | 2543 final int offset; |
| 2546 final String suffix; | 2544 final String suffix; |
| 2547 | 2545 |
| 2548 _FieldLocation(this.prefix, this.offset, this.suffix); | 2546 _FieldLocation(this.prefix, this.offset, this.suffix); |
| 2549 } | 2547 } |
| OLD | NEW |