public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
return detectHyperlinks(textViewer, new CocoRegion(region.getOffset(), region.getLength()), canShowMultipleHyperlinks);
}
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, ICocoRegion region, boolean canShowMultipleHyperlinks) {
ATGModel fATGModel = modelProvider.getATGModel();
if (region == null || fATGModel == null || !(textViewer instanceof ISourceViewer)) {
return null;
}
int offset = region.getOffset();
try { // check the partition type
String contentType = textViewer.getDocument().getPartition(offset).getType();
if (!contains(ALLOWED_PARTITIONS, contentType)) return null;
} catch (BadLocationException e) {
// should not happen
}
WordFinderAdaptor wordFinder = new WordFinderAdaptor(textViewer.getDocument(), fIdentDetector);
ICocoRegion cocoWordRegion = wordFinder.findWord(offset);
String word = wordFinder.extractWord(cocoWordRegion);
if (word == null) {
return null;
}
ATGSegment segment = fATGModel.find(word);
Region wordRegion = new Region(cocoWordRegion.getOffset(), cocoWordRegion.getLength());
if (segment != null) {
return new IHyperlink[] { new ATGHyperlink(wordRegion, new Region(segment.getRegion().getOffset(), segment.getRegion().getLength()))};
}