Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public Boolean match(CtBehavior behavior, Map<String, Object> matchResult) {
return matched;
}

private static final String LABELS_CLASS = "com.appland.appmap.annotation.Labels";

static boolean hasLabelsAnnotation(CtBehavior behavior) {
return behavior.hasAnnotation(LABELS_CLASS);
}

Comment on lines +51 to +56
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already code in CodeObject that looks for label annotiations. This code needs to either use that, or (more likely) it should be extracted to a common module.

private boolean doMatch(CtBehavior behavior, Map<String, Object> matchResult) {
CtClass declaringClass = behavior.getDeclaringClass();
String declaringClassName = declaringClass.getName();
Expand All @@ -57,7 +63,7 @@ private boolean doMatch(CtBehavior behavior, Map<String, Object> matchResult) {
}
}

if (!AppMapBehavior.isRecordable(behavior) || ignoreMethod(behavior)) {
if (!AppMapBehavior.isRecordable(behavior) || (!hasLabelsAnnotation(behavior) && ignoreMethod(behavior))) {
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated if condition is now >100 characters, which violates the repository's Checkstyle line-length rule (config/checkstyle/checkstyle.xml:44-47 sets max=100). Please wrap this condition across multiple lines (e.g., split the || / && parts) to keep it within the configured limit.

Suggested change
if (!AppMapBehavior.isRecordable(behavior) || (!hasLabelsAnnotation(behavior) && ignoreMethod(behavior))) {
if (!AppMapBehavior.isRecordable(behavior)
|| (!hasLabelsAnnotation(behavior) && ignoreMethod(behavior))) {

Copilot uses AI. Check for mistakes.
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ Stream<Arguments> notGetters() {
.setReturnType("java.lang.Integer").endMethod()));
}

@Test
void testLabeledGetterHasLabelsAnnotation(ClassBuilder classBuilder) throws Exception {
MethodBuilder methodBuilder = classBuilder.beginMethod();
methodBuilder.setName("getSomething")
.setBody("return Integer.valueOf(1);")
.setReturnType("java.lang.Integer")
.addAnnotation("com.appland.appmap.annotation.Labels")
.endMethod();
assertTrue(ConfigCondition.hasLabelsAnnotation(methodBuilder.getBehavior()));
assertTrue(ConfigCondition.isGetter(methodBuilder.getBehavior()));
}

@Test
void testUnlabeledGetterHasNoLabelsAnnotation(ClassBuilder classBuilder) throws Exception {
MethodBuilder methodBuilder = classBuilder.beginMethod();
methodBuilder.setName("getSomething")
.setBody("return Integer.valueOf(1);")
.setReturnType("java.lang.Integer")
.endMethod();
assertFalse(ConfigCondition.hasLabelsAnnotation(methodBuilder.getBehavior()));
assertTrue(ConfigCondition.isGetter(methodBuilder.getBehavior()));
}
Comment on lines +113 to +134
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new tests validate hasLabelsAnnotation, but they don't assert the actual behavior change in ConfigCondition.match() (that a trivial getter annotated with @Labels is no longer filtered out by ignoreMethod). Consider adding/adjusting tests to configure AppMapConfig.get().packages to include TestClass#getSomething, then assert new ConfigCondition().match(...) returns true for the labeled getter and false for the unlabeled getter; this will protect the intended contract without relying on the helper being package-visible.

Copilot uses AI. Check for mistakes.

@Test
void testSetterMethod(ClassBuilder classBuilder) throws Exception {
MethodBuilder methodBuilder = classBuilder.beginMethod();
Expand Down
Loading