| 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.src.correction.fix; | 5 library services.src.correction.fix; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' hide AnalysisError, Element, | 9 import 'package:analysis_server/src/protocol.dart' hide AnalysisError, Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 return; | 569 return; |
| 570 } | 570 } |
| 571 } else { | 571 } else { |
| 572 ClassDeclaration enclosingClass = | 572 ClassDeclaration enclosingClass = |
| 573 node.getAncestor((node) => node is ClassDeclaration); | 573 node.getAncestor((node) => node is ClassDeclaration); |
| 574 targetElement = | 574 targetElement = |
| 575 enclosingClass != null ? enclosingClass.element : null; | 575 enclosingClass != null ? enclosingClass.element : null; |
| 576 argument = nameNode; | 576 argument = nameNode; |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 argument = stepUpNamedExpression(argument); |
| 579 // should be argument of some invocation | 580 // should be argument of some invocation |
| 580 ParameterElement parameterElement = argument.bestParameterElement; | 581 ParameterElement parameterElement = argument.bestParameterElement; |
| 581 if (parameterElement == null) { | 582 if (parameterElement == null) { |
| 582 return; | 583 return; |
| 583 } | 584 } |
| 584 // should be parameter of function type | 585 // should be parameter of function type |
| 585 DartType parameterType = parameterElement.type; | 586 DartType parameterType = parameterElement.type; |
| 587 if (parameterType is InterfaceType && parameterType.isDartCoreFunction) { |
| 588 ExecutableElement element = new MethodElementImpl('', -1); |
| 589 parameterType = new FunctionTypeImpl.con1(element); |
| 590 } |
| 586 if (parameterType is! FunctionType) { | 591 if (parameterType is! FunctionType) { |
| 587 return; | 592 return; |
| 588 } | 593 } |
| 589 FunctionType functionType = parameterType as FunctionType; | 594 FunctionType functionType = parameterType as FunctionType; |
| 590 // add proposal | 595 // add proposal |
| 591 if (targetElement != null) { | 596 if (targetElement != null) { |
| 592 _addProposal_createFunction_method(targetElement, functionType); | 597 _addProposal_createFunction_method(targetElement, functionType); |
| 593 } else { | 598 } else { |
| 594 _addProposal_createFunction_function(functionType); | 599 _addProposal_createFunction_function(functionType); |
| 595 } | 600 } |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 /** | 1970 /** |
| 1966 * Describes the location for a newly created [ConstructorDeclaration]. | 1971 * Describes the location for a newly created [ConstructorDeclaration]. |
| 1967 */ | 1972 */ |
| 1968 class _ConstructorLocation { | 1973 class _ConstructorLocation { |
| 1969 final String _prefix; | 1974 final String _prefix; |
| 1970 final int _offset; | 1975 final int _offset; |
| 1971 final String _suffix; | 1976 final String _suffix; |
| 1972 | 1977 |
| 1973 _ConstructorLocation(this._prefix, this._offset, this._suffix); | 1978 _ConstructorLocation(this._prefix, this._offset, this._suffix); |
| 1974 } | 1979 } |
| OLD | NEW |