in remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java [707:787]
private static ResolvedLocation resolveTarget(final CompilationInfo info, final long position, final boolean resolveTargetPosition) {
final boolean[] declaration = new boolean[1];
final long[] targetPosition = new long[] { -2 };
final String[] signature = new String[1];
final String[][] superMethodsSignaturesOut = new String[1][];
final ElementKind[] kind = new ElementKind[1];
new TreePathScanner<Void, Void>() {
@Override public Void visitIdentifier(IdentifierTree node, Void p) {
handleUsage();
return super.visitIdentifier(node, p);
}
@Override public Void visitMemberSelect(MemberSelectTree node, Void p) {
handleUsage();
return super.visitMemberSelect(node, p);
}
private void handleUsage() {
Element el = info.getTrees().getElement(getCurrentPath());
if (el == null) return;
long[] span = ResolveService.nameSpan(info, getCurrentPath());
if (span[0] <= position && position <= span[1]) {
fillSignature(el);
if (resolveTargetPosition) {
TreePath tp = info.getTrees().getPath(el);
if (tp != null && tp.getCompilationUnit() == info.getCompilationUnit()) {
targetPosition[0] = info.getTrees().getSourcePositions().getStartPosition(tp.getCompilationUnit(), tp.getLeaf());
}
}
}
}
@Override public Void visitClass(ClassTree node, Void p) {
handleDeclaration();
return super.visitClass(node, p);
}
@Override public Void visitMethod(MethodTree node, Void p) {
handleDeclaration();
return super.visitMethod(node, p);
}
@Override public Void visitVariable(VariableTree node, Void p) {
handleDeclaration();
return super.visitVariable(node, p);
}
private void handleDeclaration() {
Element el = info.getTrees().getElement(getCurrentPath());
if (el == null) return;
long[] span = ResolveService.nameSpan(info, getCurrentPath());
if (span[2] <= position && position <= span[3]) {
fillSignature(el);
declaration[0] = true;
kind[0] = el.getKind();
}
}
private void fillSignature(Element el) {
if (JavaUtils.SUPPORTED_KINDS.contains(el.getKind())) {
signature[0] = JavaUtils.serialize(ElementHandle.create(el));
if (el.getKind() == ElementKind.METHOD) {
List<ElementHandle<?>> superMethods = superMethods(info, new HashSet<TypeElement>(), (ExecutableElement) el, (TypeElement) el.getEnclosingElement());
String[] superMethodsSignatures = new String[superMethods.size()];
int i = 0;
for (ElementHandle<?> m : superMethods) {
superMethodsSignatures[i++] = JavaUtils.serialize(m);
}
superMethodsSignaturesOut[0] = superMethodsSignatures;
}
}
}
}.scan(info.getCompilationUnit(), null);
return new ResolvedLocation(signature[0], kind[0], targetPosition[0], declaration[0], superMethodsSignaturesOut[0]);
}