| 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 analysis_server.src.provisional.completion.dart.completion_target; | 5 library analysis_server.src.provisional.completion.dart.completion_target; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/src/generated/scanner.dart'; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 258 } |
| 259 if (node is MethodInvocation) { | 259 if (node is MethodInvocation) { |
| 260 return node.isCascaded && offset > node.operator.offset + 1; | 260 return node.isCascaded && offset > node.operator.offset + 1; |
| 261 } | 261 } |
| 262 return false; | 262 return false; |
| 263 } | 263 } |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * Return `true` if the target is a functional argument in an argument list. | 266 * Return `true` if the target is a functional argument in an argument list. |
| 267 * The target [AstNode] hierarchy *must* be resolved for this to work. | 267 * The target [AstNode] hierarchy *must* be resolved for this to work. |
| 268 * See [maybeFunctionalArgument]. |
| 268 */ | 269 */ |
| 269 bool isFunctionalArgument() { | 270 bool isFunctionalArgument() { |
| 270 if (!maybeFunctionalArgument()) { | 271 if (!maybeFunctionalArgument()) { |
| 271 return false; | 272 return false; |
| 272 } | 273 } |
| 273 AstNode parent = containingNode.parent; | 274 AstNode parent = containingNode.parent; |
| 274 if (parent is InstanceCreationExpression) { | 275 if (parent is InstanceCreationExpression) { |
| 275 DartType instType = parent.bestType; | 276 DartType instType = parent.bestType; |
| 276 if (instType != null) { | 277 if (instType != null) { |
| 277 Element intTypeElem = instType.element; | 278 Element intTypeElem = instType.element; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 292 return _isFunctionalParameter(methodElem.parameters, argIndex); | 293 return _isFunctionalParameter(methodElem.parameters, argIndex); |
| 293 } else if (methodElem is FunctionElement) { | 294 } else if (methodElem is FunctionElement) { |
| 294 return _isFunctionalParameter(methodElem.parameters, argIndex); | 295 return _isFunctionalParameter(methodElem.parameters, argIndex); |
| 295 } | 296 } |
| 296 } | 297 } |
| 297 } | 298 } |
| 298 return false; | 299 return false; |
| 299 } | 300 } |
| 300 | 301 |
| 301 /** | 302 /** |
| 302 * Return `true` if the target is a functional argument in an argument list. | 303 * Return `true` if the target maybe a functional argument in an argument list
. |
| 303 * The target [AstNode] hierarchy *must* be resolved for this to work. | 304 * This is used in determining whether the target [AstNode] hierarchy |
| 305 * needs to be resolved so that [isFunctionalArgument] will work. |
| 304 */ | 306 */ |
| 305 bool maybeFunctionalArgument() { | 307 bool maybeFunctionalArgument() { |
| 306 if (argIndex == null) { | 308 if (argIndex == null) { |
| 307 return false; | 309 return false; |
| 308 } | 310 } |
| 309 AstNode argList = containingNode; | 311 AstNode argList = containingNode; |
| 310 if (argList is! ArgumentList) { | 312 if (argList is! ArgumentList) { |
| 311 return false; | 313 return false; |
| 312 } | 314 } |
| 313 return true; | 315 return true; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 if (param.parameterKind == ParameterKind.NAMED) { | 416 if (param.parameterKind == ParameterKind.NAMED) { |
| 415 // TODO(danrubel) handle named parameters | 417 // TODO(danrubel) handle named parameters |
| 416 return false; | 418 return false; |
| 417 } else { | 419 } else { |
| 418 return paramType is FunctionType || paramType is FunctionTypeAlias; | 420 return paramType is FunctionType || paramType is FunctionTypeAlias; |
| 419 } | 421 } |
| 420 } | 422 } |
| 421 return false; | 423 return false; |
| 422 } | 424 } |
| 423 } | 425 } |
| OLD | NEW |