Remove deprecated API in the ProgressService
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -19,6 +19,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.IndefiniteProgressTask;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.Sts4LanguageServer;
|
||||
|
||||
@@ -68,23 +69,21 @@ public abstract class AbstractFileToProjectCache<P extends IJavaProject> extends
|
||||
}
|
||||
|
||||
final protected void performUpdate(P project, boolean async, boolean notify) {
|
||||
final String taskId = getProgressId();
|
||||
final ProgressService progressService = server.getProgressService();
|
||||
if (progressService != null) {
|
||||
progressService.progressBegin(taskId, "Updating data for project", "'" + project.getElementName() + "'");
|
||||
}
|
||||
final IndefiniteProgressTask progress = progressService == null ? null
|
||||
: progressService.createIndefiniteProgressTask(getProgressId(),
|
||||
"Updating data for project '" + project.getElementName() + "'", null);
|
||||
if (async) {
|
||||
CompletableFuture.supplyAsync(() -> update(project)).thenAccept((changed) -> afterUpdate(project, changed, notify, taskId));
|
||||
CompletableFuture.supplyAsync(() -> update(project)).thenAccept((changed) -> afterUpdate(project, changed, notify, progress));
|
||||
} else {
|
||||
boolean changed = update(project);
|
||||
afterUpdate(project, changed, notify, taskId);
|
||||
afterUpdate(project, changed, notify, progress);
|
||||
}
|
||||
}
|
||||
|
||||
private void afterUpdate(P project, boolean changed, boolean notify, String taskId) {
|
||||
final ProgressService progressService = server.getProgressService();
|
||||
if (progressService != null) {
|
||||
progressService.progressDone(taskId);
|
||||
private void afterUpdate(P project, boolean changed, boolean notify, IndefiniteProgressTask progress) {
|
||||
if (progress != null) {
|
||||
progress.done();
|
||||
}
|
||||
if (changed || alwaysFireEventOnUpdate) {
|
||||
if (notify) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.eclipse.lsp4j.WorkDoneProgressReport;
|
||||
public interface ProgressService {
|
||||
|
||||
public static ProgressService NO_PROGRESS = new ProgressService() {
|
||||
|
||||
|
||||
@Override
|
||||
public void progressBegin(String taskId, WorkDoneProgressBegin report) {
|
||||
}
|
||||
@@ -32,27 +32,6 @@ public interface ProgressService {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends an event to start progress to the LSP client.
|
||||
*
|
||||
* @param taskId is an arbitrary id
|
||||
* that can be chosen by the caller. The purpose of the id is to be a 'unique'
|
||||
* id for some kind of 'long running job'
|
||||
* @param title progress main title, i.e. "Indexing", "Loading"
|
||||
* @param message detail for the title, i.e. subtask in progress at the moment
|
||||
* @deprecated Use {@link #progressBegin(String, WorkDoneProgressBegin)}
|
||||
*/
|
||||
default void progressBegin(String taskId, String title, String message) {
|
||||
WorkDoneProgressBegin report = new WorkDoneProgressBegin();
|
||||
report.setCancellable(false);
|
||||
if (message != null && !message.isEmpty()) {
|
||||
report.setMessage(message);
|
||||
}
|
||||
report.setTitle(title);
|
||||
|
||||
progressBegin(taskId, report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an event to start progress to the LSP client.
|
||||
*
|
||||
@@ -63,23 +42,6 @@ public interface ProgressService {
|
||||
*/
|
||||
void progressBegin(String taskId, WorkDoneProgressBegin report);
|
||||
|
||||
/**
|
||||
* Sends a progress event to the LSP client. Each event updates the message shown
|
||||
* to the user replacing the old one.
|
||||
* More than one message may be shown simultaneously to the user, if they
|
||||
* have different taskId.
|
||||
*
|
||||
* @param taskId
|
||||
* @param statusMsg
|
||||
*
|
||||
* @deprecated Use {@link #progressEvent(String, WorkDoneProgressReport)}
|
||||
*/
|
||||
default void progressEvent(String taskId, String statusMsg) {
|
||||
WorkDoneProgressReport report = new WorkDoneProgressReport();
|
||||
report.setMessage(statusMsg);
|
||||
progressEvent(taskId, report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a progress event to the LSP client. Each event updates the message shown
|
||||
* to the user replacing the old one.
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndex.Builder;
|
||||
import org.springframework.ide.vscode.boot.metadata.util.Listener;
|
||||
import org.springframework.ide.vscode.boot.metadata.util.ListenerManager;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.IndefiniteProgressTask;
|
||||
import org.springframework.ide.vscode.commons.languageserver.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
@@ -76,10 +77,9 @@ public class SpringPropertiesIndexManager extends ListenerManager<Listener<Sprin
|
||||
private SpringPropertyIndex initIndex(IJavaProject project, ProgressService progressService) {
|
||||
log.info("Indexing Spring Boot Properties for {}", project.getElementName());
|
||||
|
||||
String progressId = getProgressId();
|
||||
if (progressService != null) {
|
||||
progressService.progressBegin(progressId, "Indexing Spring Boot Properties", null);
|
||||
}
|
||||
IndefiniteProgressTask progress = progressService == null ? null
|
||||
: progressService.createIndefiniteProgressTask(getProgressId(), "Indexing Spring Boot Properties",
|
||||
null);
|
||||
|
||||
Builder builder = SpringPropertyIndex.builder(valueProviders).withClasspath(project.getClasspath());
|
||||
if (commonPropertiesMetadata != null) {
|
||||
@@ -87,8 +87,8 @@ public class SpringPropertiesIndexManager extends ListenerManager<Listener<Sprin
|
||||
}
|
||||
SpringPropertyIndex index = builder.build();
|
||||
|
||||
if (progressService != null) {
|
||||
progressService.progressDone(progressId);
|
||||
if (progress != null) {
|
||||
progress.done();
|
||||
}
|
||||
|
||||
log.info("Indexing Spring Boot Properties for {} DONE", project.getElementName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -63,13 +63,13 @@ public class SpringPropertyIndexTest {
|
||||
ProgressService progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressBegin(any(), any(), any());
|
||||
verify(progressService, atLeastOnce()).createIndefiniteProgressTask(any(), any(), any());
|
||||
|
||||
// Should be cached now, so progress service should not be touched
|
||||
progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, never()).progressBegin(any(), any(), any());
|
||||
verify(progressService, never()).createIndefiniteProgressTask(any(), any(), any());
|
||||
|
||||
// Change POM file for the project
|
||||
harness.changeFile(new File(directory, MavenCore.POM_XML).toURI().toString());
|
||||
@@ -78,7 +78,7 @@ public class SpringPropertyIndexTest {
|
||||
progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressBegin(any(), any(), any());
|
||||
verify(progressService, atLeastOnce()).createIndefiniteProgressTask(any(), any(), any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ public class SpringPropertiesIndexTest {
|
||||
ProgressService progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressBegin(any(), any(), any());
|
||||
verify(progressService, atLeastOnce()).createIndefiniteProgressTask(any(), any(), any());
|
||||
|
||||
// Should be cached now, so progress service should not be touched
|
||||
progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, never()).progressBegin(any(), any(), any());
|
||||
verify(progressService, never()).createIndefiniteProgressTask(any(), any(), any());
|
||||
|
||||
// Change POM file for the project
|
||||
harness.changeFile(new File(directory, MavenCore.POM_XML).toURI().toASCIIString());
|
||||
@@ -79,7 +79,7 @@ public class SpringPropertiesIndexTest {
|
||||
progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressBegin(any(), any(), any());
|
||||
verify(progressService, atLeastOnce()).createIndefiniteProgressTask(any(), any(), any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user