pepness commented on code in PR #5444:
URL: https://github.com/apache/netbeans/pull/5444#discussion_r1099540311


##########
java/j2ee.persistence/src/org/netbeans/modules/j2ee/persistence/editor/hyperlink/NamedQueryHyperlinkProvider.java:
##########
@@ -155,73 +152,69 @@ private void goToNQ(Document doc, int offset) {
 
         if (ent != null) {
             try {
-                js.runUserActionTask(new Task<CompilationController>() {
-
-                    @Override
-                    public void run(CompilationController parameter) throws 
Exception {
-                        parameter.toPhase(JavaSource.Phase.RESOLVED);
-                        AnnotationMirror foundAm = null;
-                        AnnotationValue get = null;
-                        Trees trees = parameter.getTrees();
-                        
-                        TypeElement entityElement = 
parameter.getElements().getTypeElement(entClasst);trees.getSourcePositions().getStartPosition(parameter.getCompilationUnit(),
 trees.getPath(entityElement).getLeaf());
-                        List<? extends AnnotationMirror> annotationMirrors = 
entityElement.getAnnotationMirrors();
-                        if (annotationMirrors != null) {
-                            Iterator<? extends AnnotationMirror> iterator = 
annotationMirrors.iterator();
-                            while (iterator.hasNext() && foundAm == null) {
-                                AnnotationMirror next = iterator.next();
-                                if 
(next.getAnnotationType().toString().equals("javax.persistence.NamedQueries")) 
{//NOI18N
-
-                                    Map<? extends ExecutableElement, ? extends 
AnnotationValue> maps = next.getElementValues();
-
-                                    for (AnnotationValue vl : maps.values()) {
-                                        List lst = (List) vl.getValue();
-                                        for (Object val : lst) {
-                                            if (val instanceof 
AnnotationMirror) {
-                                                AnnotationMirror am = 
(AnnotationMirror) val;
-                                                if 
("javax.persistence.NamedQuery".equals(am.getAnnotationType().toString())) 
{//NOI18N
-                                                    Map<? extends 
ExecutableElement, ? extends AnnotationValue> elementValues = 
am.getElementValues();
-                                                    for (ExecutableElement el 
: elementValues.keySet()) {
-                                                        if 
(el.getSimpleName().contentEquals("name")) { //NOI18N
-                                                            get = 
elementValues.get(el);
-                                                            if 
(get.getValue().toString().equals(nam)) {
-                                                                foundAm = am;
-                                                                break;
-                                                            }
+                js.runUserActionTask( (CompilationController parameter) -> {
+                    parameter.toPhase(JavaSource.Phase.RESOLVED);
+                    AnnotationMirror foundAm = null;
+                    AnnotationValue get = null;
+                    Trees trees = parameter.getTrees();
+                    
+                    TypeElement entityElement = 
parameter.getElements().getTypeElement(entClasst);trees.getSourcePositions().getStartPosition(parameter.getCompilationUnit(),
 trees.getPath(entityElement).getLeaf());

Review Comment:
   You are correct about the second statement, 
`trees.getSourcePositions().getStartPosition(parameter.getCompilationUnit(),trees.getPath(entityElement).getLeaf());`
 
   it is a noop that return a long primitive. Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to