| 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/suggestion_builder.dart'
; | 10 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 /** | 73 /** |
| 74 * An [AstNode] vistor for determining which suggestion builder | 74 * An [AstNode] vistor for determining which suggestion builder |
| 75 * should be used to build invocation/access suggestions. | 75 * should be used to build invocation/access suggestions. |
| 76 */ | 76 */ |
| 77 class _InvocationAstVisitor extends GeneralizingAstVisitor<SuggestionBuilder> { | 77 class _InvocationAstVisitor extends GeneralizingAstVisitor<SuggestionBuilder> { |
| 78 final DartCompletionRequest request; | 78 final DartCompletionRequest request; |
| 79 | 79 |
| 80 _InvocationAstVisitor(this.request); | 80 _InvocationAstVisitor(this.request); |
| 81 | 81 |
| 82 @override | 82 @override |
| 83 visitConstructorName(ConstructorName node) { |
| 84 // some PrefixedIdentifier nodes are transformed into |
| 85 // ConstructorName nodes during the resolution process. |
| 86 Token period = node.period; |
| 87 if (period != null && request.offset > period.offset) { |
| 88 TypeName type = node.type; |
| 89 if (type != null) { |
| 90 SimpleIdentifier prefix = type.name; |
| 91 if (prefix != null) { |
| 92 return new _PrefixedIdentifierSuggestionBuilder(request); |
| 93 } |
| 94 } |
| 95 } |
| 96 return null; |
| 97 } |
| 98 |
| 99 @override |
| 83 SuggestionBuilder visitMethodInvocation(MethodInvocation node) { | 100 SuggestionBuilder visitMethodInvocation(MethodInvocation node) { |
| 84 Token period = node.period; | 101 Token period = node.period; |
| 85 if (period == null || period.offset < request.offset) { | 102 if (period == null || period.offset < request.offset) { |
| 86 return new _ExpressionSuggestionBuilder(request); | 103 return new _ExpressionSuggestionBuilder(request); |
| 87 } | 104 } |
| 88 return null; | 105 return null; |
| 89 } | 106 } |
| 90 | 107 |
| 91 @override | 108 @override |
| 92 SuggestionBuilder visitNode(AstNode node) { | 109 SuggestionBuilder visitNode(AstNode node) { |
| 93 return null; | 110 return null; |
| 94 } | 111 } |
| 95 | 112 |
| 96 @override | 113 @override |
| 97 SuggestionBuilder visitPrefixedIdentifier(PrefixedIdentifier node) { | 114 SuggestionBuilder visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 98 // some PrefixedIdentifier nodes are transformed into | 115 // some PrefixedIdentifier nodes are transformed into |
| 99 // ConstructorName nodes during the resolution process. | 116 // ConstructorName nodes during the resolution process. |
| 100 Token period = node.period; | 117 Token period = node.period; |
| 101 if (request.offset > period.offset) { | 118 if (period != null && request.offset > period.offset) { |
| 102 SimpleIdentifier prefix = node.prefix; | 119 SimpleIdentifier prefix = node.prefix; |
| 103 if (prefix != null) { | 120 if (prefix != null) { |
| 104 return new _PrefixedIdentifierSuggestionBuilder(request); | 121 return new _PrefixedIdentifierSuggestionBuilder(request); |
| 105 } | 122 } |
| 106 } | 123 } |
| 107 return null; | 124 return null; |
| 108 } | 125 } |
| 109 | 126 |
| 110 @override | 127 @override |
| 111 SuggestionBuilder visitPropertyAccess(PropertyAccess node) { | 128 SuggestionBuilder visitPropertyAccess(PropertyAccess node) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 237 |
| 221 @override | 238 @override |
| 222 Future<bool> visitVariableElement(VariableElement element) { | 239 Future<bool> visitVariableElement(VariableElement element) { |
| 223 DartType type = element.type; | 240 DartType type = element.type; |
| 224 if (type != null) { | 241 if (type != null) { |
| 225 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); | 242 ClassElementSuggestionBuilder.suggestionsFor(request, type.element); |
| 226 } | 243 } |
| 227 return new Future.value(true); | 244 return new Future.value(true); |
| 228 } | 245 } |
| 229 } | 246 } |
| OLD | NEW |