Separate Spring AOT validations into a dedicated category

This commit is contained in:
aboyko
2022-11-04 15:15:00 -04:00
parent de524da138
commit cb7813109e
10 changed files with 171 additions and 76 deletions

View File

@@ -25,6 +25,9 @@ public class SpringProblemCategories {
public static final ProblemCategory BOOT_3 = new ProblemCategory("boot3", "Boot 3.x Validation",
new Toggle("Enablement", EnumSet.allOf(Toggle.Option.class), AUTO, "boot-java.validation.java.boot3"));
public static final ProblemCategory SPRING_AOT = new ProblemCategory("spring-aot", "Spring AOT Validation",
new Toggle("Enablement", EnumSet.of(OFF, ON), OFF, "boot-java.validation.java.spring-aot"));
public static final ProblemCategory PROPERTIES = new ProblemCategory("application-properties", "Properties Validation", null);
public static final ProblemCategory YAML = new ProblemCategory("application-yaml", "YAML Properties Validation", null);

View File

@@ -11,7 +11,6 @@
package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import org.springframework.ide.vscode.boot.common.SpringProblemCategories;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemCategory;
@@ -24,12 +23,6 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
*/
public enum Boot3JavaProblemType implements ProblemType {
JAVA_CONCRETE_BEAN_TYPE(WARNING, "Bean definition should have precise type for Spring 6 AOT", "Not precise bean defintion type"),
JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT(WARNING, "'BeanPostProcessor' behaviour is ignored in Spring 6 AOT", "'BeanPostProcessor' behaviour is ignored in AOT"),
JAVA_BEAN_NOT_REGISTERED_IN_AOT(WARNING, "Not registered as Bean", "Not registered as a Bean"),
JAVA_TYPE_NOT_SUPPORTED(ERROR, "Type no supported as of Spring Boot 3", "Type not supported as of Spring Boot 3"),
FACTORIES_KEY_NOT_SUPPORTED(ERROR, "Spring factories key not supported", "Spring factories key not supported");

View File

@@ -0,0 +1,64 @@
package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import org.springframework.ide.vscode.boot.common.SpringProblemCategories;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemCategory;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
public enum SpringAotJavaProblemType implements ProblemType {
JAVA_CONCRETE_BEAN_TYPE(WARNING, "Bean definition should have precise type", "Not precise bean defintion type"),
JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT(WARNING, "'BeanPostProcessor' behaviour is ignored", "'BeanPostProcessor' behaviour is ignored in AOT"),
JAVA_BEAN_NOT_REGISTERED_IN_AOT(WARNING, "Not registered as Bean", "Not registered as a Bean");
private final ProblemSeverity defaultSeverity;
private String description;
private String label;
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
}
@Override
public ProblemSeverity getDefaultSeverity() {
return defaultSeverity;
}
public String getLabel() {
if (label==null) {
label = createDefaultLabel();
}
return label;
}
@Override
public String getDescription() {
return description;
}
private String createDefaultLabel() {
String label = this.toString().substring(5).toLowerCase().replace('_', ' ');
return Character.toUpperCase(label.charAt(0)) + label.substring(1);
}
@Override
public String getCode() {
return name();
}
@Override
public ProblemCategory getCategory() {
return SpringProblemCategories.SPRING_AOT;
}
}

View File

@@ -24,7 +24,7 @@ import org.openrewrite.java.tree.J.ClassDeclaration;
import org.openrewrite.java.tree.J.MethodDeclaration;
import org.openrewrite.marker.Range;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemType;
import org.springframework.ide.vscode.commons.rewrite.config.RecipeCodeActionDescriptor;
@@ -81,7 +81,7 @@ public class BeanPostProcessingIgnoreInAotProblem implements RecipeCodeActionDes
@Override
public ProblemType getProblemType() {
return Boot3JavaProblemType.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT;
return SpringAotJavaProblemType.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT;
}
}

View File

