Rewrite reconciling switch via preferences. Off by default.
This commit is contained in:
@@ -98,6 +98,8 @@ public class BootJavaPreferencesPage extends FieldEditorPreferencePage implement
|
||||
addField(new BooleanFieldEditor(Constants.PREF_CHANGE_DETECTION, "Live Boot Change Detection", fieldEditorParent));
|
||||
|
||||
addField(new BooleanFieldEditor(Constants.PREF_VALIDATION_SPEL_EXPRESSIONS, "SpEL Expression Syntax Validation", fieldEditorParent));
|
||||
|
||||
addField(new BooleanFieldEditor(Constants.PREF_REWRITE_RECONCILE, "Experimental reconciling for Java source based on Rewrite project", fieldEditorParent));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,5 +33,7 @@ public class Constants {
|
||||
public static final String PREF_XML_CONFIGS_CONTENT_ASSIST = "boot-java.support-spring-xml-config.content-assist";
|
||||
|
||||
public static final String PREF_CHANGE_DETECTION = "boot-java.change-detection.on";
|
||||
|
||||
public static final String PREF_REWRITE_RECONCILE = "boot-java.rewrite.reconcile";
|
||||
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
bootJavaObj.put("change-detection", bootChangeDetection);
|
||||
bootJavaObj.put("validation", validation);
|
||||
bootJavaObj.put("remote-apps", getAllRemoteApps());
|
||||
bootJavaObj.put("rewrite", Map.of("reconcile", preferenceStore.getBoolean(Constants.PREF_REWRITE_RECONCILE)));
|
||||
settings.put("boot-java", bootJavaObj);
|
||||
|
||||
putValidationPreferences(settings);
|
||||
|
||||
@@ -42,6 +42,8 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
preferenceStore.setDefault(Constants.PREF_VALIDATION_SPEL_EXPRESSIONS, true);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_SCAN_JAVA_TEST_SOURCES, false);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_RECONCILE, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -119,6 +119,12 @@ public class BootJavaConfig implements InitializingBean {
|
||||
return enabled != null && enabled.booleanValue();
|
||||
}
|
||||
|
||||
public boolean isRewriteReconcileEnabled() {
|
||||
Boolean enabled = getRawSettings().getBoolean("boot-java", "rewrite", "reconcile");
|
||||
return enabled == null ? false : enabled.booleanValue();
|
||||
}
|
||||
|
||||
|
||||
public boolean isXmlContentAssistEnabled() {
|
||||
Boolean enabled = settings.getBoolean("boot-java", "support-spring-xml-config", "content-assist");
|
||||
return enabled != null && enabled.booleanValue();
|
||||
|
||||
@@ -34,8 +34,8 @@ public class RewriteConfig implements InitializingBean {
|
||||
private RewriteRefactorings rewriteRefactorings;
|
||||
|
||||
@Bean
|
||||
RewriteCodeActionHandler rewriteCodeActionHandler(RewriteCompilationUnitCache cuCache, RewriteRecipeRepository recipeRepo) {
|
||||
return new RewriteCodeActionHandler(cuCache, recipeRepo);
|
||||
RewriteCodeActionHandler rewriteCodeActionHandler(RewriteCompilationUnitCache cuCache, RewriteRecipeRepository recipeRepo, BootJavaConfig config) {
|
||||
return new RewriteCodeActionHandler(cuCache, recipeRepo, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -191,7 +191,8 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
RewriteReconciler rewriteJavaReconciler = new RewriteReconciler(
|
||||
appContext.getBean(RewriteRecipeRepository.class),
|
||||
orCompilationUnitCache,
|
||||
server.getQuickfixRegistry()
|
||||
server.getQuickfixRegistry(),
|
||||
config
|
||||
);
|
||||
|
||||
reconcileEngine = new BootJavaReconcileEngine(projectFinder, new JavaReconciler[] {
|
||||
|
||||
@@ -151,10 +151,9 @@ public class SpringProcessConnectorService {
|
||||
|
||||
|
||||
this.scheduler.schedule(() -> {
|
||||
progressTask.progressEvent(progressMessage);
|
||||
try {
|
||||
progressTask.progressEvent(progressMessage);
|
||||
connector.connect();
|
||||
progressTask.progressDone();
|
||||
|
||||
refreshProcess(processKey);
|
||||
}
|
||||
@@ -172,6 +171,8 @@ public class SpringProcessConnectorService {
|
||||
.error("Failed to connect to process " + processKey + " after retries: " + retryNo, e));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
progressTask.progressDone();
|
||||
}
|
||||
}, delay, unit);
|
||||
}
|
||||
@@ -182,10 +183,9 @@ public class SpringProcessConnectorService {
|
||||
|
||||
|
||||
this.scheduler.schedule(() -> {
|
||||
progressTask.progressEvent(message);
|
||||
try {
|
||||
progressTask.progressEvent(message);
|
||||
connector.disconnect();
|
||||
progressTask.progressDone();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.info("problem occured during process disconnect", e);
|
||||
@@ -200,6 +200,8 @@ public class SpringProcessConnectorService {
|
||||
.error("Failed to disconnect from process " + processKey + " after retries: " + retryNo, e));
|
||||
|
||||
}
|
||||
} finally {
|
||||
progressTask.progressDone();
|
||||
}
|
||||
}, delay, unit);
|
||||
}
|
||||
@@ -209,10 +211,9 @@ public class SpringProcessConnectorService {
|
||||
log.info(progressMessage);
|
||||
|
||||
|
||||
this.scheduler.schedule(() -> {
|
||||
|
||||
this.scheduler.schedule(() -> {
|
||||
progressTask.progressEvent(progressMessage);
|
||||
try {
|
||||
progressTask.progressEvent(progressMessage);
|
||||
SpringProcessLiveData newLiveData = connector.refresh(this.liveDataProvider.getCurrent(processKey));
|
||||
|
||||
if (newLiveData != null) {
|
||||
@@ -222,7 +223,6 @@ public class SpringProcessConnectorService {
|
||||
|
||||
this.connectedSuccess.put(processKey, true);
|
||||
}
|
||||
progressTask.progressDone();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -243,6 +243,8 @@ public class SpringProcessConnectorService {
|
||||
disconnectProcess(processKey);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
progressTask.progressDone();
|
||||
}
|
||||
}, delay, unit);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.openrewrite.java.tree.J.CompilationUnit;
|
||||
import org.openrewrite.marker.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.JavaCodeActionHandler;
|
||||
import org.springframework.ide.vscode.boot.java.rewrite.reconcile.RecipeSpringJavaProblemDescriptor;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
@@ -52,9 +53,12 @@ public class RewriteCodeActionHandler implements JavaCodeActionHandler {
|
||||
final private RewriteCompilationUnitCache cuCache;
|
||||
final private RewriteRecipeRepository recipeRepo;
|
||||
|
||||
public RewriteCodeActionHandler(RewriteCompilationUnitCache cuCache, RewriteRecipeRepository recipeRepo) {
|
||||
private BootJavaConfig config;
|
||||
|
||||
public RewriteCodeActionHandler(RewriteCompilationUnitCache cuCache, RewriteRecipeRepository recipeRepo, BootJavaConfig config) {
|
||||
this.cuCache = cuCache;
|
||||
this.recipeRepo = recipeRepo;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
protected static boolean isResolve(CodeActionCapabilities capabilities, String property) {
|
||||
@@ -89,6 +93,10 @@ public class RewriteCodeActionHandler implements JavaCodeActionHandler {
|
||||
@Override
|
||||
public List<Either<Command, CodeAction>> handle(IJavaProject project, CancelChecker cancelToken,
|
||||
CodeActionCapabilities capabilities, CodeActionContext context, TextDocument doc, IRegion region) {
|
||||
if (!config.isRewriteReconcileEnabled()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Wait for recipe repo to load if not loaded - should be loaded by the time we get here.
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.openrewrite.java.tree.J.CompilationUnit;
|
||||
import org.openrewrite.marker.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
|
||||
import org.springframework.ide.vscode.boot.java.SpringJavaProblemType;
|
||||
import org.springframework.ide.vscode.boot.java.reconcilers.JavaReconciler;
|
||||
import org.springframework.ide.vscode.boot.java.rewrite.RewriteRefactorings.Data;
|
||||
@@ -49,15 +50,22 @@ public class RewriteReconciler implements JavaReconciler {
|
||||
private QuickfixRegistry quickfixRegistry;
|
||||
|
||||
private RewriteRecipeRepository recipeRepo;
|
||||
|
||||
private BootJavaConfig config;
|
||||
|
||||
public RewriteReconciler(RewriteRecipeRepository recipeRepo, RewriteCompilationUnitCache cuCache, QuickfixRegistry quickfixRegistry) {
|
||||
public RewriteReconciler(RewriteRecipeRepository recipeRepo, RewriteCompilationUnitCache cuCache, QuickfixRegistry quickfixRegistry, BootJavaConfig config) {
|
||||
this.recipeRepo = recipeRepo;
|
||||
this.cuCache = cuCache;
|
||||
this.quickfixRegistry = quickfixRegistry;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reconcile(IJavaProject project, IDocument doc, IProblemCollector problemCollector) {
|
||||
if (!config.isRewriteReconcileEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
problemCollector.beginCollecting();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user