Files
Paul Berry afcfbbeba8 Migrate developer experience packages to new constructor decl syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288)

This change migrates the packages owned by the developer experience
team to use the new constructor declaration syntax, described in
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

This change was performed in an automated fashion, by (a) bumping the
packages' SDK constraints to `3.13.0-0`, (b) enabling the lints
`unnecessary_type_name_in_constructor` and
`unnecessary_const_in_enum_constructor`, (c) fixing the resulting lint
failures using `dart fix`, and then (d) reformatting the affected
files.

To ease code review, I've reverted unrelated formatting changes.

Since this change requires bumping SDK constaints to `3.13.0-0`, it
was only performed on packages that are *not* published on
pub. (Packages that *are* published on pub should remain on lower
language versions until at least after the stable version of 3.13 is
released, so that we don't block users on the stable channel from
receiving updates to those packages.)

Change-Id: Ibb4daebafd239da58251e838ea6a3f336a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505046
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-27 14:52:58 -07:00

86 lines
2.2 KiB
Dart

// Copyright (c) 2014, 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 'dart:io';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:path/path.dart';
import '../timing_framework.dart';
/// Perform the timing test, printing the minimum, average and maximum times, as
/// well as the standard deviation to the output.
void main(List<String> args) {
var test = SimpleTest();
test.run().then((TimingResult result) {
print('minTime = ${result.minTime}');
print('averageTime = ${result.averageTime}');
print('maxTime = ${result.maxTime}');
print('standardDeviation = ${result.standardDeviation}');
print('');
print('Press return to exit');
return stdin.first;
});
}
/// A test of how long it takes to get code completion results after making a
/// minor change inside a method body.
class SimpleTest extends TimingTest {
/// The path to the file in which code completion is to be performed.
late String mainFilePath;
/// The original content of the file.
late String originalContent;
/// The offset of the cursor when requesting code completion.
late int cursorOffset;
/// Initialize a newly created test.
new();
@override
Future<void> oneTimeSetUp() {
return super.oneTimeSetUp().then((_) {
mainFilePath = sourcePath('test.dart');
originalContent = r'''
class C {
m() {
return 0;
}
}
f(C c) {
return c;
}
''';
cursorOffset = originalContent.indexOf('c;') + 1;
writeFile(mainFilePath, originalContent);
});
}
@override
Future<void> perform() {
sendAnalysisUpdateContent({
mainFilePath: ChangeContentOverlay([SourceEdit(cursorOffset, 0, '.')]),
});
return sendCompletionGetSuggestions2(mainFilePath, cursorOffset + 1, 1000);
}
@override
Future<void> setUp() {
sendAnalysisSetAnalysisRoots([dirname(mainFilePath)], []);
sendAnalysisUpdateContent({
mainFilePath: AddContentOverlay(originalContent),
});
return Future.value();
}
@override
Future<void> tearDown() {
sendAnalysisSetAnalysisRoots([], []);
return Future.value();
}
}