1414
1515import 'package:analyzer/dart/analysis/results.dart' ;
1616import 'package:analyzer/dart/analysis/session.dart' ;
17- import 'package:analyzer/dart/element/element .dart' ;
17+ import 'package:analyzer/dart/element/element2 .dart' ;
1818import 'package:analyzer/dart/element/nullability_suffix.dart' ;
1919import 'package:analyzer/dart/element/type.dart' ;
2020
@@ -338,92 +338,87 @@ Future<void> visitLibraryAtUri(AnalysisSession session, String uri) async {
338338 final libPath = session.uriConverter.uriToPath (Uri .parse (uri));
339339 var result = await session.getResolvedLibrary (libPath! );
340340 if (result is ResolvedLibraryResult ) {
341- visitLibrary (result.element );
341+ visitLibrary (result.element2 );
342342 } else {
343343 throw StateError ('Unable to resolve "$uri "' );
344344 }
345345}
346346
347- void visitLibrary (LibraryElement library) {
347+ void visitLibrary (LibraryElement2 library) {
348348 // This uses the element model to traverse the code. The element model
349349 // represents the semantic structure of the code. A library consists of
350350 // one or more compilation units.
351- for (var unit in library.units) {
352- visitCompilationUnit (unit);
353- }
354- }
355-
356- void visitCompilationUnit (CompilationUnitElement unit) {
351+ //
357352 // Each compilation unit contains elements for all of the top-level
358353 // declarations in a single file, such as variables, functions, and
359354 // classes. Note that `types` only returns classes. You can use
360355 // `mixins` to visit mixins, `enums` to visit enum, `functionTypeAliases`
361356 // to visit typedefs, etc.
362- for (var variable in unit .topLevelVariables) {
357+ for (var variable in library .topLevelVariables) {
363358 if (variable.isPublic) {
364- addToTable (typeString (variable.type), variable.name ,
359+ addToTable (typeString (variable.type), variable.name3 ! ,
365360 [voidEncoding, voidEncoding],
366361 isMethod: false );
367362 }
368363 }
369- for (var function in unit.functions ) {
370- if (function.isPublic && ! function.isOperator ) {
371- addToTable (typeString (function.returnType), function.name ,
372- protoString (null , function.parameters ));
364+ for (var function in library.topLevelFunctions ) {
365+ if (function.isPublic) {
366+ addToTable (typeString (function.returnType), function.name3 ! ,
367+ protoString (null , function.formalParameters ));
373368 }
374369 }
375- for (var classElement in unit .classes) {
370+ for (var classElement in library .classes) {
376371 if (classElement.isPublic) {
377372 visitClass (classElement);
378373 }
379374 }
380375}
381376
382- void visitClass (ClassElement classElement) {
377+ void visitClass (ClassElement2 classElement) {
383378 // Classes that cause too many false divergences.
384- if (classElement.name == 'ProcessInfo' ||
385- classElement.name == 'Platform' ||
386- classElement.name .startsWith ('FileSystem' )) {
379+ if (classElement.name3 == 'ProcessInfo' ||
380+ classElement.name3 == 'Platform' ||
381+ classElement.name3 ! .startsWith ('FileSystem' )) {
387382 return ;
388383 }
389384 // Every class element contains elements for the members, viz. `methods` visits
390385 // methods, `fields` visits fields, `accessors` visits getters and setters, etc.
391386 // There are also accessors to get the superclass, mixins, interfaces, type
392387 // parameters, etc.
393- for (var constructor in classElement.constructors ) {
388+ for (var constructor in classElement.constructors2 ) {
394389 if (constructor.isPublic &&
395390 constructor.isFactory &&
396- constructor.name.isNotEmpty ) {
391+ constructor.name3 != 'new' ) {
397392 addToTable (
398393 typeString (classElement.thisType),
399- '${classString (classElement )}.${constructor .name }' ,
400- protoString (null , constructor.parameters ));
394+ '${classString (classElement )}.${constructor .name3 }' ,
395+ protoString (null , constructor.formalParameters ));
401396 }
402397 }
403- for (var method in classElement.methods ) {
398+ for (var method in classElement.methods2 ) {
404399 if (method.isPublic && ! method.isOperator) {
405400 if (method.isStatic) {
406401 addToTable (
407402 typeString (method.returnType),
408- '${classString (classElement )}.${method .name }' ,
409- protoString (null , method.parameters ));
403+ '${classString (classElement )}.${method .name3 }' ,
404+ protoString (null , method.formalParameters ));
410405 } else {
411- addToTable (typeString (method.returnType), method.name ,
412- protoString (classElement.thisType, method.parameters ));
406+ addToTable (typeString (method.returnType), method.name3 ! ,
407+ protoString (classElement.thisType, method.formalParameters ));
413408 }
414409 }
415410 }
416- for (var accessor in classElement.accessors ) {
417- if (accessor.isPublic && accessor.isGetter ) {
418- var variable = accessor.variable2 ! ;
411+ for (var accessor in classElement.getters2 ) {
412+ if (accessor.isPublic) {
413+ var variable = accessor.variable3 ! ;
419414 if (accessor.isStatic) {
420415 addToTable (
421416 typeString (variable.type),
422- '${classElement .name }.${variable .name }' ,
417+ '${classElement .name3 }.${variable .name3 }' ,
423418 [voidEncoding, voidEncoding],
424419 isMethod: false );
425420 } else {
426- addToTable (typeString (variable.type), variable.name ,
421+ addToTable (typeString (variable.type), variable.name3 ! ,
427422 [typeString (classElement.thisType), voidEncoding],
428423 isMethod: false );
429424 }
@@ -432,7 +427,7 @@ void visitClass(ClassElement classElement) {
432427}
433428
434429// Function that returns the explicit class name.
435- String classString (ClassElement classElement) {
430+ String classString (ClassElement2 classElement) {
436431 switch (typeString (classElement.thisType)) {
437432 case setIntEncoding:
438433 return 'Set<int>' ;
@@ -441,7 +436,7 @@ String classString(ClassElement classElement) {
441436 case mapIntStringEncoding:
442437 return 'Map<int, String>' ;
443438 default :
444- return classElement.name ;
439+ return classElement.name3 ! ;
445440 }
446441}
447442
@@ -596,7 +591,7 @@ String typeStringHelper(DartType type) {
596591}
597592
598593List <String > protoString (
599- DartType ? receiver, List <ParameterElement > parameters) {
594+ DartType ? receiver, List <FormalParameterElement > parameters) {
600595 final proto = [receiver == null ? voidEncoding : typeString (receiver)];
601596 // Construct prototype for non-named parameters.
602597 for (var parameter in parameters) {
0 commit comments