Categorize boot problems. Boot 3 reconciling.
This commit is contained in:
@@ -32,7 +32,8 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
|
||||
com.google.gson,
|
||||
org.eclipse.lsp4e.jdt;bundle-version="0.10.0",
|
||||
org.springsource.ide.eclipse.commons.boot.ls,
|
||||
org.springframework.ide.eclipse.editor.support
|
||||
org.springframework.ide.eclipse.editor.support,
|
||||
com.google.guava
|
||||
Import-Package: com.google.common.base,
|
||||
com.google.common.collect,
|
||||
com.google.gson;version="2.7.0",
|
||||
|
||||
@@ -132,24 +132,6 @@
|
||||
name="Spring Boot Language Server">
|
||||
</page>
|
||||
|
||||
<page
|
||||
name="Properties Editor"
|
||||
category="org.springframework.tooling.boot.ls.preferences"
|
||||
class="org.springframework.tooling.boot.ls.prefs.ApplicationPropertiesEditorProblemSeverityPrefsPage"
|
||||
id="org.springframework.tooling.boot.ls.prefs.ApplicationPropertiesEditorProblemSeverityPrefsPage">
|
||||
</page>
|
||||
<page
|
||||
name="Yaml Editor"
|
||||
category="org.springframework.tooling.boot.ls.preferences"
|
||||
class="org.springframework.tooling.boot.ls.prefs.ApplicationYamlEditorProblemSeverityPrefsPage"
|
||||
id="org.springframework.tooling.boot.ls.prefs.ApplicationYamlEditorProblemSeverityPrefsPage">
|
||||
</page>
|
||||
<page
|
||||
name="Java Editor"
|
||||
category="org.springframework.tooling.boot.ls.preferences"
|
||||
class="org.springframework.tooling.boot.ls.prefs.SpringJavaProblemSeverityPrefsPage"
|
||||
id="org.springframework.tooling.boot.ls.prefs.SpringJavaProblemSeverityPrefsPage">
|
||||
</page>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.keys.IBindingService;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.springframework.tooling.boot.ls.prefs.CategoryProblemsSeverityPrefsPage;
|
||||
|
||||
/**
|
||||
* Boot-Java LS extension plugin
|
||||
@@ -51,7 +52,11 @@ public class BootLanguageServerPlugin extends AbstractUIPlugin {
|
||||
super.start(context);
|
||||
deactivateDuplicateKeybindings();
|
||||
BootJavaPreferencesPage.manageCodeMiningPreferences();
|
||||
|
||||
CategoryProblemsSeverityPrefsPage.loadProblemCategoriesIntoPreferences();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
@@ -32,6 +31,9 @@ import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Message;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.springframework.tooling.boot.ls.prefs.CategoryProblemsSeverityPrefsPage;
|
||||
import org.springframework.tooling.boot.ls.prefs.ProblemCategoryData;
|
||||
import org.springframework.tooling.boot.ls.prefs.ProblemCategoryData.CategoryToggleData;
|
||||
import org.springframework.tooling.ls.eclipse.commons.LanguageServerCommonsActivator;
|
||||
import org.springsource.ide.eclipse.commons.boot.ls.remoteapps.RemoteBootAppsDataHolder;
|
||||
import org.springsource.ide.eclipse.commons.boot.ls.remoteapps.RemoteBootAppsDataHolder.RemoteAppData;
|
||||
@@ -194,6 +196,7 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
settings.put("boot-java", bootJavaObj);
|
||||
|
||||
putValidationPreferences(settings);
|
||||
putValidationCategoryToggles(settings);
|
||||
|
||||
this.languageServer.getWorkspaceService().didChangeConfiguration(new DidChangeConfigurationParams(settings));
|
||||
}
|
||||
@@ -213,6 +216,23 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
Log.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void putValidationCategoryToggles(Map<String, Object> settings) {
|
||||
try {
|
||||
IEclipsePreferences prefs = BootLanguageServerPlugin.getPreferences();
|
||||
for (ProblemCategoryData category : CategoryProblemsSeverityPrefsPage.ALL_PROBLEM_CATEGORIES) {
|
||||
if (category.getToggle() != null) {
|
||||
CategoryToggleData toggle = category.getToggle();
|
||||
String val = prefs.get(toggle.getPreferenceKey(), null);
|
||||
if (val != null) {
|
||||
dotPut(settings, toggle.getPreferenceKey(), val);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void dotPut(Object _settings, String dottedProperty, Object value) {
|
||||
if (_settings instanceof Map) {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls.prefs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferencesUtil;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferityPageFromMetadata;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
|
||||
public class ApplicationPropertiesEditorProblemSeverityPrefsPage extends ProblemSeverityPreferityPageFromMetadata {
|
||||
|
||||
public static final ProblemSeverityPreferencesUtil util = new ProblemSeverityPreferencesUtil("problem.properties.");
|
||||
|
||||
public ApplicationPropertiesEditorProblemSeverityPrefsPage() throws IOException {
|
||||
super(util, LanguageServerProblemTypesMetadata.load().get("application-properties"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluginId() {
|
||||
return BootLanguageServerPlugin.PLUGIN_ID;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls.prefs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferencesUtil;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferityPageFromMetadata;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
|
||||
public class ApplicationYamlEditorProblemSeverityPrefsPage extends ProblemSeverityPreferityPageFromMetadata {
|
||||
|
||||
public static final ProblemSeverityPreferencesUtil util = new ProblemSeverityPreferencesUtil("problem.yaml.");
|
||||
|
||||
public ApplicationYamlEditorProblemSeverityPrefsPage() throws IOException {
|
||||
super(util, LanguageServerProblemTypesMetadata.load().get("application-yaml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluginId() {
|
||||
return BootLanguageServerPlugin.PLUGIN_ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*******************************************************************************
|
||||
* 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 java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.jface.preference.ComboFieldEditor;
|
||||
import org.eclipse.jface.preference.PreferenceManager;
|
||||
import org.eclipse.jface.preference.PreferenceNode;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferencesUtil;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferityPageFromMetadata;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
import org.springframework.tooling.boot.ls.prefs.ProblemCategoryData.CategoryToggleData;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class CategoryProblemsSeverityPrefsPage extends ProblemSeverityPreferityPageFromMetadata {
|
||||
|
||||
public static ImmutableList<ProblemCategoryData> ALL_PROBLEM_CATEGORIES;
|
||||
|
||||
private static final String PREF_KEY_PREFIX = "";
|
||||
|
||||
private ProblemCategoryData category;
|
||||
|
||||
public CategoryProblemsSeverityPrefsPage(ProblemCategoryData category) {
|
||||
super(new ProblemSeverityPreferencesUtil("problem." + category.getId() + "."), category.getProblemTypes());
|
||||
this.category = category;
|
||||
setTitle(category.getLabel());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluginId() {
|
||||
return BootLanguageServerPlugin.PLUGIN_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeDefaults() {
|
||||
if (category.getToggle() != null) {
|
||||
IEclipsePreferences defaults = DefaultScope.INSTANCE.getNode(getPluginId());
|
||||
defaults.put(PREF_KEY_PREFIX + category.getToggle().getPreferenceKey(), category.getToggle().getDefaultValue());
|
||||
|
||||
}
|
||||
super.initializeDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
if (category.getToggle() != null) {
|
||||
CategoryToggleData toggle = category.getToggle();
|
||||
ComboFieldEditor field = new ComboFieldEditor(
|
||||
PREF_KEY_PREFIX + toggle.getPreferenceKey(),
|
||||
toggle.getLabel(),
|
||||
createToggleValues(toggle.getValues()),
|
||||
getFieldEditorParent()
|
||||
);
|
||||
addField(field);
|
||||
}
|
||||
super.createFieldEditors();
|
||||
}
|
||||
|
||||
private static String[][] createToggleValues(String[] values) {
|
||||
String[][] res = new String[values.length][2];
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
String value = values[i];
|
||||
res[i][0] = value.substring(0, 1).toUpperCase() + value.substring(1).toLowerCase();
|
||||
res[i][1] = value;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void loadProblemCategoriesIntoPreferences() throws Exception {
|
||||
List<ProblemCategoryData> categories = LanguageServerProblemTypesMetadata.load();
|
||||
|
||||
Collections.sort(categories, (e1, e2) -> e1.getOrder() - e2.getOrder());
|
||||
|
||||
for (ProblemCategoryData categoryData : categories) {
|
||||
|
||||
//create a new PreferenceNode that will appear in the Preference window
|
||||
PreferenceNode node = new PreferenceNode(BootLanguageServerPlugin.PLUGIN_ID + "." + categoryData.getId()) {
|
||||
|
||||
@Override
|
||||
public void createPage() {
|
||||
CategoryProblemsSeverityPrefsPage page = new CategoryProblemsSeverityPrefsPage(categoryData);
|
||||
page.init(PlatformUI.getWorkbench());
|
||||
page.setTitle(getLabelText());
|
||||
setPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabelText() {
|
||||
return categoryData.getLabel();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//use workbenches's preference manager
|
||||
PreferenceManager pm= PlatformUI.getWorkbench().getPreferenceManager();
|
||||
|
||||
pm.addTo("org.eclipse.lsp4e.preferences/org.springframework.tooling.ls.eclipse.commons.console.preferences/org.springframework.tooling.boot.ls.preferences", node); //add the node in the PreferenceManager
|
||||
}
|
||||
|
||||
ALL_PROBLEM_CATEGORIES = ImmutableList.copyOf(categories);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* Copyright (c) 2020, 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
|
||||
@@ -11,19 +11,35 @@
|
||||
package org.springframework.tooling.boot.ls.prefs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferityPageFromMetadata.ProblemTypeData;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class LanguageServerProblemTypesMetadata {
|
||||
|
||||
public static Map<String, ProblemTypeData[]> load() throws IOException {
|
||||
public static List<ProblemCategoryData> load() throws IOException {
|
||||
File root = FileLocator.getBundleFile(BootLanguageServerPlugin.getDefault().getBundle());
|
||||
File metadataFile = root.toPath().resolve("servers/spring-boot-language-server/BOOT-INF/classes/problem-types.json").toFile();
|
||||
return ApplicationPropertiesEditorProblemSeverityPrefsPage.readFromFile(metadataFile);
|
||||
return readCategoriesFromFile(metadataFile);
|
||||
}
|
||||
|
||||
public static List<ProblemCategoryData> readCategoriesFromFile(File metadataFile) throws FileNotFoundException, IOException {
|
||||
Gson gson = new Gson();
|
||||
TypeToken<List<ProblemCategoryData>> tt = new TypeToken<List<ProblemCategoryData>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
};
|
||||
try (Reader json = new FileReader(metadataFile)) {
|
||||
return gson.fromJson(json, tt.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*******************************************************************************
|
||||
* 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.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferityPageFromMetadata.ProblemTypeData;
|
||||
|
||||
public class ProblemCategoryData {
|
||||
private String id;
|
||||
private String label;
|
||||
private String description;
|
||||
private CategoryToggleData toggle;
|
||||
private int order;
|
||||
private ProblemTypeData[] problemTypes;
|
||||
|
||||
ProblemCategoryData() {}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public CategoryToggleData getToggle() {
|
||||
return toggle;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ProblemTypeData[] getProblemTypes() {
|
||||
return problemTypes;
|
||||
}
|
||||
|
||||
public static class CategoryToggleData {
|
||||
private String label;
|
||||
|
||||
private String[] values;
|
||||
|
||||
private String preferenceKey;
|
||||
|
||||
private String defaultValue;
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String[] getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public String getPreferenceKey() {
|
||||
return preferenceKey;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.boot.ls.prefs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferencesUtil;
|
||||
import org.springframework.ide.eclipse.editor.support.preferences.ProblemSeverityPreferityPageFromMetadata;
|
||||
import org.springframework.tooling.boot.ls.BootLanguageServerPlugin;
|
||||
|
||||
public class SpringJavaProblemSeverityPrefsPage extends ProblemSeverityPreferityPageFromMetadata {
|
||||
|
||||
public static final ProblemSeverityPreferencesUtil util = new ProblemSeverityPreferencesUtil("problem.java.");
|
||||
|
||||
public SpringJavaProblemSeverityPrefsPage() throws IOException {
|
||||
super(util, LanguageServerProblemTypesMetadata.load().get("java"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluginId() {
|
||||
return BootLanguageServerPlugin.PLUGIN_ID;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user