From 82934622c9fae17e5729b28b914ba66fa3affb9d Mon Sep 17 00:00:00 2001 From: Jaime Wren Date: Thu, 14 Nov 2024 18:39:51 -0800 Subject: [PATCH] Dartfmt on Dart sources in tool dir (#7786) --- tool/grind.dart | 19 +++++++------ tool/plugin/lib/build_spec.dart | 10 +++---- tool/plugin/lib/edit.dart | 7 +++-- tool/plugin/lib/lint.dart | 4 ++- tool/plugin/lib/plugin.dart | 42 ++++++++++++++++----------- tool/plugin/lib/runner.dart | 16 +++++------ tool/plugin/lib/util.dart | 47 +++++++++++++++++++++++-------- tool/plugin/lib/verify.dart | 5 ++-- tool/plugin/test/plugin_test.dart | 6 ++-- 9 files changed, 95 insertions(+), 61 deletions(-) diff --git a/tool/grind.dart b/tool/grind.dart index 5319826c6e..f5e62f9335 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -24,7 +24,8 @@ void checkUrls() async { log('checking: $url...'); if (response.statusCode != 200) { fail( - '$url GET failed: [${response.statusCode}] ${response.reasonPhrase}'); + '$url GET failed: [${response.statusCode}] ${response + .reasonPhrase}'); } } } @@ -54,19 +55,18 @@ void outlineIcons() async { } } -void _createPng( - File sourceSvg, - String targetName, { - required int? size, - bool forLight = false, -}) { +void _createPng(File sourceSvg, + String targetName, { + required int? size, + bool forLight = false, + }) { File targetFile = joinFile(sourceSvg.parent, [targetName]); String color = forLight ? '#7a7a7a' : '#9e9e9e'; String originalContent = sourceSvg.readAsStringSync(); String newContent = - originalContent.replaceAll(' specs, - ) : super.fromJson() { + SyntheticBuildSpec.fromJson(super.json, + super.releaseNum, + List specs,) : super.fromJson() { try { // 'isUnitTestTarget' should always be in the spec for the latest IntelliJ (not AS). alternate = specs.firstWhere((s) => s.isUnitTestTarget); diff --git a/tool/plugin/lib/edit.dart b/tool/plugin/lib/edit.dart index 9468f3f608..59f44e0cff 100644 --- a/tool/plugin/lib/edit.dart +++ b/tool/plugin/lib/edit.dart @@ -46,7 +46,7 @@ Future applyEdits(BuildSpec spec, Future Function() compileFn) async { // Handle skipped files. for (String file in spec.filesToSkip) { final entity = - FileSystemEntity.isFileSync(file) ? File(file) : Directory(file); + FileSystemEntity.isFileSync(file) ? File(file) : Directory(file); if (entity.existsSync()) { await entity.rename('$file~'); log('renamed $file'); @@ -82,7 +82,7 @@ Future applyEdits(BuildSpec spec, Future Function() compileFn) async { for (final file in spec.filesToSkip) { final name = '$file~'; final entity = - FileSystemEntity.isFileSync(name) ? File(name) : Directory(name); + FileSystemEntity.isFileSync(name) ? File(name) : Directory(name); if (entity.existsSync()) { await entity.rename(file); } @@ -97,7 +97,8 @@ class EditCommand { required List initials, required List replacements, this.versions = const [], - }) : assert(initials.length == replacements.length), + }) + : assert(initials.length == replacements.length), assert(initials.isNotEmpty), assert(versions.isNotEmpty), initials = initials.map(_platformAdaptiveString).toList(), diff --git a/tool/plugin/lib/lint.dart b/tool/plugin/lib/lint.dart index fc27c706a0..43c152953f 100644 --- a/tool/plugin/lib/lint.dart +++ b/tool/plugin/lib/lint.dart @@ -49,7 +49,9 @@ class LintCommand extends Command { final usages = >{}; imports.split('\n').forEach((String line) { - if (line.trim().isEmpty) { + if (line + .trim() + .isEmpty) { return; } diff --git a/tool/plugin/lib/plugin.dart b/tool/plugin/lib/plugin.dart index ab48cb62fb..c85828581e 100644 --- a/tool/plugin/lib/plugin.dart +++ b/tool/plugin/lib/plugin.dart @@ -85,11 +85,12 @@ Future genPluginXml(BuildSpec spec, String destDir, String path) async { var templatePath = '${path.substring(0, path.length - '.xml'.length)}_template.xml'; var file = - await File(p.join(rootPath, destDir, path)).create(recursive: true); + await File(p.join(rootPath, destDir, path)).create(recursive: true); log('writing ${p.relative(file.path)}'); var dest = file.openWrite(); dest.writeln( - ""); + ""); dest.writeln(); await utf8.decoder .bind(File(p.join(rootPath, 'resources', templatePath)).openRead()) @@ -110,7 +111,7 @@ bool genPresubmitYaml(List specs) { } var templateFile = - File(p.join(rootPath, '.github', 'workflows', 'presubmit.yaml.template')); + File(p.join(rootPath, '.github', 'workflows', 'presubmit.yaml.template')); var templateContents = templateFile.readAsStringSync(); // If we need to make many changes consider something like genPluginXml(). templateContents = @@ -169,7 +170,8 @@ Future performReleaseChecks(ProductCommand cmd) async { return false; } if (!cmd.isReleaseValid) { - log('the release identifier ("${cmd.release}") must be of the form xx.x (major.minor)'); + log('the release identifier ("${cmd + .release}") must be of the form xx.x (major.minor)'); return false; } var gitDir = await GitDir.fromExisting(rootPath); @@ -178,7 +180,7 @@ Future performReleaseChecks(ProductCommand cmd) async { var branch = await gitDir.currentBranch(); var name = branch.branchName; var expectedName = - cmd.isDevChannel ? 'master' : "release_${cmd.releaseMajor}"; + cmd.isDevChannel ? 'master' : "release_${cmd.releaseMajor}"; var result = name == expectedName; if (!result) { result = name.startsWith("release_${cmd.releaseMajor}") && @@ -201,7 +203,7 @@ Future performReleaseChecks(ProductCommand cmd) async { } // Finally, check that a jxbrowser.properties exists var jxBrowserFile = - File(p.join(rootPath, 'resources', 'jxbrowser', 'jxbrowser.properties')); + File(p.join(rootPath, 'resources', 'jxbrowser', 'jxbrowser.properties')); var jxBrowserFileContents = jxBrowserFile.readAsStringSync(); if (jxBrowserFile.existsSync() && jxBrowserFileContents.isNotEmpty && @@ -209,14 +211,15 @@ Future performReleaseChecks(ProductCommand cmd) async { !jxBrowserFileContents.contains('jxbrowser.license.key=')) { return true; } else { - log('Release mode requires the jxbrowser.properties file to exist and include a key.'); + log( + 'Release mode requires the jxbrowser.properties file to exist and include a key.'); } return false; } List> readProductMatrix() { var contents = - File(p.join(rootPath, 'product-matrix.json')).readAsStringSync(); + File(p.join(rootPath, 'product-matrix.json')).readAsStringSync(); var map = json.decode(contents); return (map['list'] as List).cast>(); } @@ -236,8 +239,8 @@ String substituteTemplateVariables(String line, BuildSpec spec) { case 'CHANGELOG': return spec.changeLog; case 'DEPEND': - // If found, this is the module that triggers loading the Android Studio - // support. The public sources and the installable plugin use different ones. + // If found, this is the module that triggers loading the Android Studio + // support. The public sources and the installable plugin use different ones. return spec.isSynthetic ? 'com.intellij.modules.androidstudio' : 'com.android.tools.apk'; @@ -426,7 +429,7 @@ class GradleBuildCommand extends ProductCommand { log('Content generated in ./build/distributions:\n${result.stdout}'); var source = File('build/distributions/flutter-intellij.zip'); - if(!source.existsSync()) { + if (!source.existsSync()) { source = File('build/distributions/flutter-intellij-kokoro.zip'); } _copyFile( @@ -516,7 +519,11 @@ https://plugins.jetbrains.com/plugin/uploadPlugin log('Upload failed: ${processResult.stderr} for file: $filePath'); } final out = processResult.stdout as String; - var message = out.trim().split('\n').last.trim(); + var message = out + .trim() + .split('\n') + .last + .trim(); log(message); return processResult.exitCode; } @@ -537,9 +544,9 @@ class GenerateCommand extends ProductCommand { @override String get description => 'Generate plugin.xml, .github/workflows/presubmit.yaml, ' - 'and resources/liveTemplates/flutter_miscellaneous.xml files for the ' - 'Flutter plugin.\nThe plugin.xml.template and product-matrix.json are ' - 'used as input.'; + 'and resources/liveTemplates/flutter_miscellaneous.xml files for the ' + 'Flutter plugin.\nThe plugin.xml.template and product-matrix.json are ' + 'used as input.'; @override Future doit() async { @@ -567,7 +574,7 @@ class GenerateCommand extends ProductCommand { .cast() .toList(); final templateFile = - File(p.join('resources', 'liveTemplates', 'flutter_miscellaneous.xml')); + File(p.join('resources', 'liveTemplates', 'flutter_miscellaneous.xml')); var contents = templateFile.readAsStringSync(); log('writing ${p.relative(templateFile.path)}'); @@ -585,7 +592,8 @@ class GenerateCommand extends ProductCommand { final regexp = RegExp('