@@ -23,21 +23,9 @@ import 'utils.dart';
2323final List <String > reservedWords = _collectReservedWords ();
2424
2525/// Returns direct children of [parent] .
26- List <Element > getChildren (Element parent, [String ? name]) {
27- var children = < Element > [];
28- visitChildren (parent, (Element element) {
29- if (name == null || element.displayName == name) {
30- children.add (element);
31- }
32- return false ;
33- });
34- return children;
35- }
36-
37- /// Returns direct children of [parent] .
38- List <Element2 > getChildren2 (Element2 parent, [String ? name]) {
26+ List <Element2 > getChildren (Element2 parent, [String ? name]) {
3927 var children = < Element2 > [];
40- visitChildren2 (parent, (Element2 element) {
28+ visitChildren (parent, (Element2 element) {
4129 if (name == null || element.displayName == name) {
4230 children.add (element);
4331 }
@@ -317,14 +305,8 @@ File? locatePubspecFile(CompilationUnit compilationUnit) {
317305
318306/// Uses [processor] to visit all of the children of [element] .
319307/// If [processor] returns `true` , then children of a child are visited too.
320- void visitChildren (Element element, ElementProcessor processor) {
321- element.visitChildren (_ElementVisitorAdapter (processor));
322- }
323-
324- /// Uses [processor] to visit all of the children of [element] .
325- /// If [processor] returns `true` , then children of a child are visited too.
326- void visitChildren2 (Element2 element, ElementProcessor2 processor) {
327- element.visitChildren2 (_ElementVisitorAdapter2 (processor));
308+ void visitChildren (Element2 element, ElementProcessor processor) {
309+ element.visitChildren2 (_ElementVisitorAdapter (processor));
328310}
329311
330312bool _checkForSimpleGetter (MethodDeclaration getter, Expression ? expression) {
@@ -434,35 +416,16 @@ bool _hasFieldOrMethod(ClassMember element, String name) =>
434416 (element is MethodDeclaration && element.name.lexeme == name) ||
435417 (element is FieldDeclaration && getFieldName (element, name) != null );
436418
437- /// An [Element] processor function type.
438- /// If `true` is returned, children of [element] will be visited.
439- typedef ElementProcessor = bool Function (Element element);
440-
441- /// An [Element] processor function type.
419+ /// An [Element2] processor function type.
442420/// If `true` is returned, children of [element] will be visited.
443- typedef ElementProcessor2 = bool Function (Element2 element);
421+ typedef ElementProcessor = bool Function (Element2 element);
444422
445423/// A [GeneralizingElementVisitor] adapter for [ElementProcessor] .
446- class _ElementVisitorAdapter extends GeneralizingElementVisitor <void > {
424+ class _ElementVisitorAdapter extends GeneralizingElementVisitor2 <void > {
447425 final ElementProcessor processor;
448426
449427 _ElementVisitorAdapter (this .processor);
450428
451- @override
452- void visitElement (Element element) {
453- var visitChildren = processor (element);
454- if (visitChildren) {
455- element.visitChildren (this );
456- }
457- }
458- }
459-
460- /// A [GeneralizingElementVisitor] adapter for [ElementProcessor] .
461- class _ElementVisitorAdapter2 extends GeneralizingElementVisitor2 <void > {
462- final ElementProcessor2 processor;
463-
464- _ElementVisitorAdapter2 (this .processor);
465-
466429 @override
467430 void visitElement (Element2 element) {
468431 var visitChildren = processor (element);
@@ -480,13 +443,3 @@ extension AstNodeExtension on AstNode {
480443 self.argumentList.arguments.isNotEmpty;
481444 }
482445}
483-
484- extension ElementExtension on Element ? {
485- // TODO(srawlins): Move to extensions.dart.
486- bool get isDartCorePrint {
487- var self = this ;
488- return self is FunctionElement &&
489- self.name == 'print' &&
490- self.library.isDartCore;
491- }
492- }
0 commit comments