Skip to content

Commit 0513a22

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer_cli: Bump language version to 3.9
Change-Id: I4d696cb827c993e95c1f0c946b8cbce636a390fa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447140 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent ceeb76e commit 0513a22

File tree

6 files changed

+89
-81
lines changed

6 files changed

+89
-81
lines changed

pkg/analyzer_cli/lib/src/driver.dart

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,15 @@ class Driver implements CommandLineStarter {
157157
/// Perform analysis according to the given [options].
158158
Future<DiagnosticSeverity> _analyzeAll(CommandLineOptions options) async {
159159
if (!options.jsonFormat && !options.machineFormat) {
160-
var fileNames =
161-
options.sourceFiles.map((String file) {
162-
file = path.normalize(file);
163-
if (file == '.') {
164-
file = path.basename(path.current);
165-
} else if (file == '..') {
166-
file = path.basename(path.normalize(path.absolute(file)));
167-
}
168-
return file;
169-
}).toList();
160+
var fileNames = options.sourceFiles.map((String file) {
161+
file = path.normalize(file);
162+
if (file == '.') {
163+
file = path.basename(path.current);
164+
} else if (file == '..') {
165+
file = path.basename(path.normalize(path.absolute(file)));
166+
}
167+
return file;
168+
}).toList();
170169

171170
outSink.writeln("Analyzing ${fileNames.join(', ')}...");
172171
}
@@ -238,8 +237,8 @@ class Driver implements CommandLineStarter {
238237
for (var sourcePath in pathList) {
239238
_analysisContextProvider.configureForPath(sourcePath);
240239
analysisContext = _analysisContextProvider.analysisContext;
241-
final analysisDriver =
242-
this.analysisDriver = _analysisContextProvider.analysisDriver;
240+
final analysisDriver = this.analysisDriver =
241+
_analysisContextProvider.analysisDriver;
243242
pathFilter = _analysisContextProvider.pathFilter;
244243

245244
// Add all the files to be analyzed en masse to the context. Skip any
@@ -274,8 +273,9 @@ class Driver implements CommandLineStarter {
274273
var contextRoot =
275274
analysisDriver.currentSession.analysisContext.contextRoot;
276275
var package = contextRoot.workspace.findPackageFor(file.path);
277-
var sdkVersionConstraint =
278-
(package is PubPackage) ? package.sdkVersionConstraint : null;
276+
var sdkVersionConstraint = (package is PubPackage)
277+
? package.sdkVersionConstraint
278+
: null;
279279
var errors = analyzeAnalysisOptions(
280280
FileSource(file),
281281
content,
@@ -329,12 +329,11 @@ class Driver implements CommandLineStarter {
329329
}
330330
if (diagnostics.isNotEmpty) {
331331
for (var error in diagnostics) {
332-
var severity =
333-
determineProcessedSeverity(
334-
error,
335-
options,
336-
analysisOptions,
337-
)!;
332+
var severity = determineProcessedSeverity(
333+
error,
334+
options,
335+
analysisOptions,
336+
)!;
338337
allResult = allResult.max(severity);
339338
}
340339
var lineInfo = LineInfo.fromContent(content);
@@ -383,8 +382,11 @@ class Driver implements CommandLineStarter {
383382
),
384383
]);
385384
for (var error in errors) {
386-
var severity =
387-
determineProcessedSeverity(error, options, analysisOptions)!;
385+
var severity = determineProcessedSeverity(
386+
error,
387+
options,
388+
analysisOptions,
389+
)!;
388390
allResult = allResult.max(severity);
389391
}
390392
} catch (exception) {

pkg/analyzer_cli/lib/src/options.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ class CommandLineOptions {
338338
static String _getVersion() {
339339
try {
340340
// This is relative to bin/snapshot, so ../..
341-
var versionPath =
342-
io.Platform.script.resolve('../../version').toFilePath();
341+
var versionPath = io.Platform.script
342+
.resolve('../../version')
343+
.toFilePath();
343344
var versionFile = io.File(versionPath);
344345
return versionFile.readAsStringSync().trim();
345346
} catch (_) {

pkg/analyzer_cli/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Command line interface for the Dart Analyzer.
55
publish_to: none
66

77
environment:
8-
sdk: ^3.7.0
8+
sdk: ^3.9.0
99

1010
resolution: workspace
1111

pkg/analyzer_cli/test/options_test.dart

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ void main() {
8484
});
8585

8686
test('disable cache flushing', () {
87-
var options =
88-
parse(['--dart-sdk', '.', '--disable-cache-flushing', 'foo.dart'])!;
87+
var options = parse([
88+
'--dart-sdk',
89+
'.',
90+
'--disable-cache-flushing',
91+
'foo.dart',
92+
])!;
8993
expect(options.disableCacheFlushing, isTrue);
9094
});
9195

@@ -148,29 +152,27 @@ void main() {
148152
test('mixed single and multiple flags', () {
149153
var options = overrideKnownFeatures(
150154
knownFeatures,
151-
() =>
152-
parse([
153-
'--enable-experiment',
154-
'a,b',
155-
'--enable-experiment',
156-
'c',
157-
'foo.dart',
158-
])!,
155+
() => parse([
156+
'--enable-experiment',
157+
'a,b',
158+
'--enable-experiment',
159+
'c',
160+
'foo.dart',
161+
])!,
159162
);
160163
expect(options.enabledExperiments, ['a', 'b', 'c']);
161164
});
162165

163166
test('multiple flags', () {
164167
var options = overrideKnownFeatures(
165168
knownFeatures,
166-
() =>
167-
parse([
168-
'--enable-experiment',
169-
'a',
170-
'--enable-experiment',
171-
'b',
172-
'foo.dart',
173-
])!,
169+
() => parse([
170+
'--enable-experiment',
171+
'a',
172+
'--enable-experiment',
173+
'b',
174+
'foo.dart',
175+
])!,
174176
);
175177
expect(options.enabledExperiments, ['a', 'b']);
176178
});
@@ -184,58 +186,63 @@ void main() {
184186

185187
group('format', () {
186188
test('json', () {
187-
var options =
188-
parse(['--dart-sdk', '.', '--format=json', 'foo.dart'])!;
189+
var options = parse([
190+
'--dart-sdk',
191+
'.',
192+
'--format=json',
193+
'foo.dart',
194+
])!;
189195
expect(options.jsonFormat, isTrue);
190196
expect(options.machineFormat, isFalse);
191197
});
192198

193199
test('machine', () {
194-
var options =
195-
parse(['--dart-sdk', '.', '--format=machine', 'foo.dart'])!;
200+
var options = parse([
201+
'--dart-sdk',
202+
'.',
203+
'--format=machine',
204+
'foo.dart',
205+
])!;
196206
expect(options.jsonFormat, isFalse);
197207
expect(options.machineFormat, isTrue);
198208
});
199209
});
200210

201211
test('options', () {
202-
var options =
203-
parse([
204-
'--dart-sdk',
205-
'.',
206-
'--options',
207-
'options.yaml',
208-
'foo.dart',
209-
])!;
212+
var options = parse([
213+
'--dart-sdk',
214+
'.',
215+
'--options',
216+
'options.yaml',
217+
'foo.dart',
218+
])!;
210219
expect(options.defaultAnalysisOptionsPath, endsWith('options.yaml'));
211220
});
212221

213222
test('sourceFiles', () {
214-
var options =
215-
parse([
216-
'--dart-sdk',
217-
'.',
218-
'--log',
219-
'foo.dart',
220-
'foo2.dart',
221-
'foo3.dart',
222-
])!;
223+
var options = parse([
224+
'--dart-sdk',
225+
'.',
226+
'--log',
227+
'foo.dart',
228+
'foo2.dart',
229+
'foo3.dart',
230+
])!;
223231
expect(
224232
options.sourceFiles,
225233
equals(['foo.dart', 'foo2.dart', 'foo3.dart']),
226234
);
227235
});
228236

229237
test('ignore unrecognized flags', () {
230-
var options =
231-
parse([
232-
'--ignore-unrecognized-flags',
233-
'--bar',
234-
'--baz',
235-
'--dart-sdk',
236-
'.',
237-
'foo.dart',
238-
])!;
238+
var options = parse([
239+
'--ignore-unrecognized-flags',
240+
'--bar',
241+
'--baz',
242+
'--dart-sdk',
243+
'.',
244+
'foo.dart',
245+
])!;
239246
expect(options, isNotNull);
240247
expect(options.sourceFiles, equals(['foo.dart']));
241248
});

pkg/analyzer_cli/test/perf_report_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import 'package:test/test.dart';
1212

1313
void main() {
1414
test('makePerfReport', () {
15-
var options =
16-
CommandLineOptions.parse(PhysicalResourceProvider.INSTANCE, [
17-
'somefile.dart',
18-
])!;
15+
var options = CommandLineOptions.parse(PhysicalResourceProvider.INSTANCE, [
16+
'somefile.dart',
17+
])!;
1918
var encoded = makePerfReport(1000, 1234, options, 0, AnalysisStats());
2019

2120
var jsonData = json.decode(encoded);

pkg/analyzer_cli/test/utils.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ final String testDirectory = pathos.dirname(
1818
String get packageRoot {
1919
// If the package root directory is specified on the command line using
2020
// -DpkgRoot=..., use it.
21-
var pkgRootVar =
22-
const bool.hasEnvironment('pkgRoot')
23-
? const String.fromEnvironment('pkgRoot')
24-
: null;
21+
var pkgRootVar = const bool.hasEnvironment('pkgRoot')
22+
? const String.fromEnvironment('pkgRoot')
23+
: null;
2524
if (pkgRootVar != null) {
2625
var path = pathos.join(Directory.current.path, pkgRootVar);
2726
if (!path.endsWith(pathos.separator)) path += pathos.separator;

0 commit comments

Comments
 (0)