| 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.contributor.dart.keyword; | 5 library services.completion.contributor.dart.keyword; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (previousMember is FunctionDeclaration && | 138 if (previousMember is FunctionDeclaration && |
| 139 previousMember.functionExpression is FunctionExpression && | 139 previousMember.functionExpression is FunctionExpression && |
| 140 previousMember.functionExpression.body is EmptyFunctionBody) { | 140 previousMember.functionExpression.body is EmptyFunctionBody) { |
| 141 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); | 141 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); |
| 142 } | 142 } |
| 143 _addCompilationUnitKeywords(); | 143 _addCompilationUnitKeywords(); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 @override | 147 @override |
| 148 visitPropertyAccess(PropertyAccess node) { |
| 149 // suggestions before '.' but not after |
| 150 if (entity != node.propertyName) { |
| 151 super.visitPropertyAccess(node); |
| 152 } |
| 153 } |
| 154 |
| 155 @override |
| 148 visitExpression(Expression node) { | 156 visitExpression(Expression node) { |
| 149 _addExpressionKeywords(node); | 157 _addExpressionKeywords(node); |
| 150 } | 158 } |
| 151 | 159 |
| 152 @override | 160 @override |
| 153 visitInstanceCreationExpression(InstanceCreationExpression node) { | |
| 154 if (entity == node.constructorName) { | |
| 155 // no keywords in 'new ^' expression | |
| 156 } else { | |
| 157 super.visitInstanceCreationExpression(node); | |
| 158 } | |
| 159 } | |
| 160 | |
| 161 @override | |
| 162 visitMethodInvocation(MethodInvocation node) { | |
| 163 if (entity == node.methodName) { | |
| 164 // no keywords in '.' expression | |
| 165 } else { | |
| 166 super.visitMethodInvocation(node); | |
| 167 } | |
| 168 } | |
| 169 | |
| 170 @override | |
| 171 visitExpressionFunctionBody(ExpressionFunctionBody node) { | 161 visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 172 if (entity == node.expression) { | 162 if (entity == node.expression) { |
| 173 _addExpressionKeywords(node); | 163 _addExpressionKeywords(node); |
| 174 } | 164 } |
| 175 } | 165 } |
| 176 | 166 |
| 177 @override | 167 @override |
| 178 visitFormalParameterList(FormalParameterList node) { | 168 visitFormalParameterList(FormalParameterList node) { |
| 179 AstNode constructorDecl = | 169 AstNode constructorDecl = |
| 180 node.getAncestor((p) => p is ConstructorDeclaration); | 170 node.getAncestor((p) => p is ConstructorDeclaration); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 210 if (node.deferredKeyword == null) { | 200 if (node.deferredKeyword == null) { |
| 211 _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH); | 201 _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH); |
| 212 } | 202 } |
| 213 } | 203 } |
| 214 if (entity == node.semicolon || node.combinators.contains(entity)) { | 204 if (entity == node.semicolon || node.combinators.contains(entity)) { |
| 215 _addImportDirectiveKeywords(node); | 205 _addImportDirectiveKeywords(node); |
| 216 } | 206 } |
| 217 } | 207 } |
| 218 | 208 |
| 219 @override | 209 @override |
| 210 visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 211 if (entity == node.constructorName) { |
| 212 // no keywords in 'new ^' expression |
| 213 } else { |
| 214 super.visitInstanceCreationExpression(node); |
| 215 } |
| 216 } |
| 217 |
| 218 @override |
| 219 visitLibraryIdentifier(LibraryIdentifier node) { |
| 220 // no suggestions |
| 221 } |
| 222 |
| 223 @override |
| 220 visitMethodDeclaration(MethodDeclaration node) { | 224 visitMethodDeclaration(MethodDeclaration node) { |
| 221 if (entity == node.body) { | 225 if (entity == node.body) { |
| 222 if (node.body is EmptyFunctionBody) { | 226 if (node.body is EmptyFunctionBody) { |
| 223 _addClassBodyKeywords(); | 227 _addClassBodyKeywords(); |
| 224 _addSuggestion2(ASYNC); | 228 _addSuggestion2(ASYNC); |
| 225 } else { | 229 } else { |
| 226 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); | 230 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); |
| 227 } | 231 } |
| 228 } | 232 } |
| 229 } | 233 } |
| 230 | 234 |
| 231 @override | 235 @override |
| 236 visitMethodInvocation(MethodInvocation node) { |
| 237 if (entity == node.methodName) { |
| 238 // no keywords in '.' expression |
| 239 } else { |
| 240 super.visitMethodInvocation(node); |
| 241 } |
| 242 } |
| 243 |
| 244 @override |
| 232 visitNamedExpression(NamedExpression node) { | 245 visitNamedExpression(NamedExpression node) { |
| 233 if (entity is SimpleIdentifier && entity == node.expression) { | 246 if (entity is SimpleIdentifier && entity == node.expression) { |
| 234 _addExpressionKeywords(node); | 247 _addExpressionKeywords(node); |
| 235 } | 248 } |
| 236 } | 249 } |
| 237 | 250 |
| 238 @override | 251 @override |
| 239 visitNode(AstNode node) { | 252 visitNode(AstNode node) { |
| 240 // ignored | 253 // ignored |
| 241 } | 254 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 return false; | 421 return false; |
| 409 } | 422 } |
| 410 AstNode parent = body.parent; | 423 AstNode parent = body.parent; |
| 411 if (parent is ConstructorDeclaration || parent is MethodDeclaration) { | 424 if (parent is ConstructorDeclaration || parent is MethodDeclaration) { |
| 412 return true; | 425 return true; |
| 413 } | 426 } |
| 414 node = parent; | 427 node = parent; |
| 415 } | 428 } |
| 416 } | 429 } |
| 417 } | 430 } |
| OLD | NEW |