From 1e8a9d5d45a82d43b06926430f2e0420eed43880 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Fri, 22 May 2026 11:35:09 -0700 Subject: [PATCH] [api_summary] Include mixins in textual API summaries Fixes an issue where with mixin clauses were omitted when generating textual API summaries for class and interface declarations. Regenerates api.txt for analyzer and analyzer_plugin. Change-Id: Ic33d76955cefb31709e265ec4ea9d5df9a065f7b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503701 Auto-Submit: Kevin Moore Reviewed-by: Paul Berry Commit-Queue: Kevin Moore Reviewed-by: Brian Wilkerson --- pkg/analyzer/api.txt | 4 ++-- pkg/analyzer_plugin/api.txt | 4 +++- pkg/api_summary/lib/src/api_description.dart | 6 +++++ .../test/api_description_test.dart | 22 +++++++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/pkg/analyzer/api.txt b/pkg/analyzer/api.txt index 79fe056af6a..1966cddf4e8 100644 --- a/pkg/analyzer/api.txt +++ b/pkg/analyzer/api.txt @@ -36,7 +36,7 @@ package:analyzer/analysis_rule/pubspec.dart: name (getter: PubspecNode?) path (getter: PubspecEntry?) version (getter: PubspecEntry?) - PubspecDependencyList (class extends Object, abstract): + PubspecDependencyList (class extends Object with Iterable, abstract): new (constructor: PubspecDependencyList Function()) PubspecEntry (class extends Object): new (constructor: PubspecEntry Function(PubspecNode?, PubspecNode)) @@ -60,7 +60,7 @@ package:analyzer/analysis_rule/pubspec.dart: new (constructor: PubspecNode Function()) span (getter: SourceSpan) text (getter: String?) - PubspecNodeList (class extends Object implements PubspecSection, abstract): + PubspecNodeList (class extends Object with Iterable implements PubspecSection, abstract): new (constructor: PubspecNodeList Function()) iterator (getter: Iterator) PubspecSection (class extends Object, abstract): diff --git a/pkg/analyzer_plugin/api.txt b/pkg/analyzer_plugin/api.txt index 49b7c3ba1df..a32eb08fd72 100644 --- a/pkg/analyzer_plugin/api.txt +++ b/pkg/analyzer_plugin/api.txt @@ -1663,6 +1663,8 @@ package:analyzer_plugin/src/utilities/client_uri_converter.dart: ClientUriConverter (non-public) package:analyzer_plugin/src/utilities/completion/completion_target.dart: CompletionTarget (non-public) +package:analyzer_plugin/src/utilities/completion/element_suggestion_builder.dart: + ElementSuggestionBuilder (non-public) package:analyzer_plugin/src/utilities/completion/optype.dart: OpType (non-public) package:analyzer_plugin/starter.dart: @@ -1850,7 +1852,7 @@ package:analyzer_plugin/utilities/completion/completion_core.dart: new (constructor: DartCompletionRequest Function()) result (getter: ResolvedUnitResult) package:analyzer_plugin/utilities/completion/inherited_reference_contributor.dart: - InheritedReferenceContributor (class extends Object implements CompletionContributor): + InheritedReferenceContributor (class extends Object with ElementSuggestionBuilder implements CompletionContributor): new (constructor: InheritedReferenceContributor Function()) containingLibrary (getter: LibraryElement?) containingLibrary= (setter: LibraryElement?) diff --git a/pkg/api_summary/lib/src/api_description.dart b/pkg/api_summary/lib/src/api_description.dart index e6a69c4aade..a436391d3d0 100644 --- a/pkg/api_summary/lib/src/api_description.dart +++ b/pkg/api_summary/lib/src/api_description.dart @@ -260,6 +260,7 @@ class ApiDescription { case InterfaceElement( :var typeParameters, :var supertype, + :var mixins, :var interfaces, ): var instanceDescription = [ @@ -284,6 +285,11 @@ class ApiDescription { ..._describeType(supertype), ]); } + if (mixins.isNotEmpty) { + instanceDescription.addAll( + mixins.map(_describeType).separatedBy(prefix: ' with '), + ); + } if (element is MixinElement && element.superclassConstraints.isNotEmpty) { instanceDescription.addAll( diff --git a/pkg/api_summary/test/api_description_test.dart b/pkg/api_summary/test/api_description_test.dart index de91d092a22..36b7720dc22 100644 --- a/pkg/api_summary/test/api_description_test.dart +++ b/pkg/api_summary/test/api_description_test.dart @@ -36,6 +36,28 @@ class Foo {} super.setUp(); } + Future test_class_mixins() async { + var summary = await _build({ + '$testPackageLibPath/file.dart': ''' +mixin M1 {} +mixin M2 {} +class C1 extends Object with M1 {} +class C2 extends Object with M2 implements M1 {} +''', + }); + expect(summary, ''' +package:test/file.dart: + C1 (class extends Object with M1): + new (constructor: C1 Function()) + C2 (class extends Object with M2 implements M1): + new (constructor: C2 Function()) + M1 (mixin on Object) + M2 (mixin on Object) +dart:core: + Object (referenced) +'''); + } + Future test_class_modifiers() async { var summary = await _build({ '$testPackageLibPath/file.dart': '''