GH-1345: use diagnostics tags from lsp protocol to mark unnecessary and deprecated things accordingly

This commit is contained in:
Martin Lippert
2024-11-18 13:06:59 +01:00
parent b4292f63c9
commit e285e3abb7
15 changed files with 238 additions and 93 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* Copyright (c) 2016, 2024 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,6 +11,9 @@
package org.springframework.ide.vscode.commons.languageserver.reconcile;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
import org.springframework.ide.vscode.commons.util.text.IDocument;
/**
@@ -51,6 +54,11 @@ public class BadWordReconcileEngine implements IReconcileEngine {
public ProblemCategory getCategory() {
return null;
}
@Override
public List<DiagnosticTag> getTags() {
return null;
}
}
private final String[] BADWORDS = {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* Copyright (c) 2016, 2024 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,6 +11,10 @@
package org.springframework.ide.vscode.commons.languageserver.reconcile;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
/**
* Besides the methods below, the only hard requirement for a 'problem type' is
* that it is a unique object that is not 'equals' to any other object.
@@ -29,4 +33,5 @@ public interface ProblemType {
String getLabel();
String getDescription();
ProblemCategory getCategory();
List<DiagnosticTag> getTags();
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* Copyright (c) 2017, 2024 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
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.springframework.ide.vscode.commons.languageserver.reconcile;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
public class ProblemTypes {
/**
@@ -24,7 +28,7 @@ public class ProblemTypes {
* @return A newly create problem type.
*/
@Deprecated
public static ProblemType create(String typeName, ProblemSeverity defaultSeverity, ProblemCategory category) {
public static ProblemType create(String typeName, ProblemSeverity defaultSeverity, ProblemCategory category, List<DiagnosticTag> tags) {
return new ProblemType() {
@Override
public String toString() {
@@ -50,6 +54,10 @@ public class ProblemTypes {
public ProblemCategory getCategory() {
return category;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
};
}

View File

@@ -850,10 +850,14 @@ public final class SimpleLanguageServer implements Sts4LanguageServer, SpringInd
Diagnostic d = new Diagnostic();
d.setCode(problem.getCode());
d.setMessage(problem.getMessage());
Range rng = docRef.get().toRange(problem.getOffset(), problem.getLength());
d.setRange(rng);
d.setSeverity(severity);
d.setSource(getServer().EXTENSION_ID);
d.setTags(problem.getType().getTags());
List<QuickfixData<?>> fixes = problem.getQuickfixes();
// Copy original diagnsotic without the data field to avoid stackoverflow is hashCode() method call

View File

@@ -15,6 +15,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.lsp4j.DiagnosticTag;
import org.springframework.ide.vscode.commons.languageserver.quickfix.Quickfix.QuickfixData;
import org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixType;
import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemCategory;
@@ -53,8 +54,8 @@ public class YamlSchemaProblems {
public static final ProblemType SYNTAX_PROBLEM = problemType("YamlSyntaxProblem", CATEGORY);
public static final ProblemType SCHEMA_PROBLEM = problemType("YamlSchemaProblem", CATEGORY);
public static final ProblemType DEPRECATED_PROPERTY = problemType("DeprecatedProperty", ProblemSeverity.WARNING, CATEGORY);
public static final ProblemType DEPRECATED_VALUE = problemType("DeprecatedValue", ProblemSeverity.WARNING, CATEGORY);
public static final ProblemType DEPRECATED_PROPERTY = problemType("DeprecatedProperty", ProblemSeverity.WARNING, CATEGORY, List.of(DiagnosticTag.Deprecated));
public static final ProblemType DEPRECATED_VALUE = problemType("DeprecatedValue", ProblemSeverity.WARNING, CATEGORY, List.of(DiagnosticTag.Deprecated));
public static final ProblemType MISSING_PROPERTY = problemType("MissingProperty", ProblemSeverity.ERROR, CATEGORY);
public static final ProblemType EXTRA_PROPERTY = problemType("ExtraProperty", ProblemSeverity.ERROR, CATEGORY);
public static final ProblemType EMPTY_OPTIONAL_STRING = problemType("EmptyOptionalString", ProblemSeverity.WARNING, CATEGORY);
@@ -63,8 +64,12 @@ public class YamlSchemaProblems {
MISSING_PROPERTY, EXTRA_PROPERTY
);
public static ProblemType problemType(final String typeName, ProblemSeverity defaultSeverity, ProblemCategory category, List<DiagnosticTag> tags) {
return ProblemTypes.create(typeName, defaultSeverity, category, tags);
}
public static ProblemType problemType(final String typeName, ProblemSeverity defaultSeverity, ProblemCategory category) {
return ProblemTypes.create(typeName, defaultSeverity, category);
return problemType(typeName, defaultSeverity, category, null);
}
public static ProblemType problemType(final String typeName, ProblemCategory category) {

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 VMware, Inc.
* Copyright (c) 2022, 2024 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
@@ -12,6 +12,9 @@ package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.*;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -19,42 +22,37 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
public enum Boot2JavaProblemType implements ProblemType {
JAVA_AUTOWIRED_CONSTRUCTOR(WARNING, "Unnecessary `@Autowired` over the only constructor", "Unnecessary `@Autowired`"),
JAVA_PUBLIC_BEAN_METHOD(HINT, "Public modifier on `@Bean` method. They no longer have to be public visibility to be usable by Spring.", "public `@Bean` method"),
JAVA_TEST_SPRING_EXTENSION(WARNING, "`@SpringBootTest` and all test slice annotations already applies `@SpringExtension` as of Spring Boot 2.1.0.", "Unnecessary `@SpringExtension`"),
JAVA_AUTOWIRED_CONSTRUCTOR(WARNING, "Unnecessary `@Autowired` over the only constructor", "Unnecessary `@Autowired`", List.of(DiagnosticTag.Unnecessary)),
JAVA_PUBLIC_BEAN_METHOD(HINT, "Public modifier on `@Bean` method. They no longer have to be public visibility to be usable by Spring.", "public `@Bean` method", List.of(DiagnosticTag.Unnecessary)),
JAVA_TEST_SPRING_EXTENSION(WARNING, "`@SpringBootTest` and all test slice annotations already applies `@SpringExtension` as of Spring Boot 2.1.0.", "Unnecessary `@SpringExtension`", List.of(DiagnosticTag.Unnecessary)),
JAVA_CONSTRUCTOR_PARAMETER_INJECTION(IGNORE, "Use constructor parameter injection", "Use constructor parameter injection"),
JAVA_PRECISE_REQUEST_MAPPING(HINT, "Use precise mapping annotation, i.e. '@GetMapping', '@PostMapping', etc.", "Use precise mapping annotation, i.e. '@GetMapping', '@PostMapping', etc."),
JAVA_REPOSITORY(WARNING, "Unnecessary `@Repository`", "Unnecessary `@Repository`"),
JAVA_REPOSITORY(WARNING, "Unnecessary `@Repository`", "Unnecessary `@Repository`", List.of(DiagnosticTag.Unnecessary)),
JAVA_LAMBDA_DSL(INFO, "Consider switching to Lambda DSL syntax", "Switch to Lambda DSL syntax"),
MISSING_CONFIGURATION_ANNOTATION(WARNING, "Class likely missing '@Configuration' annotation, i.e. has Bean methods but no '@Configuration' annotation", "Missing '@Configuration'"),
HTTP_SECURITY_AUTHORIZE_HTTP_REQUESTS(WARNING, "'HttpSecurity.authroizeRequests(...)' API and related classes are to be deprecated use new `authorizeHttpRequests(...) and related classes", "Usage of old 'HttpSecurity.authroizeRequests(...)' API"),
WEB_SECURITY_CONFIGURER_ADAPTER(WARNING, "'WebSecurityConfigurerAdapter' is removed in Spring-Security 6.x. Refactor classes extending the 'WebSecurityConfigurerAdapter' into 'Configuration' beans and methods into 'Bean' definitions ", "Replace usage of 'WebSecurityConfigurerAdapter' as this class to be removed in Security 6.x"),
DOMAIN_ID_FOR_REPOSITORY(ERROR, "Invalid Domain ID type for Spring Data Repository", "Invalid Domain ID Type for Spring Data Repository"),
WEB_ANNOTATION_NAMES(HINT, "Web annotation names are unnecessary when it is the same as method parameter name", "Implicit web annotations names");
WEB_ANNOTATION_NAMES(HINT, "Web annotation names are unnecessary when it is the same as method parameter name", "Implicit web annotations names", List.of(DiagnosticTag.Unnecessary));
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private List<DiagnosticTag> tags;
private Boot2JavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private Boot2JavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private Boot2JavaProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private Boot2JavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private Boot2JavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
@Override
@@ -63,7 +61,7 @@ public enum Boot2JavaProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -89,4 +87,9 @@ public enum Boot2JavaProblemType implements ProblemType {
return SpringProblemCategories.BOOT_2;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2023 Pivotal, Inc.
* Copyright (c) 2020, 2024 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
@@ -12,6 +12,9 @@ package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -24,23 +27,27 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
public enum Boot3JavaProblemType implements ProblemType {
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"),
MODULITH_TYPE_REF_VIOLATION(ERROR, "Modulith restricted type reference", "Modulith restricted type reference");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private Boot3JavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private Boot3JavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private Boot3JavaProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private Boot3JavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private Boot3JavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
@Override
@@ -49,7 +56,7 @@ public enum Boot3JavaProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -74,5 +81,10 @@ public enum Boot3JavaProblemType implements ProblemType {
public ProblemCategory getCategory() {
return SpringProblemCategories.BOOT_3;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 VMware, Inc.
* Copyright (c) 2022, 2024 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
@@ -12,6 +12,9 @@ package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -23,17 +26,23 @@ public enum SpelProblemType implements ProblemType {
PROPERTY_PLACE_HOLDER_SYNTAX(ERROR, "Property place holder raised a ParseException", "Property Place Holder Syntax");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private SpelProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private SpelProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private SpelProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private SpelProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private SpelProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
@Override
@@ -42,7 +51,7 @@ public enum SpelProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -67,4 +76,9 @@ public enum SpelProblemType implements ProblemType {
public ProblemCategory getCategory() {
return SpringProblemCategories.SPEL;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -1,7 +1,20 @@
/*******************************************************************************
* Copyright (c) 2024 Broadcom, 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:
* Broadcom, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -10,23 +23,27 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
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 final String description;
private String label;
private final List<DiagnosticTag> tags;
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private SpringAotJavaProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
@Override
@@ -35,7 +52,7 @@ public enum SpringAotJavaProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -61,4 +78,9 @@ public enum SpringAotJavaProblemType implements ProblemType {
return SpringProblemCategories.SPRING_AOT;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -12,6 +12,9 @@ package org.springframework.ide.vscode.boot.java.cron;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -23,17 +26,23 @@ public enum CronProblemType implements ProblemType {
FIELD(ERROR, "Field", "Cron Expression field");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private CronProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private CronProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private CronProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private CronProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private CronProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
@Override
@@ -42,7 +51,7 @@ public enum CronProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -67,4 +76,9 @@ public enum CronProblemType implements ProblemType {
public ProblemCategory getCategory() {
return SpringProblemCategories.CRON;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -12,6 +12,9 @@ package org.springframework.ide.vscode.boot.java.data.jpa.queries;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -24,17 +27,23 @@ public enum QueryProblemType implements ProblemType {
SQL_SYNTAX(ERROR, "Syntax", "SQL Query Syntax");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private QueryProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
private QueryProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private QueryProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private QueryProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private QueryProblemType(ProblemSeverity defaultSeverity, String description) {
this(defaultSeverity, description, null);
}
@Override
@@ -43,7 +52,7 @@ public enum QueryProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -68,5 +77,10 @@ public enum QueryProblemType implements ProblemType {
public ProblemCategory getCategory() {
return SpringProblemCategories.DATA_QUERY;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Pivotal, Inc.
* Copyright (c) 2015, 2024 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
@@ -13,6 +13,9 @@ package org.springframework.ide.vscode.boot.properties.reconcile;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -31,18 +34,24 @@ public enum ApplicationPropertiesProblemType implements ProblemType {
PROP_VALUE_TYPE_MISMATCH("Expecting a value of a certain type, but value doesn't parse as such"),
PROP_INVALID_BEAN_PROPERTY("Accessing a named property in a type that doesn't provide a property accessor with that name"),
PROP_UNKNOWN_PROPERTY(WARNING, "Property-key not found in any configuration metadata on the project's classpath"),
PROP_DEPRECATED(WARNING, "Property is marked as Deprecated"),
PROP_DEPRECATED(WARNING, "Property is marked as Deprecated", null, List.of(DiagnosticTag.Deprecated)),
PROP_DUPLICATE_KEY("Multiple assignments to the same property value"),
PROP_SYNTAX_ERROR("Syntax Error");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private ApplicationPropertiesProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private ApplicationPropertiesProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private ApplicationPropertiesProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private ApplicationPropertiesProblemType(ProblemSeverity defaultSeverity, String description) {
@@ -58,7 +67,7 @@ public enum ApplicationPropertiesProblemType implements ProblemType {
}
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -83,4 +92,9 @@ public enum ApplicationPropertiesProblemType implements ProblemType {
return SpringProblemCategories.PROPERTIES;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 VMware, Inc.
* Copyright (c) 2022, 2024 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
@@ -14,6 +14,9 @@ import static org.springframework.ide.vscode.commons.languageserver.reconcile.Pr
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.INFO;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -22,27 +25,29 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
public enum VersionValidationProblemType implements ProblemType {
SUPPORTED_OSS_VERSION(IGNORE, "Supported OSS Boot Version", "Supported OSS Boot Version"),
UNSUPPORTED_OSS_VERSION(WARNING, "Unsupported OSS Version", "Unsupported OSS Version"),
UNSUPPORTED_COMMERCIAL_VERSION(WARNING, "Unsupported Commercial Version", "Unsupported Commercial Version"),
SUPPORTED_COMMERCIAL_VERSION(IGNORE, "Supported Commercial Version", "Supported Commercial Version"),
UPDATE_LATEST_MAJOR_VERSION(IGNORE, "Update to Latest Major Version", "Update to Latest Major Version"),
UPDATE_LATEST_MINOR_VERSION(INFO, "Update to Latest Minor Version", "Update to Latest Minor Version"),
UPDATE_LATEST_PATCH_VERSION(WARNING, "Update to Latest Patch Version", "Update to Latest Patch Version");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private VersionValidationProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private VersionValidationProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private VersionValidationProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
@Override
@@ -77,4 +82,9 @@ public enum VersionValidationProblemType implements ProblemType {
return SpringProblemCategories.VERSION_VALIDATION;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}

View File

@@ -56,9 +56,7 @@ import org.springframework.ide.vscode.commons.yaml.ast.NodeRef.Kind;
import org.springframework.ide.vscode.commons.yaml.ast.NodeRef.TupleValueRef;
import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil;
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
import org.springframework.ide.vscode.commons.yaml.path.YamlPath;
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlASTReconciler;
import org.springframework.ide.vscode.commons.yaml.util.YamlUtil;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.NodeId;

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Pivotal, Inc.
* Copyright (c) 2015, 2024 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
@@ -13,6 +13,9 @@ package org.springframework.ide.vscode.boot.yaml.reconcile;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.ERROR;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
import java.util.List;
import org.eclipse.lsp4j.DiagnosticTag;
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;
@@ -32,19 +35,25 @@ public enum ApplicationYamlProblemType implements ProblemType {
YAML_EXPECT_MAPPING("Expecting a 'mapping' node but found something else"),
YAML_EXPECT_BEAN_PROPERTY_NAME("Expecting a 'bean property' name but found something more complex"),
YAML_INVALID_BEAN_PROPERTY("Accessing a named property in a type that doesn't provide a property accessor with that name"),
YAML_DEPRECATED_ERROR(ERROR, "Property is marked as Deprecated(Error)"),
YAML_DEPRECATED_WARNING(WARNING, "Property is marked as Deprecated(Warning)"),
YAML_DEPRECATED_ERROR(ERROR, "Property is marked as Deprecated(Error)", null, List.of(DiagnosticTag.Deprecated)),
YAML_DEPRECATED_WARNING(WARNING, "Property is marked as Deprecated(Warning)", null, List.of(DiagnosticTag.Deprecated)),
YAML_DUPLICATE_KEY("A mapping node contains multiple entries for the same key"),
YAML_SHOULD_ESCAPE(WARNING, "This key contains special characters and should probably be escaped by surrounding it with '[]'");
private final ProblemSeverity defaultSeverity;
private String description;
private final String description;
private String label;
private final List<DiagnosticTag> tags;
private ApplicationYamlProblemType(ProblemSeverity defaultSeverity, String description, String label) {
private ApplicationYamlProblemType(ProblemSeverity defaultSeverity, String description, String label, List<DiagnosticTag> tags) {
this.description = description;
this.defaultSeverity = defaultSeverity;
this.label = label;
this.tags = tags;
}
private ApplicationYamlProblemType(ProblemSeverity defaultSeverity, String description, String label) {
this(defaultSeverity, description, label, null);
}
private ApplicationYamlProblemType(ProblemSeverity defaultSeverity, String description) {
@@ -62,7 +71,7 @@ public enum ApplicationYamlProblemType implements ProblemType {
public String getLabel() {
if (label==null) {
if (label == null) {
label = createDefaultLabel();
}
return label;
@@ -87,4 +96,9 @@ public enum ApplicationYamlProblemType implements ProblemType {
return SpringProblemCategories.YAML;
}
@Override
public List<DiagnosticTag> getTags() {
return tags;
}
}