use of org.springframework.ide.vscode.commons.java.IClasspath in project sts4 by spring-projects.
the class SpringIndexer method getClasspathEntries.
private String[] getClasspathEntries(IJavaProject project) throws Exception {
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.IClasspath in project sts4 by spring-projects.
the class SpringResource method projectRelativePath.
private String projectRelativePath(String pathStr) {
Path path = Paths.get(pathStr);
IClasspath classpath = project.getClasspath();
Path outputFolder = classpath.getOutputFolder();
if (path.startsWith(outputFolder)) {
return outputFolder.relativize(path).toString();
}
return pathStr;
}
use of org.springframework.ide.vscode.commons.java.IClasspath in project sts4 by spring-projects.
the class CompilationUnitCache method getClasspathEntries.
private static String[] getClasspathEntries(TextDocument document, IJavaProject project) throws Exception {
if (project == null) {
return new String[0];
} else {
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.IClasspath in project sts4 by spring-projects.
the class CompilationUnitCacheTest method cu_cache_invalidated_by_doc_close.
@Test
public void cu_cache_invalidated_by_doc_close() throws Exception {
harness = BootJavaLanguageServerHarness.builder().mockDefaults().build();
harness.useProject(new IJavaProject() {
@Override
public IClasspath getClasspath() {
return new DelegatingCachedClasspath<>(() -> null, null);
}
});
harness.intialize(null);
TextDocument doc = new TextDocument(harness.createTempUri(), LanguageId.JAVA, 0, "package my.package\n" + "\n" + "public class SomeClass {\n" + "\n" + "}\n");
harness.newEditorFromFileUri(doc.getUri(), doc.getLanguageId());
CompilationUnit cu = getCompilationUnit(doc);
assertNotNull(cu);
harness.closeDocument(doc.getId());
CompilationUnit cuAnother = getCompilationUnit(doc);
assertNotNull(cuAnother);
assertFalse(cu == cuAnother);
CompilationUnit cuYetAnother = getCompilationUnit(doc);
assertTrue(cuAnother == cuYetAnother);
}
use of org.springframework.ide.vscode.commons.java.IClasspath in project sts4 by spring-projects.
the class CompilationUnitCacheTest method cu_cached.
@Test
public void cu_cached() throws Exception {
harness = BootJavaLanguageServerHarness.builder().mockDefaults().build();
harness.useProject(new IJavaProject() {
@Override
public IClasspath getClasspath() {
return new DelegatingCachedClasspath<>(() -> null, null);
}
});
harness.intialize(null);
TextDocument doc = new TextDocument(harness.createTempUri(), LanguageId.JAVA, 0, "package my.package\n" + "\n" + "public class SomeClass {\n" + "\n" + "}\n");
CompilationUnit cu = getCompilationUnit(doc);
assertNotNull(cu);
CompilationUnit cuAnother = getCompilationUnit(doc);
assertTrue(cu == cuAnother);
}
Aggregations