@@ -31,7 +31,7 @@ import org.openrewrite.java.tree.JavaType.FullyQualified;
import org.openrewrite.java.tree.TypeUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.beans.ConfigBeanSymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
@@ -169,7 +169,7 @@ public class NotRegisteredBeansProblem implements RecipeCodeActionDescriptor {
@Override
public ProblemType getProblemType() {
return Boot3JavaProblemType.JAVA_BEAN_NOT_REGISTERED_IN_AOT;
return SpringAotJavaProblemType.JAVA_BEAN_NOT_REGISTERED_IN_AOT;
}
private static String typePattern(JavaType type) {

View File

@@ -26,7 +26,7 @@ import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.TypeUtils;
import org.openrewrite.marker.Range;
import org.springframework.context.ApplicationContext;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.rewrite.config.RecipeCodeActionDescriptor;
import org.springframework.ide.vscode.commons.rewrite.config.RecipeScope;
@@ -95,8 +95,8 @@ public class PreciseBeanTypeProblem implements RecipeCodeActionDescriptor {
}
@Override
public Boot3JavaProblemType getProblemType() {
return Boot3JavaProblemType.JAVA_CONCRETE_BEAN_TYPE;
public SpringAotJavaProblemType getProblemType() {
return SpringAotJavaProblemType.JAVA_CONCRETE_BEAN_TYPE;
}
}

View File

@@ -61,24 +61,6 @@
},
"order": 2,
"problemTypes": [
{
"code": "JAVA_CONCRETE_BEAN_TYPE",
"label": "Not precise bean defintion type",
"description": "Bean definition should have precise type for Spring 6 AOT",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT",
"label": "'BeanPostProcessor' behaviour is ignored in AOT",
"description": "'BeanPostProcessor' behaviour is ignored in Spring 6 AOT",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_NOT_REGISTERED_IN_AOT",
"label": "Not registered as a Bean",
"description": "Not registered as Bean",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_TYPE_NOT_SUPPORTED",
"label": "Type not supported as of Spring Boot 3",
@@ -93,10 +75,44 @@
}
]
},
{
"id": "spring-aot",
"label": "Spring AOT Validation",
"toggle": {
"label": "Enablement",
"values": [
"OFF",
"ON"
],
"preferenceKey": "boot-java.validation.java.spring-aot",
"defaultValue": "OFF"
},
"order": 3,
"problemTypes": [
{
"code": "JAVA_CONCRETE_BEAN_TYPE",
"label": "Not precise bean defintion type",
"description": "Bean definition should have precise type",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT",
"label": "'BeanPostProcessor' behaviour is ignored in AOT",
"description": "'BeanPostProcessor' behaviour is ignored",
"defaultSeverity": "WARNING"
},
{
"code": "JAVA_BEAN_NOT_REGISTERED_IN_AOT",
"label": "Not registered as a Bean",
"description": "Not registered as Bean",
"defaultSeverity": "WARNING"
}
]
},
{
"id": "application-properties",
"label": "Properties Validation",
"order": 3,
"order": 4,
"problemTypes": [
{
"code": "PROP_INVALID_BEAN_NAVIGATION",
@@ -169,7 +185,7 @@
{
"id": "application-yaml",
"label": "YAML Properties Validation",
"order": 4,
"order": 5,
"problemTypes": [
{
"code": "YAML_SYNTAX_ERROR",
@@ -263,7 +279,7 @@
"preferenceKey": "boot-java.validation.spel.on",
"defaultValue": "ON"
},
"order": 5,
"order": 6,
"problemTypes": [
{
"code": "JAVA_SPEL_EXPRESSION_SYNTAX",

View File

@@ -12,6 +12,7 @@ package org.springframework.ide.vscode.boot.test;
import org.junit.jupiter.api.Test;
import org.springframework.ide.vscode.boot.java.Boot2JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpelProblemType;
import org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType;
@@ -29,6 +30,7 @@ public class ProblemTypesMetadataTest {
reader.validate("application-yaml", ApplicationYamlProblemType.values());
reader.validate("boot2", Boot2JavaProblemType.values());
reader.validate("boot3", Boot3JavaProblemType.values());
reader.validate("spring-aot", SpringAotJavaProblemType.values());
reader.validate("spel", SpelProblemType.values());
}

View File

@@ -20,7 +20,6 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -28,6 +27,7 @@ import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
import org.springframework.ide.vscode.boot.java.Boot2JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpringAotJavaProblemType;
import org.springframework.ide.vscode.boot.java.Boot3JavaProblemType;
import org.springframework.ide.vscode.boot.java.SpelProblemType;
import org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType;
@@ -174,6 +174,7 @@ public class ProblemTypesToJson {
writer.collectProblemTypeData(Boot2JavaProblemType.values());
writer.collectProblemTypeData(ApplicationPropertiesProblemType.values());
writer.collectProblemTypeData(Boot3JavaProblemType.values());
writer.collectProblemTypeData(SpringAotJavaProblemType.values());
Collections.sort(writer.problemCategories);

View File

@@ -378,42 +378,6 @@
"ON"
]
},
"spring-boot.ls.problem.boot3.JAVA_CONCRETE_BEAN_TYPE": {
"type": "string",
"default": "WARNING",
"description": "Bean definition should have precise type for Spring 6 AOT",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.boot3.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "'BeanPostProcessor' behaviour is ignored in Spring 6 AOT",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.boot3.JAVA_BEAN_NOT_REGISTERED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "Not registered as Bean",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.boot3.JAVA_TYPE_NOT_SUPPORTED": {
"type": "string",
"default": "ERROR",
@@ -440,10 +404,62 @@
}
}
},
{
"id": "spring-aot",
"title": "Spring AOT Validation",
"order": 403,
"properties": {
"boot-java.validation.java.spring-aot": {
"type": "string",
"default": "OFF",
"description": "Enablement",
"enum": [
"OFF",
"ON"
]
},
"spring-boot.ls.problem.spring-aot.JAVA_CONCRETE_BEAN_TYPE": {
"type": "string",
"default": "WARNING",
"description": "Bean definition should have precise type",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.spring-aot.JAVA_BEAN_POST_PROCESSOR_IGNORED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "'BeanPostProcessor' behaviour is ignored",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
},
"spring-boot.ls.problem.spring-aot.JAVA_BEAN_NOT_REGISTERED_IN_AOT": {
"type": "string",
"default": "WARNING",
"description": "Not registered as Bean",
"enum": [
"IGNORE",
"INFO",
"WARNING",
"HINT",
"ERROR"
]
}
}
},
{
"id": "application-properties",
"title": "Properties Validation",
"order": 403,
"order": 404,
"properties": {
"spring-boot.ls.problem.application-properties.PROP_INVALID_BEAN_NAVIGATION": {
"type": "string",
@@ -582,7 +598,7 @@
{
"id": "application-yaml",
"title": "YAML Properties Validation",
"order": 404,
"order": 405,
"properties": {
"spring-boot.ls.problem.application-yaml.YAML_SYNTAX_ERROR": {
"type": "string",
@@ -745,7 +761,7 @@
{
"id": "spel",
"title": "SPEL Validation",
"order": 405,
"order": 406,
"properties": {
"boot-java.validation.spel.on": {
"type": "string",
@@ -811,4 +827,4 @@
"extensionDependencies": [
"redhat.java"
]
}
}