use of org.eclipse.mylyn.internal.wikitext.ui.util.HyperlinkDetectorDelegate in project mylyn.docs by eclipse.
the class AbstractTextSourceViewerConfiguration method getHyperlinkDetectors.
@SuppressWarnings("unchecked")
@Override
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
List<IHyperlinkDetector> customDetectors = createCustomHyperlinkDetectors(sourceViewer);
if (sourceViewer == null || fPreferenceStore == null) {
return customDetectors.toArray(new IHyperlinkDetector[customDetectors.size()]);
}
HyperlinkDetectorRegistry registry = EditorsUI.getHyperlinkDetectorRegistry();
HyperlinkDetectorDescriptor[] descriptors = registry.getHyperlinkDetectorDescriptors();
Map<String, IAdaptable> targets = getHyperlinkDetectorTargets(sourceViewer);
List<IHyperlinkDetector> detectors = new ArrayList<>(8);
if (markupHyperlinksFirst) {
detectors.addAll(customDetectors);
}
if (hyperlinkDetectors != null) {
detectors.addAll(hyperlinkDetectors);
}
for (Map.Entry<String, IAdaptable> target : targets.entrySet()) {
String targetId = target.getKey();
IAdaptable context = target.getValue();
for (HyperlinkDetectorDescriptor descriptor : descriptors) {
if (targetId.equals(descriptor.getTargetId())) {
if (filterHyperlinkDescriptor(descriptor)) {
continue;
}
HyperlinkDetectorDelegate delegate = new HyperlinkDetectorDelegate(descriptor, fPreferenceStore);
delegate.setContext(context);
detectors.add(delegate);
}
}
}
if (!markupHyperlinksFirst) {
detectors.addAll(customDetectors);
}
return detectors.toArray(new IHyperlinkDetector[detectors.size()]);
}
Aggregations