Remove Declaration.computeLibraryUri

Change-Id: I8ab2d15f83e9547f19301b12d0bff9f1dc05de46
Reviewed-on: https://dart-review.googlesource.com/57561
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
This commit is contained in:
Peter von der Ahé 2018-05-31 10:31:53 +00:00 committed by commit-bot@chromium.org
parent 5ecd78222e
commit b851714bb7
2 changed files with 14 additions and 15 deletions

View file

@ -4,9 +4,7 @@
library fasta.declaration;
import '../problems.dart' show unhandled, unsupported;
import 'library_builder.dart' show LibraryBuilder;
import '../problems.dart' show unsupported;
abstract class Declaration {
/// Used when multiple things with the same name are declared within the same
@ -62,15 +60,6 @@ abstract class Declaration {
bool get isTypeVariable => false;
Uri computeLibraryUri() {
Declaration declaration = this;
do {
if (declaration is LibraryBuilder) return declaration.uri;
declaration = declaration.parent;
} while (declaration != null);
return unhandled("no library parent", "${runtimeType}", -1, null);
}
/// Applies [patch] to this declaration.
void applyPatch(Declaration patch) {
unsupported("${runtimeType}.applyPatch", charOffset, fileUri);

View file

@ -890,10 +890,10 @@ class KernelLibraryBuilder
if (scope.local[name] == declaration) {
isLocal = true;
preferred = declaration;
hiddenUri = other.computeLibraryUri();
hiddenUri = computeLibraryUri(other);
} else {
uri = declaration.computeLibraryUri();
otherUri = other.computeLibraryUri();
uri = computeLibraryUri(declaration);
otherUri = computeLibraryUri(other);
if (declaration is LoadLibraryBuilder) {
isLoadLibrary = true;
preferred = declaration;
@ -1139,3 +1139,13 @@ class KernelLibraryBuilder
addToExportScope(name, member);
}
}
Uri computeLibraryUri(Declaration declaration) {
Declaration current = declaration;
do {
if (current is LibraryBuilder) return current.uri;
current = current.parent;
} while (current != null);
return unhandled("no library parent", "${declaration.runtimeType}",
declaration.charOffset, declaration.fileUri);
}