use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class ClassReferenceProvider method getValuesAsync.
@Override
protected Flux<StsValueHint> getValuesAsync(IJavaProject javaProject, String query) {
IType targetType = target == null || target.isEmpty() ? javaProject.getClasspath().findType("java.lang.Object") : javaProject.getClasspath().findType(target);
if (targetType == null) {
return Flux.empty();
}
Set<IType> allSubclasses = javaProject.getClasspath().allSubtypesOf(targetType).filter(t -> Flags.isPublic(t.getFlags()) && !concrete || !isAbstract(t)).collect(Collectors.toSet()).block();
if (allSubclasses.isEmpty()) {
return Flux.empty();
} else {
return javaProject.getClasspath().fuzzySearchTypes(query, type -> allSubclasses.contains(type)).collectSortedList((o1, o2) -> o2.getT2().compareTo(o1.getT2())).flatMapIterable(l -> l).map(t -> StsValueHint.create(t.getT1()));
}
}
use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class BootJavaReferencesHandler method getClasspathEntries.
private String[] getClasspathEntries(IDocument doc) throws Exception {
IJavaProject project = this.projectFinder.find(new TextDocumentIdentifier(doc.getUri())).get();
IClasspath classpath = project.getClasspath();
Stream<Path> classpathEntries = classpath.getClasspathEntries().stream();
return classpathEntries.filter(path -> path.toFile().exists()).map(path -> path.toAbsolutePath().toString()).toArray(String[]::new);
}
use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.
the class GradleProjectTest method findGradleProjectWithNonStandardBuildFile.
@Test
public void findGradleProjectWithNonStandardBuildFile() throws Exception {
GradleProjectFinder finder = new GradleProjectFinder(new GradleProjectCache(server, GradleCore.getDefault(), false, null));
File sourceFile = new File(GradleProjectTest.class.getResource("/test-app-2/src/main/java/Library.java").toURI());
Optional<IJavaProject> project = finder.find(sourceFile);
assertTrue(project.isPresent());
assertTrue(project.get() instanceof GradleJavaProject);
GradleJavaProject gradleProject = (GradleJavaProject) project.get();
assertEquals(new File(GradleProjectTest.class.getResource("/test-app-2").toURI()), gradleProject.getLocation());
}
Aggregations