Skip to content

Commit

Permalink
Version 3.5.0-13.0.dev
Browse files Browse the repository at this point in the history
Merge 37e8657 into dev
  • Loading branch information
Dart CI committed Apr 3, 2024
2 parents 88a81dd + 37e8657 commit 2b5233d
Show file tree
Hide file tree
Showing 102 changed files with 3,997 additions and 4,970 deletions.
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ vars = {
"test_descriptor_rev": "b61cfb4479fafd78eb9d365cc2f7cdb43c2aed34",
"test_process_rev": "94ee46d76f89ebb7d73cef3e23bab288b1e43b50",
"test_reflective_loader_rev": "d7167a2375d8a0c02c12b960c059a115a777f238",
"tools_rev": "f611290b530123ee2f0a3fda7c440d85dd080a30", # https://github.com/dart-lang/tools/pull/247
"tools_rev": "d86ea23c79d2e9dc622d3376aa80d94fbf30bf60",
"typed_data_rev": "8c7393cbbbba7a5d38c6772371f92d6b38e433fc",
"usage_rev": "67ecd7d1328347ec15cbf8d8a46918df75a66af8",
"vector_math_rev": "7e705f734e94917e9a5347578e6e496f8db38ac6",
"watcher_rev": "1bd2f20d0d924c8422aa2b9afdb165bff4f053c0",
"web_rev": "e773de957b289d001c90c6b830e91634e305667d",
"web_socket_channel_rev": "19d82db86acb7309dd08c40a2af3285232751e83",
"webdev_rev": "51b5484348b4a8ede351e8dff0428b083495ba78", # https://github.com/flutter/devtools/issues/7231
"webdev_rev": "4067462c8d605266a23c3725948a0314102c95f9",
"webdriver_rev": "c80e01e6ce121e55c31e33a31e5d3950023e6bc9",
"webkit_inspection_protocol_rev": "153fea4fe5ac45bebf0c2e76bb3d76b0f1fcdaae",
"yaml_rev": "5a1c4be2437bc4122ccf08a3a0f06a7683e62f30",
Expand Down
3 changes: 2 additions & 1 deletion pkg/_fe_analyzer_shared/lib/src/macros/code_optimizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ class _Listener extends Listener {
}

@override
void beginExtensionTypeDeclaration(Token extensionKeyword, Token name) {
void beginExtensionTypeDeclaration(
Token? augmentToken, Token extensionKeyword, Token name) {
declaredNames.add(name.lexeme);
}

Expand Down
12 changes: 7 additions & 5 deletions pkg/_fe_analyzer_shared/lib/src/parser/forwarding_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2088,8 +2088,10 @@ class ForwardingListener implements Listener {
}

@override
void beginExtensionTypeDeclaration(Token extensionKeyword, Token name) {
listener?.beginExtensionTypeDeclaration(extensionKeyword, name);
void beginExtensionTypeDeclaration(
Token? augmentToken, Token extensionKeyword, Token name) {
listener?.beginExtensionTypeDeclaration(
augmentToken, extensionKeyword, name);
}

@override
Expand All @@ -2100,10 +2102,10 @@ class ForwardingListener implements Listener {
}

@override
void endExtensionTypeDeclaration(Token beginToken, Token extensionKeyword,
Token typeKeyword, Token endToken) {
void endExtensionTypeDeclaration(Token beginToken, Token? augmentToken,
Token extensionKeyword, Token typeKeyword, Token endToken) {
listener?.endExtensionTypeDeclaration(
beginToken, extensionKeyword, typeKeyword, endToken);
beginToken, augmentToken, extensionKeyword, typeKeyword, endToken);
}

@override
Expand Down
7 changes: 4 additions & 3 deletions pkg/_fe_analyzer_shared/lib/src/parser/listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,16 @@ class Listener implements UnescapeErrorListener {
/// - type variables
///
/// At this point we have parsed the name and type parameter declarations.
void beginExtensionTypeDeclaration(Token extensionKeyword, Token name) {}
void beginExtensionTypeDeclaration(
Token? augmentKeyword, Token extensionKeyword, Token name) {}

/// Handle the end of an extension methods declaration. Substructures:
/// - substructures from [beginExtensionTypeDeclaration]
/// - primary constructor formals
/// - implements clause
/// - body
void endExtensionTypeDeclaration(Token beginToken, Token extensionKeyword,
Token typeKeyword, Token endToken) {
void endExtensionTypeDeclaration(Token beginToken, Token? augmentToken,
Token extensionKeyword, Token typeKeyword, Token endToken) {
logEvent('ExtensionTypeDeclaration');
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3068,7 +3068,7 @@ class Parser {
// 'extension' 'type'
Token typeKeyword = token.next!;
return parseExtensionTypeDeclaration(
beginToken, token.next!, extensionKeyword, typeKeyword);
beginToken, token.next!, augmentToken, extensionKeyword, typeKeyword);
} else {
return parseExtensionDeclaration(
beginToken, token, augmentToken, extensionKeyword);
Expand Down Expand Up @@ -3178,7 +3178,7 @@ class Parser {
/// ('.' <identifier>)? <formals> '{' <memberDeclaration>* '}'
///
Token parseExtensionTypeDeclaration(Token beginToken, Token token,
Token extensionKeyword, Token typeKeyword) {
Token? augmentToken, Token extensionKeyword, Token typeKeyword) {
assert(token.isIdentifier && token.lexeme == 'type');
Token? constKeyword = null;
if (optional('const', token.next!)) {
Expand All @@ -3199,7 +3199,8 @@ class Parser {
token = name;
token = computeTypeParamOrArg(token, /* inDeclaration = */ true)
.parseVariables(token, this);
listener.beginExtensionTypeDeclaration(extensionKeyword, name);
listener.beginExtensionTypeDeclaration(
augmentToken, extensionKeyword, name);
if (optional('(', token.next!) || optional('.', token.next!)) {
Token beginPrimaryConstructor = token.next!;
listener.beginPrimaryConstructor(beginPrimaryConstructor);
Expand Down Expand Up @@ -3234,7 +3235,7 @@ class Parser {
token = parseClassOrMixinOrExtensionBody(
token, DeclarationKind.ExtensionType, name.lexeme);
listener.endExtensionTypeDeclaration(
beginToken, extensionKeyword, typeKeyword, token);
beginToken, augmentToken, extensionKeyword, typeKeyword, token);
return token;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AddCallSuper extends ResolvedCorrectionProducer {
builder.write('${builder.getIndent(2)}super.$_addition;');
if (block.statements.isEmpty) {
builder.writeln();
builder.write(builder.getIndent(1));
builder.writeIndent();
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,16 @@ class CreateField extends CreateFieldOrGetter {
if (!(targetNode is ClassDeclaration || targetNode is MixinDeclaration)) {
return;
}
// prepare location
var targetUnit = targetDeclarationResult.resolvedUnit;
if (targetUnit == null) {
return;
}
var targetLocation =
CorrectionUtils(targetUnit).prepareNewFieldLocation(targetNode);
if (targetLocation == null) {
return;
}
// build field source
// Build field source.
var targetSource = targetElement.source;
var targetFile = targetSource.fullName;
await builder.addDartFileEdit(targetFile, (builder) {
builder.addInsertion(targetLocation.offset, (builder) {
builder.write(targetLocation.prefix);
builder.addFieldInsertion(targetNode, (builder) {
builder.writeFieldDeclaration(_fieldName,
isStatic: staticModifier,
nameGroupName: 'NAME',
type: fieldType,
typeGroupName: 'TYPE');
builder.write(targetLocation.suffix);
});
});
}
Expand All @@ -113,21 +101,12 @@ class CreateField extends CreateFieldOrGetter {

_fieldName = parameter.name.lexeme;

var targetLocation = utils.prepareNewFieldLocation(targetClassNode);
if (targetLocation == null) {
return;
}

//
// Add proposal.
//
await builder.addDartFileEdit(file, (builder) {
var fieldType = parameter.type?.type;
builder.addInsertion(targetLocation.offset, (builder) {
builder.write(targetLocation.prefix);
builder.addFieldInsertion(targetClassNode, (builder) {
builder.writeFieldDeclaration(_fieldName,
nameGroupName: 'NAME', type: fieldType, typeGroupName: 'TYPE');
builder.write(targetLocation.suffix);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,28 +209,19 @@ class CreateGetter extends CreateFieldOrGetter {
} else {
return;
}
// prepare location
var resolvedUnit = targetDeclarationResult.resolvedUnit;
if (resolvedUnit == null) {
return;
}
var targetLocation =
CorrectionUtils(resolvedUnit).prepareNewGetterLocation(targetNode);
if (targetLocation == null) {
return;
}
// build method source
// Build method source.
var targetFile = targetSource.fullName;
await builder.addDartFileEdit(targetFile, (builder) {
builder.addInsertion(targetLocation.offset, (builder) {
builder.write(targetLocation.prefix);
builder.writeGetterDeclaration(_getterName,
isStatic: staticModifier,
nameGroupName: 'NAME',
returnType: fieldType ?? typeProvider.dynamicType,
returnTypeGroupName: 'TYPE');
builder.write(targetLocation.suffix);
});
builder.addGetterInsertion(
targetNode,
(builder) {
builder.writeGetterDeclaration(_getterName,
isStatic: staticModifier,
nameGroupName: 'NAME',
returnType: fieldType ?? typeProvider.dynamicType,
returnTypeGroupName: 'TYPE');
},
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,22 @@ class CreateSetter extends ResolvedCorrectionProducer {
} else {
return;
}
// prepare location
var targetUnit = targetDeclarationResult.resolvedUnit;
if (targetUnit == null) {
return;
}
var targetLocation = CorrectionUtils(targetUnit)
.prepareNewGetterLocation(targetNode); // Rename to "AccessorLocation"
if (targetLocation == null) {
return;
}
// build method source
// Build setter source.
var targetFile = targetSource.fullName;
_setterName = nameNode.name;
await builder.addDartFileEdit(targetFile, (builder) {
builder.addInsertion(targetLocation.offset, (builder) {
var parameterTypeNode = climbPropertyAccess(nameNode);
var parameterType = inferUndefinedExpressionType(parameterTypeNode);
builder.write(targetLocation.prefix);
builder.writeSetterDeclaration(_setterName,
isStatic: staticModifier,
nameGroupName: 'NAME',
parameterType: parameterType,
parameterTypeGroupName: 'TYPE');
builder.write(targetLocation.suffix);
});
builder.addGetterInsertion(
targetNode,
(builder) {
var parameterTypeNode = climbPropertyAccess(nameNode);
var parameterType = inferUndefinedExpressionType(parameterTypeNode);
builder.writeSetterDeclaration(_setterName,
isStatic: staticModifier,
nameGroupName: 'NAME',
parameterType: parameterType,
parameterTypeGroupName: 'TYPE');
},
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,10 @@ LintCode.type_literal_in_constant_pattern:
status: hasFix
LintCode.unawaited_futures:
status: hasFix
LintCode.unintended_html_in_doc_comment:
status: needsFix
notes: |-
The fix is to encode the angle brackets.
LintCode.unnecessary_await_in_return:
status: needsFix
notes: |-
Expand Down
16 changes: 0 additions & 16 deletions pkg/analysis_server/lib/src/services/correction/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -966,22 +966,6 @@ final class CorrectionUtils {
return prepareNewClassMemberLocation(classDeclaration, shouldSkip);
}

InsertionLocation? prepareNewFieldLocation(
CompilationUnitMember declaration) {
return prepareNewClassMemberLocation(
declaration, (member) => member is FieldDeclaration);
}

InsertionLocation? prepareNewGetterLocation(
CompilationUnitMember declaration) {
return prepareNewClassMemberLocation(
declaration,
(member) =>
member is FieldDeclaration ||
member is ConstructorDeclaration ||
member is MethodDeclaration && member.isGetter);
}

InsertionLocation? prepareNewMethodLocation(
CompilationUnitMember declaration) {
return prepareNewClassMemberLocation(
Expand Down
Loading

0 comments on commit 2b5233d

Please sign in to comment.