Skip to content

Commit ade6076

Browse files
authored
Latest analyzer, prepare release (#1783)
* Latest analyzer, prepare release * bump sdk * formatting the formatter
1 parent ec0048b commit ade6076

20 files changed

+87
-96
lines changed

.github/workflows/test-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
sdk: [3.7.0, dev]
23+
sdk: [3.9.0, dev]
2424
steps:
2525
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
2626
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
@@ -50,7 +50,7 @@ jobs:
5050
matrix:
5151
# Add macos-latest and/or windows-latest if relevant for this package.
5252
os: [ubuntu-latest]
53-
sdk: [3.7.0, dev]
53+
sdk: [3.9.0, dev]
5454
steps:
5555
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
5656
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 3.1.3-wip
1+
## 3.1.3
22

33
* No longer format imports with configurations and a prefix in the wrong order.
44
The parser used to accept this without error even though it violated the
@@ -12,6 +12,9 @@
1212
* Don't force a space between `?` and `.` if a null-aware element contains a
1313
dot shorthand.
1414

15+
* Require `analyzer: '>=8.2.0 <10.0.0'`.
16+
* Require `sdk: ^3.9.0`
17+
1518
### Bug fixes
1619

1720
* Respect `@dart=` version comments when determining which >3.7 style to apply.

benchmark/directory.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ void main(List<String> arguments) async {
6363
void _runFormatter(String source) {
6464
try {
6565
var formatter = DartFormatter(
66-
languageVersion:
67-
_isShort
68-
? DartFormatter.latestShortStyleLanguageVersion
69-
: DartFormatter.latestLanguageVersion,
66+
languageVersion: _isShort
67+
? DartFormatter.latestShortStyleLanguageVersion
68+
: DartFormatter.latestLanguageVersion,
7069
);
7170

7271
var result = formatter.format(source);

benchmark/run.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ List<double> _runTrials(String verb, Benchmark benchmark, int trials) {
137137
);
138138

139139
var formatter = DartFormatter(
140-
languageVersion:
141-
_isShort
142-
? DartFormatter.latestShortStyleLanguageVersion
143-
: DartFormatter.latestLanguageVersion,
140+
languageVersion: _isShort
141+
? DartFormatter.latestShortStyleLanguageVersion
142+
: DartFormatter.latestLanguageVersion,
144143
pageWidth: benchmark.pageWidth,
145144
lineEnding: '\n',
146145
);

lib/src/back_end/code_writer.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,10 @@ final class CodeWriter {
370370
// indication into account which may vary based on the surrounding pieces
371371
// when we get here.
372372
Profile.begin('CodeWriter try to bind by page width');
373-
isUnsolved =
374-
!_solution.tryBindByPageWidth(
375-
piece,
376-
_pageWidth - _indentStack.first.spaces,
377-
);
373+
isUnsolved = !_solution.tryBindByPageWidth(
374+
piece,
375+
_pageWidth - _indentStack.first.spaces,
376+
);
378377
Profile.end('CodeWriter try to bind by page width');
379378
}
380379

lib/src/cli/format_command.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,18 @@ final class FormatCommand extends Command<int> {
183183
return 0;
184184
}
185185

186-
var show =
187-
const {
188-
'all': Show.all,
189-
'changed': Show.changed,
190-
'none': Show.none,
191-
}[argResults['show']]!;
192-
193-
var output =
194-
const {
195-
'write': Output.write,
196-
'show': Output.show,
197-
'none': Output.none,
198-
'json': Output.json,
199-
}[argResults['output']]!;
186+
var show = const {
187+
'all': Show.all,
188+
'changed': Show.changed,
189+
'none': Show.none,
190+
}[argResults['show']]!;
191+
192+
var output = const {
193+
'write': Output.write,
194+
'show': Output.show,
195+
'none': Output.none,
196+
'json': Output.json,
197+
}[argResults['output']]!;
200198

201199
var summary = Summary.none;
202200
switch (argResults['summary'] as String) {

lib/src/cli/formatter_options.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'show.dart';
1313
import 'summary.dart';
1414

1515
// Note: The following line of code is modified by tool/grind.dart.
16-
const dartStyleVersion = '3.1.3-wip';
16+
const dartStyleVersion = '3.1.3';
1717

1818
/// Global options parsed from the command line that affect how the formatter
1919
/// produces and uses its outputs.

lib/src/dart_formatter.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,9 @@ final class DartFormatter {
140140
text,
141141
uri: source.uri,
142142
isCompilationUnit: false,
143-
selectionStart:
144-
source.selectionStart != null
145-
? source.selectionStart! + inputOffset
146-
: null,
143+
selectionStart: source.selectionStart != null
144+
? source.selectionStart! + inputOffset
145+
: null,
147146
selectionLength: source.selectionLength,
148147
);
149148
}
@@ -176,10 +175,9 @@ final class DartFormatter {
176175
}
177176

178177
// Throw if there are syntactic errors.
179-
var syntacticErrors =
180-
parseResult.errors.where((error) {
181-
return error.diagnosticCode.type == DiagnosticType.SYNTACTIC_ERROR;
182-
}).toList();
178+
var syntacticErrors = parseResult.errors.where((error) {
179+
return error.diagnosticCode.type == DiagnosticType.SYNTACTIC_ERROR;
180+
}).toList();
183181
if (syntacticErrors.isNotEmpty) {
184182
throw FormatterException(syntacticErrors);
185183
}
@@ -200,7 +198,7 @@ final class DartFormatter {
200198
source: stringSource,
201199
offset: token.offset - inputOffset,
202200
length: math.max(token.length, 1),
203-
diagnosticCode: ParserErrorCode.UNEXPECTED_TOKEN,
201+
diagnosticCode: ParserErrorCode.unexpectedToken,
204202
arguments: [token.lexeme],
205203
);
206204
throw FormatterException([error]);

lib/src/front_end/ast_node_visitor.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,10 +1794,9 @@ final class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
17941794
var isSinglePositional =
17951795
positionalFields.length == 1 && namedFields == null;
17961796

1797-
var listStyle =
1798-
isSinglePositional
1799-
? const ListStyle(commas: Commas.alwaysTrailing)
1800-
: const ListStyle(commas: Commas.trailing);
1797+
var listStyle = isSinglePositional
1798+
? const ListStyle(commas: Commas.alwaysTrailing)
1799+
: const ListStyle(commas: Commas.trailing);
18011800
var builder = DelimitedListBuilder(this, listStyle);
18021801

18031802
// If all parameters are optional, put the `{` right after `(`.
@@ -1963,10 +1962,9 @@ final class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
19631962
for (var element in node.elements) {
19641963
pieces.visit(
19651964
element,
1966-
context:
1967-
node.isMultiline
1968-
? NodeContext.multilineStringInterpolation
1969-
: NodeContext.none,
1965+
context: node.isMultiline
1966+
? NodeContext.multilineStringInterpolation
1967+
: NodeContext.none,
19701968
);
19711969
}
19721970
}

lib/src/front_end/delimited_list_builder.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ final class DelimitedListBuilder {
269269
hanging: hangingComments,
270270
separate: separateComments,
271271
leading: leadingComments,
272-
) = _splitCommaComments(comments, hasElementAfter: hasElementAfter);
272+
) = _splitCommaComments(
273+
comments,
274+
hasElementAfter: hasElementAfter,
275+
);
273276

274277
// Add any hanging inline block comments to the previous element before the
275278
// subsequent ",".
@@ -401,10 +404,8 @@ final class DelimitedListBuilder {
401404
}
402405
}
403406

404-
var (
405-
hangingComments,
406-
separateCommentsBeforeComma,
407-
) = remainingCommentsBeforeComma.splitAt(hangingCommentCount);
407+
var (hangingComments, separateCommentsBeforeComma) =
408+
remainingCommentsBeforeComma.splitAt(hangingCommentCount);
408409

409410
// Inline block comments on the same line as the next element lead at the
410411
// beginning of that line, as in:

0 commit comments

Comments
 (0)