Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 1814453002: Remove more calls to safelyVisit methods (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 2084
2085 @override 2085 @override
2086 bool isAccessibleIn(LibraryElement library) { 2086 bool isAccessibleIn(LibraryElement library) {
2087 if (Identifier.isPrivateName(_name)) { 2087 if (Identifier.isPrivateName(_name)) {
2088 return library == this.library; 2088 return library == this.library;
2089 } 2089 }
2090 return true; 2090 return true;
2091 } 2091 }
2092 2092
2093 /** 2093 /**
2094 * If the given [child] is not `null`, use the given [visitor] to visit it.
2095 */
2096 void safelyVisitChild(Element child, ElementVisitor visitor) {
2097 if (child != null) {
2098 child.accept(visitor);
2099 }
2100 }
2101
2102 /**
2103 * Use the given [visitor] to visit all of the [children] in the given array. 2094 * Use the given [visitor] to visit all of the [children] in the given array.
2104 */ 2095 */
2105 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { 2096 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) {
2106 if (children != null) { 2097 if (children != null) {
2107 for (Element child in children) { 2098 for (Element child in children) {
2108 child.accept(visitor); 2099 child.accept(visitor);
2109 } 2100 }
2110 } 2101 }
2111 } 2102 }
2112 2103
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 3032
3042 @override 3033 @override
3043 void appendTo(StringBuffer buffer) { 3034 void appendTo(StringBuffer buffer) {
3044 buffer.write("import "); 3035 buffer.write("import ");
3045 (importedLibrary as LibraryElementImpl).appendTo(buffer); 3036 (importedLibrary as LibraryElementImpl).appendTo(buffer);
3046 } 3037 }
3047 3038
3048 @override 3039 @override
3049 void visitChildren(ElementVisitor visitor) { 3040 void visitChildren(ElementVisitor visitor) {
3050 super.visitChildren(visitor); 3041 super.visitChildren(visitor);
3051 safelyVisitChild(prefix, visitor); 3042 prefix?.accept(visitor);
3052 } 3043 }
3053 } 3044 }
3054 3045
3055 /** 3046 /**
3056 * A concrete implementation of a [LabelElement]. 3047 * A concrete implementation of a [LabelElement].
3057 */ 3048 */
3058 class LabelElementImpl extends ElementImpl implements LabelElement { 3049 class LabelElementImpl extends ElementImpl implements LabelElement {
3059 /** 3050 /**
3060 * A flag indicating whether this label is associated with a `switch` 3051 * A flag indicating whether this label is associated with a `switch`
3061 * statement. 3052 * statement.
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 3605
3615 @override 3606 @override
3616 bool isUpToDate(int timeStamp) { 3607 bool isUpToDate(int timeStamp) {
3617 Set<LibraryElement> visitedLibraries = new Set(); 3608 Set<LibraryElement> visitedLibraries = new Set();
3618 return _safeIsUpToDate(this, timeStamp, visitedLibraries); 3609 return _safeIsUpToDate(this, timeStamp, visitedLibraries);
3619 } 3610 }
3620 3611
3621 @override 3612 @override
3622 void visitChildren(ElementVisitor visitor) { 3613 void visitChildren(ElementVisitor visitor) {
3623 super.visitChildren(visitor); 3614 super.visitChildren(visitor);
3624 safelyVisitChild(_definingCompilationUnit, visitor); 3615 _definingCompilationUnit?.accept(visitor);
3625 safelyVisitChildren(_exports, visitor); 3616 safelyVisitChildren(_exports, visitor);
3626 safelyVisitChildren(_imports, visitor); 3617 safelyVisitChildren(_imports, visitor);
3627 safelyVisitChildren(_parts, visitor); 3618 safelyVisitChildren(_parts, visitor);
3628 } 3619 }
3629 3620
3630 /** 3621 /**
3631 * Recursively fills set of visible libraries for 3622 * Recursively fills set of visible libraries for
3632 * [getVisibleElementsLibraries]. 3623 * [getVisibleElementsLibraries].
3633 */ 3624 */
3634 void _addVisibleLibraries( 3625 void _addVisibleLibraries(
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
4910 @override 4901 @override
4911 void appendTo(StringBuffer buffer) { 4902 void appendTo(StringBuffer buffer) {
4912 buffer.write(type); 4903 buffer.write(type);
4913 buffer.write(" "); 4904 buffer.write(" ");
4914 buffer.write(displayName); 4905 buffer.write(displayName);
4915 } 4906 }
4916 4907
4917 @override 4908 @override
4918 void visitChildren(ElementVisitor visitor) { 4909 void visitChildren(ElementVisitor visitor) {
4919 super.visitChildren(visitor); 4910 super.visitChildren(visitor);
4920 safelyVisitChild(_initializer, visitor); 4911 _initializer?.accept(visitor);
4921 } 4912 }
4922 } 4913 }
4923 4914
4924 /** 4915 /**
4925 * A visitor that visit all the elements recursively and fill the given [map]. 4916 * A visitor that visit all the elements recursively and fill the given [map].
4926 */ 4917 */
4927 class _BuildOffsetToElementMap extends GeneralizingElementVisitor { 4918 class _BuildOffsetToElementMap extends GeneralizingElementVisitor {
4928 final Map<int, Element> map; 4919 final Map<int, Element> map;
4929 4920
4930 _BuildOffsetToElementMap(this.map); 4921 _BuildOffsetToElementMap(this.map);
4931 4922
4932 @override 4923 @override
4933 void visitElement(Element element) { 4924 void visitElement(Element element) {
4934 int offset = element.nameOffset; 4925 int offset = element.nameOffset;
4935 if (offset != -1) { 4926 if (offset != -1) {
4936 map[offset] = element; 4927 map[offset] = element;
4937 } 4928 }
4938 super.visitElement(element); 4929 super.visitElement(element);
4939 } 4930 }
4940 } 4931 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart ('k') | pkg/analyzer/lib/src/dart/element/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698