Don't try to add new imports before leading comments of another import.

By doing this we tried to fix keeping "// ignore: xyz" correct.
https://github.com/dart-lang/sdk/issues/32432

Unfortunately this breaks a more often case, when there is a license
comment before the first import directive, and there is no reliable
way to decide if a comment is a license or not.

R=brianwilkerson@google.com

Bug: https://github.com/flutter/flutter-intellij/issues/2169
Change-Id: Id5bdf7af48bd0b8748a53f8c5b3eb79ac2d6ae01
Reviewed-on: https://dart-review.googlesource.com/52940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2018-04-27 20:59:09 +00:00 committed by commit-bot@chromium.org
parent 239b2fd090
commit c17ef848d6
2 changed files with 1 additions and 12 deletions

View file

@ -1288,17 +1288,6 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
});
} else {
int offset = next.offset;
Token comment = next.beginToken.precedingComments;
while (comment != null) {
int commentOffset = comment.offset;
if (commentOffset ==
lineInfo.getOffsetOfLine(
lineInfo.getLocation(commentOffset).lineNumber - 1)) {
offset = commentOffset;
break;
}
comment = comment.next;
}
addInsertion(offset, (EditBuilder builder) {
builder.write("import '");
builder.write(uri);

View file

@ -240,8 +240,8 @@ import 'package:aaa/a2.dart';
import 'foo.dart';
''', ['package:aaa/a1.dart'], '''
import 'package:aaa/a1.dart';
// comment a2
import 'package:aaa/a1.dart';
import 'package:aaa/a2.dart';
import 'foo.dart';