Skip to content

Commit d968611

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate runtime/tools/dartfuzz from deprecated analyzer APIs.
Change-Id: I1f4f38ffd0054997e9cf6dc9cff95a7805dc8760 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454620 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent da8ed22 commit d968611

File tree

3 files changed

+89
-90
lines changed

3 files changed

+89
-90
lines changed

runtime/tools/dartfuzz/gen_api_table.dart

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import 'package:analyzer/dart/analysis/results.dart';
1616
import 'package:analyzer/dart/analysis/session.dart';
17-
import 'package:analyzer/dart/element/element2.dart';
17+
import 'package:analyzer/dart/element/element.dart';
1818
import 'package:analyzer/dart/element/nullability_suffix.dart';
1919
import 'package:analyzer/dart/element/type.dart';
2020

@@ -340,13 +340,13 @@ Future<void> visitLibraryAtUri(AnalysisSession session, String uri) async {
340340
final libPath = session.uriConverter.uriToPath(Uri.parse(uri));
341341
var result = await session.getResolvedLibrary(libPath!);
342342
if (result is ResolvedLibraryResult) {
343-
visitLibrary(result.element2);
343+
visitLibrary(result.element);
344344
} else {
345345
throw StateError('Unable to resolve "$uri"');
346346
}
347347
}
348348

349-
void visitLibrary(LibraryElement2 library) {
349+
void visitLibrary(LibraryElement library) {
350350
// This uses the element model to traverse the code. The element model
351351
// represents the semantic structure of the code. A library consists of
352352
// one or more compilation units.
@@ -358,7 +358,7 @@ void visitLibrary(LibraryElement2 library) {
358358
// to visit typedefs, etc.
359359
for (var variable in library.topLevelVariables) {
360360
if (variable.isPublic) {
361-
addToTable(typeString(variable.type), variable.name3!, [
361+
addToTable(typeString(variable.type), variable.name!, [
362362
voidEncoding,
363363
voidEncoding,
364364
], isMethod: false);
@@ -368,7 +368,7 @@ void visitLibrary(LibraryElement2 library) {
368368
if (function.isPublic) {
369369
addToTable(
370370
typeString(function.returnType),
371-
function.name3!,
371+
function.name!,
372372
protoString(null, function.formalParameters),
373373
);
374374
}
@@ -380,57 +380,57 @@ void visitLibrary(LibraryElement2 library) {
380380
}
381381
}
382382

383-
void visitClass(ClassElement2 classElement) {
383+
void visitClass(ClassElement classElement) {
384384
// Classes that cause too many false divergences.
385-
if (classElement.name3 == 'ProcessInfo' ||
386-
classElement.name3 == 'Platform' ||
387-
classElement.name3!.startsWith('FileSystem')) {
385+
if (classElement.name == 'ProcessInfo' ||
386+
classElement.name == 'Platform' ||
387+
classElement.name!.startsWith('FileSystem')) {
388388
return;
389389
}
390390
// Every class element contains elements for the members, viz. `methods` visits
391391
// methods, `fields` visits fields, `accessors` visits getters and setters, etc.
392392
// There are also accessors to get the superclass, mixins, interfaces, type
393393
// parameters, etc.
394-
for (var constructor in classElement.constructors2) {
394+
for (var constructor in classElement.constructors) {
395395
if (constructor.isPublic &&
396396
constructor.isFactory &&
397-
constructor.name3 != 'new') {
397+
constructor.name != 'new') {
398398
addToTable(
399399
typeString(classElement.thisType),
400-
'${classString(classElement)}.${constructor.name3}',
400+
'${classString(classElement)}.${constructor.name}',
401401
protoString(null, constructor.formalParameters),
402402
);
403403
}
404404
}
405-
for (var method in classElement.methods2) {
405+
for (var method in classElement.methods) {
406406
if (method.isPublic && !method.isOperator) {
407407
if (method.isStatic) {
408408
addToTable(
409409
typeString(method.returnType),
410-
'${classString(classElement)}.${method.name3}',
410+
'${classString(classElement)}.${method.name}',
411411
protoString(null, method.formalParameters),
412412
);
413413
} else {
414414
addToTable(
415415
typeString(method.returnType),
416-
method.name3!,
416+
method.name!,
417417
protoString(classElement.thisType, method.formalParameters),
418418
);
419419
}
420420
}
421421
}
422-
for (var accessor in classElement.getters2) {
422+
for (var accessor in classElement.getters) {
423423
if (accessor.isPublic) {
424-
var variable = accessor.variable3!;
424+
var variable = accessor.variable;
425425
if (accessor.isStatic) {
426426
addToTable(
427427
typeString(variable.type),
428-
'${classElement.name3}.${variable.name3}',
428+
'${classElement.name}.${variable.name}',
429429
[voidEncoding, voidEncoding],
430430
isMethod: false,
431431
);
432432
} else {
433-
addToTable(typeString(variable.type), variable.name3!, [
433+
addToTable(typeString(variable.type), variable.name!, [
434434
typeString(classElement.thisType),
435435
voidEncoding,
436436
], isMethod: false);
@@ -440,7 +440,7 @@ void visitClass(ClassElement2 classElement) {
440440
}
441441

442442
// Function that returns the explicit class name.
443-
String classString(ClassElement2 classElement) {
443+
String classString(ClassElement classElement) {
444444
switch (typeString(classElement.thisType)) {
445445
case setIntEncoding:
446446
return 'Set<int>';
@@ -449,7 +449,7 @@ String classString(ClassElement2 classElement) {
449449
case mapIntStringEncoding:
450450
return 'Map<int, String>';
451451
default:
452-
return classElement.name3!;
452+
return classElement.name!;
453453
}
454454
}
455455

0 commit comments

Comments
 (0)