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

Unified Diff: pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Issue 2967143002: Improve warnings related to incorrect 'part of' declarations. (Closed)
Patch Set: Address Johnni's comment. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/source/source_library_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
index 9a8b17d02d59f50be99bef741233a8a923bb6674..54db00cd3f7c5c4c374d25375b138bef3604f2a7 100644
--- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart
@@ -66,7 +66,7 @@ abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
String partOfName;
- Uri partOfUri;
+ String partOfUri;
List<MetadataBuilder> metadata;
@@ -177,7 +177,7 @@ abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
void addPartOf(List<MetadataBuilder> metadata, String name, String uri) {
partOfName = name;
- partOfUri = uri == null ? null : this.uri.resolve(uri);
+ partOfUri = uri;
}
void addClass(
@@ -413,24 +413,44 @@ abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
}
void includePart(SourceLibraryBuilder<T, R> part) {
- if (name != null) {
- if (!part.isPart) {
- addCompileTimeError(
+ if (part.partOfUri != null) {
+ if (uri.resolve(part.partOfUri) != uri) {
+ // This is a warning, but the part is still included.
+ addWarning(
-1,
- "Can't use ${part.fileUri} as a part, because it has no 'part of'"
- " declaration.");
- parts.remove(part);
- return;
+ "Using '${part.relativeFileUri}' as part of '$uri' but its "
+ "'part of' declaration says '${part.partOfUri}'.");
+ if (uri.scheme == "dart" && relativeFileUri.endsWith(part.partOfUri)) {
+ addWarning(-1, "See https://github.com/dart-lang/sdk/issues/30072.");
+ }
}
- if (part.partOfName != name && part.partOfUri != uri) {
- String partName = part.partOfName ?? "${part.partOfUri}";
- String myName = name == null ? "'$uri'" : "'${name}' ($uri)";
+ } else if (part.partOfName != null) {
+ if (name != null) {
+ if (part.partOfName != name) {
+ // This is a warning, but the part is still included.
+ addWarning(
+ -1,
+ "Using '${part.relativeFileUri}' as part of '$name' but its "
+ "'part of' declaration says '${part.partOfName}'.");
+ }
+ } else {
+ // This is a warning, but the part is still included.
addWarning(
-1,
- "Using '${part.fileUri}' as part of '$myName' but its 'part of'"
- " declaration says '$partName'.");
- // The part is still included.
+ "Using '${part.relativeFileUri}' as part of '${relativeFileUri}' "
+ "but its 'part of' declaration says '${part.partOfName}'.\n"
+ "Try changing the 'part of' declaration to use a relative "
+ "file name.");
}
+ } else if (name != null) {
+ // This is an error, and the part isn't included.
+ assert(!part.isPart);
+ addCompileTimeError(
+ -1,
+ "Can't use ${part.fileUri} as a part, because it has no 'part of'"
+ " declaration.");
+ parts.remove(part);
+ return;
}
part.forEach((String name, Builder builder) {
if (builder.next != null) {
« 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