use of org.springframework.ide.vscode.commons.java.IJavadocProvider in project sts4 by spring-projects.
the class JandexIndex method createType.
private IType createType(Tuple2<File, ClassInfo> match) {
File classpathResource = match.getT1();
IJavadocProvider javadocProvider = null;
try {
javadocProvider = javadocProvidersCache.get(classpathResource, () -> {
IJavadocProvider provider = null;
if (javadocProviderFactory != null) {
provider = javadocProviderFactory.createJavadocProvider(classpathResource);
}
return provider == null ? ABSENT_JAVADOC_PROVIDER : provider;
});
} catch (ExecutionException e) {
Log.log(e);
}
return Wrappers.wrap(this, match.getT2(), javadocProvider);
}
use of org.springframework.ide.vscode.commons.java.IJavadocProvider in project sts4 by spring-projects.
the class MavenProjectClasspath method createHtmlJavdocProvider.
@Override
protected IJavadocProvider createHtmlJavdocProvider(File classpathResource) {
if (cachedData == null) {
return null;
}
if (classpathResource.isDirectory()) {
if (classpathResource.toString().startsWith(cachedData.outputDirectory)) {
return new HtmlJavadocProvider(type -> {
return SourceUrlProviderFromSourceContainer.JAVADOC_FOLDER_URL_SUPPLIER.sourceUrl(new File(cachedData.reportingOutputDirectory, "apidocs").toURI().toURL(), type.getFullyQualifiedName());
});
} else if (classpathResource.toString().startsWith(cachedData.testOutputDirectory)) {
return new HtmlJavadocProvider(type -> {
return SourceUrlProviderFromSourceContainer.JAVADOC_FOLDER_URL_SUPPLIER.sourceUrl(new File(cachedData.reportingOutputDirectory, "apidocs").toURI().toURL(), type.getFullyQualifiedName());
});
} else {
throw new IllegalArgumentException("Cannot find source folder for " + classpathResource);
}
} else {
// Assume it's a JAR file
return new HtmlJavadocProvider(type -> {
try {
Artifact artifact = cachedData.artifacts.stream().filter(a -> classpathResource.equals(a.getFile())).findFirst().get();
URL sourceContainer = maven.getJavadoc(artifact, cachedData.remoteArtifactRepositories).getFile().toURI().toURL();
return SourceUrlProviderFromSourceContainer.JAR_JAVADOC_URL_PROVIDER.sourceUrl(sourceContainer, type.getFullyQualifiedName());
} catch (MavenException e) {
Log.log("Failed to find sources JAR for " + classpathResource, e);
} catch (MalformedURLException e) {
Log.log("Invalid URL for sources JAR for " + classpathResource, e);
}
return null;
});
}
}
Aggregations