use of org.eclipse.jdt.ls.core.internal.IDecompiler in project eclipse.jdt.ls by eclipse.
the class ContentProviderManager method getContent.
private String getContent(Object source, String cacheKey, Class<? extends IContentProvider> providerType, IProgressMonitor monitor) {
URI uri = source instanceof URI ? (URI) source : null;
List<ContentProviderDescriptor> matches = findMatchingProviders(uri);
if (monitor.isCanceled()) {
return EMPTY_CONTENT;
}
int previousPriority = -1;
for (ContentProviderDescriptor match : matches) {
IContentProvider contentProvider = match.getContentProvider();
if (!providerType.isInstance(contentProvider)) {
JavaLanguageServerPlugin.logError("Unable to load " + providerType.getSimpleName() + " class for " + match.id);
continue;
}
if (monitor.isCanceled()) {
return EMPTY_CONTENT;
}
if (previousPriority == match.priority) {
requestPreferredProvider(match.priority, matches);
}
try {
contentProvider.setPreferences(preferenceManager.getPreferences());
String content = null;
if (uri != null) {
content = contentProvider.getContent(uri, monitor);
} else if (source instanceof IClassFile) {
content = ((IDecompiler) contentProvider).getSource((IClassFile) source, monitor);
}
if (monitor.isCanceled()) {
return EMPTY_CONTENT;
} else if (content != null) {
return content;
}
} catch (Exception e) {
JavaLanguageServerPlugin.logException("Error getting content via " + match.id, e);
}
previousPriority = match.priority;
}
return EMPTY_CONTENT;
}
Aggregations