Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 52ad8dc

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Gather metrics on super invocations
This only looks at method invocations and property accessors. It doesn't look at operator invocations. While it might be interesting, I doubt it would be significantly different. Change-Id: I51ffd612fdbf5b60470bd40cbe90f3c2b82fe1e5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138883 Reviewed-by: Jaime Wren <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent f5dae48 commit 52ad8dc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/analysis_server/tool/completion_metrics/relevance_metrics.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,16 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
10501050
void visitMethodInvocation(MethodInvocation node) {
10511051
var member = node.methodName.staticElement;
10521052
_recordMemberDepth(node.target?.staticType, member);
1053+
if (node.target is SuperExpression) {
1054+
var enclosingMethod = node.thisOrAncestorOfType<MethodDeclaration>();
1055+
if (enclosingMethod != null) {
1056+
if (enclosingMethod.name.name == node.methodName.name) {
1057+
data.recordTypeMatch('super invocation member', 'same');
1058+
} else {
1059+
data.recordTypeMatch('super invocation member', 'different');
1060+
}
1061+
}
1062+
}
10531063
if (node.target != null) {
10541064
var contextType = featureComputer.computeContextType(node);
10551065
if (contextType != null) {
@@ -1156,6 +1166,16 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
11561166
void visitPropertyAccess(PropertyAccess node) {
11571167
var member = node.propertyName.staticElement;
11581168
_recordMemberDepth(node.target?.staticType, member);
1169+
if (node.target is SuperExpression) {
1170+
var enclosingMethod = node.thisOrAncestorOfType<MethodDeclaration>();
1171+
if (enclosingMethod != null) {
1172+
if (enclosingMethod.name.name == node.propertyName.name) {
1173+
data.recordTypeMatch('super property access member', 'same');
1174+
} else {
1175+
data.recordTypeMatch('super property access member', 'different');
1176+
}
1177+
}
1178+
}
11591179
if (!(member is PropertyAccessorElement && member.isSetter)) {
11601180
var contextType = featureComputer.computeContextType(node);
11611181
if (contextType != null) {

0 commit comments

Comments
 (0)