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

Side by Side Diff: pkg/analysis_server/lib/src/domains/analysis/navigation_dart.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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 domains.analysis.navigation_dart; 5 library domains.analysis.navigation_dart;
6 6
7 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart' ; 7 import 'package:analysis_server/plugin/analysis/navigation/navigation_core.dart' ;
8 import 'package:analysis_server/src/protocol_server.dart' as protocol; 8 import 'package:analysis_server/src/protocol_server.dart' as protocol;
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 prefixElement = element; 120 prefixElement = element;
121 } 121 }
122 computer._addRegionForNode(name.prefix, prefixElement); 122 computer._addRegionForNode(name.prefix, prefixElement);
123 // always constructor 123 // always constructor
124 computer._addRegionForNode(name.identifier, element); 124 computer._addRegionForNode(name.identifier, element);
125 } else { 125 } else {
126 computer._addRegionForNode(name, element); 126 computer._addRegionForNode(name, element);
127 } 127 }
128 computer._addRegionForNode(node.constructorName, element); 128 computer._addRegionForNode(node.constructorName, element);
129 // arguments 129 // arguments
130 _safelyVisit(node.arguments); 130 node.arguments?.accept(this);
131 } 131 }
132 132
133 @override 133 @override
134 visitAssignmentExpression(AssignmentExpression node) { 134 visitAssignmentExpression(AssignmentExpression node) {
135 _safelyVisit(node.leftHandSide); 135 node.leftHandSide?.accept(this);
136 computer._addRegionForToken(node.operator, node.bestElement); 136 computer._addRegionForToken(node.operator, node.bestElement);
137 _safelyVisit(node.rightHandSide); 137 node.rightHandSide?.accept(this);
138 } 138 }
139 139
140 @override 140 @override
141 visitBinaryExpression(BinaryExpression node) { 141 visitBinaryExpression(BinaryExpression node) {
142 _safelyVisit(node.leftOperand); 142 node.leftOperand?.accept(this);
143 computer._addRegionForToken(node.operator, node.bestElement); 143 computer._addRegionForToken(node.operator, node.bestElement);
144 _safelyVisit(node.rightOperand); 144 node.rightOperand?.accept(this);
145 } 145 }
146 146
147 @override 147 @override
148 visitCompilationUnit(CompilationUnit unit) { 148 visitCompilationUnit(CompilationUnit unit) {
149 // prepare top-level nodes sorted by their offsets 149 // prepare top-level nodes sorted by their offsets
150 List<AstNode> nodes = <AstNode>[]; 150 List<AstNode> nodes = <AstNode>[];
151 nodes.addAll(unit.directives); 151 nodes.addAll(unit.directives);
152 nodes.addAll(unit.declarations); 152 nodes.addAll(unit.declarations);
153 nodes.sort((a, b) { 153 nodes.sort((a, b) {
154 return a.offset - b.offset; 154 return a.offset - b.offset;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 @override 248 @override
249 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { 249 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
250 Element element = node.staticElement; 250 Element element = node.staticElement;
251 if (element != null && element.isSynthetic) { 251 if (element != null && element.isSynthetic) {
252 element = element.enclosingElement; 252 element = element.enclosingElement;
253 } 253 }
254 // add region 254 // add region
255 computer._addRegionForToken(node.thisKeyword, element); 255 computer._addRegionForToken(node.thisKeyword, element);
256 computer._addRegionForNode(node.constructorName, element); 256 computer._addRegionForNode(node.constructorName, element);
257 // process arguments 257 // process arguments
258 _safelyVisit(node.argumentList); 258 node.argumentList?.accept(this);
259 } 259 }
260 260
261 @override 261 @override
262 visitSimpleIdentifier(SimpleIdentifier node) { 262 visitSimpleIdentifier(SimpleIdentifier node) {
263 if (node.parent is ConstructorDeclaration) { 263 if (node.parent is ConstructorDeclaration) {
264 return; 264 return;
265 } 265 }
266 Element element = node.bestElement; 266 Element element = node.bestElement;
267 computer._addRegionForNode(node, element); 267 computer._addRegionForNode(node, element);
268 } 268 }
269 269
270 @override 270 @override
271 visitSuperConstructorInvocation(SuperConstructorInvocation node) { 271 visitSuperConstructorInvocation(SuperConstructorInvocation node) {
272 Element element = node.staticElement; 272 Element element = node.staticElement;
273 if (element != null && element.isSynthetic) { 273 if (element != null && element.isSynthetic) {
274 element = element.enclosingElement; 274 element = element.enclosingElement;
275 } 275 }
276 // add region 276 // add region
277 computer._addRegionForToken(node.superKeyword, element); 277 computer._addRegionForToken(node.superKeyword, element);
278 computer._addRegionForNode(node.constructorName, element); 278 computer._addRegionForNode(node.constructorName, element);
279 // process arguments 279 // process arguments
280 _safelyVisit(node.argumentList); 280 node.argumentList?.accept(this);
281 } 281 }
282 282
283 void _addConstructorName(AstNode parent, ConstructorName node) { 283 void _addConstructorName(AstNode parent, ConstructorName node) {
284 Element element = node.staticElement; 284 Element element = node.staticElement;
285 if (element == null) { 285 if (element == null) {
286 return; 286 return;
287 } 287 }
288 // if a synthetic constructor, navigate to the class 288 // if a synthetic constructor, navigate to the class
289 if (element.isSynthetic) { 289 if (element.isSynthetic) {
290 element = element.enclosingElement; 290 element = element.enclosingElement;
(...skipping 26 matching lines...) Expand all
317 * then add the navigation region from the [node] to the [element]. 317 * then add the navigation region from the [node] to the [element].
318 */ 318 */
319 void _addUriDirectiveRegion(UriBasedDirective node, Element element) { 319 void _addUriDirectiveRegion(UriBasedDirective node, Element element) {
320 if (element != null) { 320 if (element != null) {
321 Source source = element.source; 321 Source source = element.source;
322 if (element.context.exists(source)) { 322 if (element.context.exists(source)) {
323 computer._addRegionForNode(node.uri, element); 323 computer._addRegionForNode(node.uri, element);
324 } 324 }
325 } 325 }
326 } 326 }
327
328 void _safelyVisit(AstNode node) {
329 if (node != null) {
330 node.accept(this);
331 }
332 }
333 } 327 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698