Adopt title in the progress notification in lsp
This commit is contained in:
@@ -126,7 +126,7 @@ public class RewriteRecipeRepository {
|
||||
|
||||
private void loadRecipes() {
|
||||
try {
|
||||
server.getProgressService().progressEvent(RECIPES_LOADING_PROGRESS, "Loading Rewrite Recipes...");
|
||||
server.getProgressService().progressBegin(RECIPES_LOADING_PROGRESS, "Loading Rewrite Recipes", null);
|
||||
log.info("Loading Rewrite Recipes...");
|
||||
for (Recipe r : Environment.builder().scanRuntimeClasspath().build().listRecipes()) {
|
||||
if (r.getName() != null) {
|
||||
@@ -151,7 +151,7 @@ public class RewriteRecipeRepository {
|
||||
log.info("Done loading Rewrite Recipes");
|
||||
server.doOnInitialized(() -> registerCommands());
|
||||
} catch (Throwable t) {
|
||||
server.getProgressService().progressEvent(RECIPES_LOADING_PROGRESS, null);
|
||||
server.getProgressService().progressDone(RECIPES_LOADING_PROGRESS);
|
||||
log.error("", t);
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ public class RewriteRecipeRepository {
|
||||
server.getClient().registerCapability(params).thenAccept((v) -> {
|
||||
server.onShutdown(() -> server.getClient().unregisterCapability(new UnregistrationParams(List.of(new Unregistration(registrationId, WORKSPACE_EXECUTE_COMMAND)))));
|
||||
log.info("Done registering commands for rewrite recipes");
|
||||
server.getProgressService().progressEvent(RECIPES_LOADING_PROGRESS, null);
|
||||
server.getProgressService().progressDone(RECIPES_LOADING_PROGRESS);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public class RewriteRecipeRepository {
|
||||
|
||||
private CompletableFuture<Object> apply(Recipe r, String uri, String progressToken) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
server.getProgressService().progressEvent(progressToken, r.getDisplayName() + ": initiated...");
|
||||
server.getProgressService().progressBegin(progressToken, r.getDisplayName(), "Initiated...");
|
||||
return projectFinder.find(new TextDocumentIdentifier(uri));
|
||||
}).thenCompose(p -> {
|
||||
if (p.isPresent()) {
|
||||
@@ -288,24 +288,23 @@ public class RewriteRecipeRepository {
|
||||
Optional<WorkspaceEdit> edit = apply(r, p.get());
|
||||
return CompletableFuture.completedFuture(edit).thenCompose(we -> {
|
||||
if (we.isPresent()) {
|
||||
server.getProgressService().progressEvent(progressToken,
|
||||
r.getDisplayName() + ": applying document changes...");
|
||||
server.getProgressService().progressEvent(progressToken, "Applying document changes...");
|
||||
return server.getClient().applyEdit(new ApplyWorkspaceEditParams(we.get(), r.getDisplayName())).thenCompose(res -> {
|
||||
if (res.isApplied()) {
|
||||
server.getProgressService().progressEvent(progressToken, null);
|
||||
server.getProgressService().progressDone(progressToken);
|
||||
return CompletableFuture.completedFuture("success");
|
||||
} else {
|
||||
server.getProgressService().progressEvent(progressToken, null);
|
||||
server.getProgressService().progressDone(progressToken);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
server.getProgressService().progressEvent(progressToken, null);
|
||||
server.getProgressService().progressDone(progressToken);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
server.getProgressService().progressEvent(progressToken, null);
|
||||
server.getProgressService().progressDone(progressToken);
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
@@ -315,12 +314,11 @@ public class RewriteRecipeRepository {
|
||||
|
||||
private Optional<WorkspaceEdit> apply(Recipe r, IJavaProject project) {
|
||||
Path absoluteProjectDir = Paths.get(project.getLocationUri());
|
||||
server.getProgressService().progressEvent(r.getName(), r.getDisplayName() + ": parsing files...");
|
||||
server.getProgressService().progressEvent(r.getName(), "Parsing files...");
|
||||
MavenProjectParser projectParser = createRewriteMavenParser(absoluteProjectDir,
|
||||
new InMemoryExecutionContext());
|
||||
List<SourceFile> sources = projectParser.parse(absoluteProjectDir, getClasspathEntries(project));
|
||||
server.getProgressService().progressEvent(r.getName(),
|
||||
r.getDisplayName() + ": computing changes...");
|
||||
server.getProgressService().progressEvent(r.getName(), "Computing changes...");
|
||||
List<Result> results = r.run(sources, new InMemoryExecutionContext(e -> log.error("", e)));
|
||||
return ORDocUtils.createWorkspaceEdit(absoluteProjectDir, server.getTextDocumentService(), results);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014, 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2014, 2022 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
|
||||
@@ -12,13 +12,14 @@ package org.springframework.ide.vscode.boot.metadata;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.ProgressService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
@@ -33,6 +34,8 @@ import com.google.common.collect.ImmutableList;
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class SpringPropertiesIndexManager extends ListenerManager<Listener<SpringPropertiesIndexManager>> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SpringPropertiesIndexManager.class);
|
||||
|
||||
private Cache<IJavaProject, SpringPropertyIndex> indexes;
|
||||
private final ValueProviderRegistry valueProviders;
|
||||
@@ -56,27 +59,27 @@ public class SpringPropertiesIndexManager extends ListenerManager<Listener<Sprin
|
||||
try {
|
||||
return indexes.get(project, () -> initIndex(project, progressService));
|
||||
} catch (ExecutionException e) {
|
||||
Log.log(e);
|
||||
log.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private SpringPropertyIndex initIndex(IJavaProject project, ProgressService progressService) {
|
||||
Log.info("Indexing Spring Boot Properties for "+project.getElementName());
|
||||
log.info("Indexing Spring Boot Properties for {}", project.getElementName());
|
||||
|
||||
String progressId = getProgressId();
|
||||
if (progressService != null) {
|
||||
progressService.progressEvent(progressId, "Indexing Spring Boot Properties...");
|
||||
progressService.progressBegin(progressId, "Indexing Spring Boot Properties", null);
|
||||
}
|
||||
|
||||
SpringPropertyIndex index = new SpringPropertyIndex(valueProviders, project.getClasspath());
|
||||
|
||||
if (progressService != null) {
|
||||
progressService.progressEvent(progressId, null);
|
||||
progressService.progressDone(progressId);
|
||||
}
|
||||
|
||||
Log.info("Indexing Spring Boot Properties for "+project.getElementName()+" DONE");
|
||||
Log.info("Indexed "+index.size()+" properties.");
|
||||
log.info("Indexing Spring Boot Properties for {} DONE", project.getElementName());
|
||||
log.info("Indexed {} properties.", index.size());
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2022 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
|
||||
@@ -10,7 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.utils.test;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -63,13 +63,13 @@ public class SpringPropertyIndexTest {
|
||||
ProgressService progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressEvent(anyObject(), anyObject());
|
||||
verify(progressService, atLeastOnce()).progressBegin(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()).progressEvent(anyObject(), anyObject());
|
||||
verify(progressService, never()).progressBegin(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()).progressEvent(anyObject(), anyObject());
|
||||
verify(progressService, atLeastOnce()).progressBegin(any(), any(), any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2022 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
|
||||
@@ -10,7 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.test;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyObject;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -64,13 +64,13 @@ public class SpringPropertiesIndexTest {
|
||||
ProgressService progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressEvent(anyObject(), anyObject());
|
||||
verify(progressService, atLeastOnce()).progressBegin(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()).progressEvent(anyObject(), anyObject());
|
||||
verify(progressService, never()).progressBegin(any(), any(), any());
|
||||
|
||||
// Change POM file for the project
|
||||
harness.changeFile(new File(directory, MavenCore.POM_XML).toURI().toString());
|
||||
@@ -79,7 +79,7 @@ public class SpringPropertiesIndexTest {
|
||||
progressService = mock(ProgressService.class);
|
||||
propertyIndexProvider.setProgressService(progressService);
|
||||
propertyIndexProvider.getIndex(doc);
|
||||
verify(progressService, atLeastOnce()).progressEvent(anyObject(), anyObject());
|
||||
verify(progressService, atLeastOnce()).progressBegin(any(), any(), any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user