Skip to content

Support augmentation-declared constructors and methods. #3712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/src/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ class Dartdoc {
if (config.showStats) {
logInfo(runtimeStats.buildReport());
}
await packageBuilder.dispose();
return DartdocResults(config.topLevelPackageMeta, packageGraph, _outputDir);
}

Expand Down
29 changes: 19 additions & 10 deletions lib/src/model/inheriting_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import 'package:meta/meta.dart';
/// Note that [Constructor]s are not considered to be modifiers so a
/// [hasModifiers] override is not necessary for this mixin.
mixin Constructable implements InheritingContainer {
late final List<Constructor> constructors = element.constructors
.map((e) => getModelFor(e, library) as Constructor)
.toList(growable: false);
late final List<Constructor> constructors =
(element.augmented?.constructors ?? element.constructors)
.map((e) => getModelFor(e, library) as Constructor)
.toList(growable: false);

@override
late final List<Constructor> publicConstructorsSorted =
Expand Down Expand Up @@ -153,12 +154,12 @@ abstract class InheritingContainer extends Container

// The mapping of all of the inherited element names to their _concrete_
// implementation element.
var concreteInheritanceMap =
packageGraph.inheritanceManager.getInheritedConcreteMap2(element);
var concreteInheritanceMap = packageGraph.inheritanceManager
.getInheritedConcreteMap2(element.augmentedDeclarationOrSelf);
// The mapping of all inherited element names to the nearest inherited
// element that they resolve to.
var inheritanceMap =
packageGraph.inheritanceManager.getInheritedMap2(element);
var inheritanceMap = packageGraph.inheritanceManager
.getInheritedMap2(element.augmentedDeclarationOrSelf);

var inheritanceChainElements =
inheritanceChain.map((c) => c.element).toList(growable: false);
Expand Down Expand Up @@ -256,9 +257,10 @@ abstract class InheritingContainer extends Container
}();

@override
late final List<Method> declaredMethods = element.methods
.map((e) => getModelFor(e, library) as Method)
.toList(growable: false);
late final List<Method> declaredMethods =
(element.augmented?.methods ?? element.methods)
.map((e) => getModelFor(e, library) as Method)
.toList(growable: false);

@override
late final List<TypeParameter> typeParameters = element.typeParameters
Expand Down Expand Up @@ -594,6 +596,13 @@ mixin MixedInTypes on InheritingContainer {
mixedInTypes.wherePublic;
}

extension on InterfaceElement {
/// This element's augmented declaration, or, if there is none, then just this
/// element itself.
InterfaceElement get augmentedDeclarationOrSelf =>
augmented?.declaration ?? this;
}

extension on InterfaceElement {
bool get isDartCoreObject => name == 'Object' && library.name == 'dart.core';
}
Expand Down
11 changes: 6 additions & 5 deletions lib/src/model/package_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ abstract class PackageBuilder {
// Builds package graph to be used by documentation generator.
Future<PackageGraph> buildPackageGraph();

Future<void> dispose();

/// The `include-external` option is deprecated, so we track whether it was
/// used, to report it.
bool get includeExternalsWasSpecified;
Expand Down Expand Up @@ -119,7 +117,11 @@ class PubPackageBuilder implements PackageBuilder {

logDebug('${DateTime.now()}: Initializing package graph...');
runtimeStats.startPerfTask('initializePackageGraph');
await newGraph.initializePackageGraph();
try {
await newGraph.initializePackageGraph();
} finally {
await _dispose();
}
runtimeStats.endPerfTask();

runtimeStats.startPerfTask('initializeCategories');
Expand All @@ -129,8 +131,7 @@ class PubPackageBuilder implements PackageBuilder {
return newGraph;
}

@override
Future<void> dispose() async {
Future<void> _dispose() async {
// Shutdown macro support.
await _contextCollection.dispose();
}
Expand Down