OLD | NEW |
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 services.completion.computer.dart.relevance; | 5 library services.completion.computer.dart.relevance; |
6 | 6 |
7 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
8 import 'package:analysis_server/src/protocol_server.dart' | 8 import 'package:analysis_server/src/protocol_server.dart' |
9 show CompletionSuggestion, CompletionSuggestionKind; | 9 show CompletionSuggestion, CompletionSuggestionKind; |
10 import 'package:analysis_server/src/provisional/completion/completion_dart.dart'
; | 10 import 'package:analysis_server/src/provisional/completion/completion_dart.dart'
; |
(...skipping 27 matching lines...) Loading... |
38 _update(request, suggestions); | 38 _update(request, suggestions); |
39 } | 39 } |
40 | 40 |
41 /** | 41 /** |
42 * Adjusts the relevance based on the given completion context. | 42 * Adjusts the relevance based on the given completion context. |
43 * The compilation unit and completion node | 43 * The compilation unit and completion node |
44 * in the given completion context may not be resolved. | 44 * in the given completion context may not be resolved. |
45 */ | 45 */ |
46 void _update(DartCompletionRequest request, | 46 void _update(DartCompletionRequest request, |
47 Iterable<CompletionSuggestion> suggestions) { | 47 Iterable<CompletionSuggestion> suggestions) { |
48 var visitor = new _BestTypeVisitor(request.target.entity); | 48 var visitor = new _BestTypeVisitor(request.parsedTarget.entity); |
49 DartType type = request.target.containingNode.accept(visitor); | 49 DartType type = request.parsedTarget.containingNode.accept(visitor); |
50 if (type != null) { | 50 if (type != null) { |
51 Element typeElem = type.element; | 51 Element typeElem = type.element; |
52 if (typeElem != null) { | 52 if (typeElem != null) { |
53 LibraryElement libElem = typeElem.library; | 53 LibraryElement libElem = typeElem.library; |
54 if (libElem != null) { | 54 if (libElem != null) { |
55 _updateInvocationRelevance(request, type, libElem, suggestions); | 55 _updateInvocationRelevance(request, type, libElem, suggestions); |
56 } | 56 } |
57 } | 57 } |
58 } | 58 } |
59 } | 59 } |
(...skipping 68 matching lines...) Loading... |
128 DartType visitPropertyAccess(PropertyAccess node) { | 128 DartType visitPropertyAccess(PropertyAccess node) { |
129 if (node.propertyName == entity) { | 129 if (node.propertyName == entity) { |
130 Expression target = node.realTarget; | 130 Expression target = node.realTarget; |
131 if (target != null) { | 131 if (target != null) { |
132 return target.bestType; | 132 return target.bestType; |
133 } | 133 } |
134 } | 134 } |
135 return null; | 135 return null; |
136 } | 136 } |
137 } | 137 } |
OLD | NEW |