if (region != null && textViewer != null) {
IDocument document = textViewer.getDocument();
// check and make sure this is a valid Java type
JSPTranslation jspTranslation = getJSPTranslation(document);
if (jspTranslation != null) {
// check if we are in JSP Java content
int javaOffset = jspTranslation.getJavaOffset(region.getOffset());
if (javaOffset > -1) {
// check that we are not in indirect Java content (like
// included files)
if (!jspTranslation.isIndirect(javaOffset)) {
// get Java elements
IJavaElement[] elements = jspTranslation.getElementsFromJspRange(region.getOffset(), region.getOffset() + region.getLength());
if (elements != null && elements.length > 0) {
// create a JSPJavaHyperlink for each Java element
for (int i = 0; i < elements.length; ++i) {
IJavaElement element = elements[i];