Part. Deprecate LibraryElement.scope

Change-Id: I85a24d0f1d0b4251415644fe1438503e41710436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2024-10-07 20:43:10 +00:00
committed by Commit Queue
parent 9b7f5a0af6
commit 164777e2cd
4 changed files with 18 additions and 1 deletions
@@ -325,7 +325,7 @@ class ImportElementsComputer {
}
bool _hasElement(String prefix, String name) {
var scope = libraryResult.libraryElement.scope;
var scope = libraryResult.libraryElement.definingCompilationUnit.scope;
if (prefix.isNotEmpty) {
var prefixElement = scope.lookup(prefix).getter;
+2
View File
@@ -12,6 +12,8 @@
use `CompilationUnitElement.libraryImportPrefixes` instead.
* Deprecated `LibraryElement.parts`,
use `CompilationUnitElement.parts` instead.
* Deprecated `LibraryElement.scope`,
use `CompilationUnitElement.scope` instead.
## 6.9.0
* `NormalFormalParameter` now implements `AnnotatedNode`.
@@ -419,6 +419,12 @@ abstract class CompilationUnitElement implements UriReferencedElement {
/// The parts included by this unit.
List<PartElement> get parts;
/// The scope used to resolve names within this compilation unit.
///
/// It includes all of the elements that are declared in the library, and all
/// of the elements imported into this unit or parent units.
Scope get scope;
@override
AnalysisSession get session;
@@ -2094,6 +2100,7 @@ abstract class LibraryOrAugmentationElement implements Element {
///
/// It consists of elements that are either declared in the library, or
/// imported into it.
@Deprecated('Use CompilationUnitElement.scope')
Scope get scope;
@override
@@ -177,6 +177,7 @@ class LibraryElementTest_featureSet extends PubPackageResolutionTest {
@reflectiveTest
class LibraryElementTest_scope extends PubPackageResolutionTest {
@deprecated
test_lookup() async {
await assertNoErrorsInCode(r'''
int foo = 0;
@@ -194,6 +195,7 @@ int foo = 0;
);
}
@deprecated
test_lookup_extension_unnamed() async {
await assertNoErrorsInCode(r'''
extension on int {}
@@ -206,6 +208,7 @@ extension on int {}
);
}
@deprecated
test_lookup_implicitCoreImport() async {
await assertNoErrorsInCode('');
@@ -217,6 +220,7 @@ extension on int {}
);
}
@deprecated
test_lookup_notFound() async {
await assertNoErrorsInCode('');
@@ -231,6 +235,7 @@ extension on int {}
);
}
@deprecated
test_lookup_prefersLocal() async {
await assertNoErrorsInCode(r'''
// ignore:unused_import
@@ -252,6 +257,7 @@ int sin() => 3;
);
}
@deprecated
test_lookup_prefix() async {
await assertNoErrorsInCode(r'''
// ignore:unused_import
@@ -266,6 +272,7 @@ import 'dart:math' as math;
);
}
@deprecated
test_lookup_respectsCombinator_hide() async {
await assertNoErrorsInCode(r'''
// ignore:unused_import
@@ -289,6 +296,7 @@ import 'dart:math' hide sin;
);
}
@deprecated
test_lookup_respectsCombinator_show() async {
await assertNoErrorsInCode(r'''
// ignore:unused_import