Skip to content

Commit 3515a19

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
DAS plugins: Start enforcing an analyzer constraint
Change-Id: Ie2f987edfd4da9c2e45298a65e645b9fb9f80670 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395261 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 630e262 commit 3515a19

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// THIS FILE IS GENERATED. DO NOT EDIT.
6+
//
7+
// Instead, run 'dart pkg/analysis_server/tool/generate_analyzer_version.dart'
8+
// to update this file.
9+
10+
/// The version of the analyzer that matches the analyzer code used by the
11+
/// analysis_server package.
12+
var analyzerVersion = '7.0.0-dev';

pkg/analysis_server/lib/src/plugin2/generator.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:analysis_server/src/plugin2/analyzer_version.g.dart';
56
import 'package:analyzer/dart/analysis/analysis_options.dart';
67

78
/// This class can generate various files to make up the shared plugin package.
@@ -60,6 +61,7 @@ Future<void> main(List<String> args, SendPort sendPort) async {
6061
name: plugin_entrypoint
6162
version: 0.0.1
6263
dependencies:
64+
analyzer: '$analyzerVersion'
6365
''');
6466

6567
for (var configuration in _pluginConfigurations) {

pkg/analysis_server/test/src/plugin2/generator_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:analysis_server/src/plugin2/analyzer_version.g.dart';
56
import 'package:analysis_server/src/plugin2/generator.dart';
67
import 'package:analyzer/src/generated/engine.dart';
78
import 'package:test/test.dart';
@@ -68,6 +69,7 @@ import 'package:no_ints/main.dart' as no_ints;
6869
pluginPackageGenerator.generatePubspec(),
6970
contains('''
7071
dependencies:
72+
analyzer: '$analyzerVersion'
7173
no_bools:
7274
git:
7375
url: https://example.com/example.git
@@ -90,6 +92,7 @@ dependencies:
9092
pluginPackageGenerator.generatePubspec(),
9193
contains('''
9294
dependencies:
95+
analyzer: '$analyzerVersion'
9396
no_bools:
9497
path: ../no_bools_plugin
9598
no_ints:
@@ -113,6 +116,7 @@ dependencies:
113116
pluginPackageGenerator.generatePubspec(),
114117
contains('''
115118
dependencies:
119+
analyzer: '$analyzerVersion'
116120
no_bools: ^1.0.0
117121
no_ints: ^1.2.0
118122
'''),
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:analyzer_utilities/package_root.dart';
8+
import 'package:analyzer_utilities/tools.dart';
9+
import 'package:path/path.dart';
10+
import 'package:yaml/yaml.dart';
11+
12+
void main() async {
13+
await GeneratedContent.generateAll(
14+
normalize(join(packageRoot, 'analysis_server')),
15+
allTargets,
16+
);
17+
}
18+
19+
List<GeneratedContent> get allTargets {
20+
return [
21+
GeneratedFile('lib/src/plugin2/analyzer_version.g.dart', (_) async {
22+
var buffer = StringBuffer('''
23+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
24+
// for details. All rights reserved. Use of this source code is governed by a
25+
// BSD-style license that can be found in the LICENSE file.
26+
27+
// THIS FILE IS GENERATED. DO NOT EDIT.
28+
//
29+
// Instead, run 'dart pkg/analysis_server/tool/generate_analyzer_version.dart'
30+
// to update this file.
31+
32+
''');
33+
var pubspecPath = normalize(
34+
join(packageRoot, 'analyzer', 'pubspec.yaml'),
35+
);
36+
var pubspec = loadYaml(File(pubspecPath).readAsStringSync());
37+
var version = (pubspec as YamlMap)['version'] as String;
38+
39+
buffer.write('''
40+
/// The version of the analyzer that matches the analyzer code used by the
41+
/// analysis_server package.
42+
var analyzerVersion = '$version';
43+
''');
44+
return buffer.toString();
45+
}),
46+
];
47+
}

0 commit comments

Comments
 (0)