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

Side by Side Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 1897293003: Required params message fix. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
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 analyzer.src.generated.error_verifier; 5 library analyzer.src.generated.error_verifier;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4234 matching lines...) Expand 10 before | Expand all | Expand 10 after
4245 DartType type, ArgumentList argumentList, AstNode node) { 4245 DartType type, ArgumentList argumentList, AstNode node) {
4246 if (type is FunctionType) { 4246 if (type is FunctionType) {
4247 List<ParameterElement> parameters = type.parameters; 4247 List<ParameterElement> parameters = type.parameters;
4248 for (ParameterElement param in parameters) { 4248 for (ParameterElement param in parameters) {
4249 if (param.parameterKind == ParameterKind.NAMED) { 4249 if (param.parameterKind == ParameterKind.NAMED) {
4250 ElementAnnotationImpl annotation = _getRequiredAnnotation(param); 4250 ElementAnnotationImpl annotation = _getRequiredAnnotation(param);
4251 if (annotation != null) { 4251 if (annotation != null) {
4252 String paramName = param.name; 4252 String paramName = param.name;
4253 if (!_containsNamedExpression(argumentList, paramName)) { 4253 if (!_containsNamedExpression(argumentList, paramName)) {
4254 DartObject constantValue = annotation.constantValue; 4254 DartObject constantValue = annotation.constantValue;
4255 String reason = 4255 String reason = constantValue.getField('reason')?.toStringValue();
4256 constantValue.getField('reason')?.toStringValue() ?? ''; 4256 if (reason != null) {
4257 _errorReporter.reportErrorForNode( 4257 _errorReporter.reportErrorForNode(
4258 HintCode.MISSING_REQUIRED_PARAM, node, [paramName, reason]); 4258 HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS,
4259 node,
4260 [paramName, reason]);
4261 } else {
4262 _errorReporter.reportErrorForNode(
4263 HintCode.MISSING_REQUIRED_PARAM, node, [paramName]);
4264 }
4259 } 4265 }
4260 } 4266 }
4261 } 4267 }
4262 } 4268 }
4263 } 4269 }
4264 } 4270 }
4265 4271
4266 /** 4272 /**
4267 * Verify that the given function [body] does not contain return statements 4273 * Verify that the given function [body] does not contain return statements
4268 * that both have and do not have return values. 4274 * that both have and do not have return values.
(...skipping 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after
6157 class _InvocationCollector extends RecursiveAstVisitor { 6163 class _InvocationCollector extends RecursiveAstVisitor {
6158 final List<String> superCalls = <String>[]; 6164 final List<String> superCalls = <String>[];
6159 6165
6160 @override 6166 @override
6161 visitMethodInvocation(MethodInvocation node) { 6167 visitMethodInvocation(MethodInvocation node) {
6162 if (node.target is SuperExpression) { 6168 if (node.target is SuperExpression) {
6163 superCalls.add(node.methodName.name); 6169 superCalls.add(node.methodName.name);
6164 } 6170 }
6165 } 6171 }
6166 } 6172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698