Skip to content
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

Investigate whether diagnostics should be applied to all methods in PersistenceMapKeyDiagnosticsParticipant. #532

Open
mrglavas opened this issue Oct 30, 2024 · 0 comments

Comments

@mrglavas
Copy link

While refactoring similar code in Liberty Tools for IntelliJ I noticed that it is looping over all methods on the application's class looking for annotations that seem to just apply to properties (accessor methods). Should this code be checking every method or should it filter the list so it only checks property methods? It seems like we might report false-positives but should probably check whether this is aligned with the Jakarta Persistence spec.

for (IMethod method : methods) {
                List<IAnnotation> mapKeyJoinCols = new ArrayList<IAnnotation>();
                boolean hasMapKeyAnnotation = false;
                boolean hasMapKeyClassAnnotation = false;
                allAnnotations = method.getAnnotations();
                for (IAnnotation annotation : allAnnotations) {
                    String matchedAnnotation = DiagnosticUtils.getMatchedJavaElementName(type,
                                                                                         annotation.getElementName(),
                                                                                         Constants.SET_OF_PERSISTENCE_ANNOTATIONS);
                    if (matchedAnnotation != null) {
                        if (Constants.MAPKEY.equals(matchedAnnotation))
                            hasMapKeyAnnotation = true;
                        else if (Constants.MAPKEYCLASS.equals(matchedAnnotation))
                            hasMapKeyClassAnnotation = true;
                        else if (Constants.MAPKEYJOINCOLUMN.equals(matchedAnnotation)) {
                            mapKeyJoinCols.add(annotation);
                        }
                    }
                }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant