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

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

Issue 1252123004: Fix highlight range for missing enum constant in switch (issue 23904) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 engine.resolver.error_verifier; 5 library engine.resolver.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/src/generated/static_type_analyzer.dart'; 10 import 'package:analyzer/src/generated/static_type_analyzer.dart';
(...skipping 4095 matching lines...) Expand 10 before | Expand all | Expand 10 after
4106 String constantName = _getConstantName((member as SwitchCase).expression); 4106 String constantName = _getConstantName((member as SwitchCase).expression);
4107 if (constantName != null) { 4107 if (constantName != null) {
4108 constantNames.remove(constantName); 4108 constantNames.remove(constantName);
4109 } 4109 }
4110 } 4110 }
4111 int nameCount = constantNames.length; 4111 int nameCount = constantNames.length;
4112 if (nameCount == 0) { 4112 if (nameCount == 0) {
4113 return false; 4113 return false;
4114 } 4114 }
4115 for (int i = 0; i < nameCount; i++) { 4115 for (int i = 0; i < nameCount; i++) {
4116 _errorReporter.reportErrorForNode( 4116 int offset = statement.offset;
4117 CompileTimeErrorCode.MISSING_ENUM_CONSTANT_IN_SWITCH, statement, 4117 int end = statement.rightParenthesis.end;
4118 _errorReporter.reportErrorForOffset(
4119 CompileTimeErrorCode.MISSING_ENUM_CONSTANT_IN_SWITCH, offset, end - of fset,
4118 [constantNames[i]]); 4120 [constantNames[i]]);
4119 } 4121 }
4120 return true; 4122 return true;
4121 } 4123 }
4122 4124
4123 /** 4125 /**
4124 * Verify that the given function [body] does not contain return statements 4126 * Verify that the given function [body] does not contain return statements
4125 * that both have and do not have return values. 4127 * that both have and do not have return values.
4126 * 4128 *
4127 * See [StaticWarningCode.MIXED_RETURN_TYPES]. 4129 * See [StaticWarningCode.MIXED_RETURN_TYPES].
(...skipping 1857 matching lines...) Expand 10 before | Expand all | Expand 10 after
5985 toCheck.add(type.element); 5987 toCheck.add(type.element);
5986 // type arguments 5988 // type arguments
5987 if (type is InterfaceType) { 5989 if (type is InterfaceType) {
5988 InterfaceType interfaceType = type; 5990 InterfaceType interfaceType = type;
5989 for (DartType typeArgument in interfaceType.typeArguments) { 5991 for (DartType typeArgument in interfaceType.typeArguments) {
5990 _addTypeToCheck(typeArgument); 5992 _addTypeToCheck(typeArgument);
5991 } 5993 }
5992 } 5994 }
5993 } 5995 }
5994 } 5996 }
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