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

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

Issue 712663002: Fix for issue 20125 - improved error messages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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 'java_engine.dart'; 10 import 'java_engine.dart';
(...skipping 2765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2776 */ 2776 */
2777 bool _checkForExportDuplicateLibraryName(ExportDirective node, ExportElement e xportElement, LibraryElement exportedLibrary) { 2777 bool _checkForExportDuplicateLibraryName(ExportDirective node, ExportElement e xportElement, LibraryElement exportedLibrary) {
2778 if (exportedLibrary == null) { 2778 if (exportedLibrary == null) {
2779 return false; 2779 return false;
2780 } 2780 }
2781 String name = exportedLibrary.name; 2781 String name = exportedLibrary.name;
2782 // check if there is other exported library with the same name 2782 // check if there is other exported library with the same name
2783 LibraryElement prevLibrary = _nameToExportElement[name]; 2783 LibraryElement prevLibrary = _nameToExportElement[name];
2784 if (prevLibrary != null) { 2784 if (prevLibrary != null) {
2785 if (prevLibrary != exportedLibrary) { 2785 if (prevLibrary != exportedLibrary) {
2786 _errorReporter.reportErrorForNode(StaticWarningCode.EXPORT_DUPLICATED_LI BRARY_NAME, node, [ 2786 if (name.isEmpty) {
2787 prevLibrary.definingCompilationUnit.displayName, 2787 _errorReporter.reportErrorForNode(
2788 exportedLibrary.definingCompilationUnit.displayName, 2788 StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_UNNAMED,
2789 name]); 2789 node,
2790 [prevLibrary.definingCompilationUnit.displayName,
2791 exportedLibrary.definingCompilationUnit.displayName]);
2792 } else {
2793 _errorReporter.reportErrorForNode(
2794 StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED,
2795 node,
2796 [prevLibrary.definingCompilationUnit.displayName,
2797 exportedLibrary.definingCompilationUnit.displayName,
2798 name]);
2799 }
2790 return true; 2800 return true;
2791 } 2801 }
2792 } else { 2802 } else {
2793 _nameToExportElement[name] = exportedLibrary; 2803 _nameToExportElement[name] = exportedLibrary;
2794 } 2804 }
2795 // OK 2805 // OK
2796 return false; 2806 return false;
2797 } 2807 }
2798 2808
2799 /** 2809 /**
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 * @return `true` if and only if an error code is generated on the passed node 3231 * @return `true` if and only if an error code is generated on the passed node
3222 * @see CompileTimeErrorCode#IMPORT_DUPLICATED_LIBRARY_NAME 3232 * @see CompileTimeErrorCode#IMPORT_DUPLICATED_LIBRARY_NAME
3223 */ 3233 */
3224 bool _checkForImportDuplicateLibraryName(ImportDirective node, ImportElement i mportElement) { 3234 bool _checkForImportDuplicateLibraryName(ImportDirective node, ImportElement i mportElement) {
3225 // prepare imported library 3235 // prepare imported library
3226 LibraryElement nodeLibrary = importElement.importedLibrary; 3236 LibraryElement nodeLibrary = importElement.importedLibrary;
3227 if (nodeLibrary == null) { 3237 if (nodeLibrary == null) {
3228 return false; 3238 return false;
3229 } 3239 }
3230 String name = nodeLibrary.name; 3240 String name = nodeLibrary.name;
3231 // check if there is other imported library with the same name 3241 // check if there is another imported library with the same name
3232 LibraryElement prevLibrary = _nameToImportElement[name]; 3242 LibraryElement prevLibrary = _nameToImportElement[name];
3233 if (prevLibrary != null) { 3243 if (prevLibrary != null) {
3234 if (prevLibrary != nodeLibrary) { 3244 if (prevLibrary != nodeLibrary) {
3235 _errorReporter.reportErrorForNode(StaticWarningCode.IMPORT_DUPLICATED_LI BRARY_NAME, node, [ 3245 if (name.isEmpty) {
3236 prevLibrary.definingCompilationUnit.displayName, 3246 _errorReporter.reportErrorForNode(
3237 nodeLibrary.definingCompilationUnit.displayName, 3247 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_UNNAMED,
3238 name]); 3248 node,
3249 [prevLibrary.definingCompilationUnit.displayName,
3250 nodeLibrary.definingCompilationUnit.displayName]);
3251 } else {
3252 _errorReporter.reportErrorForNode(
3253 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED,
3254 node,
3255 [prevLibrary.definingCompilationUnit.displayName,
3256 nodeLibrary.definingCompilationUnit.displayName,
3257 name]);
3258 }
3239 return true; 3259 return true;
3240 } 3260 }
3241 } else { 3261 } else {
3242 _nameToImportElement[name] = nodeLibrary; 3262 _nameToImportElement[name] = nodeLibrary;
3243 } 3263 }
3244 // OK 3264 // OK
3245 return false; 3265 return false;
3246 } 3266 }
3247 3267
3248 /** 3268 /**
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
5467 toCheck.add(type.element); 5487 toCheck.add(type.element);
5468 // type arguments 5488 // type arguments
5469 if (type is InterfaceType) { 5489 if (type is InterfaceType) {
5470 InterfaceType interfaceType = type; 5490 InterfaceType interfaceType = type;
5471 for (DartType typeArgument in interfaceType.typeArguments) { 5491 for (DartType typeArgument in interfaceType.typeArguments) {
5472 _addTypeToCheck(typeArgument); 5492 _addTypeToCheck(typeArgument);
5473 } 5493 }
5474 } 5494 }
5475 } 5495 }
5476 } 5496 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/generated/static_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698