Source:
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { ITextEditor textEditor = (ITextEditor) getAdapter(ITextEditor.class); if (region == null || !(textEditor instanceof JavaEditor)) return null; IAction openAction = textEditor.getAction("OpenEditor"); if (!(openAction instanceof SelectionDispatchAction)) return null; int offset = region.getOffset(); IJavaElement input = EditorUtility.getEditorInputJavaElement(textEditor, false); if (input == null) return null; try { IDocument document = textEditor.getDocumentProvider().getDocument( textEditor.getEditorInput()); IRegion wordRegion = JavaWordFinder.findWord(document, offset); if (wordRegion == null || wordRegion.getLength() == 0) return null; IJavaElement[] elements = null; elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion .getLength()); if (elements.length > 0) { IJavaElement element = elements[0]; if (element.getElementType() == IJavaElement.FIELD) { IJavaElement unit = element.getAncestor(IJavaElement.COMPILATION_UNIT); if (unit == null) { IJavaElement type = element.getAncestor(IJavaElement.TYPE); if (type != null && type.getParent() != null) { IJavaElement parentType = type.getParent(); if (parentType.getElementType() == IJavaElement.CLASS_FILE) { String pn = parentType.getElementName(); if (pn.startsWith("R$")) { return createTypeLink(element, type, wordRegion, true); } } } } else if ("R.java".equals(unit.getElementName())) { IJavaElement type = element.getAncestor(IJavaElement.TYPE); if (type != null) { return createTypeLink(element, type, wordRegion, false); } } } } return null; } catch (JavaModelException e) { return null; } }

Target:
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { ITextEditor textEditor = (ITextEditor) getAdapter(ITextEditor.class); if (region == null || !(textEditor instanceof JavaEditor)) return null; IAction openAction = textEditor.getAction("OpenEditor"); if (!(openAction instanceof SelectionDispatchAction)) return null; int offset = region.getOffset(); IJavaElement input = EditorUtility.getEditorInputJavaElement(textEditor, false); if (input == null) return null; try { IDocument document = textEditor.getDocumentProvider().getDocument( textEditor.getEditorInput()); IRegion wordRegion = JavaWordFinder.findWord(document, offset); if (wordRegion == null || wordRegion.getLength() == 0) return null; IJavaElement[] elements = null; elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(), wordRegion .getLength()); if (elements.length > 0) { IJavaElement element = elements[0]; if (element.getElementType() == IJavaElement.FIELD) { IJavaElement unit = element.getAncestor(IJavaElement.COMPILATION_UNIT); if (unit == null) { IJavaElement type = element.getAncestor(IJavaElement.TYPE); if (type != null && type.getParent() != null) { IJavaElement parentType = type.getParent(); if (parentType.getElementType() == IJavaElement.CLASS_FILE) { String pn = parentType.getElementName(); String prefix = FN_RESOURCE_BASE + "$"; if (pn.startsWith(prefix)) { return createTypeLink(element, type, wordRegion, true); } } } } else if (FN_RESOURCE_CLASS.equals(unit.getElementName())) { IJavaElement type = element.getAncestor(IJavaElement.TYPE); if (type != null) { return createTypeLink(element, type, wordRegion, false); } } } } return null; } catch (JavaModelException e) { return null; } }