Polishing Rewrite integration
This commit is contained in:
@@ -196,7 +196,7 @@
|
||||
category="org.springframework.tooling.boot.ls.preferences"
|
||||
class="org.springframework.tooling.boot.ls.RewritePreferencePage"
|
||||
id="org.springframework.tooling.boot.ls.rewrite"
|
||||
name="Rewrite">
|
||||
name="OpenRewrite">
|
||||
</page>
|
||||
<page
|
||||
category="org.springframework.tooling.boot.ls.rewrite"
|
||||
@@ -236,8 +236,12 @@
|
||||
</activeWhen>
|
||||
</handler>
|
||||
<handler
|
||||
class="org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler"
|
||||
commandId="org.springframework.tooling.boot.ls.Rewrite">
|
||||
class="org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler$RefactorBootProject"
|
||||
commandId="org.springframework.tooling.boot.ls.rewrite.refactor">
|
||||
</handler>
|
||||
<handler
|
||||
class="org.springframework.tooling.boot.ls.commands.RewriteRefactoringsHandler$UpgradeBootVersion"
|
||||
commandId="org.springframework.tooling.boot.ls.rewrite.boot-upgrade">
|
||||
</handler>
|
||||
</extension>
|
||||
<extension
|
||||
@@ -256,8 +260,14 @@
|
||||
<command
|
||||
categoryId="org.springframework.ide.eclipse.commands"
|
||||
description="Rewrite Refactorings for Spring Boot projects"
|
||||
id="org.springframework.tooling.boot.ls.Rewrite"
|
||||
name="Rewrite Refactorings...">
|
||||
id="org.springframework.tooling.boot.ls.rewrite.refactor"
|
||||
name="Refactor Spring Boot Project...">
|
||||
</command>
|
||||
<command
|
||||
categoryId="org.springframework.ide.eclipse.commands"
|
||||
description="Upgrade Spring Boot Version for a Spring Boot project"
|
||||
id="org.springframework.tooling.boot.ls.rewrite.boot-upgrade"
|
||||
name="Upgrade Spring Boot Version...">
|
||||
</command>
|
||||
</extension>
|
||||
|
||||
@@ -452,7 +462,7 @@
|
||||
requiresUIAccess="false"/>
|
||||
<computer
|
||||
class="org.springframework.tooling.boot.ls.commands.RewriteCommandsQuickAccessProvider"
|
||||
name="Spring - Rewrite Recipes">
|
||||
name="Spring - OpenRewrite Recipes">
|
||||
</computer>
|
||||
</extension>
|
||||
<extension
|
||||
@@ -467,9 +477,9 @@
|
||||
allPopups="false"
|
||||
locationURI="popup:org.springframework.ide.eclipse.ui.tools?after=boot">
|
||||
<command
|
||||
commandId="org.springframework.tooling.boot.ls.Rewrite"
|
||||
id="org.springframework.tooling.boot.ls.Rewrite"
|
||||
label="Rewrite Refactorings..."
|
||||
commandId="org.springframework.tooling.boot.ls.rewrite.boot-upgrade"
|
||||
id="org.springframework.tooling.boot.ls.rewrite.boot-upgrade"
|
||||
label="Upgrade Spring Boot Version..."
|
||||
style="push">
|
||||
<visibleWhen
|
||||
checkEnabled="false">
|
||||
@@ -522,6 +532,66 @@
|
||||
</and>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command
|
||||
commandId="org.springframework.tooling.boot.ls.rewrite.refactor"
|
||||
id="org.springframework.tooling.boot.ls.rewrite.refactor"
|
||||
label="Refactor Spring Boot Project..."
|
||||
style="push">
|
||||
<visibleWhen
|
||||
checkEnabled="false">
|
||||
<and>
|
||||
<count
|
||||
value="1">
|
||||
</count>
|
||||
<iterate>
|
||||
<or>
|
||||
<adapt
|
||||
type="org.eclipse.core.resources.IResource">
|
||||
<and>
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.springsource.ide.eclipse.boot.isBootResource">
|
||||
</test>
|
||||
<or>
|
||||
<test
|
||||
property="org.eclipse.core.resources.name"
|
||||
value="pom.xml">
|
||||
</test>
|
||||
<adapt
|
||||
type="org.eclipse.core.resources.IProject">
|
||||
<test
|
||||
property="org.eclipse.core.resources.projectNature"
|
||||
value="org.eclipse.m2e.core.maven2Nature">
|
||||
</test>
|
||||
</adapt>
|
||||
</or>
|
||||
</and>
|
||||
</adapt>
|
||||
<and>
|
||||
<instanceof
|
||||
value="org.eclipse.jdt.core.IJavaProject">
|
||||
</instanceof>
|
||||
<test
|
||||
property="org.springsource.ide.eclipse.commons.java.projectNature"
|
||||
value="org.eclipse.m2e.core.maven2Nature">
|
||||
</test>
|
||||
<test
|
||||
forcePluginActivation="true"
|
||||
property="org.springsource.ide.eclipse.boot.javaelement.isBootProject">
|
||||
</test>
|
||||
</and>
|
||||
</or>
|
||||
</iterate>
|
||||
<test
|
||||
property="org.springframework.tooling.boot.ls.areRewriteProjectRefactoringsOn">
|
||||
</test>
|
||||
</and>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<separator
|
||||
name="org.springframework.tooling.boot.ls.rewrite"
|
||||
visible="true">
|
||||
</separator>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
|
||||
@@ -31,7 +31,7 @@ public class RewritePreferencePage extends FieldEditorPreferencePage implements
|
||||
"Project refactoring actions", fieldEditorParent));
|
||||
|
||||
addField(new BooleanFieldEditor(Constants.PREF_REWRITE_RECONCILE,
|
||||
"Experimental reconciling for Java source based on Rewrite project", fieldEditorParent));
|
||||
"Reconciling of Java Sources", fieldEditorParent));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RewriteCommandsQuickAccessProvider implements IQuickAccessComputer,
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return "Reload Rewrite Recipes";
|
||||
return "Reload OpenRewrite Recipes, Code Actions, Problem and Quick Fix Descriptors";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +68,7 @@ public class RewriteCommandsQuickAccessProvider implements IQuickAccessComputer,
|
||||
ls.getWorkspaceService().executeCommand(commandParams)).toArray(CompletableFuture[]::new)).get(2, TimeUnit.SECONDS);
|
||||
}
|
||||
catch (Exception e) {
|
||||
BootLanguageServerPlugin.getDefault().getLog().error("Failed to reload Rewrite Recipes!", e);
|
||||
BootLanguageServerPlugin.getDefault().getLog().error("Failed to reload OpenRewrite Recipes!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,12 @@ import com.google.gson.JsonSerializer;
|
||||
@SuppressWarnings("restriction")
|
||||
public class RewriteRefactoringsHandler extends AbstractHandler {
|
||||
|
||||
public enum RecipeFilter {
|
||||
ALL,
|
||||
BOOT_UPGRADE,
|
||||
NON_BOOT_UPGRADE
|
||||
}
|
||||
|
||||
private static class DurationTypeConverter implements JsonSerializer<Duration>, JsonDeserializer<Duration> {
|
||||
@Override
|
||||
public JsonElement serialize(Duration src, Type srcType, JsonSerializationContext context) {
|
||||
@@ -73,6 +79,16 @@ public class RewriteRefactoringsHandler extends AbstractHandler {
|
||||
|
||||
private static final String REWRITE_REFACTORINGS_LIST = "sts/rewrite/list";
|
||||
private static final String REWRITE_REFACTORINGS_EXEC = "sts/rewrite/execute";
|
||||
|
||||
private RecipeFilter recipeFilter;
|
||||
|
||||
public RewriteRefactoringsHandler() {
|
||||
this(RecipeFilter.ALL);
|
||||
}
|
||||
|
||||
public RewriteRefactoringsHandler(RecipeFilter recipeFilter) {
|
||||
this.recipeFilter = recipeFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
@@ -96,7 +112,7 @@ public class RewriteRefactoringsHandler extends AbstractHandler {
|
||||
final String uri = project.getLocationURI().toString();
|
||||
ExecuteCommandParams commandParams = new ExecuteCommandParams();
|
||||
commandParams.setCommand(REWRITE_REFACTORINGS_LIST);
|
||||
commandParams.setArguments(List.of(uri));
|
||||
commandParams.setArguments(List.of(uri, recipeFilter.toString()));
|
||||
|
||||
try {
|
||||
List<Object> allRewriteRecipesJson = new ArrayList<>();
|
||||
@@ -152,5 +168,16 @@ public class RewriteRefactoringsHandler extends AbstractHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static class UpgradeBootVersion extends RewriteRefactoringsHandler {
|
||||
public UpgradeBootVersion() {
|
||||
super(RecipeFilter.BOOT_UPGRADE);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RefactorBootProject extends RewriteRefactoringsHandler {
|
||||
public RefactorBootProject() {
|
||||
super(RecipeFilter.NON_BOOT_UPGRADE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public class StringListEditor extends ListEditor {
|
||||
}
|
||||
|
||||
public static String[] decode(String value) {
|
||||
if (value.isEmpty()) {
|
||||
return new String[0];
|
||||
}
|
||||
return value.split(DELIMITER);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user