// get Java range, translate coordinate to JSP
try {
ISourceRange range = null;
IJSPTranslation jspTranslation = getJSPTranslation(document);
if (jspTranslation != null) {
// link to local variable definitions
if (element instanceof ILocalVariable) {
range = ((ILocalVariable) element).getNameRange();
Object cu = ((ILocalVariable) element).getDeclaringMember().getCompilationUnit();
if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
isInTranslationCU = true;
}
// linking to fields of the same compilation unit
else if (element.getElementType() == IJavaElement.FIELD) {
Object cu = ((IField) element).getCompilationUnit();
if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
range = ((ISourceReference) element).getSourceRange();
isInTranslationCU = true;
}
}
// linking to methods of the same compilation unit
else if (element.getElementType() == IJavaElement.METHOD) {
Object cu = ((IMethod) element).getCompilationUnit();
if (cu != null && cu.equals(jspTranslation.getCompilationUnit())) {
range = ((ISourceReference) element).getSourceRange();
isInTranslationCU = true;
}
}
}
if (range != null && file != null) {
jspOffset = jspTranslation.getJspOffset(range.getOffset());
if (jspOffset >= 0) {
link = new WorkspaceFileHyperlink(region, file, new Region(jspOffset, range.getLength()));
}
}
}