Skip to content

Commit 164777e

Browse files
scheglovCommit Queue
authored andcommitted
Part. Deprecate LibraryElement.scope
Change-Id: I85a24d0f1d0b4251415644fe1438503e41710436 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388682 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 9b7f5a0 commit 164777e

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

pkg/analysis_server/lib/src/computer/import_elements_computer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class ImportElementsComputer {
325325
}
326326

327327
bool _hasElement(String prefix, String name) {
328-
var scope = libraryResult.libraryElement.scope;
328+
var scope = libraryResult.libraryElement.definingCompilationUnit.scope;
329329

330330
if (prefix.isNotEmpty) {
331331
var prefixElement = scope.lookup(prefix).getter;

pkg/analyzer/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use `CompilationUnitElement.libraryImportPrefixes` instead.
1313
* Deprecated `LibraryElement.parts`,
1414
use `CompilationUnitElement.parts` instead.
15+
* Deprecated `LibraryElement.scope`,
16+
use `CompilationUnitElement.scope` instead.
1517

1618
## 6.9.0
1719
* `NormalFormalParameter` now implements `AnnotatedNode`.

pkg/analyzer/lib/dart/element/element.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ abstract class CompilationUnitElement implements UriReferencedElement {
419419
/// The parts included by this unit.
420420
List<PartElement> get parts;
421421

422+
/// The scope used to resolve names within this compilation unit.
423+
///
424+
/// It includes all of the elements that are declared in the library, and all
425+
/// of the elements imported into this unit or parent units.
426+
Scope get scope;
427+
422428
@override
423429
AnalysisSession get session;
424430

@@ -2094,6 +2100,7 @@ abstract class LibraryOrAugmentationElement implements Element {
20942100
///
20952101
/// It consists of elements that are either declared in the library, or
20962102
/// imported into it.
2103+
@Deprecated('Use CompilationUnitElement.scope')
20972104
Scope get scope;
20982105

20992106
@override

pkg/analyzer/test/src/dart/resolution/library_element_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class LibraryElementTest_featureSet extends PubPackageResolutionTest {
177177

178178
@reflectiveTest
179179
class LibraryElementTest_scope extends PubPackageResolutionTest {
180+
@deprecated
180181
test_lookup() async {
181182
await assertNoErrorsInCode(r'''
182183
int foo = 0;
@@ -194,6 +195,7 @@ int foo = 0;
194195
);
195196
}
196197

198+
@deprecated
197199
test_lookup_extension_unnamed() async {
198200
await assertNoErrorsInCode(r'''
199201
extension on int {}
@@ -206,6 +208,7 @@ extension on int {}
206208
);
207209
}
208210

211+
@deprecated
209212
test_lookup_implicitCoreImport() async {
210213
await assertNoErrorsInCode('');
211214

@@ -217,6 +220,7 @@ extension on int {}
217220
);
218221
}
219222

223+
@deprecated
220224
test_lookup_notFound() async {
221225
await assertNoErrorsInCode('');
222226

@@ -231,6 +235,7 @@ extension on int {}
231235
);
232236
}
233237

238+
@deprecated
234239
test_lookup_prefersLocal() async {
235240
await assertNoErrorsInCode(r'''
236241
// ignore:unused_import
@@ -252,6 +257,7 @@ int sin() => 3;
252257
);
253258
}
254259

260+
@deprecated
255261
test_lookup_prefix() async {
256262
await assertNoErrorsInCode(r'''
257263
// ignore:unused_import
@@ -266,6 +272,7 @@ import 'dart:math' as math;
266272
);
267273
}
268274

275+
@deprecated
269276
test_lookup_respectsCombinator_hide() async {
270277
await assertNoErrorsInCode(r'''
271278
// ignore:unused_import
@@ -289,6 +296,7 @@ import 'dart:math' hide sin;
289296
);
290297
}
291298

299+
@deprecated
292300
test_lookup_respectsCombinator_show() async {
293301
await assertNoErrorsInCode(r'''
294302
// ignore:unused_import

0 commit comments

Comments
 (0)