Skip to content

Commit 9d9b00c

Browse files
authored
Require analyzer 6.10.0, stop using deprecated properties of LibraryElement. (dart-lang#3899)
* Require analyzer 6.10.0, stop using deprecated properties of LibraryElement. * Use language 3.7.0
1 parent 5df03dd commit 9d9b00c

8 files changed

+36
-24
lines changed

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15829,6 +15829,7 @@ const _invisibleGetters = {
1582915829
'scope'
1583015830
},
1583115831
'CompilationUnitElement': {
15832+
'accessibleExtensions',
1583215833
'accessors',
1583315834
'classes',
1583415835
'enclosingElement',
@@ -15845,6 +15846,7 @@ const _invisibleGetters = {
1584515846
'mixins',
1584615847
'parts',
1584715848
'runtimeType',
15849+
'scope',
1584815850
'session',
1584915851
'topLevelVariables',
1585015852
'typeAliases'
@@ -15888,6 +15890,7 @@ const _invisibleGetters = {
1588815890
'alias',
1588915891
'element',
1589015892
'element2',
15893+
'element3',
1589115894
'extensionTypeErasure',
1589215895
'hashCode',
1589315896
'isBottom',
@@ -16033,15 +16036,15 @@ const _invisibleGetters = {
1603316036
'ExecutableMember': {
1603416037
'augmentationSubstitution',
1603516038
'children',
16036-
'children3',
16039+
'children2',
1603716040
'context',
1603816041
'declaration',
1603916042
'displayName',
1604016043
'documentationComment',
16041-
'element',
1604216044
'enclosingElement',
16045+
'enclosingElement2',
1604316046
'enclosingElement3',
16044-
'enclosingFragment',
16047+
'formalParameters',
1604516048
'hasAlwaysThrows',
1604616049
'hasDeprecated',
1604716050
'hasDoNotStore',
@@ -16087,27 +16090,27 @@ const _invisibleGetters = {
1608716090
'isSynthetic',
1608816091
'kind',
1608916092
'library',
16090-
'libraryFragment',
16093+
'library2',
1609116094
'librarySource',
1609216095
'location',
1609316096
'metadata',
1609416097
'name',
1609516098
'nameLength',
1609616099
'nameOffset',
16097-
'nextFragment',
1609816100
'nonSynthetic',
16101+
'nonSynthetic2',
1609916102
'parameters',
16100-
'parameters2',
16101-
'previousFragment',
1610216103
'returnType',
1610316104
'runtimeType',
1610416105
'session',
1610516106
'sinceSdkVersion',
1610616107
'substitution',
1610716108
'type',
16108-
'typeParameters'
16109+
'typeParameters',
16110+
'typeParameters2'
1610916111
},
1611016112
'Expression': {
16113+
'correspondingParameter',
1611116114
'hashCode',
1611216115
'inConstantContext',
1611316116
'isAssignable',
@@ -16166,6 +16169,7 @@ const _invisibleGetters = {
1616616169
'FunctionType': {
1616716170
'element',
1616816171
'element2',
16172+
'formalParameters',
1616916173
'hashCode',
1617016174
'namedParameterTypes',
1617116175
'normalParameterNames',
@@ -16175,7 +16179,8 @@ const _invisibleGetters = {
1617516179
'parameters',
1617616180
'returnType',
1617716181
'runtimeType',
16178-
'typeFormals'
16182+
'typeFormals',
16183+
'typeParameters'
1617916184
},
1618016185
'FunctionTypedElement': {
1618116186
'hashCode',
@@ -16432,6 +16437,7 @@ const _invisibleGetters = {
1643216437
'ParameterElement': {
1643316438
'declaration',
1643416439
'defaultValueCode',
16440+
'element',
1643516441
'hasDefaultValue',
1643616442
'hashCode',
1643716443
'isCovariant',
@@ -16459,6 +16465,7 @@ const _invisibleGetters = {
1645916465
'defaultValueCode',
1646016466
'displayName',
1646116467
'documentationComment',
16468+
'element',
1646216469
'enclosingElement',
1646316470
'enclosingElement3',
1646416471
'hasAlwaysThrows',

lib/src/model/library.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Library extends ModelElement
6060
var localElements = {
6161
// TODO(jcollins-g): Consider switch to `element.topLevelElements`.
6262
..._getDefinedElements(element.definingCompilationUnit),
63-
...element.parts
63+
...element.definingCompilationUnit.parts
6464
.map((e) => e.uri)
6565
.whereType<DirectiveUriWithUnit>()
6666
.map((part) => part.unit)
@@ -96,7 +96,7 @@ class Library extends ModelElement
9696

9797
/// Allow scope for Libraries.
9898
@override
99-
Scope get scope => element.scope;
99+
Scope get scope => element.definingCompilationUnit.scope;
100100

101101
bool get isInSdk => element.isInSdk;
102102

@@ -142,7 +142,7 @@ class Library extends ModelElement
142142
Map<String, Set<Library>> get _prefixToLibrary {
143143
var prefixToLibrary = <String, Set<Library>>{};
144144
// It is possible to have overlapping prefixes.
145-
for (var i in element.libraryImports) {
145+
for (var i in element.definingCompilationUnit.libraryImports) {
146146
var prefixName = i.prefix?.element.name;
147147
// Ignore invalid imports.
148148
if (prefixName != null && i.importedLibrary != null) {

lib/src/model/package_builder.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,19 +561,17 @@ extension on Set<String> {
561561

562562
if (add(path)) {
563563
var libraryImports = switch (element) {
564-
LibraryElement(:var libraryImports) ||
565-
CompilationUnitElement(:var libraryImports) =>
566-
libraryImports,
564+
LibraryElement() => element.definingCompilationUnit.libraryImports,
565+
CompilationUnitElement(:var libraryImports) => libraryImports,
567566
_ => const <LibraryImportElement>[],
568567
};
569568
for (var import in libraryImports) {
570569
addFilesReferencedBy(import.importedLibrary);
571570
}
572571

573572
var libraryExports = switch (element) {
574-
LibraryElement(:var libraryExports) ||
575-
CompilationUnitElement(:var libraryExports) =>
576-
libraryExports,
573+
LibraryElement() => element.definingCompilationUnit.libraryExports,
574+
CompilationUnitElement(:var libraryExports) => libraryExports,
577575
_ => const <LibraryExportElement>[],
578576
};
579577
for (var export in libraryExports) {

lib/src/model/package_graph.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ class PackageGraph with CommentReferable, Nameable {
554554
alreadyTagged.add(key);
555555
// Mark that `publicLibrary` exports `libraryElement`.
556556
_libraryExports.putIfAbsent(libraryElement, () => {}).add(publicLibrary);
557-
for (var exportedElement in libraryElement.libraryExports) {
557+
for (var exportedElement
558+
in libraryElement.definingCompilationUnit.libraryExports) {
558559
var exportedLibrary = exportedElement.exportedLibrary;
559560
if (exportedLibrary != null) {
560561
// Follow the exports down; as `publicLibrary` exports `libraryElement`,

lib/src/model/prefix.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Prefix extends ModelElement with HasNoPage {
2626
// TODO(jcollins-g): consider connecting PrefixElement to the imported library
2727
// in analyzer?
2828
late final Library associatedLibrary = getModelForElement(library
29-
.element.libraryImports
29+
.element.definingCompilationUnit.libraryImports
3030
.firstWhere((i) => i.prefix?.element == element)
3131
.importedLibrary!) as Library;
3232

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: ^3.2.0
88

99
dependencies:
10-
analyzer: ^6.9.0
10+
analyzer: ^6.10.0
1111
args: ^2.4.1
1212
collection: ^1.17.0
1313
crypto: ^3.0.3

test/dartdoc_test_base.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class DartdocTestBase {
4141

4242
String get dartCoreUrlPrefix => 'https://api.dart.dev/stable/3.2.0/dart-core';
4343

44-
String get sdkConstraint => '>=3.6.0 <4.0.0';
44+
String get sdkConstraint => '>=3.7.0 <4.0.0';
4545

4646
List<String> get experiments => ['enhanced-parts', 'wildcard-variables'];
4747

test/end2end/model_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,14 @@ void main() async {
909909
test('can import other libraries with unusual URIs', () {
910910
final fakeLibraryImportedExported = <Library>{
911911
for (final l in <LibraryElement>{
912-
...fakeLibrary.element.importedLibraries,
913-
...fakeLibrary.element.exportedLibraries
912+
...fakeLibrary.element.definingCompilationUnit.libraryImports
913+
.map((import) => import.uri)
914+
.whereType<DirectiveUriWithLibrary>()
915+
.map((uri) => uri.library),
916+
...fakeLibrary.element.definingCompilationUnit.libraryExports
917+
.map((import) => import.uri)
918+
.whereType<DirectiveUriWithLibrary>()
919+
.map((uri) => uri.library)
914920
})
915921
packageGraph.getModelForElement(l) as Library
916922
};

0 commit comments

Comments
 (0)