Skip to content

Commit 034067f

Browse files
authored
Migrate web_generator to new element model (#359)
New version of analyzer requires a migration: https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/element_model_migration_guide.md. Updates pubspec version to `^7.4.0`.
1 parent fa43ddd commit 034067f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

web_generator/bin/update_bindings.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:io';
88

99
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
1010
import 'package:analyzer/dart/analysis/results.dart';
11-
import 'package:analyzer/dart/element/element.dart';
11+
import 'package:analyzer/dart/element/element2.dart';
1212
import 'package:analyzer/dart/element/type.dart';
1313
import 'package:args/args.dart';
1414
import 'package:io/ansi.dart' as ansi;
@@ -201,20 +201,20 @@ Future<void> _generateJsTypeSupertypes() async {
201201
includedPaths: [p.join(_webPackagePath, 'lib', 'src', 'dom.dart')]);
202202
final dartJsInterop = (await contextCollection.contexts.single.currentSession
203203
.getLibraryByUri('dart:js_interop') as LibraryElementResult)
204-
.element;
205-
final definedNames = dartJsInterop.exportNamespace.definedNames;
204+
.element2;
205+
final definedNames = dartJsInterop.exportNamespace.definedNames2;
206206
// `SplayTreeMap` to avoid moving types around in `dart:js_interop` affecting
207207
// the code generation.
208208
final jsTypeSupertypes = SplayTreeMap<String, String?>();
209209
for (final name in definedNames.keys) {
210210
final element = definedNames[name];
211-
if (element is ExtensionTypeElement) {
211+
if (element is ExtensionTypeElement2) {
212212
// JS types are any extension type that starts with 'JS' in
213213
// `dart:js_interop`.
214-
bool isJSType(InterfaceElement element) =>
215-
element is ExtensionTypeElement &&
216-
element.library == dartJsInterop &&
217-
element.name.startsWith('JS');
214+
bool isJSType(InterfaceElement2 element) =>
215+
element is ExtensionTypeElement2 &&
216+
element.library2 == dartJsInterop &&
217+
element.name3!.startsWith('JS');
218218
if (!isJSType(element)) continue;
219219

220220
String? parentJsType;
@@ -226,8 +226,8 @@ Future<void> _generateJsTypeSupertypes() async {
226226
// We should have at most one non-trivial supertype.
227227
assert(immediateSupertypes.length <= 1);
228228
for (final supertype in immediateSupertypes) {
229-
if (isJSType(supertype.element)) {
230-
parentJsType = "'${supertype.element.name}'";
229+
if (isJSType(supertype.element3)) {
230+
parentJsType = "'${supertype.element3.name3!}'";
231231
}
232232
}
233233
// Ensure that the hierarchy forms a tree.

web_generator/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ environment:
88
sdk: ^3.6.0
99

1010
dependencies:
11-
analyzer: ^7.0.0
11+
analyzer: ^7.4.0
1212
args: ^2.4.0
1313
build_runner: ^2.4.6
1414
build_web_compilers: ^4.0.8

0 commit comments

Comments
 (0)