| Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| index 72f84cb00dabcf40cb69a2f2ff9e2a21276b5a5d..303d5f9dd19b1c61e4f449cc5c84956da62de163 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| @@ -131,6 +131,7 @@ class FixProcessor {
|
| _addFix_createConstructorSuperExplicit();
|
| }
|
| if (errorCode == CompileTimeErrorCode.URI_DOES_NOT_EXIST) {
|
| + _addFix_createImportUri();
|
| _addFix_replaceImportUri();
|
| }
|
| if (errorCode == HintCode.DIVISION_OPTIMIZATION) {
|
| @@ -227,14 +228,14 @@ class FixProcessor {
|
| return fixes;
|
| }
|
|
|
| - void _addFix(FixKind kind, List args, {String fixFile}) {
|
| + void _addFix(FixKind kind, List args, {String fixFile, int fixFileStamp}) {
|
| if (fixFile == null) {
|
| fixFile = file;
|
| + fixFileStamp =
|
| + unitElement.context.getModificationStamp(unitElement.source);
|
| }
|
| // prepare SourceFileEdit
|
| - SourceFileEdit fileEdit = new SourceFileEdit(
|
| - file,
|
| - unitElement.context.getModificationStamp(unitElement.source));
|
| + SourceFileEdit fileEdit = new SourceFileEdit(fixFile, fixFileStamp);
|
| fileEdit.addAll(edits);
|
| // prepare Change
|
| String message = formatList(kind.message, args);
|
| @@ -608,6 +609,22 @@ class FixProcessor {
|
| }
|
| }
|
|
|
| + void _addFix_createImportUri() {
|
| + if (node is SimpleStringLiteral && node.parent is ImportDirective) {
|
| + ImportDirective importDirective = node.parent;
|
| + Source source = importDirective.source;
|
| + if (source != null) {
|
| + String file = source.fullName;
|
| + if (isAbsolute(file)) {
|
| + String libName = removeEnd(source.shortName, '.dart');
|
| + libName = libName.replaceAll('_', '.');
|
| + edits.add(new SourceEdit(0, 0, 'library $libName;$eol$eol'));
|
| + }
|
| + _addFix(FixKind.CREATE_FILE, [file], fixFile: file, fixFileStamp: -1);
|
| + }
|
| + }
|
| + }
|
| +
|
| void _addFix_createMissingOverrides(List<ExecutableElement> elements) {
|
| elements = elements.toList();
|
| int numElements = elements.length;
|
|
|