-
Notifications
You must be signed in to change notification settings - Fork 17
Always record @Labels-annotated methods regardless of trivial-method filters #324
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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); | ||||||||
| } | ||||||||
|
|
||||||||
| private boolean doMatch(CtBehavior behavior, Map<String, Object> matchResult) { | ||||||||
| CtClass declaringClass = behavior.getDeclaringClass(); | ||||||||
| String declaringClassName = declaringClass.getName(); | ||||||||
|
|
@@ -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))) { | ||||||||
|
||||||||
| if (!AppMapBehavior.isRecordable(behavior) || (!hasLabelsAnnotation(behavior) && ignoreMethod(behavior))) { | |
| if (!AppMapBehavior.isRecordable(behavior) | |
| || (!hasLabelsAnnotation(behavior) && ignoreMethod(behavior))) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
|
|
||
| @Test | ||
| void testSetterMethod(ClassBuilder classBuilder) throws Exception { | ||
| MethodBuilder methodBuilder = classBuilder.beginMethod(); | ||
|
|
||
There was a problem hiding this comment.
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.