From e285e3abb76c75ae321f3020e44f542a3dea4141 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Mon, 18 Nov 2024 13:06:59 +0100 Subject: [PATCH] GH-1345: use diagnostics tags from lsp protocol to mark unnecessary and deprecated things accordingly --- .../reconcile/BadWordReconcileEngine.java | 10 +++- .../languageserver/reconcile/ProblemType.java | 7 ++- .../reconcile/ProblemTypes.java | 12 ++++- .../util/SimpleLanguageServer.java | 4 ++ .../yaml/reconcile/YamlSchemaProblems.java | 11 ++-- .../boot/java/Boot2JavaProblemType.java | 51 ++++++++++--------- .../boot/java/Boot3JavaProblemType.java | 32 ++++++++---- .../ide/vscode/boot/java/SpelProblemType.java | 30 ++++++++--- .../boot/java/SpringAotJavaProblemType.java | 40 +++++++++++---- .../boot/java/cron/CronProblemType.java | 28 +++++++--- .../data/jpa/queries/QueryProblemType.java | 28 +++++++--- .../ApplicationPropertiesProblemType.java | 24 +++++++-- .../VersionValidationProblemType.java | 26 +++++++--- .../ApplicationYamlASTReconciler.java | 2 - .../reconcile/ApplicationYamlProblemType.java | 26 +++++++--- 15 files changed, 238 insertions(+), 93 deletions(-) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/BadWordReconcileEngine.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/BadWordReconcileEngine.java index bae2feaece..9fab53c37e 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/BadWordReconcileEngine.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/BadWordReconcileEngine.java @@ -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 String getLabel() { public ProblemCategory getCategory() { return null; } + + @Override + public List getTags() { + return null; + } } private final String[] BADWORDS = { diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemType.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemType.java index a7b009d745..f20e382aff 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemType.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemType.java @@ -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 getTags(); } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemTypes.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemTypes.java index f37c1891d4..be1c9095d4 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemTypes.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/reconcile/ProblemTypes.java @@ -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 tags) { return new ProblemType() { @Override public String toString() { @@ -50,6 +54,10 @@ public String getLabel() { public ProblemCategory getCategory() { return category; } + @Override + public List getTags() { + return tags; + } }; } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleLanguageServer.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleLanguageServer.java index 028a569e49..e344bb2ac8 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleLanguageServer.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleLanguageServer.java @@ -850,10 +850,14 @@ public void accept(ReconcileProblem problem) { 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> fixes = problem.getQuickfixes(); // Copy original diagnsotic without the data field to avoid stackoverflow is hashCode() method call diff --git a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/YamlSchemaProblems.java b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/YamlSchemaProblems.java index f5bbfcf5fc..cf8f655070 100644 --- a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/YamlSchemaProblems.java +++ b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/YamlSchemaProblems.java @@ -15,6 +15,7 @@ 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 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) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot2JavaProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot2JavaProblemType.java index 2310bcd877..36529bf273 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot2JavaProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot2JavaProblemType.java @@ -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 @@ 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 @@ 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 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 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -89,4 +87,9 @@ public ProblemCategory getCategory() { return SpringProblemCategories.BOOT_2; } + @Override + public List getTags() { + return tags; + } + } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot3JavaProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot3JavaProblemType.java index 4610bea915..3b32ae2cf8 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot3JavaProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/Boot3JavaProblemType.java @@ -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 @@ 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 @@ 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 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 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -74,5 +81,10 @@ public String getCode() { public ProblemCategory getCategory() { return SpringProblemCategories.BOOT_3; } + + @Override + public List getTags() { + return tags; + } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpelProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpelProblemType.java index a1eb66e18d..98a219e301 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpelProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpelProblemType.java @@ -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 @@ 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 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 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -67,4 +76,9 @@ public String getCode() { public ProblemCategory getCategory() { return SpringProblemCategories.SPEL; } + + @Override + public List getTags() { + return tags; + } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpringAotJavaProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpringAotJavaProblemType.java index 752522bcd9..6c9f03f263 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpringAotJavaProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/SpringAotJavaProblemType.java @@ -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 @@ 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 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 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -61,4 +78,9 @@ public ProblemCategory getCategory() { return SpringProblemCategories.SPRING_AOT; } + @Override + public List getTags() { + return tags; + } + } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/cron/CronProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/cron/CronProblemType.java index 4550894894..17bc023e15 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/cron/CronProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/cron/CronProblemType.java @@ -12,6 +12,9 @@ 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 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 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -67,4 +76,9 @@ public String getCode() { public ProblemCategory getCategory() { return SpringProblemCategories.CRON; } + + @Override + public List getTags() { + return tags; + } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/data/jpa/queries/QueryProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/data/jpa/queries/QueryProblemType.java index 448231310f..8941f54b97 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/data/jpa/queries/QueryProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/data/jpa/queries/QueryProblemType.java @@ -12,6 +12,9 @@ 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 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 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -68,5 +77,10 @@ public String getCode() { public ProblemCategory getCategory() { return SpringProblemCategories.DATA_QUERY; } + + @Override + public List getTags() { + return tags; + } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/ApplicationPropertiesProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/ApplicationPropertiesProblemType.java index e82c0c4bfc..ba56f195e8 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/ApplicationPropertiesProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/ApplicationPropertiesProblemType.java @@ -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 @@ 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 tags; - private ApplicationPropertiesProblemType(ProblemSeverity defaultSeverity, String description, String label) { + private ApplicationPropertiesProblemType(ProblemSeverity defaultSeverity, String description, String label, List 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 ProblemSeverity getDefaultSeverity() { } public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -83,4 +92,9 @@ public ProblemCategory getCategory() { return SpringProblemCategories.PROPERTIES; } + @Override + public List getTags() { + return tags; + } + } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/preferences/VersionValidationProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/preferences/VersionValidationProblemType.java index d87037543b..5e2119fcdd 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/preferences/VersionValidationProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/preferences/VersionValidationProblemType.java @@ -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.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 @@ 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 tags; - private VersionValidationProblemType(ProblemSeverity defaultSeverity, String description, String label) { + private VersionValidationProblemType(ProblemSeverity defaultSeverity, String description, String label, List 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 ProblemCategory getCategory() { return SpringProblemCategories.VERSION_VALIDATION; } + @Override + public List getTags() { + return tags; + } + } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java index 40b407177d..307de4b795 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java @@ -56,9 +56,7 @@ 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; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlProblemType.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlProblemType.java index 57ffebdf9c..d5c8765fa5 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlProblemType.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlProblemType.java @@ -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 @@ 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 tags; - private ApplicationYamlProblemType(ProblemSeverity defaultSeverity, String description, String label) { + private ApplicationYamlProblemType(ProblemSeverity defaultSeverity, String description, String label, List 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 ProblemSeverity getDefaultSeverity() { public String getLabel() { - if (label==null) { + if (label == null) { label = createDefaultLabel(); } return label; @@ -87,4 +96,9 @@ public ProblemCategory getCategory() { return SpringProblemCategories.YAML; } + @Override + public List getTags() { + return tags; + } + }