Skip to content

Commit ade10f4

Browse files
fshcheglovCommit Queue
authored andcommitted
Deprecate 'Element.library2', use 'library' instead.
Deprecate `LibraryElement.loadLibraryFunction2`, use `loadLibraryFunction` instead. Change-Id: I117fb182e6bb62c1a76b3d578c0a6d4b6f32b9c4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435920 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 3160b3b commit ade10f4

File tree

142 files changed

+496
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+496
-361
lines changed

pkg/analysis_server/lib/src/cider/rename.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CanRenameResponse {
9797
FlutterWidgetState? _findFlutterStateClass(Element element, String newName) {
9898
if (element is ClassElement && element.isStatefulWidgetDeclaration) {
9999
var oldStateName = '${element.displayName}State';
100-
var library = element.library2;
100+
var library = element.library;
101101
var state =
102102
library.getClass2(oldStateName) ??
103103
library.getClass2('_$oldStateName');
@@ -217,7 +217,7 @@ class CheckNameResponse {
217217
);
218218
}
219219
// add element declaration
220-
var sourcePath = element.library2!.firstFragment.source.fullName;
220+
var sourcePath = element.library!.firstFragment.source.fullName;
221221
var infos = await _addElementDeclaration(element, sourcePath);
222222
replaceMatches.addMatch(sourcePath, infos);
223223
}
@@ -365,7 +365,7 @@ class CheckNameResponse {
365365
var interfaceElement = element.enclosingElement!;
366366

367367
var fileResolver = canRename._fileResolver;
368-
var libraryPath = interfaceElement.library2!.firstFragment.source.fullName;
368+
var libraryPath = interfaceElement.library!.firstFragment.source.fullName;
369369
var resolvedLibrary = await fileResolver.resolveLibrary2(path: libraryPath);
370370
var result = resolvedLibrary.getFragmentDeclaration(
371371
interfaceElement.firstFragment,
@@ -429,7 +429,7 @@ class CiderRenameComputer {
429429
if (node == null || element == null) {
430430
return null;
431431
}
432-
if (element.library2?.isInSdk == true) {
432+
if (element.library?.isInSdk == true) {
433433
return null;
434434
}
435435
if (element is MethodElement && element.isOperator) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ class ColorComputer {
228228
}
229229

230230
/// Checks whether this elements library is dart:ui.
231-
bool _isDartUi(Element? element) => element?.library2?.name3 == 'dart.ui';
231+
bool _isDartUi(Element? element) => element?.library?.name3 == 'dart.ui';
232232

233233
/// Checks whether this elements library is Flutter Material colors.
234234
bool _isFlutterMaterial(Element? element) =>
235-
element?.library2?.identifier ==
235+
element?.library?.identifier ==
236236
'package:flutter/src/material/colors.dart';
237237

238238
/// Checks whether this elements library is Flutter Painting colors.
239239
bool _isFlutterPainting(Element? element) =>
240-
element?.library2?.identifier ==
240+
element?.library?.identifier ==
241241
'package:flutter/src/painting/colors.dart';
242242

243243
/// Tries to record a color from [colorConst] for [expression].

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class DartUnitHoverComputer {
151151

152152
/// Returns information about the library that contains [element].
153153
_LibraryInfo _libraryInfo(Element element) {
154-
var library = element.library2;
154+
var library = element.library;
155155
if (library == null) {
156156
return null;
157157
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ class _FunctionBodyOutlinesVisitor extends RecursiveAstVisitor<void> {
653653
/// Return `true` if the given [element] is a top-level member of the test
654654
/// package.
655655
bool _isInsideTestPackage(engine.TopLevelFunctionElement element) {
656-
var parent = element.library2;
656+
var parent = element.library;
657657
return parent.firstFragment.source.fullName.endsWith('test.dart');
658658
}
659659
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class _OverriddenElementsFinder {
123123

124124
factory _OverriddenElementsFinder(Element seed) {
125125
var class_ = seed.enclosingElement as InterfaceElement;
126-
var library = class_.library2;
126+
var library = class_.library;
127127
var name = seed.displayName;
128128
List<ElementKind> kinds;
129129
if (seed is FieldElement) {
@@ -217,7 +217,7 @@ class _OverriddenElementsFinder {
217217
Element? _lookupMember(InterfaceElement classElement) {
218218
Element? findMatchingElement(Iterable<Element> elements) {
219219
return elements.firstWhereOrNull((Element element) {
220-
if (!identical(element.library2, _library) && _name.startsWith('_')) {
220+
if (!identical(element.library, _library) && _name.startsWith('_')) {
221221
return false;
222222
}
223223
return element.name3 == _name;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class _Visitor extends UnifyingAstVisitor<void> {
119119
return;
120120
}
121121

122-
var path = element.library2?.firstFragment.source.fullName;
122+
var path = element.library?.firstFragment.source.fullName;
123123
if (path == null) {
124124
return;
125125
}

pkg/analysis_server/lib/src/search/type_hierarchy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class TypeHierarchyComputerHelper {
194194

195195
return TypeHierarchyComputerHelper(
196196
pivotElement,
197-
pivotElement.library2!,
197+
pivotElement.library!,
198198
pivotElement.kind,
199199
pivotElement.name3,
200200
pivotFieldFinal,

pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class DeclarationHelper {
218218
collector.addSuggestion(
219219
LoadLibraryFunctionSuggestion(
220220
kind: CompletionSuggestionKind.INVOCATION,
221-
element: importedLibrary.loadLibraryFunction2,
221+
element: importedLibrary.loadLibraryFunction,
222222
matcherScore: matcherScore,
223223
),
224224
);
@@ -1627,7 +1627,7 @@ class DeclarationHelper {
16271627
if (element.isInternal) {
16281628
switch (request.fileState.workspacePackage) {
16291629
case PubPackage pubPackage:
1630-
var librarySource = element.library2.firstFragment.source;
1630+
var librarySource = element.library.firstFragment.source;
16311631
if (!pubPackage.contains(librarySource)) {
16321632
return false;
16331633
}
@@ -1640,7 +1640,7 @@ class DeclarationHelper {
16401640
return false;
16411641
}
16421642

1643-
if (elementInterface.library2 != requestLibrary) {
1643+
if (elementInterface.library != requestLibrary) {
16441644
var contextInterface = request.target.enclosingInterfaceElement;
16451645
if (contextInterface == null) {
16461646
return false;
@@ -1654,12 +1654,12 @@ class DeclarationHelper {
16541654
}
16551655

16561656
if (element.isVisibleForTesting) {
1657-
if (element.library2 != requestLibrary) {
1657+
if (element.library != requestLibrary) {
16581658
var fileState = request.fileState;
16591659
switch (fileState.workspacePackage) {
16601660
case PubPackage pubPackage:
16611661
// Must be in the same package.
1662-
var librarySource = element.library2.firstFragment.source;
1662+
var librarySource = element.library.firstFragment.source;
16631663
if (!pubPackage.contains(librarySource)) {
16641664
return false;
16651665
}
@@ -2698,7 +2698,7 @@ extension on Element {
26982698
/// An element is visible if it's declared in the [referencingLibrary] or if
26992699
/// the name is not private.
27002700
bool isVisibleIn(LibraryElement referencingLibrary) {
2701-
if (library2 == referencingLibrary) {
2701+
if (library == referencingLibrary) {
27022702
return true;
27032703
}
27042704
var name = name3;

pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ parent3: ${node.parent?.parent?.parent}
12811281
if (type is! InterfaceType) {
12821282
return null;
12831283
}
1284-
var declaredElement = field.element2?.library2;
1284+
var declaredElement = field.element2?.library;
12851285
var uri = declaredElement?.uri;
12861286
var member = type.element.getInterfaceMember(Name(uri, name));
12871287
if (member is GetterElement) {

pkg/analysis_server/lib/src/services/completion/dart/override_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class OverrideHelper {
7777
/// yet declared in the class.
7878
List<Name> _namesToOverride(InterfaceElement interfaceElement) {
7979
var namesToOverride = <Name>[];
80-
var libraryUri = interfaceElement.library2.uri;
80+
var libraryUri = interfaceElement.library.uri;
8181
var memberNames = interfaceElement.interfaceMembers.keys;
8282
for (var name in memberNames) {
8383
if (name.isAccessibleFor(libraryUri)) {

0 commit comments

Comments
 (0)