JellyHyperlinkProvider implements HyperlinkProviderExt { static @CheckForNull String correspondingJellyResource(Document doc, int offset) { int[] span = hyperlinkSpan(doc, offset); if (span[1] == 0) { return null; } try { String fqn = doc.getText(span[0], span[1] - span[0]); int colon = fqn.indexOf(':'); assert colon != -1 : fqn; String prefix = fqn.substring(0, colon); String element = fqn.substring(colon + 1); String all = doc.getText(0, doc.getLength()); String decl = "xmlns:" + prefix + "=\"/"; int declStart = all.indexOf(decl); if (declStart == -1) { return null; } int path = declStart + decl.length() - 1; int end = all.indexOf('"', path); if (end == -1) { return null; } return all.substring(path, end) + "/" + element + ".jelly"; } catch (BadLocationException x) { Exceptions.printStackTrace(x); return null; } }  @Override Set<HyperlinkType> getSupportedHyperlinkTypes(); @Override boolean isHyperlinkPoint(Document doc, int offset, HyperlinkType type); @Override int[] getHyperlinkSpan(Document doc, int offset, HyperlinkType type); @Override void performClickAction(Document doc, int offset, HyperlinkType type); @Override String getTooltipText(Document doc, int offset, HyperlinkType type);  }
@Test public void correspondingJellyResource() throws Exception { assertEquals(null, JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("iv align"))); assertEquals("/lib/form/entry.jelly", JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("ntry title=\"${"))); assertEquals("/lib/form/entry.jelly", JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("ntry title=\"\""))); assertEquals("/lib/form/repeatableDeleteButton.jelly", JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("peatableD"))); assertEquals("/lib/form/textbox.jelly", JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("f:textbox"))); assertEquals("/lib/hudson/project/config-trigger.jelly", JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("trigger"))); assertEquals(null, JellyHyperlinkProvider.correspondingJellyResource(doc, offsetOf("j:if"))); }