use of org.springframework.ide.vscode.commons.java.IClasspath in project sts4 by spring-projects.
the class CompilationUnitCacheTest method cu_cache_invalidated_by_doc_change.
@Test
public void cu_cache_invalidated_by_doc_change() 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.changeDocument(doc.getUri(), 0, 0, " ");
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 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);
}
Aggregations