Skip to content

Commit

Permalink
Add a constructor name for self-documenting
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Feb 7, 2024
1 parent 4ed2601 commit 9166de9
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkgs/dart_services/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Future<void> main(List<String> args) async {
print('warning: no redis server specified.\n');
}

final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();

final int port;

Expand Down
5 changes: 4 additions & 1 deletion pkgs/dart_services/lib/src/sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ final class Sdk {
required this.engineVersion,
}) : _flutterBinPath = flutterBinPath;

factory Sdk() {
/// Create an [Sdk] to track the location and version information
/// of the Flutter SDK used to run `dart_services`, or if not valid,
/// the one configured using the `FLUTTER_ROOT` environment variable.
factory Sdk.fromLocalFlutter() {
// Note below, 'Platform.resolvedExecutable' will not lead to a real SDK if
// we've been compiled into an AOT binary. In those cases we fall back to
// looking for a 'FLUTTER_ROOT' environment variable.
Expand Down
4 changes: 2 additions & 2 deletions pkgs/dart_services/test/analysis_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() => defineTests();

void defineTests() {
group('analysis', () {
final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();
late AnalysisServerWrapper analysisServer;

setUpAll(() async {
Expand Down Expand Up @@ -183,7 +183,7 @@ void defineTests() {
});

group('analysis flutter', () {
final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();
late AnalysisServerWrapper analysisServer;

setUpAll(() async {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/dart_services/test/caching_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void defineTests(bool hasRedis) {

setUpAll(() async {
redisProcess = await startRedisProcessAndDrainIO(9501);
sdk = Sdk();
sdk = Sdk.fromLocalFlutter();
log.onRecord.listen((LogRecord rec) {
logMessages.add('${rec.level.name}: ${rec.time}: ${rec.message}');
});
Expand Down
3 changes: 2 additions & 1 deletion pkgs/dart_services/test/compiling_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ void defineTests() {
late Compiler compiler;

setUpAll(() async {
compiler = Compiler(Sdk(), storageBucket: 'nnbd_artifacts');
compiler =
Compiler(Sdk.fromLocalFlutter(), storageBucket: 'nnbd_artifacts');
});

tearDownAll(() async {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/dart_services/test/project_creator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:test_descriptor/test_descriptor.dart' as d;
void main() => defineTests();

void defineTests() {
final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();

final languageVersion = sdk.dartVersion;

Expand Down
2 changes: 1 addition & 1 deletion pkgs/dart_services/test/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void defineTests() {
late final ServicesClient client;

setUpAll(() async {
sdk = Sdk();
sdk = Sdk.fromLocalFlutter();
server = await EndpointsServer.serve(0, sdk, null, 'nnbd_artifacts');

httpClient = Client();
Expand Down
8 changes: 4 additions & 4 deletions pkgs/dart_services/tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final List<String> compilationArtifacts = [
'google storage')
void validateStorageArtifacts() async {
final args = context.invocation.arguments;
final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();
final version = sdk.dartVersion;
final bucket = switch (args.hasOption('bucket')) {
true => args.getOption('bucket'),
Expand Down Expand Up @@ -72,7 +72,7 @@ void buildProjectTemplates() async {
await templatesDirectory.delete(recursive: true);
}

final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();
final projectCreator = ProjectCreator(
sdk,
templatesPath,
Expand All @@ -87,7 +87,7 @@ void buildProjectTemplates() async {
@Task('build the sdk compilation artifacts for upload to google storage')
@Depends(updatePubDependencies)
void buildStorageArtifacts() async {
final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();
delete(getDir('artifacts'));
final instructions = <String>[];

Expand Down Expand Up @@ -268,7 +268,7 @@ Future<void> _run(
@Task('Update pubspec dependency versions')
@Depends(buildProjectTemplates)
void updatePubDependencies() async {
final sdk = Sdk();
final sdk = Sdk.fromLocalFlutter();
await _updateDependenciesFile(channel: sdk.channel, sdk: sdk);
}

Expand Down

0 comments on commit 9166de9

Please sign in to comment.