Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Unified Diff: pkg/analyzer/lib/src/dart/analysis/index.dart

Issue 2956403002: Record ClassTypeAlias(s) as subtypes. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/index_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/index.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/index.dart b/pkg/analyzer/lib/src/dart/analysis/index.dart
index f0a067855a8b80d1f5a2c5d187c8dbb797b3f4f3..17edccbcc30ada712474d18fa1df6b01d0fcf9fe 100644
--- a/pkg/analyzer/lib/src/dart/analysis/index.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/index.dart
@@ -510,7 +510,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
@override
visitClassDeclaration(ClassDeclaration node) {
- _addSubtype(node);
+ _addSubtypeForClassDeclaration(node);
if (node.extendsClause == null) {
ClassElement objectElement = resolutionMap
.elementDeclaredByClassDeclaration(node)
@@ -525,6 +525,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
@override
visitClassTypeAlias(ClassTypeAlias node) {
+ _addSubtypeForClassTypeAlis(node);
recordIsAncestorOf(node.element);
super.visitClassTypeAlias(node);
}
@@ -728,7 +729,8 @@ class _IndexContributor extends GeneralizingAstVisitor {
/**
* Record the given class as a subclass of its direct superclasses.
*/
- void _addSubtype(ClassDeclaration node) {
+ void _addSubtype(String name, TypeName superclass, WithClause withClause,
+ ImplementsClause implementsClause, List<ClassMember> memberNodes) {
List<String> supertypes = [];
List<String> members = [];
@@ -748,9 +750,9 @@ class _IndexContributor extends GeneralizingAstVisitor {
}
}
- addSupertype(node.extendsClause?.superclass);
- node.withClause?.mixinTypes?.forEach(addSupertype);
- node.implementsClause?.interfaces?.forEach(addSupertype);
+ addSupertype(superclass);
+ withClause?.mixinTypes?.forEach(addSupertype);
+ implementsClause?.interfaces?.forEach(addSupertype);
void addMemberName(SimpleIdentifier identifier) {
if (identifier != null) {
@@ -761,7 +763,7 @@ class _IndexContributor extends GeneralizingAstVisitor {
}
}
- for (ClassMember member in node.members) {
+ for (ClassMember member in memberNodes) {
if (member is MethodDeclaration && !member.isStatic) {
addMemberName(member.name);
} else if (member is FieldDeclaration && !member.isStatic) {
@@ -775,7 +777,23 @@ class _IndexContributor extends GeneralizingAstVisitor {
members.sort();
assembler.subtypes.add(new AnalysisDriverSubtypeBuilder(
- name: node.name.name, supertypes: supertypes, members: members));
+ name: name, supertypes: supertypes, members: members));
+ }
+
+ /**
+ * Record the given class as a subclass of its direct superclasses.
+ */
+ void _addSubtypeForClassDeclaration(ClassDeclaration node) {
+ _addSubtype(node.name.name, node.extendsClause?.superclass, node.withClause,
+ node.implementsClause, node.members);
+ }
+
+ /**
+ * Record the given class as a subclass of its direct superclasses.
+ */
+ void _addSubtypeForClassTypeAlis(ClassTypeAlias node) {
+ _addSubtype(node.name.name, node.superclass, node.withClause,
+ node.implementsClause, const []);
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/index_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698