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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart

Issue 2931893004: Report an error when a part-of refers to an unnamed library. (Closed)
Patch Set: Address comments. Created 3 years, 6 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/context/declared_variables.dart'; 5 import 'package:analyzer/context/declared_variables.dart';
6 import 'package:analyzer/dart/ast/ast.dart'; 6 import 'package:analyzer/dart/ast/ast.dart';
7 import 'package:analyzer/dart/ast/visitor.dart'; 7 import 'package:analyzer/dart/ast/visitor.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/error/listener.dart'; 10 import 'package:analyzer/error/listener.dart';
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 _NameOrSource nameOrSource = _getPartLibraryNameOrUri( 472 _NameOrSource nameOrSource = _getPartLibraryNameOrUri(
473 partSource, partUnit, directivesToResolve); 473 partSource, partUnit, directivesToResolve);
474 if (nameOrSource == null) { 474 if (nameOrSource == null) {
475 libraryErrorReporter.reportErrorForNode( 475 libraryErrorReporter.reportErrorForNode(
476 CompileTimeErrorCode.PART_OF_NON_PART, 476 CompileTimeErrorCode.PART_OF_NON_PART,
477 partUri, 477 partUri,
478 [partUri.toSource()]); 478 [partUri.toSource()]);
479 } else { 479 } else {
480 String name = nameOrSource.name; 480 String name = nameOrSource.name;
481 if (name != null) { 481 if (name != null) {
482 if (libraryNameNode != null && libraryNameNode.name != name) { 482 if (libraryNameNode == null) {
483 libraryErrorReporter.reportErrorForNode(
484 ResolverErrorCode.PART_OF_UNNAMED_LIBRARY, partUri, [name]);
485 } else if (libraryNameNode.name != name) {
483 libraryErrorReporter.reportErrorForNode( 486 libraryErrorReporter.reportErrorForNode(
484 StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, 487 StaticWarningCode.PART_OF_DIFFERENT_LIBRARY,
485 partUri, 488 partUri,
486 [libraryNameNode.name, name]); 489 [libraryNameNode.name, name]);
487 } 490 }
488 } else { 491 } else {
489 Source source = nameOrSource.source; 492 Source source = nameOrSource.source;
490 if (source != _library.source) { 493 if (source != _library.source) {
491 libraryErrorReporter.reportErrorForNode( 494 libraryErrorReporter.reportErrorForNode(
492 StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, 495 StaticWarningCode.PART_OF_DIFFERENT_LIBRARY,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 799 }
797 800
798 /** 801 /**
799 * Either the name or the source associated with a part-of directive. 802 * Either the name or the source associated with a part-of directive.
800 */ 803 */
801 class _NameOrSource { 804 class _NameOrSource {
802 final String name; 805 final String name;
803 final Source source; 806 final Source source;
804 _NameOrSource(this.name, this.source); 807 _NameOrSource(this.name, this.source);
805 } 808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698