One more attempt to handle deprecation level
... in spring boot configuration metadata
This commit is contained in:
@@ -28,12 +28,10 @@ import java.io.Serializable;
|
||||
@SuppressWarnings("serial")
|
||||
public class Deprecation implements Serializable {
|
||||
|
||||
private Level level = Level.warning;
|
||||
private Level level = Level.WARNING;
|
||||
|
||||
private String reason;
|
||||
|
||||
private String shortReason;
|
||||
|
||||
private String replacement;
|
||||
|
||||
/**
|
||||
@@ -61,20 +59,6 @@ public class Deprecation implements Serializable {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* A single-line, single-sentence reason why the related property is deprecated, if
|
||||
* any.
|
||||
* @return the short deprecation reason
|
||||
* @see #getReason()
|
||||
*/
|
||||
public String getShortReason() {
|
||||
return this.shortReason;
|
||||
}
|
||||
|
||||
public void setShortReason(String shortReason) {
|
||||
this.shortReason = shortReason;
|
||||
}
|
||||
|
||||
/**
|
||||
* The full name of the property that replaces the related deprecated property, if
|
||||
* any.
|
||||
@@ -102,12 +86,12 @@ public class Deprecation implements Serializable {
|
||||
/**
|
||||
* The property is still bound.
|
||||
*/
|
||||
warning,
|
||||
WARNING,
|
||||
|
||||
/**
|
||||
* The property has been removed and is no longer bound.
|
||||
*/
|
||||
error
|
||||
ERROR
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.springframework.ide.eclipse.org.json.JSONArray;
|
||||
import org.springframework.ide.eclipse.org.json.JSONObject;
|
||||
@@ -156,6 +157,8 @@ class JsonReader {
|
||||
if (object.has("deprecation")) {
|
||||
JSONObject deprecationJsonObject = object.getJSONObject("deprecation");
|
||||
Deprecation deprecation = new Deprecation();
|
||||
deprecation.setLevel(parseDeprecationLevel(
|
||||
deprecationJsonObject.optString("level", null)));
|
||||
deprecation.setReason(deprecationJsonObject.optString("reason", null));
|
||||
deprecation
|
||||
.setReplacement(deprecationJsonObject.optString("replacement", null));
|
||||
@@ -164,6 +167,18 @@ class JsonReader {
|
||||
return (object.optBoolean("deprecated") ? new Deprecation() : null);
|
||||
}
|
||||
|
||||
private Deprecation.Level parseDeprecationLevel(String value) {
|
||||
if (value != null) {
|
||||
try {
|
||||
return Deprecation.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
// let's use the default
|
||||
}
|
||||
}
|
||||
return Deprecation.Level.WARNING;
|
||||
}
|
||||
|
||||
private Object readItemValue(Object value) {
|
||||
if (value instanceof JSONArray) {
|
||||
JSONArray array = (JSONArray) value;
|
||||
|
||||
@@ -404,7 +404,7 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler {
|
||||
|
||||
protected SpringPropertyProblem deprecatedPropertyProblem(String docUri, String name, String contextType, Node keyNode,
|
||||
String replace, String reason, Level level, QuickfixType fixType) {
|
||||
ApplicationYamlProblemType problemType = level==Level.error ? YAML_DEPRECATED_ERROR : YAML_DEPRECATED_WARNING;
|
||||
ApplicationYamlProblemType problemType = level==Level.ERROR ? YAML_DEPRECATED_ERROR : YAML_DEPRECATED_WARNING;
|
||||
SpringPropertyProblem problem = problem(problemType, keyNode, TypeUtil.deprecatedPropertyMessage(name, contextType, replace, reason));
|
||||
problem.setPropertyName(name);
|
||||
Range range = new Range(new Position(keyNode.getStartMark().getLine(), keyNode.getStartMark().getColumn()),
|
||||
|
||||
@@ -4026,7 +4026,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
data("spring.devtools.remote.debug.local-port", "java.lang.Integer",
|
||||
8000, "Local remote debug server port."
|
||||
);
|
||||
deprecate("spring.devtools.remote.debug.local-port", null, "No longer supported", Level.error);
|
||||
deprecate("spring.devtools.remote.debug.local-port", null, "No longer supported", Level.ERROR);
|
||||
|
||||
Editor editor = harness.newEditor(
|
||||
"spring:\n" +
|
||||
|
||||
Reference in New Issue
Block a user