use of org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector in project linuxtools by eclipse.
the class SpecfileConfiguration method getHyperlinkDetectors.
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
if (sourceViewer == null) {
return null;
}
Map<String, IAdaptable> targets = getHyperlinkDetectorTargets(sourceViewer);
HyperlinkDetectorRegistry hlDetectorRegistry = EditorsUI.getHyperlinkDetectorRegistry();
HyperlinkDetectorDescriptor[] hlDetectorDescriptor = hlDetectorRegistry.getHyperlinkDetectorDescriptors();
List<IHyperlinkDetector> tempHDList = new ArrayList<>();
for (Map.Entry<String, IAdaptable> entry : targets.entrySet()) {
for (HyperlinkDetectorDescriptor hdd : hlDetectorDescriptor) {
try {
AbstractHyperlinkDetector ahld = (AbstractHyperlinkDetector) hdd.createHyperlinkDetectorImplementation();
// however, allow URLHyperlinkWithMacroDetector
if (hdd.getTargetId().equals(entry.getKey()) && (!(ahld instanceof URLHyperlinkDetector) || ahld instanceof URLHyperlinkWithMacroDetector)) {
ahld.setContext(entry.getValue());
tempHDList.add(ahld);
}
} catch (CoreException e) {
SpecfileLog.logError(e);
}
}
}
if (!tempHDList.isEmpty()) {
return tempHDList.toArray(new IHyperlinkDetector[tempHDList.size()]);
} else {
return null;
}
}
Aggregations