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

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

Issue 668763002: Issue 21238. Fix for NPE in occurrences computer when FieldFormalParameterElement references unreso… (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_occurrences_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.occurrences; 5 library computer.occurrences;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/protocol_server.dart' as protocol; 9 import 'package:analysis_server/src/protocol_server.dart' as protocol;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 19 matching lines...) Expand all
30 List<protocol.Occurrences> occurrences = <protocol.Occurrences>[]; 30 List<protocol.Occurrences> occurrences = <protocol.Occurrences>[];
31 _elementsOffsets.forEach((engineElement, offsets) { 31 _elementsOffsets.forEach((engineElement, offsets) {
32 var serverElement = protocol.newElement_fromEngine(engineElement); 32 var serverElement = protocol.newElement_fromEngine(engineElement);
33 var length = engineElement.displayName.length; 33 var length = engineElement.displayName.length;
34 occurrences.add(new protocol.Occurrences(serverElement, offsets, length)); 34 occurrences.add(new protocol.Occurrences(serverElement, offsets, length));
35 }); 35 });
36 return occurrences; 36 return occurrences;
37 } 37 }
38 38
39 void _addOccurrence(Element element, int offset) { 39 void _addOccurrence(Element element, int offset) {
40 element = _canonicalizeElement(element);
40 if (element == null || element == DynamicElementImpl.instance) { 41 if (element == null || element == DynamicElementImpl.instance) {
41 return; 42 return;
42 } 43 }
43 element = _canonicalizeElement(element);
44 List<int> offsets = _elementsOffsets[element]; 44 List<int> offsets = _elementsOffsets[element];
45 if (offsets == null) { 45 if (offsets == null) {
46 offsets = <int>[]; 46 offsets = <int>[];
47 _elementsOffsets[element] = offsets; 47 _elementsOffsets[element] = offsets;
48 } 48 }
49 offsets.add(offset); 49 offsets.add(offset);
50 } 50 }
51 51
52 Element _canonicalizeElement(Element element) { 52 Element _canonicalizeElement(Element element) {
53 if (element is FieldFormalParameterElement) { 53 if (element is FieldFormalParameterElement) {
(...skipping 17 matching lines...) Expand all
71 71
72 @override 72 @override
73 visitSimpleIdentifier(SimpleIdentifier node) { 73 visitSimpleIdentifier(SimpleIdentifier node) {
74 Element element = node.bestElement; 74 Element element = node.bestElement;
75 if (element != null) { 75 if (element != null) {
76 computer._addOccurrence(element, node.offset); 76 computer._addOccurrence(element, node.offset);
77 } 77 }
78 return super.visitSimpleIdentifier(node); 78 return super.visitSimpleIdentifier(node);
79 } 79 }
80 } 80 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis/notification_occurrences_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698