Preference for "Rewrite Refactorings" in Eclipse. Default is 'true'
This commit is contained in:
@@ -33,7 +33,8 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
|
||||
org.eclipse.lsp4e.jdt;bundle-version="0.10.0",
|
||||
org.springsource.ide.eclipse.commons.boot.ls,
|
||||
org.springframework.ide.eclipse.editor.support,
|
||||
com.google.guava
|
||||
com.google.guava,
|
||||
org.eclipse.core.expressions
|
||||
Import-Package: com.google.common.base,
|
||||
com.google.common.collect,
|
||||
com.google.gson;version="2.7.0",
|
||||
|
||||
@@ -137,6 +137,18 @@
|
||||
id="org.springframework.tooling.boot.ls.rewrite"
|
||||
name="Rewrite">
|
||||
</page>
|
||||
<page
|
||||
category="org.springframework.tooling.boot.ls.rewrite"
|
||||
class="org.springframework.tooling.boot.ls.RecipeFiltersPreferencePage"
|
||||
id="org.springframework.tooling.boot.ls.rewrite.filters"
|
||||
name="Filter Recipes">
|
||||
</page>
|
||||
<page
|
||||
category="org.springframework.tooling.boot.ls.rewrite"
|
||||
class="org.springframework.tooling.boot.ls.PlugRecipesPreferencePage"
|
||||
id="org.springframework.tooling.boot.ls.rewrite.load"
|
||||
name="Plug Recipes">
|
||||
</page>
|
||||
|
||||
</extension>
|
||||
|
||||
@@ -413,15 +425,24 @@
|
||||
</and>
|
||||
</or>
|
||||
</iterate>
|
||||
<systemTest
|
||||
property="sts.rewrite.recipes"
|
||||
value="true">
|
||||
</systemTest>
|
||||
<test
|
||||
property="org.springframework.tooling.boot.ls.areRewriteProjectRefactoringsOn">
|
||||
</test>
|
||||
</and>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.expressions.propertyTesters">
|
||||
<propertyTester
|
||||
class="org.springframework.tooling.boot.ls.prefs.PrefsPropertyTester"
|
||||
id="org.springframework.tooling.boot.ls"
|
||||
namespace="org.springframework.tooling.boot.ls"
|
||||
properties="areRewriteProjectRefactoringsOn"
|
||||
type="java.lang.Object">
|
||||
</propertyTester>
|
||||
</extension>
|
||||
<!--
|
||||
<extension
|
||||
point="org.eclipse.wildwebdeveloper.xml.lemminxExtension">
|
||||
|
||||
@@ -38,4 +38,6 @@ public class Constants {
|
||||
public static final String PREF_REWRITE_RECIPES_SCAN_FILES = "boot-java.rewrite.scan-files";
|
||||
|
||||
public static final String PREF_REWRITE_RECIPES_SCAN_DIRS = "boot-java.rewrite.scan-directories";
|
||||
|
||||
public static final String PREF_REWRITE_PROJECT_REFACTORINGS = "boot-java.rewrite.project-refactorings";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.PathEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.springframework.tooling.boot.ls.prefs.FileListEditor;
|
||||
|
||||
public class PlugRecipesPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
setPreferenceStore(BootLanguageServerPlugin.getDefault().getPreferenceStore());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
Composite fieldEditorParent = getFieldEditorParent();
|
||||
|
||||
addField(new FileListEditor(Constants.PREF_REWRITE_RECIPES_SCAN_FILES, "JAR and YAML files to scan for Recipes",
|
||||
"Select JARs and YAML files:", fieldEditorParent, List.of("jar", "yml", "yaml")));
|
||||
|
||||
addField(new PathEditor(Constants.PREF_REWRITE_RECIPES_SCAN_DIRS, "Directories to scan for Recipes",
|
||||
"Select directory to scan for Recipes", fieldEditorParent));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
preferenceStore.setDefault(Constants.PREF_SCAN_JAVA_TEST_SOURCES, false);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_RECONCILE, false);
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_PROJECT_REFACTORINGS, true);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_REWRITE_RECIPE_FILTERS, StringListEditor.encode(new String[] {
|
||||
"org.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls;
|
||||
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.springframework.tooling.boot.ls.prefs.StringListEditor;
|
||||
|
||||
public class RecipeFiltersPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
@Override
|
||||
public void init(IWorkbench workbench) {
|
||||
setPreferenceStore(BootLanguageServerPlugin.getDefault().getPreferenceStore());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
Composite fieldEditorParent = getFieldEditorParent();
|
||||
|
||||
addField(new StringListEditor(fieldEditorParent, Constants.PREF_REWRITE_RECIPE_FILTERS,
|
||||
"Recipe filter IDs and patterns", "Filter Value",
|
||||
"Either exact ID or pattern with '*' as the wild-card:", text -> text.isBlank() ? "Cannot be blank" : null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.PathEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.springframework.tooling.boot.ls.prefs.FileListEditor;
|
||||
import org.springframework.tooling.boot.ls.prefs.StringListEditor;
|
||||
|
||||
public class RewritePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
@@ -22,19 +27,12 @@ public class RewritePreferencePage extends FieldEditorPreferencePage implements
|
||||
protected void createFieldEditors() {
|
||||
Composite fieldEditorParent = getFieldEditorParent();
|
||||
|
||||
addField(new BooleanFieldEditor(Constants.PREF_REWRITE_PROJECT_REFACTORINGS,
|
||||
"Project refactoring actions", fieldEditorParent));
|
||||
|
||||
addField(new BooleanFieldEditor(Constants.PREF_REWRITE_RECONCILE,
|
||||
"Experimental reconciling for Java source based on Rewrite project", fieldEditorParent));
|
||||
|
||||
addField(new StringListEditor(fieldEditorParent, Constants.PREF_REWRITE_RECIPE_FILTERS,
|
||||
"Recipe filter IDs and patterns", "Filter Value",
|
||||
"Either exact ID or pattern with '*' as the wild-card:", text -> text.isBlank() ? "Cannot be blank" : null));
|
||||
|
||||
addField(new FileListEditor(Constants.PREF_REWRITE_RECIPES_SCAN_FILES, "JAR and YAML files to scan for Recipes",
|
||||
"Select JARs and YAML files:", fieldEditorParent, List.of("jar", "yml", "yaml")));
|
||||
|
||||
addField(new PathEditor(Constants.PREF_REWRITE_RECIPES_SCAN_DIRS, "Directories to scan for Recipes",
|
||||
"Select directory to scan for Recipes", fieldEditorParent));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls.prefs;
|
||||
|
||||
import org.eclipse.core.expressions.PropertyTester;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
import org.springframework.tooling.boot.ls.Constants;
|
||||
|
||||
public class PrefsPropertyTester extends PropertyTester {
|
||||
|
||||
public PrefsPropertyTester() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
|
||||
switch (property) {
|
||||
case "areRewriteProjectRefactoringsOn":
|
||||
return BootLanguageServerPlugin.getDefault().getPreferenceStore().getBoolean(Constants.PREF_REWRITE_PROJECT_REFACTORINGS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,7 +76,7 @@
|
||||
],
|
||||
"explorer/context": [
|
||||
{
|
||||
"when": "resourceFilename == pom.xml && config.boot-java.rewrite.globa-commands.on == true",
|
||||
"when": "resourceFilename == pom.xml && config.boot-java.rewrite.refactorings.on == true",
|
||||
"command": "vscode-spring-boot.rewrite.list",
|
||||
"group": "SpringBoot"
|
||||
}
|
||||
@@ -89,7 +89,7 @@
|
||||
"category": "Spring Boot"
|
||||
},
|
||||
{
|
||||
"enablement": "config.boot-java.rewrite.globa-commands.on == true",
|
||||
"enablement": "config.boot-java.rewrite.refactorings.on == true",
|
||||
"command": "vscode-spring-boot.rewrite.list",
|
||||
"category": "Spring Boot",
|
||||
"title": "Rewrite Refactorings..."
|
||||
@@ -106,11 +106,6 @@
|
||||
"title": "Features",
|
||||
"order": 100,
|
||||
"properties": {
|
||||
"boot-java.rewrite.globa-commands.on": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Experimental support for Rewrite recipes refactoring the whole maven projects via commands"
|
||||
},
|
||||
"boot-java.live-information.automatic-connection.on": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
@@ -193,6 +188,11 @@
|
||||
"title": "Rewrite",
|
||||
"order": 400,
|
||||
"properties": {
|
||||
"boot-java.rewrite.refactorings.on": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Recipes refactoring entire Maven project via commands"
|
||||
},
|
||||
"boot-java.rewrite.reconcile": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
||||
Reference in New Issue
Block a user