Version 2.18.0-90.0.dev
Merge commit '838b68914fecd0df3feb40c79e02856d0233a53c' into 'dev'
diff --git a/DEPS b/DEPS
index 4d99350..e12bacc 100644
--- a/DEPS
+++ b/DEPS
@@ -125,7 +125,7 @@
"linter_rev": "14c916a16e78315e212cf79e7ccf4c19159a1bda",
"lints_rev": "8294e5648ab49474541527e2911e72e4c5aefe55",
"logging_rev": "dfbe88b890c3b4f7bc06da5a7b3b43e9e263b688",
- "markdown_rev": "5699cafa9ef004875fd7de8ae9ea00e5295e87a4", # 5.0.0
+ "markdown_rev": "7479783f0493f6717e1d7ae31cb37d39a91026b2",
"markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
"matcher_rev": "07595a7739d47a8315caba5a8e58fb9ae3d81261",
"mime_rev": "c2c5ffd594674f32dc277521369da1557a1622d3",
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart
index 87c6f3b..5b4d3b1 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart
@@ -285,3 +285,14 @@
abstract class ToJsonable {
Object toJson();
}
+
+extension IncomingMessageExtension on IncomingMessage {
+ /// Returns the amount of time (in milliseconds) since the client sent this
+ /// request or `null` if the client did not provide [clientRequestTime].
+ int? get timeSinceRequest {
+ var clientRequestTime = this.clientRequestTime;
+ return clientRequestTime != null
+ ? DateTime.now().millisecondsSinceEpoch - clientRequestTime
+ : null;
+ }
+}
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index 306c6e0..1669d7b 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -14,6 +14,8 @@
import 'package:analysis_server/src/plugin/plugin_watcher.dart';
import 'package:analysis_server/src/server/crash_reporting_attachments.dart';
import 'package:analysis_server/src/server/diagnostic_server.dart';
+import 'package:analysis_server/src/server/performance.dart';
+import 'package:analysis_server/src/services/completion/completion_performance.dart';
import 'package:analysis_server/src/services/completion/dart/documentation_cache.dart';
import 'package:analysis_server/src/services/correction/namespace.dart';
import 'package:analysis_server/src/services/pub/pub_api.dart';
@@ -124,6 +126,9 @@
/// Performance information before initial analysis is complete.
final ServerPerformance performanceDuringStartup = ServerPerformance();
+ /// Performance about recent requests.
+ final ServerRecentPerformance recentPerformance = ServerRecentPerformance();
+
RequestStatisticsHelper? requestStatistics;
PerformanceLog? analysisPerformanceLogger;
@@ -543,3 +548,18 @@
return null;
}
}
+
+class ServerRecentPerformance {
+ /// The maximum number of performance measurements to keep.
+ static const int performanceListMaxLength = 50;
+
+ /// A list of code completion performance measurements for the latest
+ /// completion operation up to [performanceListMaxLength] measurements.
+ final RecentBuffer<CompletionPerformance> completion =
+ RecentBuffer<CompletionPerformance>(performanceListMaxLength);
+
+ /// A [RecentBuffer] for performance information about the most recent
+ /// requests.
+ final RecentBuffer<RequestPerformance> requests =
+ RecentBuffer(performanceListMaxLength);
+}
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart
index ecba1d8..570ccb6 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart
@@ -93,13 +93,13 @@
}
final completionPerformance = CompletionPerformance(
- operation: performance,
+ performance: performance,
path: file,
requestLatency: requestLatency,
content: resolvedUnit.content,
offset: offset,
);
- server.completionState.performanceList.add(completionPerformance);
+ server.recentPerformance.completion.add(completionPerformance);
var declarationsTracker = server.declarationsTracker;
if (declarationsTracker == null) {
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
index 5b84755..fd4f85c 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
@@ -176,13 +176,13 @@
}
final completionPerformance = CompletionPerformance(
- operation: performance,
+ performance: performance,
path: file,
requestLatency: requestLatency,
content: resolvedUnit.content,
offset: offset,
);
- server.completionState.performanceList.add(completionPerformance);
+ server.recentPerformance.completion.add(completionPerformance);
var analysisSession = resolvedUnit.analysisSession;
var enclosingNode =
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
index c4b32d4..62dfcd7 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart
@@ -115,14 +115,14 @@
'request',
(performance) async {
final thisPerformance = CompletionPerformance(
- operation: performance,
+ performance: performance,
path: result.path,
requestLatency: requestLatency,
content: result.content,
offset: offset,
);
completionPerformance = thisPerformance;
- server.performanceStats.completion.add(thisPerformance);
+ server.recentPerformance.completion.add(thisPerformance);
// `await` required for `performance.runAsync` to count time.
return await _getServerDartItems(
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
index 4142d81..2751311 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
@@ -183,7 +183,7 @@
final params =
paramsJson != null ? jsonHandler.convertParams(paramsJson) : null as P;
- final messageInfo = MessageInfo(message.clientRequestTime);
+ final messageInfo = MessageInfo(timeSinceRequest: message.timeSinceRequest);
return handle(params, messageInfo, token);
}
}
@@ -191,18 +191,11 @@
/// Additional information about an incoming message (request or notification)
/// provided to a handler.
class MessageInfo {
- final int? clientRequestTime;
-
- MessageInfo(this.clientRequestTime);
-
/// Returns the amount of time (in milliseconds) since the client sent this
/// request or `null` if the client did not provide [clientRequestTime].
- int? get timeSinceRequest {
- var clientRequestTime = this.clientRequestTime;
- return clientRequestTime != null
- ? DateTime.now().millisecondsSinceEpoch - clientRequestTime
- : null;
- }
+ final int? timeSinceRequest;
+
+ MessageInfo({this.timeSinceRequest});
}
/// A message handler that handles all messages for a given server state.
diff --git a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
index 7617056..fe24db5 100644
--- a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
+++ b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
@@ -9,7 +9,6 @@
import 'package:analysis_server/lsp_protocol/protocol_special.dart';
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/analysis_server_abstract.dart';
-import 'package:analysis_server/src/collections.dart';
import 'package:analysis_server/src/computer/computer_closingLabels.dart';
import 'package:analysis_server/src/computer/computer_outline.dart';
import 'package:analysis_server/src/context_manager.dart';
@@ -30,9 +29,7 @@
import 'package:analysis_server/src/server/crash_reporting_attachments.dart';
import 'package:analysis_server/src/server/diagnostic_server.dart';
import 'package:analysis_server/src/server/error_notifier.dart';
-import 'package:analysis_server/src/services/completion/completion_performance.dart'
- show CompletionPerformance;
-import 'package:analysis_server/src/services/completion/completion_state.dart';
+import 'package:analysis_server/src/server/performance.dart';
import 'package:analysis_server/src/services/refactoring/refactoring.dart';
import 'package:analysis_server/src/utilities/process.dart';
import 'package:analyzer/dart/analysis/context_locator.dart';
@@ -47,6 +44,7 @@
import 'package:analyzer/src/dart/analysis/status.dart' as analysis;
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
+import 'package:analyzer/src/util/performance/operation_performance.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
@@ -99,8 +97,6 @@
ServerCapabilities? capabilities;
late ServerCapabilitiesComputer capabilitiesComputer;
- LspPerformance performanceStats = LspPerformance();
-
/// Whether or not the server is controlling the shutdown and will exit
/// automatically.
bool willExit = false;
@@ -355,15 +351,25 @@
if (message is ResponseMessage) {
handleClientResponse(message);
} else if (message is RequestMessage) {
- final result = await messageHandler.handleMessage(message);
- if (result.isError) {
- sendErrorResponse(message, result.error);
- } else {
- channel.sendResponse(ResponseMessage(
- id: message.id,
- result: result.result,
- jsonrpc: jsonRpcVersion));
- }
+ // Record performance information for the request.
+ final performance = OperationPerformanceImpl('<root>');
+ await performance.runAsync('request', (performance) async {
+ final requestPerformance = RequestPerformance(
+ operation: message.method.toString(),
+ performance: performance,
+ requestLatency: message.timeSinceRequest,
+ );
+ recentPerformance.requests.add(requestPerformance);
+ final result = await messageHandler.handleMessage(message);
+ if (result.isError) {
+ sendErrorResponse(message, result.error);
+ } else {
+ channel.sendResponse(ResponseMessage(
+ id: message.id,
+ result: result.result,
+ jsonrpc: jsonRpcVersion));
+ }
+ });
} else if (message is NotificationMessage) {
final result = await messageHandler.handleMessage(message);
if (result.isError) {
@@ -857,14 +863,6 @@
flutterOutline = options != null && options['flutterOutline'] == true;
}
-class LspPerformance {
- /// A list of code completion performance measurements for the latest
- /// completion operation up to [performanceListMaxLength] measurements.
- final RecentBuffer<CompletionPerformance> completion =
- RecentBuffer<CompletionPerformance>(
- CompletionState.performanceListMaxLength);
-}
-
class LspServerContextManagerCallbacks extends ContextManagerCallbacks {
// TODO(dantup): Lots of copy/paste from the Analysis Server one here.
diff --git a/pkg/analysis_server/lib/src/server/performance.dart b/pkg/analysis_server/lib/src/server/performance.dart
new file mode 100644
index 0000000..9f3a12b
--- /dev/null
+++ b/pkg/analysis_server/lib/src/server/performance.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/util/performance/operation_performance.dart';
+
+class RequestPerformance {
+ static var _nextId = 1;
+ final int id;
+ final OperationPerformance performance;
+ final int? requestLatency;
+ final String operation;
+
+ RequestPerformance({
+ required this.operation,
+ required this.performance,
+ this.requestLatency,
+ }) : id = _nextId++;
+}
diff --git a/pkg/analysis_server/lib/src/services/completion/completion_performance.dart b/pkg/analysis_server/lib/src/services/completion/completion_performance.dart
index 0988854..1a1eca5 100644
--- a/pkg/analysis_server/lib/src/services/completion/completion_performance.dart
+++ b/pkg/analysis_server/lib/src/services/completion/completion_performance.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/src/util/performance/operation_performance.dart';
+import 'package:analysis_server/src/server/performance.dart';
/// Compute a string representing a code completion operation at the
/// given source and location.
@@ -34,24 +34,20 @@
}
/// Overall performance of a code completion operation.
-class CompletionPerformance {
- static var _nextId = 1;
- final int id;
- final OperationPerformance operation;
+class CompletionPerformance extends RequestPerformance {
final String path;
final String snippet;
- final int? requestLatency;
int? computedSuggestionCount;
int? transmittedSuggestionCount;
CompletionPerformance({
- required this.operation,
+ required super.performance,
required this.path,
- this.requestLatency,
+ super.requestLatency,
required String content,
required int offset,
- }) : id = _nextId++,
- snippet = _computeCompletionSnippet(content, offset);
+ }) : snippet = _computeCompletionSnippet(content, offset),
+ super(operation: 'Completion');
String get computedSuggestionCountStr {
if (computedSuggestionCount == null) return '';
@@ -59,7 +55,7 @@
}
int get elapsedInMilliseconds {
- return operation.elapsed.inMilliseconds;
+ return performance.elapsed.inMilliseconds;
}
String get transmittedSuggestionCountStr {
diff --git a/pkg/analysis_server/lib/src/services/completion/completion_state.dart b/pkg/analysis_server/lib/src/services/completion/completion_state.dart
index ad3b85c..2af5830 100644
--- a/pkg/analysis_server/lib/src/services/completion/completion_state.dart
+++ b/pkg/analysis_server/lib/src/services/completion/completion_state.dart
@@ -3,14 +3,9 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/protocol/protocol_generated.dart';
-import 'package:analysis_server/src/collections.dart';
-import 'package:analysis_server/src/services/completion/completion_performance.dart';
import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
class CompletionState {
- /// The maximum number of performance measurements to keep.
- static const int performanceListMaxLength = 50;
-
/// The time budget for a completion request.
Duration budgetDuration = CompletionBudget.defaultDuration;
@@ -20,11 +15,6 @@
/// The next completion response id.
int nextCompletionId = 0;
- /// A list of code completion performance measurements for the latest
- /// completion operation up to [performanceListMaxLength] measurements.
- final RecentBuffer<CompletionPerformance> performanceList =
- RecentBuffer<CompletionPerformance>(performanceListMaxLength);
-
/// The current request being processed or `null` if none.
DartCompletionRequest? currentRequest;
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
index 0996659..6fd8abf 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
@@ -824,7 +824,18 @@
@override
DartType? visitListLiteral(ListLiteral node) {
if (range.endStart(node.leftBracket, node.rightBracket).contains(offset)) {
- return (node.staticType as InterfaceType).typeArguments[0];
+ final type = node.staticType;
+ // TODO(scheglov) https://github.com/dart-lang/sdk/issues/48965
+ if (type == null) {
+ throw '''
+No type.
+node: $node
+parent: ${node.parent}
+parent2: ${node.parent?.parent}
+parent3: ${node.parent?.parent?.parent}
+''';
+ }
+ return (type as InterfaceType).typeArguments[0];
}
return null;
}
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index 03c6ddd..10c6d66 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -14,6 +14,7 @@
show LspAnalysisServer;
import 'package:analysis_server/src/plugin/plugin_manager.dart';
import 'package:analysis_server/src/server/http_server.dart';
+import 'package:analysis_server/src/server/performance.dart';
import 'package:analysis_server/src/services/completion/completion_performance.dart';
import 'package:analysis_server/src/socket_server.dart';
import 'package:analysis_server/src/status/ast_writer.dart';
@@ -156,136 +157,6 @@
return '$name: <code>$value</code><br> ';
}
-abstract class AbstractCompletionPage extends DiagnosticPageWithNav {
- AbstractCompletionPage(DiagnosticsSite site)
- : super(site, 'completion', 'Code Completion',
- description: 'Latency statistics for code completion.');
-
- path.Context get pathContext;
-
- List<CompletionPerformance> get performanceItems;
-
- @override
- Future generateContent(Map<String, String> params) async {
- var completions = performanceItems;
-
- if (completions.isEmpty) {
- blankslate('No completions recorded.');
- return;
- }
-
- var fastCount =
- completions.where((c) => c.elapsedInMilliseconds <= 100).length;
- p('${completions.length} results; ${printPercentage(fastCount / completions.length)} within 100ms.');
-
- // draw a chart
- buf.writeln(
- '<div id="chart-div" style="width: 700px; height: 300px;"></div>');
- var rowData = StringBuffer();
- for (var i = completions.length - 1; i >= 0; i--) {
- if (rowData.isNotEmpty) {
- rowData.write(',');
- }
- var latency = completions[i].requestLatency ?? 0;
- var completionTime = completions[i].elapsedInMilliseconds;
- // label, latency, time
- // [' ', 21.0, 101.5]
- rowData.write("[' ', $latency, $completionTime]");
- }
- buf.writeln('''
- <script type="text/javascript">
- google.charts.load('current', {'packages':['bar']});
- google.charts.setOnLoadCallback(drawChart);
- function drawChart() {
- var data = google.visualization.arrayToDataTable([
- [ 'Completion', 'Latency', 'Time' ],
- $rowData
- ]);
- var options = {
- bars: 'vertical',
- vAxis: {format: 'decimal'},
- height: 300,
- isStacked: true,
- series: {
- 0: { color: '#C0C0C0' },
- 1: { color: '#4285f4' },
- }
- };
- var chart = new google.charts.Bar(document.getElementById('chart-div'));
- chart.draw(data, google.charts.Bar.convertOptions(options));
- }
- </script>
-''');
-
- // emit the data as a table
- buf.writeln('<table>');
- buf.writeln(
- '<tr><th>Time</th><th>Computed Results</th><th>Transmitted Results</th><th>Source</th><th>Snippet</th></tr>');
- for (var completion in completions) {
- var shortName = pathContext.basename(completion.path);
- buf.writeln('<tr>'
- '<td class="pre right"><a href="/timing?id=${completion.id}">'
- '${_formatTiming(completion)}'
- '</a></td>'
- '<td class="right">${completion.computedSuggestionCountStr}</td>'
- '<td class="right">${completion.transmittedSuggestionCountStr}</td>'
- '<td>${escape(shortName)}</td>'
- '<td><code>${escape(completion.snippet)}</code></td>'
- '</tr>');
- }
- buf.writeln('</table>');
- }
-
- String _formatTiming(CompletionPerformance completion) {
- var buffer = StringBuffer();
- buffer.write(printMilliseconds(completion.elapsedInMilliseconds));
-
- var latency = completion.requestLatency;
- if (latency != null) {
- buffer
- ..write(' <small class="subtle" title="client-to-server latency">(+ ')
- ..write(printMilliseconds(latency))
- ..write(')</small>');
- }
-
- return buffer.toString();
- }
-}
-
-abstract class AbstractCompletionTimingPage extends DiagnosticPageWithNav {
- AbstractCompletionTimingPage(DiagnosticsSite site)
- : super(site, 'timing', 'Timing', description: 'Timing statistics.');
-
- path.Context get pathContext;
-
- List<CompletionPerformance> get performanceItems;
-
- @override
- bool get showInNav => false;
-
- @override
- Future generateContent(Map<String, String> params) async {
- var id = int.parse(params['id'] ?? '');
- var completionInfo =
- performanceItems.firstWhereOrNull((info) => info.id == id);
-
- if (completionInfo == null) {
- blankslate('Unable to find completion data for $id. '
- 'Perhaps newer completion requests have pushed it out of the buffer?');
- return;
- }
-
- var buffer = StringBuffer();
- completionInfo.operation.write(buffer: buffer);
- pre(() {
- buf.write('<code>');
- buf.write(escape('$buffer'));
- buf.writeln('</code>');
- });
- return;
- }
-}
-
class AstPage extends DiagnosticPageWithNav {
String? _description;
@@ -416,32 +287,66 @@
}
}
-class CompletionPage extends AbstractCompletionPage {
- @override
- AnalysisServer server;
+class CompletionPage extends DiagnosticPageWithNav with PerformanceChartMixin {
+ CompletionPage(DiagnosticsSite site)
+ : super(site, 'completion', 'Code Completion',
+ description: 'Latency statistics for code completion.');
- CompletionPage(super.site, this.server);
-
- @override
path.Context get pathContext => server.resourceProvider.pathContext;
- @override
List<CompletionPerformance> get performanceItems =>
- server.completionState.performanceList.items.toList();
-}
-
-class CompletionTimingPage extends AbstractCompletionTimingPage {
- @override
- AnalysisServer server;
-
- CompletionTimingPage(super.site, this.server);
+ server.recentPerformance.completion.items.toList();
@override
- path.Context get pathContext => server.resourceProvider.pathContext;
+ Future generateContent(Map<String, String> params) async {
+ var completions = performanceItems;
- @override
- List<CompletionPerformance> get performanceItems =>
- server.completionState.performanceList.items.toList();
+ if (completions.isEmpty) {
+ blankslate('No completions recorded.');
+ return;
+ }
+
+ var fastCount =
+ completions.where((c) => c.elapsedInMilliseconds <= 100).length;
+ p('${completions.length} results; ${printPercentage(fastCount / completions.length)} within 100ms.');
+
+ drawChart(completions);
+
+ // emit the data as a table
+ buf.writeln('<table>');
+ buf.writeln(
+ '<tr><th>Time</th><th>Computed Results</th><th>Transmitted Results</th><th>Source</th><th>Snippet</th></tr>');
+ for (var completion in completions) {
+ var shortName = pathContext.basename(completion.path);
+ buf.writeln(
+ '<tr>'
+ '<td class="pre right"><a href="/timing?id=${completion.id}&kind=completion">'
+ '${_formatTiming(completion)}'
+ '</a></td>'
+ '<td class="right">${completion.computedSuggestionCountStr}</td>'
+ '<td class="right">${completion.transmittedSuggestionCountStr}</td>'
+ '<td>${escape(shortName)}</td>'
+ '<td><code>${escape(completion.snippet)}</code></td>'
+ '</tr>',
+ );
+ }
+ buf.writeln('</table>');
+ }
+
+ String _formatTiming(CompletionPerformance completion) {
+ var buffer = StringBuffer();
+ buffer.write(printMilliseconds(completion.elapsedInMilliseconds));
+
+ var latency = completion.requestLatency;
+ if (latency != null) {
+ buffer
+ ..write(' <small class="subtle" title="client-to-server latency">(+ ')
+ ..write(printMilliseconds(latency))
+ ..write(')</small>');
+ }
+
+ return buffer.toString();
+ }
}
class ContentsPage extends DiagnosticPageWithNav {
@@ -844,15 +749,13 @@
if (server != null) {
pages.add(PluginsPage(this, server));
}
+ pages.add(CompletionPage(this));
if (server is AnalysisServer) {
- pages.add(CompletionPage(this, server));
- pages.add(CompletionTimingPage(this, server));
pages.add(SubscriptionsPage(this, server));
} else if (server is LspAnalysisServer) {
- pages.add(LspCompletionPage(this, server));
- pages.add(LspCompletionTimingPage(this, server));
pages.add(LspCapabilitiesPage(this, server));
}
+ pages.add(TimingPage(this));
var profiler = ProcessProfiler.getProfilerForPlatform();
if (profiler != null) {
@@ -1110,34 +1013,6 @@
// }
// }
-class LspCompletionPage extends AbstractCompletionPage {
- @override
- LspAnalysisServer server;
-
- LspCompletionPage(super.site, this.server);
-
- @override
- path.Context get pathContext => server.resourceProvider.pathContext;
-
- @override
- List<CompletionPerformance> get performanceItems =>
- server.performanceStats.completion.items.toList();
-}
-
-class LspCompletionTimingPage extends AbstractCompletionTimingPage {
- @override
- LspAnalysisServer server;
-
- LspCompletionTimingPage(super.site, this.server);
-
- @override
- path.Context get pathContext => server.resourceProvider.pathContext;
-
- @override
- List<CompletionPerformance> get performanceItems =>
- server.performanceStats.completion.items.toList();
-}
-
class MemoryAndCpuPage extends DiagnosticPageWithNav {
final ProcessProfiler profiler;
@@ -1255,7 +1130,7 @@
var requestName = entry.key;
var data = entry.value;
// TODO(brianwilkerson) Consider displaying these times as a graph,
- // similar to the one in AbstractCompletionPage.generateContent.
+ // similar to the one in CompletionPage.generateContent.
var buffer = StringBuffer();
buffer.write(requestName);
buffer.write(' ');
@@ -1356,3 +1231,84 @@
});
}
}
+
+class TimingPage extends DiagnosticPageWithNav with PerformanceChartMixin {
+ TimingPage(DiagnosticsSite site)
+ : super(site, 'timing', 'Timing', description: 'Timing statistics.');
+
+ @override
+ Future generateContent(Map<String, String> params) async {
+ var kind = params['kind'];
+
+ List<RequestPerformance> items;
+ if (kind == 'completion') {
+ items = server.recentPerformance.completion.items.toList();
+ } else {
+ items = server.recentPerformance.requests.items.toList();
+ }
+
+ var id = int.tryParse(params['id'] ?? '');
+ if (id == null) {
+ return _generateList(items);
+ } else {
+ return _generateDetails(id, items);
+ }
+ }
+
+ String _formatTiming(RequestPerformance item) {
+ var buffer = StringBuffer();
+ buffer.write(printMilliseconds(item.performance.elapsed.inMilliseconds));
+
+ var latency = item.requestLatency;
+ if (latency != null) {
+ buffer
+ ..write(' <small class="subtle" title="client-to-server latency">(+ ')
+ ..write(printMilliseconds(latency))
+ ..write(')</small>');
+ }
+
+ return buffer.toString();
+ }
+
+ void _generateDetails(int id, List<RequestPerformance> items) {
+ var item = items.firstWhereOrNull((info) => info.id == id);
+
+ if (item == null) {
+ blankslate('Unable to find data for $id. '
+ 'Perhaps newer requests have pushed it out of the buffer?');
+ return;
+ }
+
+ var buffer = StringBuffer();
+ item.performance.write(buffer: buffer);
+ pre(() {
+ buf.write('<code>');
+ buf.write(escape('$buffer'));
+ buf.writeln('</code>');
+ });
+ }
+
+ void _generateList(List<RequestPerformance> items) {
+ if (items.isEmpty) {
+ blankslate('No requests recorded.');
+ return;
+ }
+
+ drawChart(items);
+
+ // emit the data as a table
+ buf.writeln('<table>');
+ buf.writeln('<tr><th>Time</th><th>Request</th></tr>');
+ for (var item in items) {
+ buf.writeln(
+ '<tr>'
+ '<td class="pre right"><a href="/timing?id=${item.id}">'
+ '${_formatTiming(item)}'
+ '</a></td>'
+ '<td>${escape(item.operation)}</td>'
+ '</tr>',
+ );
+ }
+ buf.writeln('</table>');
+ }
+}
diff --git a/pkg/analysis_server/lib/src/status/pages.dart b/pkg/analysis_server/lib/src/status/pages.dart
index d2c6bb3..66538d6 100644
--- a/pkg/analysis_server/lib/src/status/pages.dart
+++ b/pkg/analysis_server/lib/src/status/pages.dart
@@ -5,6 +5,8 @@
import 'dart:convert';
import 'dart:io';
+import 'package:analysis_server/src/server/performance.dart';
+
String escape(String? text) => text == null ? '' : htmlEscape.convert(text);
String printMilliseconds(int value) => '$value ms';
@@ -130,6 +132,48 @@
}
}
+mixin PerformanceChartMixin on Page {
+ void drawChart(List<RequestPerformance> items) {
+ buf.writeln(
+ '<div id="chart-div" style="width: 700px; height: 300px; padding-bottom: 30px;"></div>');
+ var rowData = StringBuffer();
+ for (var i = items.length - 1; i >= 0; i--) {
+ if (rowData.isNotEmpty) {
+ rowData.write(',');
+ }
+ var latency = items[i].requestLatency ?? 0;
+ var time = items[i].performance.elapsed.inMilliseconds;
+ // label, latency, time
+ // [' ', 21.0, 101.5]
+ rowData.write("[' ', $latency, $time]");
+ }
+ buf.writeln('''
+ <script type="text/javascript">
+ google.charts.load('current', {'packages':['bar']});
+ google.charts.setOnLoadCallback(drawChart);
+ function drawChart() {
+ var data = google.visualization.arrayToDataTable([
+ [ 'Request', 'Latency', 'Time' ],
+ $rowData
+ ]);
+ var options = {
+ bars: 'vertical',
+ vAxis: {format: 'decimal'},
+ height: 300,
+ isStacked: true,
+ series: {
+ 0: { color: '#C0C0C0' },
+ 1: { color: '#4285f4' },
+ }
+ };
+ var chart = new google.charts.Bar(document.getElementById('chart-div'));
+ chart.draw(data, google.charts.Bar.convertOptions(options));
+ }
+ </script>
+''');
+ }
+}
+
/// Contains a collection of Pages.
abstract class Site {
final String title;
diff --git a/pkg/analysis_server/test/lsp/server_test.dart b/pkg/analysis_server/test/lsp/server_test.dart
index a1a3ef2..ec72020 100644
--- a/pkg/analysis_server/test/lsp/server_test.dart
+++ b/pkg/analysis_server/test/lsp/server_test.dart
@@ -36,6 +36,19 @@
expect(server.performanceDuringStartup.latencyCount, isPositive);
}
+ Future<void> test_capturesRequestPerformance() async {
+ await initialize(includeClientRequestTime: true);
+ await openFile(mainFileUri, '');
+ await expectLater(
+ getHover(mainFileUri, startOfDocPos),
+ completes,
+ );
+ final performanceItems = server.recentPerformance.requests.items;
+ final hoverItems = performanceItems.where(
+ (item) => item.operation == Method.textDocument_hover.toString());
+ expect(hoverItems, hasLength(1));
+ }
+
Future<void> test_inconsistentStateError() async {
await initialize(
// Error is expected and checked below.
diff --git a/pkg/analysis_server/test/services/completion/dart/relevance/deprecated_member_test.dart b/pkg/analysis_server/test/services/completion/dart/relevance/deprecated_member_test.dart
index 40826b7..e97f3b3 100644
--- a/pkg/analysis_server/test/services/completion/dart/relevance/deprecated_member_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/relevance/deprecated_member_test.dart
@@ -38,7 +38,7 @@
void a2() { }
}
-void main() {
+void f() {
var a = A();
a.^
}
diff --git a/pkg/analysis_server/test/services/correction/organize_directives_test.dart b/pkg/analysis_server/test/services/correction/organize_directives_test.dart
index 737ad25..686b25d 100644
--- a/pkg/analysis_server/test/services/correction/organize_directives_test.dart
+++ b/pkg/analysis_server/test/services/correction/organize_directives_test.dart
@@ -93,7 +93,7 @@
import 'dart:async' as async1;
import 'dart:async' as async2;
-main() {
+void f() {
async1.Future f;
async2.Stream s;
}''');
@@ -102,7 +102,7 @@
import 'dart:async' as async1;
import 'dart:async' as async2;
-main() {
+void f() {
async1.Future f;
async2.Stream s;
}''', removeUnused: true);
@@ -199,14 +199,14 @@
import 'dart:async';
import 'dart:async';
-main() {
+void f() {
Completer f;
}''');
// validate change
_assertOrganize(r'''
import 'dart:async';
-main() {
+void f() {
Completer f;
}''', removeUnused: true);
}
@@ -216,14 +216,14 @@
import 'dart:async' as async;
import "dart:async" as async;
-main() {
+void f() {
async.Future f;
}''');
// validate change
_assertOrganize(r'''
import 'dart:async' as async;
-main() {
+void f() {
async.Future f;
}''', removeUnused: true);
}
@@ -233,14 +233,14 @@
import 'dart:async' as async;
import 'dart:async' as async;
-main() {
+void f() {
async.Future f;
}''');
// validate change
_assertOrganize(r'''
import 'dart:async' as async;
-main() {
+void f() {
async.Future f;
}''', removeUnused: true);
}
@@ -254,7 +254,7 @@
import 'dart:convert';
import 'dart:collection';
-main() {
+void f() {
print(pi);
new HashMap();
}
@@ -266,7 +266,7 @@
import 'dart:collection';
import 'dart:math';
-main() {
+void f() {
print(pi);
new HashMap();
}
@@ -280,7 +280,7 @@
class A {}
-main() {
+void f() {
Completer f;
}''');
// validate change
@@ -289,7 +289,7 @@
class A {}
-main() {
+void f() {
Completer f;
}''', removeUnused: true);
}
@@ -304,13 +304,13 @@
_assertOrganize(code, removeUnused: true);
}
- await check('main() { Unresolved v; }');
- await check('main() { new Unresolved(); }');
- await check('main() { const Unresolved(); }');
- await check('main() { unresolvedFunction(); }');
- await check('main() { print(unresolvedVariable); }');
- await check('main() { unresolvedVariable = 0; }');
- await check('main() { Unresolved.field = 0; }');
+ await check('void f() { Unresolved v; }');
+ await check('void f() { new Unresolved(); }');
+ await check('void f() { const Unresolved(); }');
+ await check('void f() { unresolvedFunction(); }');
+ await check('void f() { print(unresolvedVariable); }');
+ await check('void f() { unresolvedVariable = 0; }');
+ await check('void f() { Unresolved.field = 0; }');
await check('class A extends Unresolved {}');
await check('List<Unresolved> v;');
}
@@ -338,7 +338,7 @@
part 'bbb/bbb.dart';
part 'aaa/aaa.dart';
-main() {
+void f() {
}
''');
// validate change
@@ -372,7 +372,7 @@
part 'aaa/aaa.dart';
part 'bbb/bbb.dart';
-main() {
+void f() {
}
''');
}
@@ -394,7 +394,7 @@
import 'a.dart'; // Trailing comment A
/** doc */
-main() {
+void f() {
}
''');
// validate change
@@ -414,7 +414,7 @@
import 'c.dart'; // Trailing comment C
/** doc */
-main() {
+void f() {
}
''');
}
@@ -433,7 +433,7 @@
import 'a.dart'; // Trailing comment A
/** doc */
-main() {
+void f() {
}
''');
// validate change
@@ -450,7 +450,7 @@
import 'c.dart'; // Trailing comment C
/** doc */
-main() {
+void f() {
}
''');
}
@@ -472,7 +472,7 @@
import 'a.dart'; // Trailing comment A
/** doc */
-main() {
+void f() {
}
''');
// validate change
@@ -492,7 +492,7 @@
import 'c.dart'; // Trailing comment C
/** doc */
-main() {
+void f() {
}
''');
}
@@ -511,7 +511,7 @@
import 'a.dart'; // Trailing comment A
/** doc */
-main() {
+void f() {
}
''');
// validate change
@@ -528,7 +528,7 @@
import 'c.dart'; // Trailing comment C
/** doc */
-main() {
+void f() {
}
''');
}
@@ -543,7 +543,7 @@
import 'b.dart';// bbb
/** doc */
-main() {
+void f() {
}
''');
// validate change
@@ -556,7 +556,7 @@
import 'c.dart';// c
/** doc */
-main() {
+void f() {
}
''');
}
diff --git a/pkg/analysis_server/test/services/correction/sort_members_test.dart b/pkg/analysis_server/test/services/correction/sort_members_test.dart
index bd2bf66..a8595c8 100644
--- a/pkg/analysis_server/test/services/correction/sort_members_test.dart
+++ b/pkg/analysis_server/test/services/correction/sort_members_test.dart
@@ -362,7 +362,7 @@
part 'bbb/bbb.dart';
part 'aaa/aaa.dart';
-main() {
+void f() {
}
''');
// validate change
@@ -396,7 +396,7 @@
part 'aaa/aaa.dart';
part 'bbb/bbb.dart';
-main() {
+void f() {
}
''');
}
diff --git a/pkg/analysis_server/test/services/correction/status_test.dart b/pkg/analysis_server/test/services/correction/status_test.dart
index 055c0e4..29af706 100644
--- a/pkg/analysis_server/test/services/correction/status_test.dart
+++ b/pkg/analysis_server/test/services/correction/status_test.dart
@@ -57,10 +57,10 @@
Future<void> test_createLocation_forNode() async {
await resolveTestCode('''
-main() {
+void f() {
}
''');
- var node = findNode.simple('main');
+ var node = findNode.simple('f');
// check
var location = newLocation_fromNode(node);
expect(location.file, testFile);
diff --git a/pkg/analysis_server/test/services/correction/util_test.dart b/pkg/analysis_server/test/services/correction/util_test.dart
index a88aa8e..1734e00 100644
--- a/pkg/analysis_server/test/services/correction/util_test.dart
+++ b/pkg/analysis_server/test/services/correction/util_test.dart
@@ -22,7 +22,7 @@
class UtilTest extends AbstractSingleUnitTest {
Future<void> assert_invertCondition(String expr, String expected) async {
await resolveTestCode('''
-main() {
+void f() {
int? v1, v2, v3, v4, v5;
bool b1 = true, b2 = true, b3 = true;
bool? b4, b5;
diff --git a/pkg/analysis_server/test/services/refactoring/convert_getter_to_method_test.dart b/pkg/analysis_server/test/services/refactoring/convert_getter_to_method_test.dart
index ee79e97..a0a8d9a 100644
--- a/pkg/analysis_server/test/services/refactoring/convert_getter_to_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/convert_getter_to_method_test.dart
@@ -45,7 +45,7 @@
Future<void> test_change_function() async {
await indexTestUnit('''
int get test => 42;
-main() {
+void f() {
var a = test;
var b = test;
}
@@ -57,7 +57,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
int test() => 42;
-main() {
+void f() {
var a = test();
var b = test();
}
@@ -144,7 +144,7 @@
Future<void> test_checkInitialConditions_syntheticGetter() async {
await indexTestUnit('''
int test = 42;
-main() {
+void f() {
}
''');
var element = findElement.topGet('test');
diff --git a/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart b/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart
index 58aea84..3c20426 100644
--- a/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/convert_method_to_getter_test.dart
@@ -24,7 +24,7 @@
Future<void> test_change_function() async {
await indexTestUnit('''
int test() => 42;
-main() {
+void f() {
var a = test();
var b = test();
}
@@ -34,7 +34,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
int get test => 42;
-main() {
+void f() {
var a = test;
var b = test;
}
@@ -121,7 +121,7 @@
Future<void> test_checkInitialConditions_alreadyGetter() async {
await indexTestUnit('''
int get test => 42;
-main() {
+void f() {
var a = test;
var b = test;
}
@@ -136,7 +136,7 @@
Future<void> test_checkInitialConditions_hasParameters() async {
await indexTestUnit('''
int test(x) => x * 2;
-main() {
+void f() {
var v = test(1);
}
''');
@@ -149,7 +149,7 @@
Future<void> test_checkInitialConditions_localFunction() async {
await indexTestUnit('''
-main() {
+void f() {
test() {}
var v = test();
}
diff --git a/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart b/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart
index 540729e..ab67627 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart
@@ -146,7 +146,7 @@
await indexTestUnit('''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
Widget foo() {
return new Row(
children: <Widget>[
@@ -163,7 +163,7 @@
await _assertSuccessfulRefactoring('''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
Widget foo() {
return new Row(
children: <Widget>[
@@ -228,7 +228,7 @@
await indexTestUnit('''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
return new Container();
}
''');
@@ -240,7 +240,7 @@
await _assertSuccessfulRefactoring('''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
return Test();
}
@@ -275,7 +275,7 @@
await indexTestUnit('''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
return new Row(
children: <Widget>[
new Text('AAA'),
@@ -289,7 +289,7 @@
await _assertSuccessfulRefactoring('''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
return new Row(
children: <Widget>[
Test(),
@@ -1127,7 +1127,7 @@
await indexTestUnit(r'''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
var index = 0;
var a = 'a $index';
// start
@@ -1146,7 +1146,7 @@
await _assertSuccessfulRefactoring(r'''
import 'package:flutter/material.dart';
-Widget main() {
+Widget f() {
var index = 0;
var a = 'a $index';
// start
@@ -1182,7 +1182,7 @@
await indexTestUnit(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
// start
// end
}
@@ -1197,7 +1197,7 @@
await indexTestUnit(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
// start
new Text('text');
// end
diff --git a/pkg/analysis_server/test/services/refactoring/inline_local_test.dart b/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
index 1285872..3f299ed 100644
--- a/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/inline_local_test.dart
@@ -23,7 +23,7 @@
Future<void> test_access() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 1 + 2;
print(test);
print(test);
@@ -39,10 +39,10 @@
Future<void> test_bad_selectionMethod() async {
await indexTestUnit(r'''
-main() {
+void f() {
}
''');
- _createRefactoring('main() {');
+ _createRefactoring('f() {');
var status = await refactoring.checkInitialConditions();
_assert_fatalError_selection(status);
}
@@ -59,7 +59,7 @@
Future<void> test_bad_selectionVariable_hasAssignments_1() async {
await indexTestUnit(r'''
-main() {
+void f() {
int test = 0;
test = 1;
}
@@ -72,7 +72,7 @@
Future<void> test_bad_selectionVariable_hasAssignments_2() async {
await indexTestUnit(r'''
-main() {
+void f() {
int test = 0;
test += 1;
}
@@ -85,7 +85,7 @@
Future<void> test_bad_selectionVariable_notInBlock() async {
await indexTestUnit(r'''
-main() {
+void f() {
if (true)
int test = 0;
}
@@ -97,7 +97,7 @@
Future<void> test_bad_selectionVariable_notInitialized() async {
await indexTestUnit(r'''
-main() {
+void f() {
int test;
}
''');
@@ -112,7 +112,7 @@
foo() {}
bar() {}
}
-main() {
+void f() {
A test = new A()..foo();
test..bar();
}
@@ -124,7 +124,7 @@
foo() {}
bar() {}
}
-main() {
+void f() {
new A()..foo()..bar();
}
''');
@@ -136,7 +136,7 @@
foo() {}
bar() {}
}
-main() {
+void f() {
A test = new A()..foo();
test.bar();
}
@@ -148,7 +148,7 @@
foo() {}
bar() {}
}
-main() {
+void f() {
(new A()..foo()).bar();
}
''');
@@ -180,7 +180,7 @@
Future<void> test_OK_intoStringInterpolation_binaryExpression() async {
await indexTestUnit(r'''
-main() {
+void f() {
int test = 1 + 2;
print('test = $test');
print('test = ${test}');
@@ -191,7 +191,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print('test = ${1 + 2}');
print('test = ${1 + 2}');
print('test = ${process(1 + 2)}');
@@ -202,7 +202,7 @@
Future<void> test_OK_intoStringInterpolation_simpleIdentifier() async {
await indexTestUnit(r'''
-main() {
+void f() {
int foo = 1 + 2;
int test = foo;
print('test = $test');
@@ -214,7 +214,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
int foo = 1 + 2;
print('test = $foo');
print('test = ${foo}');
@@ -226,7 +226,7 @@
Future<void> test_OK_intoStringInterpolation_string_differentQuotes() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = "aaa";
String b = '$a bbb';
}
@@ -234,7 +234,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String b = '${"aaa"} bbb';
}
''');
@@ -242,7 +242,7 @@
Future<void> test_OK_intoStringInterpolation_string_doubleQuotes() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = "aaa";
String b = "$a bbb";
}
@@ -250,7 +250,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String b = "aaa bbb";
}
''');
@@ -259,7 +259,7 @@
Future<void>
test_OK_intoStringInterpolation_string_multiLineIntoMulti_leadingSpaces() async {
await indexTestUnit(r"""
-main() {
+void f() {
String a = '''\ \
a
a''';
@@ -271,7 +271,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r"""
-main() {
+void f() {
String b = '''
a
a
@@ -283,7 +283,7 @@
Future<void>
test_OK_intoStringInterpolation_string_multiLineIntoMulti_unixEOL() async {
await indexTestUnit(r"""
-main() {
+void f() {
String a = '''
a
a
@@ -296,7 +296,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r"""
-main() {
+void f() {
String b = '''
a
a
@@ -309,7 +309,7 @@
Future<void>
test_OK_intoStringInterpolation_string_multiLineIntoMulti_windowsEOL() async {
await indexTestUnit(r"""
-main() {
+void f() {
String a = '''
a
a
@@ -323,7 +323,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r"""
-main() {
+void f() {
String b = '''
a
a
@@ -337,7 +337,7 @@
Future<void>
test_OK_intoStringInterpolation_string_multiLineIntoSingle() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = """aaa""";
String b = "$a bbb";
}
@@ -345,7 +345,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String b = "${"""aaa"""} bbb";
}
''');
@@ -353,7 +353,7 @@
Future<void> test_OK_intoStringInterpolation_string_raw() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = r'an $ignored interpolation';
String b = '$a bbb';
}
@@ -361,7 +361,7 @@
_createRefactoring('a =');
// we don't unwrap raw strings
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String b = '${r'an $ignored interpolation'} bbb';
}
''');
@@ -370,7 +370,7 @@
Future<void>
test_OK_intoStringInterpolation_string_singleLineIntoMulti_doubleQuotes() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = "aaa";
String b = """$a bbb""";
}
@@ -378,7 +378,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String b = """aaa bbb""";
}
''');
@@ -387,7 +387,7 @@
Future<void>
test_OK_intoStringInterpolation_string_singleLineIntoMulti_singleQuotes() async {
await indexTestUnit(r"""
-main() {
+void f() {
String a = 'aaa';
String b = '''$a bbb''';
}
@@ -395,7 +395,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r"""
-main() {
+void f() {
String b = '''aaa bbb''';
}
""");
@@ -403,7 +403,7 @@
Future<void> test_OK_intoStringInterpolation_string_singleQuotes() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = 'aaa';
String b = '$a bbb';
}
@@ -411,7 +411,7 @@
_createRefactoring('a =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String b = 'aaa bbb';
}
''');
@@ -419,7 +419,7 @@
Future<void> test_OK_intoStringInterpolation_stringInterpolation() async {
await indexTestUnit(r'''
-main() {
+void f() {
String a = 'aaa';
String b = '$a bbb';
String c = '$b ccc';
@@ -428,7 +428,7 @@
_createRefactoring('b =');
// validate change
return assertSuccessfulRefactoring(r'''
-main() {
+void f() {
String a = 'aaa';
String c = '$a bbb ccc';
}
@@ -438,7 +438,7 @@
/// https://code.google.com/p/dart/issues/detail?id=18587
Future<void> test_OK_keepNextCommentedLine() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 1 + 2;
// foo
print(test);
@@ -448,7 +448,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
// foo
print(1 + 2);
// bar
@@ -458,7 +458,7 @@
Future<void> test_OK_noUsages_1() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 1 + 2;
print(0);
}
@@ -466,7 +466,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
print(0);
}
''');
@@ -474,21 +474,21 @@
Future<void> test_OK_noUsages_2() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 1 + 2;
}
''');
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
}
''');
}
Future<void> test_OK_oneUsage() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 1 + 2;
print(test);
}
@@ -496,7 +496,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -504,7 +504,7 @@
Future<void> test_OK_parenthesis_decrement_intoNegate() async {
await indexTestUnit('''
-main() {
+void f() {
var a = 1;
var test = --a;
var b = -test;
@@ -513,7 +513,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
var a = 1;
var b = -(--a);
}
@@ -523,7 +523,7 @@
Future<void> test_OK_parenthesis_instanceCreation_intoList() async {
await indexTestUnit('''
class A {}
-main() {
+void f() {
var test = new A();
var list = [test];
}
@@ -532,7 +532,7 @@
// validate change
return assertSuccessfulRefactoring('''
class A {}
-main() {
+void f() {
var list = [new A()];
}
''');
@@ -540,7 +540,7 @@
Future<void> test_OK_parenthesis_intoIndexExpression_index() async {
await indexTestUnit('''
-main() {
+void f() {
var items = [];
var test = 1 + 2;
items[test] * 5;
@@ -549,7 +549,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
var items = [];
items[1 + 2] * 5;
}
@@ -576,7 +576,7 @@
Future<void> test_OK_parenthesis_negate_intoNegate() async {
await indexTestUnit('''
-main() {
+void f() {
var a = 1;
var test = -a;
var b = -test;
@@ -585,7 +585,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
var a = 1;
var b = -(-a);
}
@@ -594,7 +594,7 @@
Future<void> test_OK_parenthesis_plus_intoMultiply() async {
await indexTestUnit('''
-main() {
+void f() {
var test = 1 + 2;
print(test * 3);
}
@@ -602,7 +602,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
print((1 + 2) * 3);
}
''');
@@ -610,7 +610,7 @@
Future<void> test_OK_twoUsages() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 1 + 2;
print(test);
print(test);
@@ -619,7 +619,7 @@
_createRefactoring('test =');
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
print(1 + 2);
print(1 + 2);
}
diff --git a/pkg/analysis_server/test/services/refactoring/inline_method_test.dart b/pkg/analysis_server/test/services/refactoring/inline_method_test.dart
index e775831..372ce62 100644
--- a/pkg/analysis_server/test/services/refactoring/inline_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/inline_method_test.dart
@@ -97,7 +97,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res = test(1, 2);
}
''');
@@ -116,7 +116,7 @@
test(a, b) {
return a + b;
}
- main() {
+ void f() {
var res = test(1, 2);
}
}
@@ -187,7 +187,7 @@
bar() {}
test() {}
}
-main() {
+void f() {
A a = new A();
a..foo()..test()..bar();
}
@@ -217,7 +217,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res1 = test(1, 2);
var res2 = test(10, 20);
}
@@ -237,7 +237,7 @@
Future<void> test_bad_notExecutableElement() async {
await indexTestUnit(r'''
-main() {
+void f() {
}
''');
_createRefactoring(') {');
@@ -247,7 +247,7 @@
Future<void> test_bad_notSimpleIdentifier() async {
await indexTestUnit(r'''
-main() {
+void f() {
var test = 42;
var res = test;
}
@@ -291,7 +291,7 @@
print(b);
}
}
-main() {
+void f() {
print(new A().test);
}
''');
@@ -308,7 +308,7 @@
}
return 2;
}
-main() {
+void f() {
var res = test();
}
''');
@@ -328,7 +328,7 @@
Inner inner = Inner();
}
-void main() {
+void f() {
Inner createInner() => new Inner()
..a = 'a'
..b = 'b';
@@ -349,7 +349,7 @@
Inner inner = Inner();
}
-void main() {
+void f() {
Inner createInner() => new Inner()
..a = 'a'
..b = 'b';
@@ -370,7 +370,7 @@
return f * 2;
}
}
-main() {
+void f() {
A a = new A();
print(a.foo);
}
@@ -381,7 +381,7 @@
class A {
var f;
}
-main() {
+void f() {
A a = new A();
print(a.f * 2);
}
@@ -399,7 +399,7 @@
class B {
A a = new A();
}
-main() {
+void f() {
B b = new B();
print(b.a.foo);
}
@@ -413,7 +413,7 @@
class B {
A a = new A();
}
-main() {
+void f() {
B b = new B();
print(b.a.f * 2);
}
@@ -428,7 +428,7 @@
f = x;
}
}
-main() {
+void f() {
A a = new A();
a.foo = 0;
}
@@ -439,7 +439,7 @@
class A {
var f;
}
-main() {
+void f() {
A a = new A();
a.f = 0;
}
@@ -457,7 +457,7 @@
class B {
A a = new A();
}
-main() {
+void f() {
B b = new B();
b.a.foo = 0;
}
@@ -471,7 +471,7 @@
class B {
A a = new A();
}
-main() {
+void f() {
B b = new B();
b.a.f = 0;
}
@@ -481,14 +481,14 @@
Future<void> test_function_expressionFunctionBody() async {
await indexTestUnit(r'''
test(a, b) => a + b;
-main() {
+void f() {
print(test(1, 2));
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -501,7 +501,7 @@
print(b);
return a + b;
}
-main() {
+void f() {
var v;
v = test(1, 2);
}
@@ -509,7 +509,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var v;
print(1);
print(2);
@@ -523,14 +523,14 @@
int test(a, b) {
return a + b;
}
-main() {
+void f() {
var v = test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var v = 1 + 2;
}
''');
@@ -543,14 +543,14 @@
print(b);
return;
}
-main() {
+void f() {
test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(1);
print(2);
}
@@ -564,14 +564,14 @@
print(b);
return a + b;
}
-main() {
+void f() {
var v = test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(1);
print(2);
var v = 1 + 2;
@@ -581,7 +581,7 @@
Future<void> test_function_multilineString() async {
await indexTestUnit(r"""
-main() {
+void f() {
{
test();
}
@@ -596,7 +596,7 @@
_createRefactoring('test() {');
// validate change
return _assertSuccessfulRefactoring(r"""
-main() {
+void f() {
{
print('''
first line
@@ -671,7 +671,7 @@
var c = a + b;
print(c);
}
-main() {
+void f() {
test(1, 2);
var c = 0;
}
@@ -679,7 +679,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var c2 = 1 + 2;
print(c2);
var c = 0;
@@ -693,7 +693,7 @@
var c = a + b;
print(c);
}
-main() {
+void f() {
var c = 0;
test(1, 2);
}
@@ -701,7 +701,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var c = 0;
var c2 = 1 + 2;
print(c2);
@@ -715,14 +715,14 @@
var c = a + b;
print(c);
}
-main() {
+void f() {
test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var c = 1 + 2;
print(c);
}
@@ -735,14 +735,14 @@
print(a);
print(b);
}
-main() {
+void f() {
test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(1);
print(2);
}
@@ -755,7 +755,7 @@
print(a);
print(b);
}
-main() {
+void f() {
{
test(1, 2);
}
@@ -764,7 +764,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
{
print(1);
print(2);
@@ -778,14 +778,14 @@
void test(a, b) {
print(a + b);
}
-main() {
+void f() {
test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -796,7 +796,7 @@
test(int p) {
print(p * 2);
}
-main() {
+void f() {
var v;
v = test(0);
}
@@ -804,7 +804,7 @@
_createRefactoring('test(int p)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var v;
v = (int p) {
print(p * 2);
@@ -819,14 +819,14 @@
test(int p) {
print(p * 2);
}
-main() {
+void f() {
var v = test(0);
}
''');
_createRefactoring('test(int p)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var v = (int p) {
print(p * 2);
}(0);
@@ -840,14 +840,14 @@
print(p);
print(p * 2);
}
-main() {
+void f() {
var v = test(0);
}
''');
_createRefactoring('test(int p)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var v = (int p) {
print(p);
print(p * 2);
@@ -860,14 +860,14 @@
await indexTestUnit(r'''
test(int p) {
}
-main() {
+void f() {
var v = test(0);
}
''');
_createRefactoring('test(int p)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var v = (int p) {
}(0);
}
@@ -880,7 +880,7 @@
test() {
print(topLevelField);
}
-main() {
+void f() {
test();
}
''');
@@ -888,7 +888,7 @@
// validate change
return _assertSuccessfulRefactoring(r'''
var topLevelField = 0;
-main() {
+void f() {
print(topLevelField);
}
''');
@@ -1015,7 +1015,7 @@
class A {
static int get result => 1 + 2;
}
-main() {
+void f() {
print(A.result);
}
''');
@@ -1024,7 +1024,7 @@
return _assertSuccessfulRefactoring(r'''
class A {
}
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -1033,14 +1033,14 @@
Future<void> test_getter_topLevel() async {
await indexTestUnit(r'''
String get message => 'Hello, World!';
-main() {
+void f() {
print(message);
}
''');
_createRefactoring('message =>');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print('Hello, World!');
}
''');
@@ -1051,7 +1051,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res = test(1, 2);
}
''');
@@ -1067,7 +1067,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res1 = test(1, 2);
var res2 = test(10, 20);
}
@@ -1154,7 +1154,7 @@
print(this.fB);
}
}
-main() {
+void f() {
B b = new B();
b.test();
}
@@ -1168,7 +1168,7 @@
class B extends A {
var fB;
}
-main() {
+void f() {
B b = new B();
print(b.fA);
print(b.fB);
@@ -1191,7 +1191,7 @@
print(B.FB);
}
}
-main() {
+void f() {
B b = new B();
b.test();
}
@@ -1205,7 +1205,7 @@
class B extends A {
static var FB = 2;
}
-main() {
+void f() {
B b = new B();
print(B.FB);
print(A.FA);
@@ -1346,7 +1346,7 @@
a.accept(this);
}
}
-main() {
+void f() {
B b = new B();
A a = new A();
b.test(a);
@@ -1360,7 +1360,7 @@
}
class B {
}
-main() {
+void f() {
B b = new B();
A a = new A();
print(b);
@@ -1399,7 +1399,7 @@
await indexTestUnit(r'''
fa(pa) => fb(pb: true);
fb({pb: false}) {}
-main() {
+void f() {
fa(null);
}
''');
@@ -1408,7 +1408,7 @@
return _assertSuccessfulRefactoring(r'''
fa(pa) => fb(pb: true);
fb({pb: false}) {}
-main() {
+void f() {
fb(pb: true);
}
''');
@@ -1419,7 +1419,7 @@
test({a: 0, b: 2}) {
print(a + b);
}
-main() {
+void f() {
test(a: 10, b: 20);
test(b: 20, a: 10);
}
@@ -1427,7 +1427,7 @@
_createRefactoring('test({');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(10 + 20);
print(10 + 20);
}
@@ -1440,14 +1440,14 @@
test({a: 42}) {
print(a);
}
-main() {
+void f() {
test();
}
''');
_createRefactoring('test(');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(42);
}
''');
@@ -1459,14 +1459,14 @@
test([a = 42]) {
print(a);
}
-main() {
+void f() {
test();
}
''');
_createRefactoring('test(');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(42);
}
''');
@@ -1478,14 +1478,14 @@
test([a]) {
print(a);
}
-main() {
+void f() {
test();
}
''');
_createRefactoring('test(');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(null);
}
''');
@@ -1497,7 +1497,7 @@
test(a) {
print(a);
}
-main() {
+void f() {
test();
}
''');
@@ -1513,14 +1513,14 @@
Future<void> test_reference_expressionBody() async {
await indexTestUnit(r'''
String message() => 'Hello, World!';
-main() {
+void f() {
print(message);
}
''');
_createRefactoring('message()');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(() => 'Hello, World!');
}
''');
@@ -1552,7 +1552,7 @@
Future<void> test_reference_toLocal() async {
await indexTestUnit(r'''
-main() {
+void f() {
test(a, b) {
print(a);
print(b);
@@ -1563,7 +1563,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print((a, b) {
print(a);
print(b);
@@ -1578,14 +1578,14 @@
print(a);
print(b);
}
-main() {
+void f() {
print(test);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print((a, b) {
print(a);
print(b);
@@ -1653,14 +1653,14 @@
void set result(x) {
print(x + 1);
}
-main() {
+void f() {
result = 5;
}
''');
_createRefactoring('result(x)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
print(5 + 1);
}
''');
@@ -1671,14 +1671,14 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res = test(1, 2);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var res = 1 + 2;
}
''');
@@ -1689,7 +1689,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res = test(1, 2);
}
''');
@@ -1700,7 +1700,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res = 1 + 2;
}
''');
@@ -1711,7 +1711,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res1 = test(1, 2);
var res2 = test(10, 20);
}
@@ -1719,7 +1719,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var res1 = 1 + 2;
var res2 = 10 + 20;
}
@@ -1731,7 +1731,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res1 = test(1, 2);
var res2 = test(10, 20);
}
@@ -1742,7 +1742,7 @@
test(a, b) {
return a + b;
}
-main() {
+void f() {
var res1 = 1 + 2;
var res2 = test(10, 20);
}
@@ -1755,14 +1755,14 @@
test(a, b) {
return a * (b);
}
-main() {
+void f() {
var res = test(1, 2 + 3);
}
''');
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var res = 1 * (2 + 3);
}
''');
@@ -1773,7 +1773,7 @@
test(a, b) {
return a * b;
}
-main() {
+void f() {
var res1 = test(1, 2 + 3);
var res2 = test(1, (2 + 3));
}
@@ -1781,7 +1781,7 @@
_createRefactoring('test(a, b)');
// validate change
return _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var res1 = 1 * (2 + 3);
var res2 = 1 * (2 + 3);
}
diff --git a/pkg/analysis_server/test/services/refactoring/move_file_test.dart b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
index 6a02009..8963644 100644
--- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
@@ -261,7 +261,7 @@
addSource(binMainPath, '''
import 'package:test/test.dart';
-main() {
+void f() {
var a = new Foo();
}
''');
@@ -274,7 +274,7 @@
assertFileChangeResult(binMainPath, '''
import 'test.dart';
-main() {
+void f() {
var a = new Foo();
}
''');
diff --git a/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart b/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart
index 9a40d78..acb01ea 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart
@@ -21,7 +21,7 @@
class RenameConstructorClassTest extends _RenameConstructorTest {
Future<void> test_checkInitialConditions_inSDK() async {
await indexTestUnit('''
-main() {
+void f() {
new String.fromCharCodes([]);
}
''');
@@ -101,7 +101,7 @@
class B extends A {
B() : super() {}
}
-main() {
+void f() {
new A();
A.new;
}
@@ -123,7 +123,7 @@
class B extends A {
B() : super.newName() {}
}
-main() {
+void f() {
new A.newName();
A.newName;
}
@@ -140,7 +140,7 @@
class B extends A {
B() : super() {}
}
-main() {
+void f() {
new A();
A.new;
}
@@ -163,7 +163,7 @@
class B extends A {
B() : super.newName() {}
}
-main() {
+void f() {
new A.newName();
A.newName;
}
@@ -181,7 +181,7 @@
class B extends A {
B() : super.test() {}
}
-main() {
+void f() {
new A.test();
A.test;
}
@@ -203,7 +203,7 @@
class B extends A {
B() : super.newName() {}
}
-main() {
+void f() {
new A.newName();
A.newName;
}
@@ -216,7 +216,7 @@
class A {
int field = 0;
}
-main() {
+void f() {
new A();
}
''');
@@ -233,7 +233,7 @@
int field = 0;
}
-main() {
+void f() {
new A.newName();
}
''');
@@ -250,7 +250,7 @@
class B extends A {
B() : super.test() {}
}
-main() {
+void f() {
new A.test();
A.test;
}
@@ -272,7 +272,7 @@
class B extends A {
B() : super() {}
}
-main() {
+void f() {
new A();
A.new;
}
diff --git a/pkg/analysis_server/test/services/refactoring/rename_import_test.dart b/pkg/analysis_server/test/services/refactoring/rename_import_test.dart
index 998fc74..8ad640e 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_import_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_import_test.dart
@@ -54,7 +54,7 @@
await indexTestUnit('''
import 'dart:async';
import 'dart:math' show Random, min hide max;
-main() {
+void f() {
Future f;
Random r;
min(1, 2);
@@ -68,7 +68,7 @@
return assertSuccessfulRefactoring('''
import 'dart:async';
import 'dart:math' as newName show Random, min hide max;
-main() {
+void f() {
Future f;
newName.Random r;
newName.min(1, 2);
@@ -80,7 +80,7 @@
test_createChange_add_interpolationExpression_hasCurlyBrackets() async {
await indexTestUnit(r'''
import 'dart:async';
-main() {
+void f() {
Future f;
print('Future type: ${Future}');
}
@@ -92,7 +92,7 @@
// validate change
return assertSuccessfulRefactoring(r'''
import 'dart:async' as newName;
-main() {
+void f() {
newName.Future f;
print('Future type: ${newName.Future}');
}
@@ -103,7 +103,7 @@
test_createChange_add_interpolationExpression_noCurlyBrackets() async {
await indexTestUnit(r'''
import 'dart:async';
-main() {
+void f() {
Future f;
print('Future type: $Future');
}
@@ -115,7 +115,7 @@
// validate change
return assertSuccessfulRefactoring(r'''
import 'dart:async' as newName;
-main() {
+void f() {
newName.Future f;
print('Future type: ${newName.Future}');
}
@@ -126,7 +126,7 @@
await indexTestUnit('''
import 'dart:math' as test;
import 'dart:async' as test;
-main() {
+void f() {
test.Future f;
}
''');
@@ -139,7 +139,7 @@
return assertSuccessfulRefactoring('''
import 'dart:math' as test;
import 'dart:async' as newName;
-main() {
+void f() {
newName.Future f;
}
''');
@@ -149,7 +149,7 @@
await indexTestUnit('''
import 'dart:math' as test;
import 'dart:async' as test;
-main() {
+void f() {
test.max(1, 2);
test.Future f;
}
@@ -163,7 +163,7 @@
return assertSuccessfulRefactoring('''
import 'dart:math' as newName;
import 'dart:async' as test;
-main() {
+void f() {
newName.max(1, 2);
test.Future f;
}
@@ -174,7 +174,7 @@
await indexTestUnit('''
import 'dart:async' as test;
import 'dart:math' as test;
-main() {
+void f() {
test.Future f;
test.pi;
test.e;
@@ -189,7 +189,7 @@
return assertSuccessfulRefactoring('''
import 'dart:async' as test;
import 'dart:math' as newName;
-main() {
+void f() {
test.Future f;
newName.pi;
newName.e;
@@ -201,7 +201,7 @@
await indexTestUnit('''
import 'dart:math' as test;
import 'dart:async' as test;
-main() {
+void f() {
test.Future f;
}
''');
@@ -214,7 +214,7 @@
return assertSuccessfulRefactoring('''
import 'dart:math' as test;
import 'dart:async';
-main() {
+void f() {
Future f;
}
''');
@@ -224,7 +224,7 @@
await indexTestUnit('''
import 'dart:math';
import 'dart:async';
-main() {
+void f() {
Future f;
}
''');
diff --git a/pkg/analysis_server/test/services/refactoring/rename_label_test.dart b/pkg/analysis_server/test/services/refactoring/rename_label_test.dart
index 3c824f2..3b6a8e2 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_label_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_label_test.dart
@@ -18,7 +18,7 @@
class RenameLabelTest extends RenameRefactoringTest {
Future<void> test_checkNewName_LocalVariableElement() async {
await indexTestUnit('''
-main() {
+void f() {
test:
while (true) {
break test;
@@ -38,7 +38,7 @@
Future<void> test_createChange() async {
await indexTestUnit('''
-main() {
+void f() {
test:
while (true) {
break test;
@@ -52,7 +52,7 @@
refactoring.newName = 'newName';
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
newName:
while (true) {
break newName;
@@ -63,7 +63,7 @@
Future<void> test_oldName() async {
await indexTestUnit('''
-main() {
+void f() {
test:
while (true) {
break test;
diff --git a/pkg/analysis_server/test/src/cider/assists_test.dart b/pkg/analysis_server/test/src/cider/assists_test.dart
index ffd68d6..af5dc8e 100644
--- a/pkg/analysis_server/test/src/cider/assists_test.dart
+++ b/pkg/analysis_server/test/src/cider/assists_test.dart
@@ -66,7 +66,7 @@
await _compute('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
^Text('a');
}
''');
@@ -74,7 +74,7 @@
assertHasAssist(DartAssistKind.FLUTTER_WRAP_STREAM_BUILDER, r'''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
StreamBuilder<Object>(
stream: null,
builder: (context, snapshot) {
@@ -87,13 +87,13 @@
Future<void> test_assignToLocalVariable() async {
await _compute(r'''
-main() {
+void f() {
12^345;
}
''');
assertHasAssist(DartAssistKind.ASSIGN_TO_LOCAL_VARIABLE, r'''
-main() {
+void f() {
var i = 12345;
}
''');
diff --git a/pkg/analysis_server/test/src/cider/rename_test.dart b/pkg/analysis_server/test/src/cider/rename_test.dart
index 3a3ec88..86347e6 100644
--- a/pkg/analysis_server/test/src/cider/rename_test.dart
+++ b/pkg/analysis_server/test/src/cider/rename_test.dart
@@ -31,7 +31,7 @@
void test_cannotRename_inSdk() async {
var refactor = await _compute(r'''
-main() {
+void f() {
new String.^fromCharCodes([]);
}
''');
@@ -87,7 +87,7 @@
void test_canRename_label() async {
var refactor = await _compute(r'''
-main() {
+void f() {
myLabel:
while (true) {
continue ^myLabel;
@@ -302,7 +302,7 @@
class B extends A {
B() : super() {}
}
-main() {
+void f() {
new A();
A.new;
}
@@ -319,7 +319,7 @@
class B extends A {
B() : super.newName() {}
}
-main() {
+void f() {
new A.newName();
A.newName;
}
@@ -469,7 +469,7 @@
class B extends A {
B() : super.test() {}
}
-main() {
+void f() {
new A.test();
A.test;
}
@@ -486,7 +486,7 @@
class B extends A {
B() : super.newName() {}
}
-main() {
+void f() {
new A.newName();
A.newName;
}
@@ -504,7 +504,7 @@
class B extends A {
B() : super.test() {}
}
-main() {
+void f() {
new A.test();
A.test;
}
@@ -521,7 +521,7 @@
class B extends A {
B() : super() {}
}
-main() {
+void f() {
new A();
A.new;
}
@@ -538,7 +538,7 @@
class B extends A {
B() : super() {}
}
-main() {
+void f() {
new A();
A.^new;
}
@@ -556,7 +556,7 @@
class B extends A {
B() : super.newName() {}
}
-main() {
+void f() {
new A.newName();
A.newName;
}
diff --git a/pkg/analysis_server/test/src/computer/color_computer_test.dart b/pkg/analysis_server/test/src/computer/color_computer_test.dart
index 43e6469..159d18e 100644
--- a/pkg/analysis_server/test/src/computer/color_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/color_computer_test.dart
@@ -198,7 +198,7 @@
Future<void> test_collectionLiteral_const() async {
const testCode = '''
-main() {
+void f() {
const colors = [
[[COLOR]],
];
@@ -209,7 +209,7 @@
Future<void> test_collectionLiteral_nonConst() async {
const testCode = '''
-main() {
+void f() {
final colors = [
[[COLOR]],
];
@@ -222,7 +222,7 @@
const testCode = '''
import 'other_file.dart';
-void main() {
+void f() {
final a1 = MyTheme.staticWhite;
final a2 = MyTheme.staticMaterialRedAccent;
const theme = MyTheme();
@@ -258,7 +258,7 @@
Future<void> test_local_const() async {
const testCode = '''
-main() {
+void f() {
const a = [[COLOR]];
}
''';
@@ -267,7 +267,7 @@
Future<void> test_local_nonConst() async {
const testCode = '''
-main() {
+void f() {
final a = [[COLOR]];
}
''';
@@ -276,7 +276,7 @@
Future<void> test_namedParameter_const() async {
const testCode = '''
-main() {
+void f() {
const w = Widget(color: [[COLOR]]);
}
@@ -290,7 +290,7 @@
Future<void> test_namedParameter_nonConst() async {
const testCode = '''
-main() {
+void f() {
final w = Widget(color: [[COLOR]]);
}
@@ -304,7 +304,7 @@
Future<void> test_nested_const() async {
const testCode = '''
-main() {
+void f() {
const a = [[COLOR]];
}
''';
@@ -313,7 +313,7 @@
Future<void> test_nested_nonConst() async {
const testCode = '''
-main() {
+void f() {
final a = [[COLOR]];
}
''';
diff --git a/pkg/analysis_server/test/src/computer/folding_computer_test.dart b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
index a0ce7df7..4adaf63 100644
--- a/pkg/analysis_server/test/src/computer/folding_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
@@ -38,7 +38,7 @@
"this",
"is a test"
)/*1:EXC:ANNOTATIONS*/
-main() {}
+void f() {}
@noFoldNecessary
main2() {}
@@ -98,7 +98,7 @@
Future<void> test_assertStatement() async {
var content = '''
-main() {/*1:INC*/
+void f() {/*1:INC*/
assert(/*2:INC*/
true,
''
@@ -134,7 +134,7 @@
var content = """
// This is not the file header/*1:EXC*/
// It's just a comment/*1:INC:COMMENT*/
-main() {}
+void f() {}
""";
// Since there are no region comment markers above
@@ -145,7 +145,7 @@
Future<void> test_comment_multiline() async {
var content = '''
-main() {
+void f() {
/*/*1:EXC*/
* comment 1
*//*1:EXC:COMMENT*/
@@ -162,7 +162,7 @@
Future<void> test_comment_singleFollowedByBlankLine() async {
var content = '''
-main() {
+void f() {
// this is/*1:EXC*/
// a comment/*1:INC:COMMENT*/
/// this is not part of it
@@ -175,7 +175,7 @@
Future<void> test_comment_singleFollowedByMulti() async {
var content = '''
-main() {
+void f() {
// this is/*1:EXC*/
// a comment/*1:INC:COMMENT*/
/* this is not part of it */
@@ -189,7 +189,7 @@
Future<void> test_comment_singleFollowedByTripleSlash() async {
var content = '''
-main() {
+void f() {
// this is/*1:EXC*/
// a comment/*1:INC:COMMENT*/
/// this is not part of it
@@ -204,7 +204,7 @@
var content = '''
// Content before
-main() {/*1:INC*/
+void f() {/*1:INC*/
return new Text(/*2:INC*/
"Hello, world!",
/*2:INC:INVOCATION*/);
@@ -224,7 +224,7 @@
// This is not the file header
// It's just a comment
-main() {}
+void f() {}
""";
final regions = await _computeRegions(content);
@@ -239,7 +239,7 @@
*/
/* This shouldn't be part of the file header */
-main() {}
+void f() {}
""";
final regions = await _computeRegions(content);
@@ -251,7 +251,7 @@
// Copyright some year by some people/*1:EXC*/
// See LICENCE etc./*1:INC:FILE_HEADER*/
-main() {}
+void f() {}
''';
final regions = await _computeRegions(content);
@@ -264,7 +264,7 @@
// See LICENCE etc./*1:INC:FILE_HEADER*/
/* This shouldn't be part of the file header */
-main() {}
+void f() {}
""";
final regions = await _computeRegions(content);
@@ -279,7 +279,7 @@
// This is not the file header
// It's just a comment
-main() {}
+void f() {}
""";
final regions = await _computeRegions(content);
@@ -292,7 +292,7 @@
// a file header/*1:INC:FILE_HEADER*/
// this is not part of it
-main() {}
+void f() {}
''';
final regions = await _computeRegions(content);
@@ -303,7 +303,7 @@
var content = '''
// Content before
-main() {/*1:INC*/
+void f() {/*1:INC*/
print("Hello, world!");
/*1:INC:FUNCTION_BODY*/}
@@ -342,7 +342,7 @@
/// This is a doc comment/*1:EXC*/
/// that spans lines/*1:INC:DOCUMENTATION_COMMENT*/
-main() {/*2:INC*/
+void f() {/*2:INC*/
print("Hello, world!");
/*2:INC:FUNCTION_BODY*/}
@@ -357,7 +357,7 @@
var content = '''
// Content before
-main() {/*1:INC*/
+void f() {/*1:INC*/
print(/*2:INC*/
"Hello, world!",
/*2:INC:INVOCATION*/);
@@ -374,7 +374,7 @@
var content = '''
// Content before
-main() {/*1:INC*/
+void f() {/*1:INC*/
final List<String> things = <String>[/*2:INC*/
"one",
"two"
@@ -433,7 +433,7 @@
export '../a.dart';/*1:EXC:DIRECTIVES*/
-main() {}
+void f() {}
""";
final regions = await _computeRegions(content);
@@ -450,7 +450,7 @@
import '../a.dart';/*1:EXC:DIRECTIVES*/
-main() {}
+void f() {}
""";
final regions = await _computeRegions(content);
@@ -461,7 +461,7 @@
var content = '''
// Content before
-main() {/*1:INC*/
+void f() {/*1:INC*/
doPrint() {/*2:INC*/
print("Hello, world!");
/*2:INC:FUNCTION_BODY*/}
@@ -479,7 +479,7 @@
var content = '''
// Content before
-main() {/*1:INC*/
+void f() {/*1:INC*/
a(/*2:INC*/
b(/*3:INC*/
c(/*4:INC*/
@@ -525,7 +525,7 @@
var content = """
import 'dart:async';
-main() {}
+void f() {}
""";
// Since there are no region comment markers above
diff --git a/pkg/analysis_server/test/src/computer/highlights_computer_test.dart b/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
index 939b4b3..982a12c 100644
--- a/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
@@ -55,7 +55,7 @@
await _computeHighlights('''
extension E on int {}
-main() {
+void f() {
E(0).foo();
}
''', hasErrors: true);
@@ -86,7 +86,7 @@
Future<void> test_throwExpression() async {
await _computeHighlights('''
-void main() {
+void f() {
throw 'foo';
}
''');
diff --git a/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
index d83c58b..e4e1704 100644
--- a/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
@@ -63,7 +63,7 @@
Future<void> test_createEdits_addImport_noDirectives() async {
await createBuilder('''
-main() {
+void f() {
// paste here
}
''');
@@ -74,7 +74,7 @@
assertChanges('''
import 'dart:math';
-main() {
+void f() {
// paste here
}
''');
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
index bc8f079..13eabf0 100644
--- a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -153,7 +153,7 @@
Future<void> test_multiple() async {
var selection = r'''
-main() {
+void f() {
Random r = new Random();
String s = r.nextBool().toString();
print(s);
@@ -364,7 +364,7 @@
var selection = 'f.foo';
var content = '''
import 'package:foo/foo.dart' as f;
-main() {
+void f() {
$selection = '';
}
''';
diff --git a/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart b/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart
index d2bb3cd..5310801 100644
--- a/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart
+++ b/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart
@@ -24,7 +24,7 @@
}
''');
addTestFile(r'''
-main() {} // ref
+void f() {} // ref
''');
var set = await waitForSetWithUri('package:test/a.dart');
@@ -40,7 +40,7 @@
_assertTestFileChange(result.change!, r'''
import 'package:test/a.dart';
-main() {} // ref
+void f() {} // ref
''');
}
@@ -48,7 +48,7 @@
addTestFile(r'''
import 'dart:math';
-main() {} // ref
+void f() {} // ref
''');
var mathSet = await waitForSetWithUri('dart:math');
@@ -68,7 +68,7 @@
addTestFile(r'''
import 'dart:math' as math;
-main() {} // ref
+void f() {} // ref
''');
var mathSet = await waitForSetWithUri('dart:math');
@@ -99,7 +99,7 @@
Future<void> test_newImport() async {
addTestFile(r'''
-main() {} // ref
+void f() {} // ref
''');
var mathSet = await waitForSetWithUri('dart:math');
@@ -115,7 +115,7 @@
_assertTestFileChange(result.change!, r'''
import 'dart:math';
-main() {} // ref
+void f() {} // ref
''');
}
@@ -128,7 +128,7 @@
@myAnnotation
import 'package:zzz';
-main() {} // ref
+void f() {} // ref
''');
var mathSet = await waitForSetWithUri('dart:math');
@@ -149,7 +149,7 @@
@myAnnotation
import 'package:zzz';
-main() {} // ref
+void f() {} // ref
''');
}
@@ -162,7 +162,7 @@
import 'package:zzz';
-main() {} // ref
+void f() {} // ref
''');
var mathSet = await waitForSetWithUri('dart:math');
@@ -182,7 +182,7 @@
import 'package:zzz';
-main() {} // ref
+void f() {} // ref
''');
}
@@ -194,7 +194,7 @@
@myAnnotation
import 'package:zzz';
-main() {} // ref
+void f() {} // ref
''');
var mathSet = await waitForSetWithUri('dart:math');
@@ -213,7 +213,7 @@
@myAnnotation
import 'package:zzz';
-main() {} // ref
+void f() {} // ref
''');
}
@@ -221,7 +221,7 @@
var partCode = r'''
part of 'test.dart';
-main() {} // ref
+void f() {} // ref
''';
var partFile = newFile('/home/test/lib/a.dart', partCode);
addTestFile(r'''
diff --git a/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart b/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart
index b9f479a..c243a24 100644
--- a/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart
+++ b/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart
@@ -91,7 +91,7 @@
Future<void> test_dart_instanceCreationExpression() async {
addTestFile(r'''
-main() {
+void f() {
new ; // ref
}
''');
@@ -185,7 +185,7 @@
Future<void> test_includedElementKinds_value() async {
addTestFile(r'''
-main() {
+void f() {
print(); // ref
}
''');
@@ -229,7 +229,7 @@
addTestFile(r'''
void foo(List<int> a) {}
-main() {
+void f() {
foo(); // ref
}
''');
@@ -327,7 +327,7 @@
addTestFile(r'''
void foo({int a, String b}) {}
-main() {
+void f() {
foo(b: ); // ref
}
''');
@@ -391,7 +391,7 @@
addTestFile(r'''
void foo(double a) {}
-main() {
+void f() {
foo(); // ref
}
''');
@@ -461,7 +461,7 @@
Future<void> test_relevanceTags_location_assignment() async {
addTestFile(r'''
-main() {
+void f() {
int v;
v = // ref;
}
@@ -592,7 +592,7 @@
Future<void> test_relevanceTags_location_listLiteral() async {
addTestFile(r'''
-main() {
+void f() {
var v = [0, ]; // ref
}
''');
diff --git a/pkg/analysis_server/test/src/domains/flutter/get_widget_description_test.dart b/pkg/analysis_server/test/src/domains/flutter/get_widget_description_test.dart
index b926395..4af4ad0 100644
--- a/pkg/analysis_server/test/src/domains/flutter/get_widget_description_test.dart
+++ b/pkg/analysis_server/test/src/domains/flutter/get_widget_description_test.dart
@@ -20,7 +20,7 @@
addTestFile(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -37,7 +37,7 @@
Future<void> test_notInstanceCreation() async {
addTestFile(r'''
-void main() {
+void f() {
42;
}
''');
@@ -52,7 +52,7 @@
Future<void> test_unresolvedInstanceCreation() async {
addTestFile(r'''
-void main() {
+void f() {
new Foo();
}
''');
diff --git a/pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart b/pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart
index af74a41..9c527eb 100644
--- a/pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart
+++ b/pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart
@@ -20,7 +20,7 @@
addTestFile(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('');
}
''');
@@ -36,7 +36,7 @@
_assertTestFileChange(result.change, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text(
'',
maxLines: 42,
@@ -49,7 +49,7 @@
addTestFile(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1);
}
''');
@@ -65,7 +65,7 @@
_assertTestFileChange(result.change, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 42);
}
''');
@@ -75,7 +75,7 @@
addTestFile(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1);
}
''');
@@ -88,7 +88,7 @@
_assertTestFileChange(result.change, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', );
}
''');
@@ -98,7 +98,7 @@
addTestFile(r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -114,7 +114,7 @@
_assertTestFileChange(result.change, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('bbb');
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_curly_braces_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_curly_braces_test.dart
index 18da15e..0c207a6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_curly_braces_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_curly_braces_test.dart
@@ -27,12 +27,12 @@
Future<void> test_do_block() async {
await resolveTestCode('''
-main() {
+void f() {
do print(0); while (true);
}
''');
await assertHasFix('''
-main() {
+void f() {
do {
print(0);
} while (true);
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_named_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_named_test.dart
index b7e793b..96a7999 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_named_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_named_test.dart
@@ -25,7 +25,7 @@
A(int a, {int b = 0}) {}
}
-main() {
+void f() {
new A(1, b: 2, named: 3.0);
}
''');
@@ -34,7 +34,7 @@
A(int a, {int b = 0, required double named}) {}
}
-main() {
+void f() {
new A(1, b: 2, named: 3.0);
}
''');
@@ -46,7 +46,7 @@
A(int a) {}
}
-main() {
+void f() {
new A(1, named: 2.0);
}
''');
@@ -55,7 +55,7 @@
A(int a, {required double named}) {}
}
-main() {
+void f() {
new A(1, named: 2.0);
}
''');
@@ -67,7 +67,7 @@
A() {}
}
-main() {
+void f() {
new A(named: 42);
}
''');
@@ -76,7 +76,7 @@
A({required int named}) {}
}
-main() {
+void f() {
new A(named: 42);
}
''');
@@ -88,7 +88,7 @@
A.aaa() {}
}
-main() {
+void f() {
new A.aaa(named: 42);
}
''');
@@ -97,7 +97,7 @@
A.aaa({required int named}) {}
}
-main() {
+void f() {
new A.aaa(named: 42);
}
''');
@@ -107,14 +107,14 @@
await resolveTestCode('''
test(int a, {int b: 0}) {}
-main() {
+void f() {
test(1, b: 2, named: 3.0);
}
''');
await assertHasFix('''
test(int a, {int b: 0, required double named}) {}
-main() {
+void f() {
test(1, b: 2, named: 3.0);
}
''');
@@ -124,14 +124,14 @@
await resolveTestCode('''
test(int a) {}
-main() {
+void f() {
test(1, named: 2.0);
}
''');
await assertHasFix('''
test(int a, {required double named}) {}
-main() {
+void f() {
test(1, named: 2.0);
}
''');
@@ -141,14 +141,14 @@
await resolveTestCode('''
test() {}
-main() {
+void f() {
test(named: 42);
}
''');
await assertHasFix('''
test({required int named}) {}
-main() {
+void f() {
test(named: 42);
}
''');
@@ -159,7 +159,7 @@
class A {
test(int a, {int b: 0}) {}
- main() {
+ void f() {
test(1, b: 2, named: 3.0);
}
}
@@ -168,7 +168,7 @@
class A {
test(int a, {int b: 0, required double named}) {}
- main() {
+ void f() {
test(1, b: 2, named: 3.0);
}
}
@@ -180,7 +180,7 @@
class A {
test(int a, [int b = 0]) {}
- main() {
+ void f() {
test(1, 2, named: 3.0);
}
}
@@ -193,7 +193,7 @@
class A {
test(int a) {}
- main() {
+ void f() {
test(1, named: 2.0);
}
}
@@ -202,7 +202,7 @@
class A {
test(int a, {required double named}) {}
- main() {
+ void f() {
test(1, named: 2.0);
}
}
@@ -214,7 +214,7 @@
class A {
test() {}
- main() {
+ void f() {
test(named: 42);
}
}
@@ -223,7 +223,7 @@
class A {
test({required int named}) {}
- main() {
+ void f() {
test(named: 42);
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_positional_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_positional_test.dart
index dae57ea..4467cd9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_positional_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_positional_test.dart
@@ -126,7 +126,7 @@
Future<void> test_function_hasNamed() async {
await resolveTestCode('''
test({int a = 0}) {}
-main() {
+void f() {
test(1);
}
''');
@@ -136,7 +136,7 @@
Future<void> test_function_hasZero() async {
await resolveTestCode('''
test() {}
-main() {
+void f() {
test(1);
}
''');
@@ -144,7 +144,7 @@
// I'm leaving the test as is to keep it passing.
await assertHasFix('''
test([int i]) {}
-main() {
+void f() {
test(1);
}
''');
@@ -154,7 +154,7 @@
await resolveTestCode('''
class A {
test(int a) {}
- main() {
+ void f() {
test(1, 2.0);
}
}
@@ -162,7 +162,7 @@
await assertHasFix('''
class A {
test(int a, [double d]) {}
- main() {
+ void f() {
test(1, 2.0);
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart
index c23f105..74236cce 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart
@@ -27,7 +27,7 @@
class A {
A.named(int a) {}
}
-main() {
+void f() {
new A.named(1, 2.0);
}
''');
@@ -35,7 +35,7 @@
class A {
A.named(int a, double d) {}
}
-main() {
+void f() {
new A.named(1, 2.0);
}
''');
@@ -46,7 +46,7 @@
class A {
A(int a) {}
}
-main() {
+void f() {
new A(1, 2.0);
}
''');
@@ -54,7 +54,7 @@
class A {
A(int a, double d) {}
}
-main() {
+void f() {
new A(1, 2.0);
}
''');
@@ -63,13 +63,13 @@
Future<void> test_function_hasNamed() async {
await resolveTestCode('''
test({int a = 0}) {}
-main() {
+void f() {
test(1);
}
''');
await assertHasFix('''
test(int i, {int a = 0}) {}
-main() {
+void f() {
test(1);
}
''');
@@ -78,13 +78,13 @@
Future<void> test_function_hasOne() async {
await resolveTestCode('''
test(int a) {}
-main() {
+void f() {
test(1, 2.0);
}
''');
await assertHasFix('''
test(int a, double d) {}
-main() {
+void f() {
test(1, 2.0);
}
''');
@@ -93,13 +93,13 @@
Future<void> test_function_hasZero() async {
await resolveTestCode('''
test() {}
-main() {
+void f() {
test(1);
}
''');
await assertHasFix('''
test(int i) {}
-main() {
+void f() {
test(1);
}
''');
@@ -109,7 +109,7 @@
await resolveTestCode('''
part of my_lib;
test() {}
-main() {
+void f() {
test(1);
}
''');
@@ -120,7 +120,7 @@
await resolveTestCode('''
class A {
test(int a) {}
- main() {
+ void f() {
test(1, 2.0);
}
}
@@ -128,7 +128,7 @@
await assertHasFix('''
class A {
test(int a, double d) {}
- main() {
+ void f() {
test(1, 2.0);
}
}
@@ -139,7 +139,7 @@
await resolveTestCode('''
class A {
test() {}
- main() {
+ void f() {
test(1);
}
}
@@ -147,7 +147,7 @@
await assertHasFix('''
class A {
test(int i) {}
- main() {
+ void f() {
test(1);
}
}
@@ -181,7 +181,7 @@
await resolveTestCode('''
import 'package:aaa/a.dart';
-main() {
+void f() {
test(42);
}
''');
@@ -203,7 +203,7 @@
await resolveTestCode('''
import 'package:bbb/b.dart';
-main() {
+void f() {
test(42);
}
''');
@@ -212,7 +212,7 @@
Future<void> test_method_inSdk() async {
await resolveTestCode('''
-main() {
+void f() {
42.abs(true);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
index 798725d..9f07038 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
@@ -110,7 +110,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -118,7 +118,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(a: null);
print(a);
}
@@ -136,7 +136,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -144,7 +144,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(onPressed: () { });
print(a);
}
@@ -162,7 +162,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -170,7 +170,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(callback: (e) { });
print(a);
}
@@ -188,7 +188,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -196,7 +196,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(callback: (a, b, c) { });
print(a);
}
@@ -214,7 +214,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -222,7 +222,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(callback: (int a, String b, c) { });
print(a);
}
@@ -240,7 +240,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -248,7 +248,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(callback: (int? a) { });
print(a);
}
@@ -269,7 +269,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -277,7 +277,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(callback: (int a) { });
print(a);
}
@@ -298,7 +298,7 @@
// @dart = 2.8
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -307,7 +307,7 @@
// @dart = 2.8
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(callback: (int a) { });
print(a);
}
@@ -323,7 +323,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A();
print(a);
}
@@ -331,7 +331,7 @@
await assertHasFix('''
import 'package:test/a.dart';
-main() {
+void f() {
A a = new A(names: []);
print(a);
}
@@ -363,13 +363,13 @@
Future<void> test_multiple() async {
await resolveTestCode('''
test({required int a, required int bcd}) {}
-main() {
+void f() {
test(a: 3);
}
''');
await assertHasFix('''
test({required int a, required int bcd}) {}
-main() {
+void f() {
test(a: 3, bcd: null);
}
''');
@@ -378,13 +378,13 @@
Future<void> test_multiple_1of2() async {
await resolveTestCode('''
test({required int a, required int bcd}) {}
-main() {
+void f() {
test();
}
''');
await assertHasFix('''
test({required int a, required int bcd}) {}
-main() {
+void f() {
test(a: null);
}
''', errorFilter: (error) => error.message.contains("'a'"));
@@ -393,13 +393,13 @@
Future<void> test_multiple_2of2() async {
await resolveTestCode('''
test({required int a, required int bcd}) {}
-main() {
+void f() {
test();
}
''');
await assertHasFix('''
test({required int a, required int bcd}) {}
-main() {
+void f() {
test(bcd: null);
}
''', errorFilter: (error) => error.message.contains("'bcd'"));
@@ -498,13 +498,13 @@
Future<void> test_single() async {
await resolveTestCode('''
test({required int abc}) {}
-main() {
+void f() {
test();
}
''');
await assertHasFix('''
test({required int abc}) {}
-main() {
+void f() {
test(abc: null);
}
''');
@@ -514,13 +514,13 @@
Future<void> test_single_normal() async {
await resolveTestCode('''
test(String x, {required int abc}) {}
-main() {
+void f() {
test("foo");
}
''');
await assertHasFix('''
test(String x, {required int abc}) {}
-main() {
+void f() {
test("foo", abc: null);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_class_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_class_test.dart
index 976bef5..ad0a3b1 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_class_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_class_test.dart
@@ -52,7 +52,7 @@
Future<void> test_hasUnresolvedPrefix() async {
await resolveTestCode('''
-main() {
+void f() {
prefix.Test v = null;
print(v);
}
@@ -80,7 +80,7 @@
await resolveTestCode('''
import 'lib.dart' as lib;
-main() {
+void f() {
lib.A? a = null;
lib.Test? t = null;
print('\$a \$t');
@@ -123,12 +123,12 @@
Future<void> test_instanceCreation_withoutNew_fromFunction() async {
await resolveTestCode('''
-main() {
+void f() {
Test ();
}
''');
await assertHasFix('''
-main() {
+void f() {
Test ();
}
@@ -141,14 +141,14 @@
Future<void> test_instanceCreation_withoutNew_fromMethod() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
Test ();
}
}
''');
await assertHasFix('''
class A {
- main() {
+ void f() {
Test ();
}
}
@@ -161,13 +161,13 @@
Future<void> test_itemOfList() async {
await resolveTestCode('''
-main() {
+void f() {
var a = [Test];
print(a);
}
''');
await assertHasFix('''
-main() {
+void f() {
var a = [Test];
print(a);
}
@@ -184,14 +184,14 @@
const MyAnnotation(a, b);
}
@MyAnnotation(int, const [Test])
-main() {}
+void f() {}
''');
await assertHasFix('''
class MyAnnotation {
const MyAnnotation(a, b);
}
@MyAnnotation(int, const [Test])
-main() {}
+void f() {}
class Test {
}
@@ -203,13 +203,13 @@
Future<void> test_simple() async {
await resolveTestCode('''
-main() {
+void f() {
Test v = null;
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
Test v = null;
print(v);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
index 783000a..7d31ed0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
@@ -120,7 +120,7 @@
Future<void> test_inTopLevelMethod() async {
await resolveTestCode('''
-main() {
+void f() {
final int v;
print(v);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart
index 76ea6cb..31ee456 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart
@@ -24,7 +24,7 @@
await resolveTestCode('''
mixin M {}
-main() {
+void f() {
new M.named();
}
''');
@@ -47,7 +47,7 @@
await resolveTestCode('''
import 'a.dart';
-main() {
+void f() {
new A.named(1, 2.0);
}
''');
@@ -67,7 +67,7 @@
await resolveTestCode('''
import 'a.dart';
-main() {
+void f() {
new A(1, 2.0);
}
''');
@@ -99,7 +99,7 @@
method() {}
}
-main() {
+void f() {
new A(1, 2.0);
}
''');
@@ -111,7 +111,7 @@
method() {}
}
-main() {
+void f() {
new A(1, 2.0);
}
''');
@@ -133,7 +133,7 @@
class A {
method() {}
}
-main() {
+void f() {
new A.named(1, 2.0);
}
''');
@@ -143,7 +143,7 @@
method() {}
}
-main() {
+void f() {
new A.named(1, 2.0);
}
''');
@@ -153,7 +153,7 @@
Future<void> test_named_emptyClassBody() async {
await resolveTestCode('''
class A {}
-main() {
+void f() {
new A.named(1);
}
''');
@@ -161,7 +161,7 @@
class A {
A.named(int i);
}
-main() {
+void f() {
new A.named(1);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_function_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_function_test.dart
index 1018a76..e87134b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_function_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_function_test.dart
@@ -40,12 +40,12 @@
Future<void> test_bottomArgument() async {
await resolveTestCode('''
-main() {
+void f() {
test(throw 42);
}
''');
await assertHasFix('''
-main() {
+void f() {
test(throw 42);
}
@@ -80,13 +80,13 @@
Future<void> test_dynamicArgument() async {
await resolveTestCode('''
-main() {
+void f() {
dynamic v;
test(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
dynamic v;
test(v);
}
@@ -98,13 +98,13 @@
Future<void> test_dynamicReturnType() async {
await resolveTestCode('''
-main() {
+void f() {
dynamic v = test();
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
dynamic v = test();
print(v);
}
@@ -116,13 +116,13 @@
Future<void> test_fromFunction() async {
await resolveTestCode('''
-main() {
+void f() {
int v = myUndefinedFunction(1, 2.0, '3');
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
int v = myUndefinedFunction(1, 2.0, '3');
print(v);
}
@@ -135,7 +135,7 @@
Future<void> test_fromMethod() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
int v = myUndefinedFunction(1, 2.0, '3');
print(v);
}
@@ -143,7 +143,7 @@
''');
await assertHasFix('''
class A {
- main() {
+ void f() {
int v = myUndefinedFunction(1, 2.0, '3');
print(v);
}
@@ -163,7 +163,7 @@
useFunction(int g(double a, String b)) {}
}
-main() {
+void f() {
A a = new A();
a..ma().useFunction(test);
}
@@ -176,7 +176,7 @@
useFunction(int g(double a, String b)) {}
}
-main() {
+void f() {
A a = new A();
a..ma().useFunction(test);
}
@@ -188,13 +188,13 @@
Future<void> test_functionType_coreFunction() async {
await resolveTestCode('''
-main() {
+void f() {
useFunction(g: test);
}
useFunction({Function? g}) {}
''');
await assertHasFix('''
-main() {
+void f() {
useFunction(g: test);
}
useFunction({Function? g}) {}
@@ -206,13 +206,13 @@
Future<void> test_functionType_dynamicArgument() async {
await resolveTestCode('''
-main() {
+void f() {
useFunction(test);
}
useFunction(int g(a, b)) {}
''');
await assertHasFix('''
-main() {
+void f() {
useFunction(test);
}
useFunction(int g(a, b)) {}
@@ -224,13 +224,13 @@
Future<void> test_functionType_function() async {
await resolveTestCode('''
-main() {
+void f() {
useFunction(test);
}
useFunction(int g(double a, String b)) {}
''');
await assertHasFix('''
-main() {
+void f() {
useFunction(test);
}
useFunction(int g(double a, String b)) {}
@@ -242,13 +242,13 @@
Future<void> test_functionType_function_namedArgument() async {
await resolveTestCode('''
-main() {
+void f() {
useFunction(g: test);
}
useFunction({int g(double a, String b)?}) {}
''');
await assertHasFix('''
-main() {
+void f() {
useFunction(g: test);
}
useFunction({int g(double a, String b)?}) {}
@@ -270,7 +270,7 @@
await resolveTestCode('''
import 'package:test/b.dart';
-main() {
+void f() {
useFunction(test);
}
''');
@@ -278,7 +278,7 @@
import 'package:test/a.dart';
import 'package:test/b.dart';
-main() {
+void f() {
useFunction(test);
}
@@ -302,7 +302,7 @@
await resolveTestCode('''
class A {
List<int> items = [];
- main() {
+ void f() {
process(items);
}
}
@@ -310,7 +310,7 @@
await assertHasFix('''
class A {
List<int> items = [];
- main() {
+ void f() {
process(items);
}
}
@@ -329,7 +329,7 @@
await resolveTestCode('''
class A<T> {
Map<int, T> items = {};
- main() {
+ void f() {
process(items);
}
}
@@ -337,7 +337,7 @@
await assertHasFix('''
class A<T> {
Map<int, T> items = {};
- main() {
+ void f() {
process(items);
}
}
@@ -355,13 +355,13 @@
''');
await resolveTestCode('''
import 'lib.dart';
-main() {
+void f() {
test(getFuture());
}
''');
await assertHasFix('''
import 'lib.dart';
-main() {
+void f() {
test(getFuture());
}
@@ -372,12 +372,12 @@
Future<void> test_nullArgument() async {
await resolveTestCode('''
-main() {
+void f() {
test(null);
}
''');
await assertHasFix('''
-main() {
+void f() {
test(null);
}
@@ -448,14 +448,14 @@
Future<void> test_returnType_fromAssignment_eq() async {
await resolveTestCode('''
-main() {
+void f() {
int v;
v = myUndefinedFunction();
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
int v;
v = myUndefinedFunction();
print(v);
@@ -468,14 +468,14 @@
Future<void> test_returnType_fromAssignment_plusEq() async {
await resolveTestCode('''
-main() {
+void f() {
num v = 0;
v += myUndefinedFunction();
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
num v = 0;
v += myUndefinedFunction();
print(v);
@@ -488,12 +488,12 @@
Future<void> test_returnType_fromBinary_right() async {
await resolveTestCode('''
-main() {
+void f() {
0 + myUndefinedFunction();
}
''');
await assertHasFix('''
-main() {
+void f() {
0 + myUndefinedFunction();
}
@@ -504,13 +504,13 @@
Future<void> test_returnType_fromInitializer() async {
await resolveTestCode('''
-main() {
+void f() {
int v = myUndefinedFunction();
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
int v = myUndefinedFunction();
print(v);
}
@@ -523,13 +523,13 @@
Future<void> test_returnType_fromInvocationArgument() async {
await resolveTestCode('''
foo(int p) {}
-main() {
+void f() {
foo( myUndefinedFunction() );
}
''');
await assertHasFix('''
foo(int p) {}
-main() {
+void f() {
foo( myUndefinedFunction() );
}
@@ -540,12 +540,12 @@
Future<void> test_returnType_fromReturn() async {
await resolveTestCode('''
-int main() {
+int f() {
return myUndefinedFunction();
}
''');
await assertHasFix('''
-int main() {
+int f() {
return myUndefinedFunction();
}
@@ -580,12 +580,12 @@
Future<void> test_returnType_void() async {
await resolveTestCode('''
-main() {
+void f() {
myUndefinedFunction();
}
''');
await assertHasFix('''
-main() {
+void f() {
myUndefinedFunction();
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart
index 4bf0798..1ff5ed5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart
@@ -31,14 +31,14 @@
await resolveTestCode('''
typedef MY_FUNCTION(int p);
foo(MY_FUNCTION f) {}
-main() {
+void f() {
foo(bar);
}
''');
await assertHasFix('''
typedef MY_FUNCTION(int p);
foo(MY_FUNCTION f) {}
-main() {
+void f() {
MY_FUNCTION bar;
foo(bar);
}
@@ -49,14 +49,14 @@
await resolveTestCode('''
typedef MY_FUNCTION<T>(T p);
foo(MY_FUNCTION<int> f) {}
-main() {
+void f() {
foo(bar);
}
''');
await assertHasFix('''
typedef MY_FUNCTION<T>(T p);
foo(MY_FUNCTION<int> f) {}
-main() {
+void f() {
MY_FUNCTION<int> bar;
foo(bar);
}
@@ -66,13 +66,13 @@
Future<void> test_functionType_synthetic() async {
await resolveTestCode('''
foo(f(int p)) {}
-main() {
+void f() {
foo(bar);
}
''');
await assertHasFix('''
foo(f(int p)) {}
-main() {
+void f() {
Function(int p) bar;
foo(bar);
}
@@ -92,13 +92,13 @@
Future<void> test_read_typeAssignment() async {
await resolveTestCode('''
-main() {
+void f() {
int a = test;
print(a);
}
''');
await assertHasFix('''
-main() {
+void f() {
int test;
int a = test;
print(a);
@@ -108,14 +108,14 @@
Future<void> test_read_typeCondition() async {
await resolveTestCode('''
-main() {
+void f() {
if (!test) {
print(42);
}
}
''');
await assertHasFix('''
-main() {
+void f() {
bool test;
if (!test) {
print(42);
@@ -126,17 +126,17 @@
Future<void> test_read_typeInvocationArgument() async {
await resolveTestCode('''
-main() {
- f(test);
+void f() {
+ g(test);
}
-f(String p) {}
+g(String p) {}
''');
await assertHasFix('''
-main() {
+void f() {
String test;
- f(test);
+ g(test);
}
-f(String p) {}
+g(String p) {}
''');
assertLinkedGroup(change.linkedEditGroups[0], ['String test;']);
assertLinkedGroup(change.linkedEditGroups[1], ['test;', 'test);']);
@@ -144,12 +144,12 @@
Future<void> test_read_typeInvocationTarget() async {
await resolveTestCode('''
-main() {
+void f() {
test.add('hello');
}
''');
await assertHasFix('''
-main() {
+void f() {
var test;
test.add('hello');
}
@@ -182,7 +182,7 @@
import 'package:pkg/a/a.dart';
import 'package:pkg/c/c.dart';
-main() {
+void f() {
A? a;
new C(a, b);
}
@@ -192,7 +192,7 @@
import 'package:pkg/b/b.dart';
import 'package:pkg/c/c.dart';
-main() {
+void f() {
A? a;
B b;
new C(a, b);
@@ -203,22 +203,22 @@
var typeGroup = groups[0];
var typePositions = typeGroup.positions;
expect(typePositions, hasLength(1));
- expect(typePositions[0].offset, 113);
+ expect(typePositions[0].offset, 115);
var nameGroup = groups[1];
var groupPositions = nameGroup.positions;
expect(groupPositions, hasLength(2));
- expect(groupPositions[0].offset, 115);
- expect(groupPositions[1].offset, 129);
+ expect(groupPositions[0].offset, 117);
+ expect(groupPositions[1].offset, 131);
}
Future<void> test_write_assignment() async {
await resolveTestCode('''
-main() {
+void f() {
test = 42;
}
''');
await assertHasFix('''
-main() {
+void f() {
var test = 42;
}
''');
@@ -226,12 +226,12 @@
Future<void> test_write_assignment_compound() async {
await resolveTestCode('''
-main() {
+void f() {
test += 42;
}
''');
await assertHasFix('''
-main() {
+void f() {
int test;
test += 42;
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_mixin_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_mixin_test.dart
index fb68eca..eab8bea 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_mixin_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_mixin_test.dart
@@ -23,7 +23,7 @@
Future<void> test_hasUnresolvedPrefix() async {
await resolveTestCode('''
-main() {
+void f() {
prefix.Test v = null;
print(v);
}
@@ -39,7 +39,7 @@
await resolveTestCode('''
import 'lib.dart' as lib;
-main() {
+void f() {
lib.A? a = null;
lib.Test? t = null;
print('\$a \$t');
@@ -81,7 +81,7 @@
Future<void> test_instanceCreation_withNew() async {
await resolveTestCode('''
-main() {
+void f() {
new Test();
}
''');
@@ -90,7 +90,7 @@
Future<void> test_instanceCreation_withoutNew() async {
await resolveTestCode('''
-main() {
+void f() {
Test();
}
''');
@@ -99,13 +99,13 @@
Future<void> test_itemOfList() async {
await resolveTestCode('''
-main() {
+void f() {
var a = [Test];
print(a);
}
''');
await assertHasFix('''
-main() {
+void f() {
var a = [Test];
print(a);
}
@@ -122,14 +122,14 @@
const MyAnnotation(a, b);
}
@MyAnnotation(int, const [Test])
-main() {}
+void f() {}
''');
await assertHasFix('''
class MyAnnotation {
const MyAnnotation(a, b);
}
@MyAnnotation(int, const [Test])
-main() {}
+void f() {}
mixin Test {
}
@@ -141,13 +141,13 @@
Future<void> test_simple() async {
await resolveTestCode('''
-main() {
+void f() {
Test v = null;
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
Test v = null;
print(v);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart b/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart
index e185798..24bc1e5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart
@@ -30,7 +30,7 @@
''');
await resolveTestCode('''
import 'lib.dart' show A;
-main() {
+void f() {
A? a;
B? b;
print('\$a \$b');
@@ -314,7 +314,7 @@
''');
await resolveTestCode('''
-main() {
+void f() {
Test test = null;
print(test);
}
@@ -323,7 +323,7 @@
await assertHasFix('''
import 'package:my_pkg/a.dart';
-main() {
+void f() {
Test test = null;
print(test);
}
@@ -377,7 +377,7 @@
my_pkg: any
''');
await resolveTestCode('''
-main() {
+void f() {
Test test = null;
print(test);
}
@@ -390,7 +390,7 @@
class Test {}
''');
await resolveTestCode('''
-main() {
+void f() {
Test t;
print(t);
}
@@ -403,12 +403,12 @@
class Foo {}
''');
await resolveTestCode('''
-main() { new Foo(); }
+void f() { new Foo(); }
''');
await assertHasFix('''
import 'a.dart';
-main() { new Foo(); }
+void f() { new Foo(); }
''',
expectedNumberOfFixesForKind: 2,
matchFixMessage: "Import library 'a.dart'");
@@ -425,12 +425,12 @@
class Foo {}
''');
await resolveTestCode('''
-main() { new Foo(); }
+void f() { new Foo(); }
''');
await assertHasFix('''
import 'dir/a.dart';
-main() { new Foo(); }
+void f() { new Foo(); }
''',
expectedNumberOfFixesForKind: 2,
matchFixMessage: "Import library 'dir/a.dart'");
@@ -442,12 +442,12 @@
class Foo {}
''');
await resolveTestCode('''
-main() { new Foo(); }
+void f() { new Foo(); }
''');
await assertHasFix('''
import 'a.dart';
-main() { new Foo(); }
+void f() { new Foo(); }
''',
expectedNumberOfFixesForKind: 2,
matchFixMessage: "Import library 'a.dart'");
@@ -465,12 +465,12 @@
''');
testFile = convertPath('$testPackageLibPath/dir/test.dart');
await resolveTestCode('''
-main() { new Foo(); }
+void f() { new Foo(); }
''');
await assertHasFix('''
import '../a.dart';
-main() { new Foo(); }
+void f() { new Foo(); }
''',
expectedNumberOfFixesForKind: 2,
matchFixMessage: "Import library '../a.dart'");
@@ -485,14 +485,14 @@
''');
await resolveTestCode('''
@Test(0)
-main() {
+void f() {
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
@Test(0)
-main() {
+void f() {
}
''');
}
@@ -557,7 +557,7 @@
class Test {}
''');
await resolveTestCode('''
-main() {
+void f() {
Test t = null;
print(t);
}
@@ -565,7 +565,7 @@
await assertHasFix('''
import '../lib.dart';
-main() {
+void f() {
Test t = null;
print(t);
}
@@ -579,7 +579,7 @@
class Test {}
''');
await resolveTestCode('''
-main() {
+void f() {
Test t = null;
print(t);
}
@@ -587,7 +587,7 @@
await assertHasFix('''
import '../tool/sub/folder/lib.dart';
-main() {
+void f() {
Test t = null;
print(t);
}
@@ -601,7 +601,7 @@
class Test {}
''');
await resolveTestCode('''
-main() {
+void f() {
Test t = null;
print(t);
}
@@ -609,7 +609,7 @@
await assertHasFix('''
import 'lib.dart';
-main() {
+void f() {
Test t = null;
print(t);
}
@@ -623,14 +623,14 @@
}
''');
await resolveTestCode('''
-main() {
+void f() {
return const Test();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
return const Test();
}
''');
@@ -643,14 +643,14 @@
}
''');
await resolveTestCode('''
-main() {
+void f() {
const Test.named();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
const Test.named();
}
''');
@@ -663,14 +663,14 @@
}
''');
await resolveTestCode('''
-main() {
+void f() {
return Test();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
return Test();
}
''');
@@ -683,14 +683,14 @@
}
''');
await resolveTestCode('''
-main() {
+void f() {
return new Test();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
return new Test();
}
''');
@@ -703,14 +703,14 @@
}
''');
await resolveTestCode('''
-main() {
+void f() {
new Test.named();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
new Test.named();
}
''');
@@ -940,14 +940,14 @@
myFunction() {}
''');
await resolveTestCode('''
-main() {
+void f() {
myFunction();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
myFunction();
}
''');
@@ -958,14 +958,14 @@
var myFunction = () {};
''');
await resolveTestCode('''
-main() {
+void f() {
myFunction();
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
myFunction();
}
''');
@@ -976,14 +976,14 @@
var myFunction = () {};
''');
await resolveTestCode('''
-main() {
+void f() {
myFunction;
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
myFunction;
}
''');
@@ -995,14 +995,14 @@
myFunction() {}
''');
await resolveTestCode('''
-main() {
+void f() {
myFunction;
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
myFunction;
}
''');
@@ -1014,7 +1014,7 @@
int zero = 0;
''');
await resolveTestCode('''
-main() {
+void f() {
zero();
}
''');
@@ -1028,7 +1028,7 @@
''');
await resolveTestCode('''
class A {
- main() {
+ void f() {
myFunction();
}
}
@@ -1037,7 +1037,7 @@
import 'package:test/lib.dart';
class A {
- main() {
+ void f() {
myFunction();
}
}
@@ -1050,7 +1050,7 @@
typedef MyFunction();
''');
await resolveTestCode('''
-main() {
+void f() {
MyFunction t = null;
print(t);
}
@@ -1058,7 +1058,7 @@
await assertHasFix('''
import 'package:test/lib.dart';
-main() {
+void f() {
MyFunction t = null;
print(t);
}
@@ -1242,7 +1242,7 @@
my_pkg: any
''');
await resolveTestCode('''
-main() {
+void f() {
Test test = null;
print(test);
}
@@ -1250,7 +1250,7 @@
await assertHasFix('''
import 'package:my_pkg/a.dart';
-main() {
+void f() {
Test test = null;
print(test);
}
@@ -1275,7 +1275,7 @@
my_pkg: any
''');
await resolveTestCode('''
-main() {
+void f() {
Test test = null;
print(test);
}
@@ -1283,7 +1283,7 @@
await assertHasFix('''
import 'package:my_pkg/a.dart';
-main() {
+void f() {
Test test = null;
print(test);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/import_library_show_test.dart b/pkg/analysis_server/test/src/services/correction/fix/import_library_show_test.dart
index 7c57f67..6cb0f76 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/import_library_show_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/import_library_show_test.dart
@@ -139,7 +139,7 @@
''');
await resolveTestCode(r'''
import 'lib.dart' show A;
-main() {
+void f() {
A? a;
B b;
print('$a $b');
@@ -147,7 +147,7 @@
''');
await assertHasFix(r'''
import 'lib.dart' show A, B;
-main() {
+void f() {
A? a;
B b;
print('$a $b');
@@ -158,7 +158,7 @@
Future<void> test_sdk() async {
await resolveTestCode(r'''
import 'dart:collection' show HashMap;
-main() {
+void f() {
HashMap? s = null;
LinkedHashMap? f = null;
print('$s $f');
@@ -166,7 +166,7 @@
''');
await assertHasFix(r'''
import 'dart:collection' show HashMap, LinkedHashMap;
-main() {
+void f() {
HashMap? s = null;
LinkedHashMap? f = null;
print('$s $f');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/insert_semicolon_test.dart b/pkg/analysis_server/test/src/services/correction/fix/insert_semicolon_test.dart
index 937ff59..e044b08 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/insert_semicolon_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/insert_semicolon_test.dart
@@ -21,12 +21,12 @@
Future<void> test_expectedToken_semicolon() async {
await resolveTestCode('''
-main() {
+void f() {
print(0)
}
''');
await assertHasFix('''
-main() {
+void f() {
print(0);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_field_not_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_field_not_final_test.dart
index 941643a..2f6c372 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_field_not_final_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_field_not_final_test.dart
@@ -23,7 +23,7 @@
await resolveTestCode('''
class A {
final int fff = 1;
- main() {
+ void f() {
fff = 2;
}
}
@@ -31,7 +31,7 @@
await assertHasFix('''
class A {
int fff = 1;
- main() {
+ void f() {
fff = 2;
}
}
@@ -42,7 +42,7 @@
await resolveTestCode('''
class A {
final fff = 1;
- main() {
+ void f() {
fff = 2;
}
}
@@ -50,7 +50,7 @@
await assertHasFix('''
class A {
var fff = 1;
- main() {
+ void f() {
fff = 2;
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_variable_not_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_variable_not_final_test.dart
index c87fde3..131cb77 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_variable_not_final_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_variable_not_final_test.dart
@@ -21,14 +21,14 @@
Future<void> test_hasType() async {
await resolveTestCode('''
-main() {
+void f() {
final int fff = 1;
fff = 2;
print(fff);
}
''');
await assertHasFix('''
-main() {
+void f() {
int fff = 1;
fff = 2;
print(fff);
@@ -38,14 +38,14 @@
Future<void> test_noType() async {
await resolveTestCode('''
-main() {
+void f() {
final fff = 1;
fff = 2;
print(fff);
}
''');
await assertHasFix('''
-main() {
+void f() {
var fff = 1;
fff = 2;
print(fff);
diff --git a/pkg/analysis_server/test/src/services/correction/fix/move_type_arguments_to_class_test.dart b/pkg/analysis_server/test/src/services/correction/fix/move_type_arguments_to_class_test.dart
index c3b99ff..6cc900d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/move_type_arguments_to_class_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/move_type_arguments_to_class_test.dart
@@ -21,7 +21,7 @@
Future<void> test_explicitConst() async {
await resolveTestCode('''
-main() {
+void f() {
const C.named<int>();
}
class C<E> {
@@ -29,7 +29,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
const C<int>.named();
}
class C<E> {
@@ -40,7 +40,7 @@
Future<void> test_explicitNew() async {
await resolveTestCode('''
-main() {
+void f() {
new C.named<int>();
}
class C<E> {
@@ -48,7 +48,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
new C<int>.named();
}
class C<E> {
@@ -59,7 +59,7 @@
Future<void> test_explicitNew_alreadyThere() async {
await resolveTestCode('''
-main() {
+void f() {
new C<String>.named<int>();
}
class C<E> {
@@ -71,7 +71,7 @@
Future<void> test_explicitNew_wrongNumber() async {
await resolveTestCode('''
-main() {
+void f() {
new C.named<int, String>();
}
class C<E> {
@@ -83,7 +83,7 @@
Future<void> test_implicitConst() async {
await resolveTestCode('''
-main() {
+void f() {
const C c = C.named<int>();
print(c);
}
@@ -92,7 +92,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
const C c = C<int>.named();
print(c);
}
@@ -104,7 +104,7 @@
Future<void> test_implicitNew() async {
await resolveTestCode('''
-main() {
+void f() {
C.named<int>();
}
class C<E> {
@@ -112,7 +112,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
C<int>.named();
}
class C<E> {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
index c9ab551..f62a24e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
@@ -26,7 +26,7 @@
void f({bool valWithDefault = true, bool val}) {}
void f2({bool valWithDefault = true, bool val}) {}
-void main() {
+void g() {
f(valWithDefault: true);
f2(valWithDefault: true, val: false);
}
@@ -35,7 +35,7 @@
void f({bool valWithDefault = true, bool val}) {}
void f2({bool valWithDefault = true, bool val}) {}
-void main() {
+void g() {
f();
f2(val: false);
}
@@ -94,14 +94,14 @@
await resolveTestCode('''
void f({bool valWithDefault = true, bool? val}) {}
-void main() {
+void g() {
f(valWithDefault: true);
}
''');
await assertHasFix('''
void f({bool valWithDefault = true, bool? val}) {}
-void main() {
+void g() {
f();
}
''');
@@ -128,14 +128,14 @@
await resolveTestCode('''
void f({bool valWithDefault = true, bool? val}) {}
-void main() {
+void g() {
f(valWithDefault: true, val: false);
}
''');
await assertHasFix('''
void f({bool valWithDefault = true, bool? val}) {}
-void main() {
+void g() {
f(val: false);
}
''');
@@ -145,14 +145,14 @@
await resolveTestCode('''
void g(int x, [int y = 0]) {}
-void main() {
+void f() {
g(1, 0);
}
''');
await assertHasFix('''
void g(int x, [int y = 0]) {}
-void main() {
+void f() {
g(1);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
index 646d310..fd9b58d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
@@ -23,13 +23,13 @@
Future<void> test_singleFile() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 42;
print('v: ${ v}, ${ v}');
}
''');
await assertHasFix(r'''
-main() {
+void f() {
var v = 42;
print('v: $v, $v');
}
@@ -47,13 +47,13 @@
Future<void> test_withSpace() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 42;
print('v: ${ v}');
}
''');
await assertHasFix(r'''
-main() {
+void f() {
var v = 42;
print('v: $v');
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_leading_underscore_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_leading_underscore_test.dart
index 3f0a3cd..d722b66 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_leading_underscore_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_leading_underscore_test.dart
@@ -24,7 +24,7 @@
Future<void> test_singleFile() async {
await resolveTestCode('''
-main() {
+void f() {
int _foo = 42;
print(_foo);
[0, 1, 2].forEach((_bar) {
@@ -33,7 +33,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
int foo = 42;
print(foo);
[0, 1, 2].forEach((bar) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_name_from_combinator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_name_from_combinator_test.dart
index e833910..4f61de5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_name_from_combinator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_name_from_combinator_test.dart
@@ -23,14 +23,14 @@
await resolveTestCode('''
import 'dart:math' hide cos, sin, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
@@ -40,14 +40,14 @@
await resolveTestCode('''
import 'dart:math' hide cos, cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
@@ -60,14 +60,14 @@
await resolveTestCode('''
import 'dart:math' hide cos, sin hide sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
@@ -80,14 +80,14 @@
await resolveTestCode('''
import 'dart:math' hide cos hide cos hide sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos hide sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
@@ -184,14 +184,14 @@
await resolveTestCode('''
import 'dart:math' hide aaa hide cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
@@ -201,14 +201,14 @@
await resolveTestCode('''
import 'dart:math' hide cos, sin hide aaa;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos, sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
@@ -218,14 +218,14 @@
await resolveTestCode('''
import 'dart:math' hide cos hide aaa hide sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
await assertHasFix('''
import 'dart:math' hide cos hide sin;
-main() {
+void f() {
print(min(0, 1));
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_type_arguments_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_type_arguments_test.dart
index 62bf7e6..472127c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_type_arguments_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_type_arguments_test.dart
@@ -21,7 +21,7 @@
Future<void> test_explicitConst() async {
await resolveTestCode('''
-main() {
+void f() {
const C.named<int>();
}
class C<E> {
@@ -29,7 +29,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
const C.named();
}
class C<E> {
@@ -40,7 +40,7 @@
Future<void> test_explicitNew() async {
await resolveTestCode('''
-main() {
+void f() {
new C.named<int>();
}
class C<E> {
@@ -48,7 +48,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
new C.named();
}
class C<E> {
@@ -59,7 +59,7 @@
Future<void> test_implicitConst() async {
await resolveTestCode('''
-main() {
+void f() {
const C c = C.named<int>();
print(c);
}
@@ -68,7 +68,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
const C c = C.named();
print(c);
}
@@ -80,7 +80,7 @@
Future<void> test_implicitNew() async {
await resolveTestCode('''
-main() {
+void f() {
C.named<int>();
}
class C<E> {
@@ -88,7 +88,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
C.named();
}
class C<E> {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart
index 171e2e1..b63e4ca 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart
@@ -23,7 +23,7 @@
Future<void> test_singleFile() async {
await resolveTestCode('''
-main() {
+void f() {
try {
throw 42;
} on int catch (i) {
@@ -32,7 +32,7 @@
}
''');
await assertHasFixAllFix(HintCode.UNUSED_CATCH_CLAUSE, '''
-main() {
+void f() {
try {
throw 42;
} on int {
@@ -50,7 +50,7 @@
Future<void> test_removeUnusedCatchClause() async {
await resolveTestCode('''
-main() {
+void f() {
try {
throw 42;
} on int catch (e) {
@@ -58,7 +58,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
try {
throw 42;
} on int {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_stack_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_stack_test.dart
index f72b354..94f4105 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_stack_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_stack_test.dart
@@ -23,7 +23,7 @@
Future<void> test_singleFile() async {
await resolveTestCode('''
-main() {
+void f() {
try {
throw 42;
} on int catch (i, stack) {
@@ -32,7 +32,7 @@
}
''');
await assertHasFixAllFix(HintCode.UNUSED_CATCH_STACK, '''
-main() {
+void f() {
try {
throw 42;
} on int catch (i) {
@@ -50,7 +50,7 @@
Future<void> test_removeUnusedCatchStack() async {
await resolveTestCode('''
-main() {
+void f() {
try {
throw 42;
} catch (e, stack) {
@@ -58,7 +58,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
try {
throw 42;
} catch (e) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_field_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_field_test.dart
index 8524de5..e09d62c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_field_test.dart
@@ -179,14 +179,14 @@
await resolveTestCode(r'''
class A {
int? _f;
- main() {
+ void f() {
_f = 2;
}
}
''');
await assertHasFix(r'''
class A {
- main() {
+ void f() {
}
}
''');
@@ -196,14 +196,14 @@
await resolveTestCode(r'''
class A {
var _f;
- main() {
+ void f() {
_f = () { _f = 0; };
}
}
''');
await assertHasFix(r'''
class A {
- main() {
+ void f() {
}
}
''');
@@ -213,14 +213,14 @@
await resolveTestCode(r'''
class A {
int _f = 0;
- main() {
+ void f() {
_f += 2;
}
}
''');
await assertHasFix(r'''
class A {
- main() {
+ void f() {
}
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_local_variable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_local_variable_test.dart
index dac33f8..291c8b6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_local_variable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_local_variable_test.dart
@@ -22,14 +22,14 @@
Future<void> test_assignmentInAssignment() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 1;
v = (v = 2);
print(0);
}
''');
await assertHasFix(r'''
-main() {
+void f() {
print(0);
}
''');
@@ -37,13 +37,13 @@
Future<void> test_inArgumentList() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 1;
print(v = 2);
}
''');
await assertHasFix(r'''
-main() {
+void f() {
print(2);
}
''');
@@ -51,14 +51,14 @@
Future<void> test_inArgumentList2() async {
await resolveTestCode(r'''
-main() {
+void g() {
var v = 1;
f(v = 1, 2);
}
void f(a, b) { }
''');
await assertHasFix(r'''
-main() {
+void g() {
f(1, 2);
}
void f(a, b) { }
@@ -67,14 +67,14 @@
Future<void> test_inArgumentList3() async {
await resolveTestCode(r'''
-main() {
+void g() {
var v = 1;
f(v = 1, v = 2);
}
void f(a, b) { }
''');
await assertHasFix(r'''
-main() {
+void g() {
f(1, 2);
}
void f(a, b) { }
@@ -83,14 +83,14 @@
Future<void> test_inDeclarationList() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 1, v2 = 3;
v = 2;
print(v2);
}
''');
await assertHasFix(r'''
-main() {
+void f() {
var v2 = 3;
print(v2);
}
@@ -99,13 +99,13 @@
Future<void> test_inDeclarationList2() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 1, v2 = 3;
print(v);
}
''');
await assertHasFix(r'''
-main() {
+void f() {
var v = 1;
print(v);
}
@@ -121,13 +121,13 @@
Future<void> test_withReferences() async {
await resolveTestCode(r'''
-main() {
+void f() {
var v = 1;
v = 2;
}
''');
await assertHasFix(r'''
-main() {
+void f() {
}
''');
}
@@ -136,13 +136,13 @@
// CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION
verifyNoTestUnitErrors = false;
await resolveTestCode(r'''
-main() {
+void f() {
v = 2;
var v = 1;
}
''');
await assertHasFix(r'''
-main() {
+void f() {
}
''',
errorFilter: (e) =>
diff --git a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
index 806eb6b..a658d2d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
@@ -23,7 +23,7 @@
Future<void> test_singleFile() async {
await resolveTestCode('''
-main() {
+void f() {
int my_integer_variable = 42;
int foo;
print(my_integer_variable);
@@ -34,7 +34,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
int myIntegerVariable = 42;
int foo;
print(myIntegerVariable);
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart
index 2d35370..ec432a0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart
@@ -23,13 +23,13 @@
Future<void> test_all() async {
await resolveTestCode('''
-main() {
+void f() {
boolean v;
boolean w;
}
''');
await assertHasFixAllFix(CompileTimeErrorCode.UNDEFINED_CLASS_BOOLEAN, '''
-main() {
+void f() {
bool v;
bool w;
}
@@ -44,13 +44,13 @@
Future<void> test_single() async {
await resolveTestCode('''
-main() {
+void f() {
boolean v;
print(v);
}
''');
await assertHasFix('''
-main() {
+void f() {
bool v;
print(v);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart
index 4fca1eb..8abaadb 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart
@@ -26,7 +26,7 @@
class A {
const A();
}
-main() {
+void f() {
var a = new A();
var b = new A();
}
@@ -35,7 +35,7 @@
class A {
const A();
}
-main() {
+void f() {
var a = const A();
var b = const A();
}
@@ -48,7 +48,7 @@
const A({A? parent});
const A.a();
}
-main() {
+void f() {
var a = new A(
parent: new A(),
);
@@ -60,7 +60,7 @@
const A({A? parent});
const A.a();
}
-main() {
+void f() {
var a = new A(
parent: const A(),
);
@@ -74,7 +74,7 @@
const A({A? parent});
const A.a();
}
-main() {
+void f() {
var b = new A(
parent: const A.a(),
);
@@ -86,7 +86,7 @@
const A({A? parent});
const A.a();
}
-main() {
+void f() {
var b = const A(
parent: const A.a(),
);
@@ -108,7 +108,7 @@
class C {
const C();
}
-main() {
+void f() {
var c = new C();
print(c);
}
@@ -117,7 +117,7 @@
class C {
const C();
}
-main() {
+void f() {
var c = const C();
print(c);
}
@@ -129,7 +129,7 @@
class C {
const C();
}
-main() {
+void f() {
var c = C();
print(c);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart b/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
index b571ad5..213b17b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
@@ -25,7 +25,7 @@
writeTestPackageConfig(flutter: true);
await resolveTestCode('''
import 'package:flutter/material.dart';
-main() {
+void f() {
Column(
children: [
Column(
@@ -46,7 +46,7 @@
// see: linter/test/rules/sort_child_properties_last.dart:nestedChildren()
await assertHasFix('''
import 'package:flutter/material.dart';
-main() {
+void f() {
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@@ -86,7 +86,7 @@
Future<void> test_sort() async {
await resolveTestCode('''
import 'package:flutter/material.dart';
-main() {
+void f() {
Column(
children: <Widget>[
Text('aaa'),
@@ -99,7 +99,7 @@
''');
await assertHasFix('''
import 'package:flutter/material.dart';
-main() {
+void f() {
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_effective_integer_division_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_effective_integer_division_test.dart
index b8b788d..4336a8c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_effective_integer_division_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_effective_integer_division_test.dart
@@ -19,14 +19,14 @@
class UseEffectiveIntegerDivisionMultiTest extends BulkFixProcessorTest {
Future<void> test_singleFile() async {
await resolveTestCode('''
-main() {
+void f() {
var a = 5;
var b = 2;
print((a / ((a / b).toInt())).toInt());
}
''');
await assertHasFix('''
-main() {
+void f() {
var a = 5;
var b = 2;
print(a ~/ (a ~/ b));
@@ -42,14 +42,14 @@
Future<void> test_normalDivision() async {
await resolveTestCode('''
-main() {
+void f() {
var a = 5;
var b = 2;
print((a / b).toInt());
}
''');
await assertHasFix('''
-main() {
+void f() {
var a = 5;
var b = 2;
print(a ~/ b);
diff --git a/pkg/analysis_server/test/src/services/flutter/container_properties_test.dart b/pkg/analysis_server/test/src/services/flutter/container_properties_test.dart
index ed3ff69..a603964 100644
--- a/pkg/analysis_server/test/src/services/flutter/container_properties_test.dart
+++ b/pkg/analysis_server/test/src/services/flutter/container_properties_test.dart
@@ -23,7 +23,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
alignment: Alignment.centerRight,
@@ -52,7 +52,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Column(
children: [
Text(''),
@@ -85,7 +85,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
alignment: Alignment.centerRight,
widthFactor: 2,
@@ -102,7 +102,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
alignment: Alignment.centerRight,
child: Text(''),
@@ -134,7 +134,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
alignment: Alignment.centerRight,
@@ -166,7 +166,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
alignment: AlignmentDirectional.centerStart,
@@ -198,7 +198,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
alignment: Alignment.centerRight,
child: Text(''),
@@ -217,7 +217,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
alignment: Alignment.bottomLeft,
child: Text(''),
@@ -230,7 +230,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
alignment: Alignment.centerRight,
child: Text(''),
@@ -247,7 +247,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
child: Text(''),
);
@@ -259,7 +259,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
);
@@ -277,7 +277,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
alignment: Alignment.bottomLeft,
child: Text(''),
@@ -290,7 +290,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
alignment: Alignment.centerRight,
child: Text(''),
@@ -309,7 +309,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
alignment: Alignment.bottomLeft,
child: Text(''),
@@ -322,7 +322,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
alignment: Alignment.centerRight,
child: Text(''),
@@ -339,7 +339,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
);
@@ -351,7 +351,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Padding(
padding: EdgeInsets.only(left: 1, right: 3),
child: Text(''),
@@ -370,7 +370,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
alignment: Alignment.bottomLeft,
padding: EdgeInsets.only(left: 1, right: 3),
@@ -384,7 +384,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Column(
children: [
Text(''),
@@ -404,7 +404,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Column(
children: [
Container(
@@ -441,7 +441,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.all(4),
child: Text(''),
@@ -519,7 +519,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.fromLTRB(1, 2, 3, 4),
child: Text(''),
@@ -597,7 +597,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1, right: 3),
child: Text(''),
@@ -667,7 +667,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.symmetric(horizontal: 2, vertical: 4),
child: Text(''),
@@ -745,7 +745,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Padding(
padding: EdgeInsets.only(left: 1, right: 3),
child: Text(''),
@@ -815,7 +815,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Align(
alignment: Alignment.centerRight,
child: Text(''),
@@ -835,7 +835,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
alignment: Alignment.centerRight,
padding: EdgeInsets.only(left: 1),
@@ -849,7 +849,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
);
@@ -868,7 +868,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1),
child: Text(''),
@@ -881,7 +881,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1, top: 2, right: 1, bottom: 1),
child: Text(''),
@@ -901,7 +901,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.all(1),
child: Text(''),
@@ -914,7 +914,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1, right: 3),
child: Text(''),
@@ -934,7 +934,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 11, right: 3),
child: Text(''),
@@ -947,7 +947,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1),
child: Text(''),
@@ -967,7 +967,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
child: Text(''),
);
@@ -979,7 +979,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1, top: 2, right: 1, bottom: 4),
child: Text(''),
@@ -999,7 +999,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.symmetric(horizontal: 1, vertical: 4),
child: Text(''),
@@ -1012,7 +1012,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(left: 1, right: 3),
child: Text(''),
@@ -1032,7 +1032,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.symmetric(horizontal: 3),
child: Text(''),
@@ -1045,7 +1045,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.only(top: 2, bottom: 4),
child: Text(''),
@@ -1065,7 +1065,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Container(
padding: EdgeInsets.symmetric(vertical: 4),
child: Text(''),
@@ -1078,7 +1078,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Padding(
padding: EdgeInsets.only(left: 1, right: 3),
child: Text(''),
@@ -1098,7 +1098,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Padding(
padding: EdgeInsets.only(left: 11, right: 3),
child: Text(''),
@@ -1111,7 +1111,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Column(
children: [
Text(''),
@@ -1132,7 +1132,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Column(
children: [
Container(
diff --git a/pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart b/pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart
index c2a1b33..b0cd476 100644
--- a/pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart
+++ b/pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart
@@ -52,7 +52,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -75,7 +75,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa', softWrap: true);
}
''');
@@ -102,7 +102,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -129,7 +129,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('');
}
''');
@@ -153,7 +153,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', style: TextStyle(fontSize: 24));
}
''');
@@ -204,7 +204,7 @@
Future<void> test_notInstanceCreation() async {
await resolveTestCode('''
-void main() {
+void f() {
42;
}
''');
@@ -216,7 +216,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -238,7 +238,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', overflow: TextOverflow.fade);
}
''');
@@ -297,7 +297,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -318,7 +318,7 @@
Future<void> test_unresolvedInstanceCreation() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-void main() {
+void f() {
new Foo();
}
''');
@@ -333,7 +333,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1);
}
''');
@@ -347,7 +347,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1 + 2);
}
''');
@@ -357,7 +357,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1);
}
''');
@@ -384,7 +384,7 @@
1 + 2; // two spaces
}
-void main() {
+void f() {
Text('', );
}
@@ -406,7 +406,7 @@
1 + 2; // two spaces
}
-void main() {
+void f() {
Text(
'',
maxLines: 42,
@@ -435,7 +435,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
child: Text(''),
);
@@ -455,7 +455,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
xxx: 42,
child: Text(''),
@@ -472,7 +472,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
children: [Text('')],
);
@@ -492,7 +492,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
xxx: 42,
children: [Text('')],
@@ -509,7 +509,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', );
}
''');
@@ -523,7 +523,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text(
'',
maxLines: 42,
@@ -536,7 +536,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('');
}
''');
@@ -550,7 +550,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text(
'',
maxLines: 42,
@@ -563,7 +563,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
bbb: 2,
);
@@ -583,7 +583,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
aaa: 42,
bbb: 2,
@@ -600,7 +600,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
aaa: 1,
);
@@ -620,7 +620,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
aaa: 1,
bbb: 42,
@@ -637,7 +637,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
aaa: 1,
ccc: 3,
@@ -658,7 +658,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
MyWidget<int>(
aaa: 1,
bbb: 42,
@@ -676,7 +676,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1);
}
''');
@@ -690,7 +690,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 42);
}
''');
@@ -700,7 +700,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1,);
}
''');
@@ -711,7 +711,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', );
}
''');
@@ -721,7 +721,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', maxLines: 1, softWrap: true,);
}
''');
@@ -732,7 +732,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', softWrap: true,);
}
''');
@@ -742,7 +742,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', style: TextStyle(), );
}
''');
@@ -758,7 +758,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text(
'',
style: TextStyle(
@@ -773,7 +773,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('', );
}
''');
@@ -789,7 +789,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text(
'',
style: TextStyle(
@@ -804,7 +804,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -818,7 +818,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('bbbb');
}
''');
@@ -828,7 +828,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('aaa');
}
''');
@@ -847,7 +847,7 @@
await resolveTestCode('''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text('');
}
''');
@@ -867,7 +867,7 @@
assertExpectedChange(result, r'''
import 'package:flutter/material.dart';
-void main() {
+void f() {
Text(
'',
overflow: TextOverflow.ellipsis,
diff --git a/pkg/analyzer/lib/error/listener.dart b/pkg/analyzer/lib/error/listener.dart
index c21fe48..acc1838 100644
--- a/pkg/analyzer/lib/error/listener.dart
+++ b/pkg/analyzer/lib/error/listener.dart
@@ -11,6 +11,7 @@
import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/diagnostic/diagnostic.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:meta/meta.dart';
import 'package:source_span/source_span.dart';
/// An object that listen for [AnalysisError]s being produced by the analysis
@@ -51,6 +52,11 @@
/// The source to be used when reporting errors.
final Source _source;
+ /// The lock level, if greater than zero, no errors will be reported.
+ /// This is used to prevent reporting errors inside comments.
+ @internal
+ int lockLevel = 0;
+
/// Initialize a newly created error reporter that will report errors to the
/// given [_errorListener]. Errors will be reported against the
/// [_defaultSource] unless another source is provided later.
@@ -101,6 +107,10 @@
/// of the error is specified by the given [offset] and [length].
void reportErrorForOffset(ErrorCode errorCode, int offset, int length,
[List<Object>? arguments, List<DiagnosticMessage>? messages]) {
+ if (lockLevel != 0) {
+ return;
+ }
+
_convertElements(arguments);
messages ??= [];
messages.addAll(_convertTypeNames(arguments));
diff --git a/pkg/analyzer/lib/src/dart/resolver/comment_reference_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/comment_reference_resolver.dart
index e67b6b1..f43eecf 100644
--- a/pkg/analyzer/lib/src/dart/resolver/comment_reference_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/comment_reference_resolver.dart
@@ -23,16 +23,21 @@
/// Resolves [commentReference].
void resolve(CommentReference commentReference) {
- var expression = commentReference.expression;
- if (expression is SimpleIdentifierImpl) {
- _resolveSimpleIdentifierReference(expression,
- hasNewKeyword: commentReference.newKeyword != null);
- } else if (expression is PrefixedIdentifierImpl) {
- _resolvePrefixedIdentifierReference(expression,
- hasNewKeyword: commentReference.newKeyword != null);
- } else if (expression is PropertyAccessImpl) {
- _resolvePropertyAccessReference(expression,
- hasNewKeyword: commentReference.newKeyword != null);
+ _resolver.errorReporter.lockLevel++;
+ try {
+ var expression = commentReference.expression;
+ if (expression is SimpleIdentifierImpl) {
+ _resolveSimpleIdentifierReference(expression,
+ hasNewKeyword: commentReference.newKeyword != null);
+ } else if (expression is PrefixedIdentifierImpl) {
+ _resolvePrefixedIdentifierReference(expression,
+ hasNewKeyword: commentReference.newKeyword != null);
+ } else if (expression is PropertyAccessImpl) {
+ _resolvePropertyAccessReference(expression,
+ hasNewKeyword: commentReference.newKeyword != null);
+ }
+ } finally {
+ _resolver.errorReporter.lockLevel--;
}
}
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index 50e62f5..acef1f4 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -64,7 +64,11 @@
return null;
}
- return LibraryMacroApplier(macroExecutor, this);
+ return LibraryMacroApplier(
+ macroExecutor: macroExecutor,
+ declarationBuilder: linker.macroDeclarationBuilder,
+ libraryBuilder: this,
+ );
}();
LibraryBuilder._({
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 7c4a048..31000d1 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -17,6 +17,7 @@
import 'package:analyzer/src/summary2/detach_nodes.dart';
import 'package:analyzer/src/summary2/library_builder.dart';
import 'package:analyzer/src/summary2/linked_element_factory.dart';
+import 'package:analyzer/src/summary2/macro_declarations.dart';
import 'package:analyzer/src/summary2/reference.dart';
import 'package:analyzer/src/summary2/simply_bounded.dart';
import 'package:analyzer/src/summary2/super_constructor_resolver.dart';
@@ -42,6 +43,7 @@
class Linker {
final LinkedElementFactory elementFactory;
final macro.MultiMacroExecutor? macroExecutor;
+ final DeclarationBuilder macroDeclarationBuilder = DeclarationBuilder();
/// Libraries that are being linked.
final Map<Uri, LibraryBuilder> builders = {};
@@ -124,6 +126,8 @@
await library.executeMacroTypesPhase();
}
+ macroDeclarationBuilder.transferToElements();
+
for (var library in builders.values) {
library.buildInitialExportScope();
}
diff --git a/pkg/analyzer/lib/src/summary2/macro_application.dart b/pkg/analyzer/lib/src/summary2/macro_application.dart
index e3cb33d..6b7dd6c 100644
--- a/pkg/analyzer/lib/src/summary2/macro_application.dart
+++ b/pkg/analyzer/lib/src/summary2/macro_application.dart
@@ -8,8 +8,6 @@
as macro;
import 'package:_fe_analyzer_shared/src/macros/executor/multi_executor.dart';
import 'package:_fe_analyzer_shared/src/macros/executor/protocol.dart' as macro;
-import 'package:_fe_analyzer_shared/src/macros/executor/remote_instance.dart'
- as macro;
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/element/type.dart';
@@ -18,23 +16,27 @@
import 'package:analyzer/src/summary2/library_builder.dart';
import 'package:analyzer/src/summary2/link.dart';
import 'package:analyzer/src/summary2/macro_application_error.dart';
+import 'package:analyzer/src/summary2/macro_declarations.dart';
class LibraryMacroApplier {
final MultiMacroExecutor macroExecutor;
+ final DeclarationBuilder declarationBuilder;
final LibraryBuilder libraryBuilder;
final List<_MacroTarget> _targets = [];
- final Map<ClassDeclaration, macro.ClassDeclarationImpl> _classDeclarations =
- {};
-
final macro.IdentifierResolver _identifierResolver = _IdentifierResolver();
final macro.TypeResolver _typeResolver = _TypeResolver();
- final macro.ClassIntrospector _classIntrospector = _ClassIntrospector();
+ late final macro.ClassIntrospector _classIntrospector =
+ _ClassIntrospector(declarationBuilder);
- LibraryMacroApplier(this.macroExecutor, this.libraryBuilder);
+ LibraryMacroApplier({
+ required this.macroExecutor,
+ required this.declarationBuilder,
+ required this.libraryBuilder,
+ });
Linker get _linker => libraryBuilder.linker;
@@ -51,7 +53,7 @@
targetElement,
targetNode.metadata,
macro.DeclarationKind.clazz,
- () => getClassDeclaration(targetNode),
+ () => declarationBuilder.fromNode.classDeclaration(targetNode),
);
}
}
@@ -103,12 +105,6 @@
return _buildAugmentationLibrary(results);
}
- /// TODO(scheglov) Do we need this caching?
- /// Or do we need it only during macro applications creation?
- macro.ClassDeclarationImpl getClassDeclaration(ClassDeclaration node) {
- return _classDeclarations[node] ??= _buildClassDeclaration(node);
- }
-
/// If there are any macro applications in [annotations], add a new
/// element into [_targets].
Future<void> _buildApplications(
@@ -337,121 +333,6 @@
return macro.Arguments(positional, named);
}
- static macro.ClassDeclarationImpl _buildClassDeclaration(
- ClassDeclaration node,
- ) {
- return macro.ClassDeclarationImpl(
- id: macro.RemoteInstance.uniqueId,
- identifier: _buildIdentifier(node.name),
- typeParameters: _buildTypeParameters(node.typeParameters),
- interfaces: _buildTypeAnnotations(node.implementsClause?.interfaces),
- isAbstract: node.abstractKeyword != null,
- isExternal: false,
- mixins: _buildTypeAnnotations(node.withClause?.mixinTypes),
- superclass: node.extendsClause?.superclass.mapOrNull(
- _buildTypeAnnotation,
- ),
- );
- }
-
- static macro.FunctionTypeParameterImpl _buildFormalParameter(
- FormalParameter node,
- ) {
- if (node is DefaultFormalParameter) {
- node = node.parameter;
- }
-
- final macro.TypeAnnotationImpl typeAnnotation;
- if (node is SimpleFormalParameter) {
- typeAnnotation = _buildTypeAnnotation(node.type);
- } else {
- throw UnimplementedError('(${node.runtimeType}) $node');
- }
-
- return macro.FunctionTypeParameterImpl(
- id: macro.RemoteInstance.uniqueId,
- isNamed: node.isNamed,
- isRequired: node.isRequired,
- name: node.identifier?.name,
- type: typeAnnotation,
- );
- }
-
- static macro.IdentifierImpl _buildIdentifier(Identifier node) {
- final String name;
- if (node is SimpleIdentifier) {
- name = node.name;
- } else {
- name = (node as PrefixedIdentifier).identifier.name;
- }
- return _IdentifierImpl(
- id: macro.RemoteInstance.uniqueId,
- name: name,
- );
- }
-
- static macro.TypeAnnotationImpl _buildTypeAnnotation(TypeAnnotation? node) {
- if (node == null) {
- return macro.OmittedTypeAnnotationImpl(
- id: macro.RemoteInstance.uniqueId,
- );
- } else if (node is GenericFunctionType) {
- return macro.FunctionTypeAnnotationImpl(
- id: macro.RemoteInstance.uniqueId,
- isNullable: node.question != null,
- namedParameters: node.parameters.parameters
- .where((e) => e.isNamed)
- .map(_buildFormalParameter)
- .toList(),
- positionalParameters: node.parameters.parameters
- .where((e) => e.isPositional)
- .map(_buildFormalParameter)
- .toList(),
- returnType: _buildTypeAnnotation(node.returnType),
- typeParameters: _buildTypeParameters(node.typeParameters),
- );
- } else if (node is NamedType) {
- return macro.NamedTypeAnnotationImpl(
- id: macro.RemoteInstance.uniqueId,
- identifier: _buildIdentifier(node.name),
- isNullable: node.question != null,
- typeArguments: _buildTypeAnnotations(node.typeArguments?.arguments),
- );
- } else {
- throw UnimplementedError('(${node.runtimeType}) $node');
- }
- }
-
- static List<macro.TypeAnnotationImpl> _buildTypeAnnotations(
- List<TypeAnnotation>? elements,
- ) {
- if (elements != null) {
- return elements.map(_buildTypeAnnotation).toList();
- } else {
- return const [];
- }
- }
-
- static macro.TypeParameterDeclarationImpl _buildTypeParameter(
- TypeParameter node,
- ) {
- return macro.TypeParameterDeclarationImpl(
- id: macro.RemoteInstance.uniqueId,
- identifier: _buildIdentifier(node.name),
- bound: node.bound?.mapOrNull(_buildTypeAnnotation),
- );
- }
-
- static List<macro.TypeParameterDeclarationImpl> _buildTypeParameters(
- TypeParameterList? typeParameterList,
- ) {
- if (typeParameterList != null) {
- return typeParameterList.typeParameters.map(_buildTypeParameter).toList();
- } else {
- return const [];
- }
- }
-
/// Run the [body], report exceptions as [MacroApplicationError]s to [onError].
static Future<T?> _runWithCatchingExceptions<T>(
Future<T> Function() body, {
@@ -558,6 +439,10 @@
}
class _ClassIntrospector implements macro.ClassIntrospector {
+ final DeclarationBuilder declarationBuilder;
+
+ _ClassIntrospector(this.declarationBuilder);
+
@override
Future<List<macro.ConstructorDeclaration>> constructorsOf(
covariant macro.ClassDeclaration clazz) {
@@ -594,15 +479,17 @@
@override
Future<macro.ClassDeclaration?> superclassOf(
- covariant macro.ClassDeclaration clazz) {
- // TODO: implement superclassOf
- throw UnimplementedError();
- }
-}
+ covariant ClassDeclarationImpl clazz,
+ ) async {
+ final superType = clazz.element.supertype;
+ if (superType == null) {
+ return null;
+ }
-class _IdentifierImpl extends macro.IdentifierImpl {
- _IdentifierImpl({required int id, required String name})
- : super(id: id, name: name);
+ return declarationBuilder.fromElement.classDeclaration(
+ superType.element,
+ );
+ }
}
class _IdentifierResolver extends macro.IdentifierResolver {
@@ -696,10 +583,3 @@
bool get isNotEmpty =>
libraryAugmentations.isNotEmpty || classAugmentations.isNotEmpty;
}
-
-extension _IfNotNull<T> on T? {
- R? mapOrNull<R>(R Function(T) mapper) {
- final self = this;
- return self != null ? mapper(self) : null;
- }
-}
diff --git a/pkg/analyzer/lib/src/summary2/macro_declarations.dart b/pkg/analyzer/lib/src/summary2/macro_declarations.dart
new file mode 100644
index 0000000..47bcc2b
--- /dev/null
+++ b/pkg/analyzer/lib/src/summary2/macro_declarations.dart
@@ -0,0 +1,225 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:_fe_analyzer_shared/src/macros/executor/introspection_impls.dart'
+ as macro;
+import 'package:_fe_analyzer_shared/src/macros/executor/remote_instance.dart'
+ as macro;
+import 'package:analyzer/dart/ast/ast.dart' as ast;
+import 'package:analyzer/dart/element/element.dart';
+
+class ClassDeclarationImpl extends macro.ClassDeclarationImpl {
+ late final ClassElement element;
+
+ ClassDeclarationImpl._({
+ required int id,
+ required macro.IdentifierImpl identifier,
+ required List<macro.TypeParameterDeclarationImpl> typeParameters,
+ required List<macro.TypeAnnotationImpl> interfaces,
+ required bool isAbstract,
+ required bool isExternal,
+ required List<macro.TypeAnnotationImpl> mixins,
+ required macro.TypeAnnotationImpl? superclass,
+ }) : super(
+ id: id,
+ identifier: identifier,
+ typeParameters: typeParameters,
+ interfaces: interfaces,
+ isAbstract: isAbstract,
+ isExternal: isExternal,
+ mixins: mixins,
+ superclass: superclass,
+ );
+}
+
+class DeclarationBuilder {
+ final DeclarationBuilderFromNode fromNode = DeclarationBuilderFromNode();
+
+ final DeclarationBuilderFromElement fromElement =
+ DeclarationBuilderFromElement();
+
+ /// Associate declarations that were previously created for nodes with the
+ /// corresponding elements. So, we can access them uniformly via interfaces,
+ /// mixins, etc.
+ void transferToElements() {
+ for (final entry in fromNode._classNodes.entries) {
+ final element = entry.key.declaredElement as ClassElement;
+ final declaration = entry.value;
+ declaration.element = element;
+ fromElement._classMap[element] = declaration;
+ }
+ }
+}
+
+class DeclarationBuilderFromElement {
+ final Map<ClassElement, ClassDeclarationImpl> _classMap = Map.identity();
+
+ macro.ClassDeclarationImpl classDeclaration(ClassElement element) {
+ return _classMap[element] ??= _classDeclaration(element);
+ }
+
+ ClassDeclarationImpl _classDeclaration(ClassElement element) {
+ assert(!_classMap.containsKey(element));
+ return ClassDeclarationImpl._(
+ id: macro.RemoteInstance.uniqueId,
+ identifier: _identifierFromName(element.name),
+ typeParameters: [], // TODO _buildTypeParameters(node.typeParameters),
+ interfaces: [], // TODO _buildTypeAnnotations(node.implementsClause?.interfaces),
+ isAbstract: false, // TODO node.abstractKeyword != null,
+ isExternal: false,
+ mixins: [], // TODO _buildTypeAnnotations(node.withClause?.mixinTypes),
+ superclass: null,
+ // TODO(scheglov) implement
+ // superclass: node.extendsClause?.superclass.mapOrNull(
+ // _buildTypeAnnotation,
+ // ),
+ )..element = element;
+ }
+
+ macro.IdentifierImpl _identifierFromName(String name) {
+ return _IdentifierImpl(
+ id: macro.RemoteInstance.uniqueId,
+ name: name,
+ );
+ }
+}
+
+class DeclarationBuilderFromNode {
+ final Map<ast.ClassDeclaration, ClassDeclarationImpl> _classNodes =
+ Map.identity();
+
+ macro.ClassDeclarationImpl classDeclaration(
+ ast.ClassDeclaration node,
+ ) {
+ return _classNodes[node] ??= _classDeclaration(node);
+ }
+
+ ClassDeclarationImpl _classDeclaration(
+ ast.ClassDeclaration node,
+ ) {
+ assert(!_classNodes.containsKey(node));
+ return ClassDeclarationImpl._(
+ id: macro.RemoteInstance.uniqueId,
+ identifier: _identifier(node.name),
+ typeParameters: _typeParameters(node.typeParameters),
+ interfaces: _typeAnnotations(node.implementsClause?.interfaces),
+ isAbstract: node.abstractKeyword != null,
+ isExternal: false,
+ mixins: _typeAnnotations(node.withClause?.mixinTypes),
+ superclass: node.extendsClause?.superclass.mapOrNull(
+ _typeAnnotation,
+ ),
+ );
+ }
+
+ macro.FunctionTypeParameterImpl _formalParameter(
+ ast.FormalParameter node,
+ ) {
+ if (node is ast.DefaultFormalParameter) {
+ node = node.parameter;
+ }
+
+ final macro.TypeAnnotationImpl typeAnnotation;
+ if (node is ast.SimpleFormalParameter) {
+ typeAnnotation = _typeAnnotation(node.type);
+ } else {
+ throw UnimplementedError('(${node.runtimeType}) $node');
+ }
+
+ return macro.FunctionTypeParameterImpl(
+ id: macro.RemoteInstance.uniqueId,
+ isNamed: node.isNamed,
+ isRequired: node.isRequired,
+ name: node.identifier?.name,
+ type: typeAnnotation,
+ );
+ }
+
+ macro.IdentifierImpl _identifier(ast.Identifier node) {
+ final String name;
+ if (node is ast.SimpleIdentifier) {
+ name = node.name;
+ } else {
+ name = (node as ast.PrefixedIdentifier).identifier.name;
+ }
+ return _IdentifierImpl(
+ id: macro.RemoteInstance.uniqueId,
+ name: name,
+ );
+ }
+
+ macro.TypeAnnotationImpl _typeAnnotation(ast.TypeAnnotation? node) {
+ if (node == null) {
+ return macro.OmittedTypeAnnotationImpl(
+ id: macro.RemoteInstance.uniqueId,
+ );
+ } else if (node is ast.GenericFunctionType) {
+ return macro.FunctionTypeAnnotationImpl(
+ id: macro.RemoteInstance.uniqueId,
+ isNullable: node.question != null,
+ namedParameters: node.parameters.parameters
+ .where((e) => e.isNamed)
+ .map(_formalParameter)
+ .toList(),
+ positionalParameters: node.parameters.parameters
+ .where((e) => e.isPositional)
+ .map(_formalParameter)
+ .toList(),
+ returnType: _typeAnnotation(node.returnType),
+ typeParameters: _typeParameters(node.typeParameters),
+ );
+ } else if (node is ast.NamedType) {
+ return macro.NamedTypeAnnotationImpl(
+ id: macro.RemoteInstance.uniqueId,
+ identifier: _identifier(node.name),
+ isNullable: node.question != null,
+ typeArguments: _typeAnnotations(node.typeArguments?.arguments),
+ );
+ } else {
+ throw UnimplementedError('(${node.runtimeType}) $node');
+ }
+ }
+
+ List<macro.TypeAnnotationImpl> _typeAnnotations(
+ List<ast.TypeAnnotation>? elements,
+ ) {
+ if (elements != null) {
+ return elements.map(_typeAnnotation).toList();
+ } else {
+ return const [];
+ }
+ }
+
+ macro.TypeParameterDeclarationImpl _typeParameter(
+ ast.TypeParameter node,
+ ) {
+ return macro.TypeParameterDeclarationImpl(
+ id: macro.RemoteInstance.uniqueId,
+ identifier: _identifier(node.name),
+ bound: node.bound?.mapOrNull(_typeAnnotation),
+ );
+ }
+
+ List<macro.TypeParameterDeclarationImpl> _typeParameters(
+ ast.TypeParameterList? typeParameterList,
+ ) {
+ if (typeParameterList != null) {
+ return typeParameterList.typeParameters.map(_typeParameter).toList();
+ } else {
+ return const [];
+ }
+ }
+}
+
+class _IdentifierImpl extends macro.IdentifierImpl {
+ _IdentifierImpl({required int id, required String name})
+ : super(id: id, name: name);
+}
+
+extension<T> on T? {
+ R? mapOrNull<R>(R Function(T) mapper) {
+ final self = this;
+ return self != null ? mapper(self) : null;
+ }
+}
diff --git a/pkg/analyzer/test/src/dart/resolution/comment_test.dart b/pkg/analyzer/test/src/dart/resolution/comment_test.dart
index 16fa635..f3e4408 100644
--- a/pkg/analyzer/test/src/dart/resolution/comment_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/comment_test.dart
@@ -91,6 +91,44 @@
assertElement(findNode.simple('foo]'), findElement.setter('foo'));
}
+ test_class_invalid_ambiguousExtension() async {
+ await assertNoErrorsInCode('''
+/// [foo]
+class A {}
+
+extension E1 on A {
+ int get foo => 1;
+}
+
+extension E2 on A {
+ int get foo => 2;
+}
+''');
+
+ assertResolvedNodeText(findNode.commentReference('foo]'), r'''
+CommentReference
+ expression: SimpleIdentifier
+ token: foo
+ staticElement: <null>
+ staticType: null
+''');
+ }
+
+ test_class_invalid_unresolved() async {
+ await assertNoErrorsInCode('''
+/// [foo]
+class A {}
+''');
+
+ assertResolvedNodeText(findNode.commentReference('foo]'), r'''
+CommentReference
+ expression: SimpleIdentifier
+ token: foo
+ staticElement: <null>
+ staticType: null
+''');
+ }
+
test_class_staticGetter() async {
await assertNoErrorsInCode('''
class A {
diff --git a/pkg/analyzer/test/src/summary/macro/introspect_declarations_phase.dart b/pkg/analyzer/test/src/summary/macro/introspect_declarations_phase.dart
new file mode 100644
index 0000000..3a2515a
--- /dev/null
+++ b/pkg/analyzer/test/src/summary/macro/introspect_declarations_phase.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import 'package:_fe_analyzer_shared/src/macros/api.dart';
+
+const introspectMacro = IntrospectDeclarationsPhaseMacro();
+
+/*macro*/ class IntrospectDeclarationsPhaseMacro
+ implements ClassDeclarationsMacro {
+ const IntrospectDeclarationsPhaseMacro();
+
+ @override
+ Future<void> buildDeclarationsForClass(
+ ClassDeclaration declaration,
+ ClassMemberDeclarationBuilder builder,
+ ) async {
+ final printer = _DeclarationPrinter(
+ classIntrospector: builder,
+ );
+ await printer.writeClassDeclaration(declaration);
+ final text = printer._sink.toString();
+
+ final resultName = 'introspect_${declaration.identifier.name}';
+ builder.declareInLibrary(
+ DeclarationCode.fromString(
+ 'const $resultName = r"""$text""";',
+ ),
+ );
+ }
+}
+
+class _DeclarationPrinter {
+ final ClassIntrospector classIntrospector;
+ final StringBuffer _sink = StringBuffer();
+ String _indent = '';
+
+ _DeclarationPrinter({
+ required this.classIntrospector,
+ });
+
+ Future<void> writeClassDeclaration(ClassDeclaration e) async {
+ _sink.write(_indent);
+ _writeIf(e.isAbstract, 'abstract ');
+ _writeIf(e.isExternal, 'external ');
+
+ _writeln('class ${e.identifier.name}');
+
+ await _withIndent(() async {
+ var superclass = await classIntrospector.superclassOf(e);
+ if (superclass != null) {
+ _writelnWithIndent('superclass');
+ await _withIndent(() => writeClassDeclaration(superclass));
+ }
+
+ // TODO(scheglov) implement
+ // _writeTypeParameters(e.typeParameters);
+ // _writeTypeAnnotations('mixins', e.mixins);
+ // _writeTypeAnnotations('interfaces', e.interfaces);
+ });
+ }
+
+ Future<void> _withIndent(Future<void> Function() f) async {
+ var savedIndent = _indent;
+ _indent = '$savedIndent ';
+ await f();
+ _indent = savedIndent;
+ }
+
+ void _writeIf(bool flag, String str) {
+ if (flag) {
+ _sink.write(str);
+ }
+ }
+
+ void _writeln(String line) {
+ _sink.writeln(line);
+ }
+
+ void _writelnWithIndent(String line) {
+ _sink.write(_indent);
+ _sink.writeln(line);
+ }
+}
diff --git a/pkg/analyzer/test/src/summary/macro_test.dart b/pkg/analyzer/test/src/summary/macro_test.dart
index 0762782..a775b53 100644
--- a/pkg/analyzer/test/src/summary/macro_test.dart
+++ b/pkg/analyzer/test/src/summary/macro_test.dart
@@ -56,6 +56,15 @@
return code.replaceAll('/*macro*/', 'macro');
}
+ /// Return the code for `IntrospectDeclarationsPhaseMacro`.
+ String get _introspectDeclarationsPhaseCode {
+ final path = 'test/src/summary/macro/introspect_declarations_phase.dart';
+ final code = MacrosEnvironment.instance.packageAnalyzerFolder
+ .getChildAssumingFile(path)
+ .readAsStringSync();
+ return code.replaceAll('/*macro*/', 'macro');
+ }
+
Future<void> setUp() async {
writeTestPackageConfig(
PackageConfigFileBuilder(),
@@ -1143,6 +1152,32 @@
''');
}
+ test_introspect_declarations_ClassDeclaration_superclassOf_implicit() async {
+ await _assertIntrospectDeclarationsText(r'''
+@introspectMacro
+class X {}
+''', r'''
+class X
+ superclass
+ class Object
+''');
+ }
+
+ test_introspect_declarations_ClassDeclaration_superclassOf_local() async {
+ await _assertIntrospectDeclarationsText(r'''
+class A<T> {}
+
+@introspectMacro
+class X extends A<int> {}
+''', r'''
+class X
+ superclass
+ class A
+ superclass
+ class Object
+''');
+ }
+
test_introspect_types_ClassDeclaration_interfaces() async {
await _assertTypesPhaseIntrospectionText(r'''
class A implements B, C<int, String> {}
@@ -1454,6 +1489,19 @@
);
}
+ /// Assert that the textual dump of the introspection information for
+ /// annotated declarations is the same as [expected].
+ Future<void> _assertIntrospectDeclarationsText(
+ String declarationCode,
+ String expected,
+ ) async {
+ var actual = await _getIntrospectDeclarationsText(declarationCode);
+ if (actual != expected) {
+ print(actual);
+ }
+ expect(actual, expected);
+ }
+
/// Build a macro with specified [fields], initialized in the constructor
/// with [constructorParametersCode], and apply this macro with
/// [argumentsCode] to an empty class.
@@ -1574,6 +1622,34 @@
return x_literal.value;
}
+ /// Use `IntrospectDeclarationsPhaseMacro` to generate top-level constants
+ /// that contain textual dump of the introspection information for
+ /// macro annotated declarations.
+ Future<String> _getIntrospectDeclarationsText(String declarationCode) async {
+ newFile(
+ '$testPackageLibPath/introspect_declarations_phase.dart',
+ _introspectDeclarationsPhaseCode,
+ );
+
+ var library = await buildLibrary('''
+import 'introspect_declarations_phase.dart';
+
+$declarationCode
+''', preBuildSequence: [
+ {'package:test/introspect_declarations_phase.dart'}
+ ]);
+
+ for (final class_ in library.definingCompilationUnit.classes) {
+ _assertNoErrorsForClassElement(class_);
+ }
+
+ return library.definingCompilationUnit.topLevelVariables
+ .whereType<ConstTopLevelVariableElementImpl>()
+ .where((e) => e.name.startsWith('introspect_'))
+ .map((e) => (e.constantInitializer as SimpleStringLiteral).value)
+ .join('\n');
+ }
+
static void _assertNoErrorsForClassElement(ClassElement? element) {
var actual = _errorsStrForClassElement(element);
expect(actual, isEmpty);
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 3888c85..3cc7fdd 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -218,6 +218,14 @@
}
@override
+ void visitCommentReference(CommentReference node) {
+ _writeln('CommentReference');
+ _withIndent(() {
+ _writeNamedChildEntities(node);
+ });
+ }
+
+ @override
void visitCompilationUnit(CompilationUnit node) {
_writeln('CompilationUnit');
_withIndent(() {
diff --git a/pkg/vm_service/pubspec.yaml b/pkg/vm_service/pubspec.yaml
index 8936629..8d8a774 100644
--- a/pkg/vm_service/pubspec.yaml
+++ b/pkg/vm_service/pubspec.yaml
@@ -14,7 +14,7 @@
async: ^2.5.0
expect: any
lints: any
- markdown: '>=4.0.0 <6.0.0'
+ markdown: ^4.0.0
mockito: any
path: ^1.8.0
process: ^4.0.0
diff --git a/sdk/lib/_internal/js_runtime/lib/rti.dart b/sdk/lib/_internal/js_runtime/lib/rti.dart
index 7c915db..356298b 100644
--- a/sdk/lib/_internal/js_runtime/lib/rti.dart
+++ b/sdk/lib/_internal/js_runtime/lib/rti.dart
@@ -75,9 +75,8 @@
}
@pragma('dart2js:tryInline')
- static bool _asCheck(Rti rti, Object? object) {
- return JS(
- 'bool', '#.#(#)', rti, JS_GET_NAME(JsGetName.RTI_FIELD_AS), object);
+ static Object? _asCheck(Rti rti, Object? object) {
+ return JS('', '#.#(#)', rti, JS_GET_NAME(JsGetName.RTI_FIELD_AS), object);
}
@pragma('dart2js:tryInline')
@@ -916,7 +915,7 @@
///
/// The first time this default `_as` method is called, it replaces itself with
/// a specialized version.
-bool _installSpecializedAsCheck(Object? object) {
+Object? _installSpecializedAsCheck(Object? object) {
// This static method is installed on an Rti object as a JavaScript instance
// method. The Rti object is 'this'.
Rti testRti = _Utils.asRti(JS('', 'this'));
diff --git a/sdk/lib/isolate/isolate.dart b/sdk/lib/isolate/isolate.dart
index 8098a0f..60d6899 100644
--- a/sdk/lib/isolate/isolate.dart
+++ b/sdk/lib/isolate/isolate.dart
@@ -24,6 +24,12 @@
part "capability.dart";
+// Examples can assume:
+// Isolate findSomeIsolate() => Isolate.current;
+// void untrustedCode(Isolate isolate) {}
+// RawReceivePort rawPort = RawReceivePort();
+// void actualHandler() {}
+
/// Thrown when an isolate cannot be created.
class IsolateSpawnException implements Exception {
/// Error message reported by the spawn operation.
@@ -734,8 +740,8 @@
///
/// The handler is invoked in the [Zone.root] zone.
/// If the handler should be invoked in the current zone, do:
- /// ```dart
- /// rawPort.handler = Zone.current.bind(actualHandler);
+ /// ```dart import:async
+ /// rawPort.handler = Zone.current.bindCallback(actualHandler);
/// ```
///
/// The handler must be a function which can accept one argument
diff --git a/tools/VERSION b/tools/VERSION
index 84dbb00..24622c4 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 89
+PRERELEASE 90
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index 7bab851..b243173 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -3688,6 +3688,7 @@
"dart:convert",
"dart:developer",
"dart:ffi",
+ "dart:isolate",
"dart:js",
"dart:js_util",
"dart:math",