diff --git a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java index 3060a45c87..470aceef35 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java @@ -650,7 +650,7 @@ private void visitMethodOverrides(ClassNode node) { public void visitAnnotation(AnnotationNode node) { ClassNode type = node.getClassNode(); VariableScope scope = scopes.getLast(); - TypeLookupResult noLookup = new TypeLookupResult(type, type, type, TypeConfidence.EXACT, scope); + TypeLookupResult noLookup = new TypeLookupResult(type, type, node, TypeConfidence.EXACT, scope); VisitStatus status = notifyRequestor(node, requestor, noLookup); switch (status) { diff --git a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java index 1ac33a53dc..adfb8a3ad1 100644 --- a/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java +++ b/ide/org.codehaus.groovy.eclipse.codebrowsing/src/org/codehaus/groovy/eclipse/codebrowsing/requestor/CodeSelectRequestor.java @@ -186,7 +186,9 @@ private void handleMatch(TypeLookupResult result, IJavaElement enclosingElement) } } else if (requestedNode instanceof ImportNode) { ImportNode importNode = (ImportNode) requestedNode; - requestedNode = Optional.ofNullable(importNode.getType()).map(ClassNode::redirect).get(); + if (importNode.getType() != null) { + requestedNode = importNode.getType().redirect(); + } } if (requestedNode != null) { @@ -222,14 +224,13 @@ private void handleMatch(TypeLookupResult result, IJavaElement enclosingElement) if (start < until) { String pack = gunit.getSource().substring(start, until).replaceFirst("^import\\s+", ""); for (IPackageFragmentRoot root : gunit.getJavaProject().getPackageFragmentRoots()) { - IPackageFragment frag = root.getPackageFragment(pack); - if (frag != null && frag.exists()) { - requestedElement = frag; + IPackageFragment fragment = root.getPackageFragment(pack); + if (fragment != null && fragment.exists()) { + requestedElement = fragment; break; } } } - requestedNode = nodeToLookFor; } else { String qualifier = checkQualifiedType(result, enclosingElement);