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

Side by Side Diff: pkg/analysis_server/lib/src/services/index/indexable_element.dart

Issue 1162853004: Issue 23568. Fix for NPE in index when unresolved field formal parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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) 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 src.services.index; 5 library src.services.index;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/analysis/index/index_core.dart'; 9 import 'package:analysis_server/analysis/index/index_core.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 13
14 /** 14 /**
15 * A wrapper around an [Element] that implements the [IndexableObject] interface . 15 * A wrapper around an [Element] that implements the [IndexableObject] interface .
16 */ 16 */
17 class IndexableElement implements IndexableObject { 17 class IndexableElement implements IndexableObject {
18 /** 18 /**
19 * The element being wrapped. 19 * The element being wrapped.
20 */ 20 */
21 final Element element; 21 final Element element;
22 22
23 /** 23 /**
24 * Initialize a newly created wrapper to wrap the given [element]. 24 * Initialize a newly created wrapper to wrap the given [element].
25 */ 25 */
26 IndexableElement(this.element); 26 IndexableElement(this.element) {
27 if (element == null) {
28 throw new ArgumentError.notNull('element');
29 }
30 }
27 31
28 @override 32 @override
29 int get hashCode => element.hashCode; 33 int get hashCode => element.hashCode;
30 34
31 @override 35 @override
32 IndexableObjectKind get kind => IndexableElementKind.forElement(element); 36 IndexableObjectKind get kind => IndexableElementKind.forElement(element);
33 37
34 @override 38 @override
35 int get length => element.displayName.length; 39 int get length => element.displayName.length;
36 40
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 * Return the indexable element kind representing the given [element]. 149 * Return the indexable element kind representing the given [element].
146 */ 150 */
147 static IndexableElementKind forElement(Element element) { 151 static IndexableElementKind forElement(Element element) {
148 if (element is ConstructorElement) { 152 if (element is ConstructorElement) {
149 ClassElement classElement = element.enclosingElement; 153 ClassElement classElement = element.enclosingElement;
150 int constructorIndex = classElement.constructors.indexOf(element); 154 int constructorIndex = classElement.constructors.indexOf(element);
151 return _constructorKinds.putIfAbsent(constructorIndex, 155 return _constructorKinds.putIfAbsent(constructorIndex,
152 () => new IndexableElementKind._(ElementKind.CONSTRUCTOR)); 156 () => new IndexableElementKind._(ElementKind.CONSTRUCTOR));
153 } 157 }
154 ElementKind elementKind = element.kind; 158 ElementKind elementKind = element.kind;
155 return _kindMap.putIfAbsent(elementKind, () => 159 return _kindMap.putIfAbsent(
156 new IndexableElementKind._(elementKind)); 160 elementKind, () => new IndexableElementKind._(elementKind));
157 } 161 }
158 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698