Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 1147543002: [WEB-16445] When create a missing imported library/part, add the edit once. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698