Skip to content

Commit 439bac4

Browse files
committed
Always use the SDK version of the formatter
This helps guard against skew when new formatting logic is released in the dart_style package before it's available in a stable SDK release.
1 parent 9e6e3bf commit 439bac4

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ dev_dependencies:
4141
analyzer: ^6.8.0
4242
archive: ^3.1.2
4343
crypto: ^3.0.0
44-
dart_style: ^3.0.0
4544
dartdoc: ^8.0.14
4645
grinder: ^0.9.0
4746
node_preamble: ^2.0.2

tool/assert-formatted.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

tool/grind/generate_deprecations.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'dart:convert';
66
import 'dart:io';
77

88
import 'package:crypto/crypto.dart';
9-
import 'package:dart_style/dart_style.dart';
109
import 'package:grinder/grinder.dart';
1110
import 'package:pub_semver/pub_semver.dart';
1211
import 'package:yaml/yaml.dart';
@@ -23,10 +22,9 @@ final _blockRegex =
2322
@Depends(updateLanguageRepo)
2423
void deprecations() {
2524
var yamlFile = File(yamlPath);
26-
var dartFile = File(dartPath);
2725
var yamlText = yamlFile.readAsStringSync();
2826
var data = loadYaml(yamlText, sourceUrl: yamlFile.uri) as Map;
29-
var dartText = dartFile.readAsStringSync();
27+
var dartText = File(dartPath).readAsStringSync();
3028
var buffer = StringBuffer('''// START AUTOGENERATED CODE
3129
//
3230
// DO NOT EDIT. This section was generated from the language repo.
@@ -79,7 +77,6 @@ void deprecations() {
7977
fail("Couldn't find block for generated code in lib/src/deprecation.dart");
8078
}
8179
var newCode = dartText.replaceFirst(_blockRegex, buffer.toString());
82-
dartFile.writeAsStringSync(DartFormatter(
83-
languageVersion: Version.parse(Platform.version.split(' ').first))
84-
.format(newCode));
80+
File(dartPath).writeAsStringSync(newCode);
81+
DartFmt.format(dartPath);
8582
}

tool/grind/synchronize.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import 'package:analyzer/dart/ast/token.dart';
1313
import 'package:analyzer/dart/ast/visitor.dart';
1414
import 'package:collection/collection.dart';
1515
import 'package:crypto/crypto.dart';
16-
import 'package:dart_style/dart_style.dart';
1716
import 'package:grinder/grinder.dart';
1817
import 'package:path/path.dart' as p;
1918
import 'package:pub_semver/pub_semver.dart';
2019
import 'package:source_span/source_span.dart';
2120

21+
import 'package:sass/src/util/map.dart';
2222
import 'package:sass/src/util/nullable.dart';
2323

2424
/// The files to compile to synchronous versions.
@@ -47,8 +47,10 @@ final _sharedClasses = const ['EvaluateResult'];
4747
/// to a synchronous equivalent.
4848
@Task('Compile async code to synchronous code.')
4949
void synchronize() {
50-
sources.forEach((source, target) =>
51-
File(target).writeAsStringSync(synchronizeFile(source)));
50+
for (var (source, target) in sources.pairs) {
51+
File(target).writeAsStringSync(synchronizeFile(source));
52+
DartFmt.format(target);
53+
}
5254
}
5355

5456
/// Returns the result of synchronizing [source].
@@ -59,9 +61,7 @@ String synchronizeFile(String source) {
5961
parseFile(path: source, featureSet: FeatureSet.latestLanguageVersion())
6062
.unit
6163
.accept(visitor);
62-
return DartFormatter(
63-
languageVersion: Version.parse(Platform.version.split(' ').first))
64-
.format(visitor.result);
64+
return visitor.result;
6565
}
6666

6767
/// The visitor that traverses the asynchronous parse tree and converts it to

0 commit comments

Comments
 (0)