Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 1776353003: Issue 25962. Check for the number of arguments vs. number of required parameters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 analysis_server.src.services.correction.fix_internal; 5 library analysis_server.src.services.correction.fix_internal;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:core' hide Resource; 9 import 'dart:core' hide Resource;
10 10
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 SimpleIdentifier methodName = invocation.methodName; 421 SimpleIdentifier methodName = invocation.methodName;
422 Element targetElement = methodName.bestElement; 422 Element targetElement = methodName.bestElement;
423 List<Expression> arguments = argumentList.arguments; 423 List<Expression> arguments = argumentList.arguments;
424 if (targetElement is ExecutableElement) { 424 if (targetElement is ExecutableElement) {
425 List<ParameterElement> parameters = targetElement.parameters; 425 List<ParameterElement> parameters = targetElement.parameters;
426 int numParameters = parameters.length; 426 int numParameters = parameters.length;
427 Iterable<ParameterElement> requiredParameters = parameters 427 Iterable<ParameterElement> requiredParameters = parameters
428 .takeWhile((p) => p.parameterKind == ParameterKind.REQUIRED); 428 .takeWhile((p) => p.parameterKind == ParameterKind.REQUIRED);
429 Iterable<ParameterElement> optionalParameters = parameters 429 Iterable<ParameterElement> optionalParameters = parameters
430 .skipWhile((p) => p.parameterKind == ParameterKind.REQUIRED); 430 .skipWhile((p) => p.parameterKind == ParameterKind.REQUIRED);
431 // prepare the argument to add a new parameter for
431 int numRequired = requiredParameters.length; 432 int numRequired = requiredParameters.length;
433 if (numRequired >= arguments.length) {
434 return;
435 }
432 Expression argument = arguments[numRequired]; 436 Expression argument = arguments[numRequired];
433 // prepare target 437 // prepare target
434 int targetOffset; 438 int targetOffset;
435 if (numRequired != 0) { 439 if (numRequired != 0) {
436 AstNode parameterNode = requiredParameters.last.computeNode(); 440 AstNode parameterNode = requiredParameters.last.computeNode();
437 targetOffset = parameterNode.end; 441 targetOffset = parameterNode.end;
438 } else { 442 } else {
439 AstNode targetNode = targetElement.computeNode(); 443 AstNode targetNode = targetElement.computeNode();
440 if (targetNode is FunctionDeclaration) { 444 if (targetNode is FunctionDeclaration) {
441 FunctionExpression function = targetNode.functionExpression; 445 FunctionExpression function = targetNode.functionExpression;
(...skipping 2529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 /** 2975 /**
2972 * Describes the location for a newly created [FieldDeclaration]. 2976 * Describes the location for a newly created [FieldDeclaration].
2973 */ 2977 */
2974 class _FieldLocation { 2978 class _FieldLocation {
2975 final String prefix; 2979 final String prefix;
2976 final int offset; 2980 final int offset;
2977 final String suffix; 2981 final String suffix;
2978 2982
2979 _FieldLocation(this.prefix, this.offset, this.suffix); 2983 _FieldLocation(this.prefix, this.offset, this.suffix);
2980 } 2984 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698