Clear diagnostics if project isn't Boot project anymore
This commit is contained in:
@@ -99,7 +99,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
|
||||
@Override
|
||||
public void deleted(IJavaProject project) {
|
||||
doNotValidateProject(project.getLocationUri());
|
||||
doNotValidateProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -209,7 +209,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
|
||||
URI uri = project.getLocationUri();
|
||||
|
||||
doNotValidateProject(uri);
|
||||
doNotValidateProject(project);
|
||||
|
||||
projectReconcileRequests.put(uri, Mono.delay(Duration.ofMillis(100))
|
||||
.publishOn(projectReconcileScheduler)
|
||||
@@ -222,15 +222,18 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
.subscribe());
|
||||
}
|
||||
|
||||
private void doNotValidateProject(URI uri) {
|
||||
private void doNotValidateProject(IJavaProject project) {
|
||||
if (configProps.isReconcileOnlyOpenedDocs()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
URI uri = project.getLocationUri();
|
||||
Disposable request = projectReconcileRequests.remove(uri);
|
||||
if (request != null) {
|
||||
request.dispose();
|
||||
}
|
||||
|
||||
projectReconciler.clear(project);
|
||||
}
|
||||
|
||||
private void handleFiles(String[] files) {
|
||||
|
||||
@@ -19,5 +19,7 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
public interface IJavaProjectReconcileEngine {
|
||||
|
||||
void reconcile(IJavaProject project, Function<TextDocument, IProblemCollector> problemCollectorFactory);
|
||||
|
||||
void clear(IJavaProject project);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -129,14 +130,14 @@ public class BootJavaReconcileEngine implements IReconcileEngine, IJavaProjectRe
|
||||
}
|
||||
Stream<Path> files = IClasspathUtil.getProjectJavaSourceFolders(project.getClasspath()).flatMap(folder -> {
|
||||
try {
|
||||
return Files.walk(folder.toPath());
|
||||
return Files.walk(folder.toPath()).filter(Files::isRegularFile);
|
||||
} catch (IOException e) {
|
||||
return Stream.empty();
|
||||
}
|
||||
});
|
||||
Stream<TextDocumentIdentifier> docIds = files.filter(f -> {
|
||||
return Files.isRegularFile(f) && f.getFileName().toString().endsWith(".java");
|
||||
}).map(f -> new TextDocumentIdentifier(f.toUri().toString()));
|
||||
Stream<TextDocumentIdentifier> docIds = files
|
||||
.filter(f -> f.getFileName().toString().endsWith(".java"))
|
||||
.map(f -> new TextDocumentIdentifier(f.toUri().toString()));
|
||||
|
||||
List<TextDocument> docs = docIds.filter(docId -> documents.getLatestSnapshot(docId.getUri()) == null)
|
||||
.map(docId -> new LazyTextDocument(docId.getUri(), LanguageId.JAVA)).collect(Collectors.toList());
|
||||
@@ -163,4 +164,23 @@ public class BootJavaReconcileEngine implements IReconcileEngine, IJavaProjectRe
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(IJavaProject project) {
|
||||
// Build file
|
||||
if (project.getProjectBuild() != null && project.getProjectBuild().getBuildFile() != null) {
|
||||
documents.publishDiagnostics(new TextDocumentIdentifier(project.getProjectBuild().getBuildFile().toString()), Collections.emptyList());
|
||||
}
|
||||
// Rest of the files
|
||||
IClasspathUtil.getProjectJavaSourceFolders(project.getClasspath()).flatMap(folder -> {
|
||||
try {
|
||||
return Files.walk(folder.toPath()).filter(Files::isRegularFile);
|
||||
} catch (IOException e) {
|
||||
return Stream.empty();
|
||||
}
|
||||
})
|
||||
.filter(f -> f.getFileName().toString().endsWith(".java"))
|
||||
.forEach(p -> documents.publishDiagnostics(new TextDocumentIdentifier(p.toUri().toString()), Collections.emptyList()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user