diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index bca3efddaf..1ecbdd2ab6 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -15829,6 +15829,7 @@ const _invisibleGetters = { 'scope' }, 'CompilationUnitElement': { + 'accessibleExtensions', 'accessors', 'classes', 'enclosingElement', @@ -15845,6 +15846,7 @@ const _invisibleGetters = { 'mixins', 'parts', 'runtimeType', + 'scope', 'session', 'topLevelVariables', 'typeAliases' @@ -15888,6 +15890,7 @@ const _invisibleGetters = { 'alias', 'element', 'element2', + 'element3', 'extensionTypeErasure', 'hashCode', 'isBottom', @@ -16033,15 +16036,15 @@ const _invisibleGetters = { 'ExecutableMember': { 'augmentationSubstitution', 'children', - 'children3', + 'children2', 'context', 'declaration', 'displayName', 'documentationComment', - 'element', 'enclosingElement', + 'enclosingElement2', 'enclosingElement3', - 'enclosingFragment', + 'formalParameters', 'hasAlwaysThrows', 'hasDeprecated', 'hasDoNotStore', @@ -16087,27 +16090,27 @@ const _invisibleGetters = { 'isSynthetic', 'kind', 'library', - 'libraryFragment', + 'library2', 'librarySource', 'location', 'metadata', 'name', 'nameLength', 'nameOffset', - 'nextFragment', 'nonSynthetic', + 'nonSynthetic2', 'parameters', - 'parameters2', - 'previousFragment', 'returnType', 'runtimeType', 'session', 'sinceSdkVersion', 'substitution', 'type', - 'typeParameters' + 'typeParameters', + 'typeParameters2' }, 'Expression': { + 'correspondingParameter', 'hashCode', 'inConstantContext', 'isAssignable', @@ -16166,6 +16169,7 @@ const _invisibleGetters = { 'FunctionType': { 'element', 'element2', + 'formalParameters', 'hashCode', 'namedParameterTypes', 'normalParameterNames', @@ -16175,7 +16179,8 @@ const _invisibleGetters = { 'parameters', 'returnType', 'runtimeType', - 'typeFormals' + 'typeFormals', + 'typeParameters' }, 'FunctionTypedElement': { 'hashCode', @@ -16432,6 +16437,7 @@ const _invisibleGetters = { 'ParameterElement': { 'declaration', 'defaultValueCode', + 'element', 'hasDefaultValue', 'hashCode', 'isCovariant', @@ -16459,6 +16465,7 @@ const _invisibleGetters = { 'defaultValueCode', 'displayName', 'documentationComment', + 'element', 'enclosingElement', 'enclosingElement3', 'hasAlwaysThrows', diff --git a/lib/src/model/library.dart b/lib/src/model/library.dart index 9c4f06c62b..81afa238cb 100644 --- a/lib/src/model/library.dart +++ b/lib/src/model/library.dart @@ -60,7 +60,7 @@ class Library extends ModelElement var localElements = { // TODO(jcollins-g): Consider switch to `element.topLevelElements`. ..._getDefinedElements(element.definingCompilationUnit), - ...element.parts + ...element.definingCompilationUnit.parts .map((e) => e.uri) .whereType() .map((part) => part.unit) @@ -96,7 +96,7 @@ class Library extends ModelElement /// Allow scope for Libraries. @override - Scope get scope => element.scope; + Scope get scope => element.definingCompilationUnit.scope; bool get isInSdk => element.isInSdk; @@ -142,7 +142,7 @@ class Library extends ModelElement Map> get _prefixToLibrary { var prefixToLibrary = >{}; // It is possible to have overlapping prefixes. - for (var i in element.libraryImports) { + for (var i in element.definingCompilationUnit.libraryImports) { var prefixName = i.prefix?.element.name; // Ignore invalid imports. if (prefixName != null && i.importedLibrary != null) { diff --git a/lib/src/model/package_builder.dart b/lib/src/model/package_builder.dart index e6fe631550..b0c06ba1ab 100644 --- a/lib/src/model/package_builder.dart +++ b/lib/src/model/package_builder.dart @@ -561,9 +561,8 @@ extension on Set { if (add(path)) { var libraryImports = switch (element) { - LibraryElement(:var libraryImports) || - CompilationUnitElement(:var libraryImports) => - libraryImports, + LibraryElement() => element.definingCompilationUnit.libraryImports, + CompilationUnitElement(:var libraryImports) => libraryImports, _ => const [], }; for (var import in libraryImports) { @@ -571,9 +570,8 @@ extension on Set { } var libraryExports = switch (element) { - LibraryElement(:var libraryExports) || - CompilationUnitElement(:var libraryExports) => - libraryExports, + LibraryElement() => element.definingCompilationUnit.libraryExports, + CompilationUnitElement(:var libraryExports) => libraryExports, _ => const [], }; for (var export in libraryExports) { diff --git a/lib/src/model/package_graph.dart b/lib/src/model/package_graph.dart index 8d388c4c35..e80a9d0fb4 100644 --- a/lib/src/model/package_graph.dart +++ b/lib/src/model/package_graph.dart @@ -554,7 +554,8 @@ class PackageGraph with CommentReferable, Nameable { alreadyTagged.add(key); // Mark that `publicLibrary` exports `libraryElement`. _libraryExports.putIfAbsent(libraryElement, () => {}).add(publicLibrary); - for (var exportedElement in libraryElement.libraryExports) { + for (var exportedElement + in libraryElement.definingCompilationUnit.libraryExports) { var exportedLibrary = exportedElement.exportedLibrary; if (exportedLibrary != null) { // Follow the exports down; as `publicLibrary` exports `libraryElement`, diff --git a/lib/src/model/prefix.dart b/lib/src/model/prefix.dart index d0c5c407d6..7a8a198c5f 100644 --- a/lib/src/model/prefix.dart +++ b/lib/src/model/prefix.dart @@ -26,7 +26,7 @@ class Prefix extends ModelElement with HasNoPage { // TODO(jcollins-g): consider connecting PrefixElement to the imported library // in analyzer? late final Library associatedLibrary = getModelForElement(library - .element.libraryImports + .element.definingCompilationUnit.libraryImports .firstWhere((i) => i.prefix?.element == element) .importedLibrary!) as Library; diff --git a/pubspec.yaml b/pubspec.yaml index a321ee4cb9..6cb986b40f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: ^3.2.0 dependencies: - analyzer: ^6.9.0 + analyzer: ^6.10.0 args: ^2.4.1 collection: ^1.17.0 crypto: ^3.0.3 diff --git a/test/dartdoc_test_base.dart b/test/dartdoc_test_base.dart index 606a1fb78b..ea261c864d 100644 --- a/test/dartdoc_test_base.dart +++ b/test/dartdoc_test_base.dart @@ -41,7 +41,7 @@ abstract class DartdocTestBase { String get dartCoreUrlPrefix => 'https://api.dart.dev/stable/3.2.0/dart-core'; - String get sdkConstraint => '>=3.6.0 <4.0.0'; + String get sdkConstraint => '>=3.7.0 <4.0.0'; List get experiments => ['enhanced-parts', 'wildcard-variables']; diff --git a/test/end2end/model_test.dart b/test/end2end/model_test.dart index 052bb4c652..bcba862e04 100644 --- a/test/end2end/model_test.dart +++ b/test/end2end/model_test.dart @@ -909,8 +909,14 @@ void main() async { test('can import other libraries with unusual URIs', () { final fakeLibraryImportedExported = { for (final l in { - ...fakeLibrary.element.importedLibraries, - ...fakeLibrary.element.exportedLibraries + ...fakeLibrary.element.definingCompilationUnit.libraryImports + .map((import) => import.uri) + .whereType() + .map((uri) => uri.library), + ...fakeLibrary.element.definingCompilationUnit.libraryExports + .map((import) => import.uri) + .whereType() + .map((uri) => uri.library) }) packageGraph.getModelForElement(l) as Library };