public void createHyperlinksByOffset(XtextResource resource, int offset,
IHyperlinkAcceptor acceptor) {
EObject crossLinkedEObject = helper.resolveElementAt(resource, offset);
if (crossLinkedEObject != null){
INode node=NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
if (node instanceof ILeafNode && ((ILeafNode) node).isHidden()){
//no linking in comments
return;
}
Region region = new Region(node.getOffset(), node.getLength());
if(crossLinkedEObject instanceof Resource){
if(!crossLinkedEObject.eIsProxy()){
//links to all known local definitions
QualifiedName name = nameProvider.getFullyQualifiedName(crossLinkedEObject);
IResourceDescriptions index = indexService.getResourceDescriptions(resource);
Iterable<IEObjectDescription> matches = index.getExportedObjectsByType(XturtlePackage.Literals.RESOURCE);//, name, false);
for (final IEObjectDescription desc : matches) {
if(desc.getQualifiedName().equals(name)){
XtextHyperlink result = getHyperlinkProvider().get();
result.setHyperlinkRegion(region);
result.setURI(desc.getEObjectURI());
result.setHyperlinkText(desc.getEObjectURI().trimFragment().toString());
acceptor.accept(result);
}
}
}
//always allow browser link (if uri is absolute, text editor will create URLHyperlink anyway)
EObject actualNode=NodeModelUtils.findActualSemanticObjectFor(node);
String uri = service.getUriString(actualNode);
if(uri!=null && !isAbsoluteUri(actualNode)){
URLHyperlink result = new URLHyperlink(region, uri);
acceptor.accept(result);
}
} else if(!crossLinkedEObject.eIsProxy() && !(node.getGrammarElement() instanceof Keyword)) {
//non-resource crosslinks are dealt with as in default implementation
createHyperlinksTo(resource, region, crossLinkedEObject, acceptor);
}
}
// super.createHyperlinksByOffset(resource, offset, acceptor);