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

Side by Side Diff: pkg/analysis_server/lib/src/computer/computer_navigation.dart

Issue 616953002: Fix for NPE when FieldFormalParameterElement references an unresolved field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/notification_navigation_test.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) 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 computer.navigation; 5 library computer.navigation;
6 6
7 import 'package:analysis_server/src/protocol.dart' as protocol; 7 import 'package:analysis_server/src/protocol.dart' as protocol;
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
(...skipping 12 matching lines...) Expand all
23 23
24 /** 24 /**
25 * Returns the computed navigation regions, not `null`. 25 * Returns the computed navigation regions, not `null`.
26 */ 26 */
27 List<protocol.NavigationRegion> compute() { 27 List<protocol.NavigationRegion> compute() {
28 _unit.accept(new _DartUnitNavigationComputerVisitor(this)); 28 _unit.accept(new _DartUnitNavigationComputerVisitor(this));
29 return new List.from(_regions); 29 return new List.from(_regions);
30 } 30 }
31 31
32 void _addRegion(int offset, int length, Element element) { 32 void _addRegion(int offset, int length, Element element) {
33 if (element is FieldFormalParameterElement) {
34 element = (element as FieldFormalParameterElement).field;
35 }
33 if (element == null || element == DynamicElementImpl.instance) { 36 if (element == null || element == DynamicElementImpl.instance) {
34 return; 37 return;
35 } 38 }
36 if (element is FieldFormalParameterElement) {
37 element = (element as FieldFormalParameterElement).field;
38 }
39 protocol.Element target = new protocol.Element.fromEngine(element); 39 protocol.Element target = new protocol.Element.fromEngine(element);
40 _regions.add(new protocol.NavigationRegion(offset, length, [target])); 40 _regions.add(new protocol.NavigationRegion(offset, length, [target]));
41 } 41 }
42 42
43 void _addRegionForNode(AstNode node, Element element) { 43 void _addRegionForNode(AstNode node, Element element) {
44 int offset = node.offset; 44 int offset = node.offset;
45 int length = node.length; 45 int length = node.length;
46 _addRegion(offset, length, element); 46 _addRegion(offset, length, element);
47 } 47 }
48 48
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 @override 199 @override
200 visitSimpleIdentifier(SimpleIdentifier node) { 200 visitSimpleIdentifier(SimpleIdentifier node) {
201 if (node.parent is ConstructorDeclaration) { 201 if (node.parent is ConstructorDeclaration) {
202 } else { 202 } else {
203 computer._addRegionForNode(node, node.bestElement); 203 computer._addRegionForNode(node, node.bestElement);
204 } 204 }
205 return super.visitSimpleIdentifier(node); 205 return super.visitSimpleIdentifier(node);
206 } 206 }
207 } 207 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/notification_navigation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698