| OLD | NEW |
| 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 services.completion.computer.dart.invocation; | 5 library services.completion.computer.dart.invocation; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 9 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 10 import 'package:analysis_server/src/services/completion/optype.dart'; | 10 import 'package:analysis_server/src/services/completion/optype.dart'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 Future<bool> computeFull(AstNode node) { | 57 Future<bool> computeFull(AstNode node) { |
| 58 if (node is SimpleIdentifier) { | 58 if (node is SimpleIdentifier) { |
| 59 node = node.parent; | 59 node = node.parent; |
| 60 } | 60 } |
| 61 if (node is MethodInvocation) { | 61 if (node is MethodInvocation) { |
| 62 node = (node as MethodInvocation).realTarget; | 62 node = (node as MethodInvocation).realTarget; |
| 63 } else if (node is PropertyAccess) { | 63 } else if (node is PropertyAccess) { |
| 64 node = (node as PropertyAccess).realTarget; | 64 node = (node as PropertyAccess).realTarget; |
| 65 } | 65 } |
| 66 if (node is Expression) { | 66 if (node is Expression) { |
| 67 DartType type = node.bestType; | 67 InterfaceTypeSuggestionBuilder.suggestionsFor(request, node.bestType); |
| 68 if (type != null) { | 68 return new Future.value(true); |
| 69 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); | |
| 70 return new Future.value(true); | |
| 71 } | |
| 72 } | 69 } |
| 73 return new Future.value(false); | 70 return new Future.value(false); |
| 74 } | 71 } |
| 75 } | 72 } |
| 76 | 73 |
| 77 /** | 74 /** |
| 78 * An [AstNode] vistor for determining which suggestion builder | 75 * An [AstNode] vistor for determining which suggestion builder |
| 79 * should be used to build invocation/access suggestions. | 76 * should be used to build invocation/access suggestions. |
| 80 */ | 77 */ |
| 81 class _InvocationAstVisitor extends GeneralizingAstVisitor<SuggestionBuilder> { | 78 class _InvocationAstVisitor extends GeneralizingAstVisitor<SuggestionBuilder> { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 151 } |
| 155 } | 152 } |
| 156 return new Future.value(false); | 153 return new Future.value(false); |
| 157 } | 154 } |
| 158 | 155 |
| 159 @override | 156 @override |
| 160 Future<bool> visitClassElement(ClassElement element) { | 157 Future<bool> visitClassElement(ClassElement element) { |
| 161 if (element != null) { | 158 if (element != null) { |
| 162 InterfaceType type = element.type; | 159 InterfaceType type = element.type; |
| 163 if (type != null) { | 160 if (type != null) { |
| 164 ClassElementSuggestionBuilder.suggestionsFor( | 161 StaticClassElementSuggestionBuilder.suggestionsFor( |
| 165 request, | 162 request, |
| 166 type.element, | 163 type.element); |
| 167 staticOnly: true); | |
| 168 } | 164 } |
| 169 } | 165 } |
| 170 return new Future.value(false); | 166 return new Future.value(false); |
| 171 } | 167 } |
| 172 | 168 |
| 173 @override | 169 @override |
| 174 Future<bool> visitElement(Element element) { | 170 Future<bool> visitElement(Element element) { |
| 175 return new Future.value(false); | 171 return new Future.value(false); |
| 176 } | 172 } |
| 177 | 173 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 197 } | 193 } |
| 198 }); | 194 }); |
| 199 return new Future.value(modified); | 195 return new Future.value(modified); |
| 200 } | 196 } |
| 201 | 197 |
| 202 @override | 198 @override |
| 203 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { | 199 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { |
| 204 if (element != null) { | 200 if (element != null) { |
| 205 PropertyInducingElement elemVar = element.variable; | 201 PropertyInducingElement elemVar = element.variable; |
| 206 if (elemVar != null) { | 202 if (elemVar != null) { |
| 207 DartType type = elemVar.type; | 203 InterfaceTypeSuggestionBuilder.suggestionsFor(request, elemVar.type); |
| 208 if (type != null) { | |
| 209 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); | |
| 210 } | |
| 211 } | 204 } |
| 212 return new Future.value(true); | 205 return new Future.value(true); |
| 213 } | 206 } |
| 214 return new Future.value(false); | 207 return new Future.value(false); |
| 215 } | 208 } |
| 216 | 209 |
| 217 @override | 210 @override |
| 218 Future<bool> visitVariableElement(VariableElement element) { | 211 Future<bool> visitVariableElement(VariableElement element) { |
| 219 DartType type = element.type; | 212 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type); |
| 220 if (type != null) { | |
| 221 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); | |
| 222 } | |
| 223 return new Future.value(true); | 213 return new Future.value(true); |
| 224 } | 214 } |
| 225 } | 215 } |
| OLD | NEW |