mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:59:41 +00:00
Better loop for ADD_TYPE_ANNOTATION
Fixes #47015 Change-Id: I3b3c6e88e601c5da9bc60936f08007bdea52375d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211444 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
5c582f82f0
commit
47b7fd4b75
|
@ -142,11 +142,9 @@ class AddTypeAnnotation extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
// Ensure that there is a single type.
|
||||
if (variables.length > 1) {
|
||||
for (var v in variables) {
|
||||
if (v != variable && _typeForVariable(v) != type) {
|
||||
return;
|
||||
}
|
||||
for (var i = 1; i < variables.length; i++) {
|
||||
if (_typeForVariable(variables[i]) != type) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((type is! InterfaceType || type.isDartCoreNull) &&
|
||||
|
|
|
@ -54,8 +54,8 @@ class CreateMissingOverrides extends CorrectionProducer {
|
|||
await builder.addDartFileEdit(file, (builder) {
|
||||
final syntheticLeftBracket = targetClass.leftBracket.isSynthetic;
|
||||
if (syntheticLeftBracket) {
|
||||
var previousToLeftBracket = targetClass.leftBracket.previous;
|
||||
builder.addSimpleInsertion(previousToLeftBracket!.end, ' {');
|
||||
var previousToLeftBracket = targetClass.leftBracket.previous!;
|
||||
builder.addSimpleInsertion(previousToLeftBracket.end, ' {');
|
||||
}
|
||||
|
||||
builder.addInsertion(location.offset, (builder) {
|
||||
|
@ -109,8 +109,8 @@ class CreateMissingOverrides extends CorrectionProducer {
|
|||
builder.write(location.suffix);
|
||||
|
||||
if (targetClass.rightBracket.isSynthetic) {
|
||||
var next = targetClass.rightBracket.next;
|
||||
if (next!.type != TokenType.CLOSE_CURLY_BRACKET) {
|
||||
var next = targetClass.rightBracket.next!;
|
||||
if (next.type != TokenType.CLOSE_CURLY_BRACKET) {
|
||||
if (!syntheticLeftBracket) {
|
||||
builder.write(eol);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue