Skip to content

Commit

Permalink
CQ. Remove unnecessary 'async' where no 'await'.
Browse files Browse the repository at this point in the history
Change-Id: I58f56c098c9cec753325ab56d0aad37e1fde0ec6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403082
Reviewed-by: Samuel Rawlins <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Jan 7, 2025
1 parent 9b9f7c2 commit a546836
Show file tree
Hide file tree
Showing 63 changed files with 119 additions and 124 deletions.
2 changes: 1 addition & 1 deletion pkg/analysis_server/benchmark/integration/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Driver extends IntegrationTest {
/// Launch the analysis server.
///
/// Return a [Future] that completes when analysis server has started.
Future<void> startServer() async {
Future<void> startServer() {
logger.log(Level.FINE, 'starting server');
server = Server();
var serverConnected = Completer<void>();
Expand Down
4 changes: 2 additions & 2 deletions pkg/analysis_server/lib/src/cider/completion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class CiderCompletionComputer {
required int column,
@visibleForTesting
void Function(ResolvedForCompletionResultImpl)? testResolvedUnit,
}) async {
}) {
return _performanceRoot.runAsync('completion', (performance) async {
var resolvedUnit = await performance.runAsync('resolution', (
performance,
) async {
) {
return _fileResolver.resolveForCompletion(
completionLine: line,
completionColumn: column,
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/context_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class ContextManagerImpl implements ContextManager {
/// rebuild will occur only once it has exited.
///
/// Returns a [Future] that completes once the requested rebuild completes.
Future<void> _createAnalysisContexts() async {
Future<void> _createAnalysisContexts() {
/// A helper that performs a context rebuild while monitoring the included
/// paths for changes until the contexts file watchers are ready.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CodeActionHandler
CodeActionParams params,
MessageInfo message,
CancellationToken token,
) async {
) {
var performance = message.performance;

var textDocument = params.textDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abstract class AbstractSemanticTokensHandler<T>
TextDocumentIdentifier textDocument,
CancellationToken token, {
Range? range,
}) async {
}) {
var path = pathOfDoc(textDocument);

return path.mapResult((path) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ abstract class TemporaryOverlayOperation {
/// temporary overlays and re-enabled after the overlays are restored.
Future<T> lockRequestsWithTemporaryOverlays<T>(
Future<T> Function() operation,
) async {
) {
return server.lockRequestsWhile(() async {
// Wait for any in-progress analysis to complete before we start
// suppressing analysis results.
Expand Down
4 changes: 1 addition & 3 deletions pkg/analysis_server/lib/src/search/element_references.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ class ElementReferencesComputer {
}

/// Returns a [Future] completing with a [List] of references to [element].
Future<List<SearchMatch>> _findSingleElementReferences(
Element2 element,
) async {
Future<List<SearchMatch>> _findSingleElementReferences(Element2 element) {
return searchEngine.searchReferences(element);
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/server/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ class Driver implements ServerStarter {

capture(instrumentationService, () {
var stdioServer = LspStdioAnalysisServer(socketServer);
stdioServer.serveStdio().then((_) async {
stdioServer.serveStdio().then((_) {
// Only shutdown the server and exit if the server is not already
// handling the shutdown.
if (!socketServer.analysisServer!.willExit) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/server/http_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class HttpAnalysisServer {

/// Attach a listener to a newly created HTTP server.
void _handleServer(HttpServer httpServer) {
httpServer.listen((HttpRequest request) async {
httpServer.listen((HttpRequest request) {
var updateValues = request.headers[HttpHeaders.upgradeHeader];
if (request.method == 'GET') {
_httpHandler.handleGetRequest(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandAssert(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(kind, processor.findAssertExpression, (expr) {
return 'assert(${processor.utils.getNodeText(expr)});';
}, withBraces: false);
Expand All @@ -142,7 +142,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandElse(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findBoolExpression,
Expand All @@ -153,7 +153,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandFor(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(kind, processor.findIterableExpression, (expr) {
var value = processor.newVariable('value');
return 'for (var $value in ${processor.utils.getNodeText(expr)})';
Expand All @@ -163,7 +163,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandFori(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(kind, processor.findIntExpression, (expr) {
var index = processor.newVariable('i');
return 'for (int $index = 0; $index < ${processor.utils.getNodeText(expr)}; $index++)';
Expand All @@ -173,7 +173,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandIf(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findBoolExpression,
Expand All @@ -184,7 +184,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandNegate(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findBoolExpression,
Expand All @@ -196,7 +196,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandNotNull(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(kind, processor.findObjectExpression, (expr) {
return expr is NullLiteral
? 'if (false)'
Expand All @@ -207,7 +207,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandNull(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(kind, processor.findObjectExpression, (expr) {
return expr is NullLiteral
? 'if (true)'
Expand All @@ -218,7 +218,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandParen(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findObjectExpression,
Expand All @@ -230,7 +230,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandReturn(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findObjectExpression,
Expand All @@ -242,7 +242,7 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandSwitch(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findObjectExpression,
Expand All @@ -253,21 +253,21 @@ abstract final class DartPostfixCompletion {
static Future<PostfixCompletion?> expandTry(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expandTry(kind, processor.findStatement);
}

static Future<PostfixCompletion?> expandTryon(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expandTry(kind, processor.findStatement, withOn: true);
}

static Future<PostfixCompletion?> expandWhile(
PostfixCompletionProcessor processor,
PostfixCompletionKind kind,
) async {
) {
return processor.expand(
kind,
processor.findBoolExpression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ class IterativeBulkFixProcessor {
OperationPerformanceImpl performance,
String path, {
required bool autoTriggered,
}) async {
}) {
return performance.runAsync('IterativeBulkFixProcessor.fixErrorsForFile', (
performance,
) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ abstract class _RemoveConst extends ParsedCorrectionProducer {
if (constKeyword != null) {
switch (constantContext.$1) {
case InstanceCreationExpression contextNode:
await builder.addDartFileEdit(file, (builder) async {
await builder.addDartFileEdit(file, (builder) {
_deleteToken(builder, constKeyword);
contextNode.accept(_PushConstVisitor(builder, expression));
});
case TypedLiteral contextNode:
await builder.addDartFileEdit(file, (builder) async {
await builder.addDartFileEdit(file, (builder) {
_deleteToken(builder, constKeyword);
contextNode.accept(_PushConstVisitor(builder, expression));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DtdServices {
IncomingMessage message,
OperationPerformanceImpl performance,
Completer<Map<String, Object?>> completer,
Completer<void> schedulerCompleter,
Completer<void> schedulerCompleter,
) async {
var info = MessageInfo(
performance: performance,
Expand Down Expand Up @@ -189,7 +189,7 @@ class DtdServices {
Method method,
Parameters params,
OperationPerformanceImpl performance,
) async {
) {
// Map the incoming request into types we use for LSP request handling.
var message = IncomingMessage(
jsonrpc: jsonRpcVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Availability analyzeAvailability({

/// Continues analysis of the selection in [available], and returns either
/// a [ValidSelectionState], or one of [ErrorSelectionState] subtypes.
Future<SelectionState> analyzeSelection({required Available available}) async {
Future<SelectionState> analyzeSelection({required Available available}) {
return _SelectionAnalyzer(available: available).analyze();
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/analysis/get_signature_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AnalysisSignatureTest extends PubPackageAnalysisServerTest {
return prepareRawSignatureAt(offset);
}

Future<Response> prepareRawSignatureAt(int offset, {String? file}) async {
Future<Response> prepareRawSignatureAt(int offset, {String? file}) {
var request = AnalysisGetSignatureParams(
file ?? testFile.path,
offset,
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/domain_completion_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ completion: Test
String content, {
required String completion,
required String libraryUri,
}) async {
}) {
return _getCodeDetails(
path: convertPath(testFilePath),
content: content,
Expand Down
6 changes: 3 additions & 3 deletions pkg/analysis_server/test/edit/refactoring_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ class GetAvailableRefactoringsTest extends PubPackageAnalysisServerTest {
}

/// Tests that there is a RENAME refactoring available at the [search] offset.
Future<void> assertHasRenameRefactoring(String code, String search) async {
Future<void> assertHasRenameRefactoring(String code, String search) {
return assertHasKind(code, search, RefactoringKind.RENAME, true);
}

Expand Down Expand Up @@ -1516,7 +1516,7 @@ import 'dart:math';
import 'original_folder/file.dart';
''');
_setOptions('$testPackageLibPath/new_folder');
return assertEmptySuccessfulRefactoring(() async {
return assertEmptySuccessfulRefactoring(() {
return _sendAndCancelMoveRequest(
getFolder('$testPackageLibPath/original_folder').path,
);
Expand All @@ -1531,7 +1531,7 @@ import 'original_folder/file.dart';
''');
_setOptions('$testPackageLibPath/new_folder');
return assertSuccessfulRefactoring(
() async {
() {
return _sendMoveRequest(
getFolder('$testPackageLibPath/original_folder').path,
);
Expand Down
10 changes: 5 additions & 5 deletions pkg/analysis_server/test/edit/sort_members_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class C {}
''');
}

Future<void> test_OK_classMembers_method() async {
Future<void> test_OK_classMembers_method() {
addTestFile('''
class A {
c() {}
Expand All @@ -126,7 +126,7 @@ class A {
''');
}

Future<void> test_OK_directives() async {
Future<void> test_OK_directives() {
addTestFile('''
library lib;
Expand Down Expand Up @@ -177,7 +177,7 @@ void f() {
''');
}

Future<void> test_OK_directives_withAnnotation() async {
Future<void> test_OK_directives_withAnnotation() {
addTestFile('''
library lib;
Expand Down Expand Up @@ -211,7 +211,7 @@ class MyAnnotation {
''');
}

Future<void> test_OK_genericFunctionType() async {
Future<void> test_OK_genericFunctionType() {
addTestFile('''
class C {
void caller() {
Expand Down Expand Up @@ -278,7 +278,7 @@ class Z {
''');
}

Future<void> test_OK_unitMembers_class() async {
Future<void> test_OK_unitMembers_class() {
addTestFile('''
class C {}
class A {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void f() {
Matcher? parameter = isNull,
}) {
var offset = text.indexOf(target);
return sendAnalysisGetHover(pathname, offset).then((result) async {
return sendAnalysisGetHover(pathname, offset).then((result) {
expect(result.hovers, hasLength(1));
var info = result.hovers[0];
expect(info.offset, equals(offset));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void f() {

// Respond to any applyEdit requests from the server with successful responses
// and capturing the last edit.
requestsFromServer.listen((request) async {
requestsFromServer.listen((request) {
if (request.method == Method.workspace_applyEdit) {
ApplyWorkspaceEditParams.fromJson(
request.params as Map<String, Object?>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void newMethod() {
// Respond to any applyEdit requests from the server with successful responses
// and capturing the last edit.
late WorkspaceEdit edit;
requestsFromServer.listen((request) async {
requestsFromServer.listen((request) {
if (request.method == Method.workspace_applyEdit) {
var params = ApplyWorkspaceEditParams.fromJson(
request.params as Map<String, Object?>,
Expand Down
Loading

0 comments on commit a546836

Please sign in to comment.