From b851714bb76cd2ecbc229325aeb9835d73cf8754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20von=20der=20Ahe=CC=81?= Date: Thu, 31 May 2018 10:31:53 +0000 Subject: [PATCH] Remove Declaration.computeLibraryUri MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8ab2d15f83e9547f19301b12d0bff9f1dc05de46 Reviewed-on: https://dart-review.googlesource.com/57561 Reviewed-by: Dmitry Stefantsov Commit-Queue: Peter von der Ahé --- .../lib/src/fasta/builder/declaration.dart | 13 +------------ .../src/fasta/kernel/kernel_library_builder.dart | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pkg/front_end/lib/src/fasta/builder/declaration.dart b/pkg/front_end/lib/src/fasta/builder/declaration.dart index fa1f97b1ae7..f68699ee9cf 100644 --- a/pkg/front_end/lib/src/fasta/builder/declaration.dart +++ b/pkg/front_end/lib/src/fasta/builder/declaration.dart @@ -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); diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart index 34ab1901c29..c5291dfc85b 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart @@ -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); +}