Skip to content

Commit

Permalink
Adjust Boot version validations to include Spring Runtime support
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed Mar 4, 2024
1 parent 2f52905 commit 387e8b1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
import java.util.Collection;
import java.util.List;

import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeActionKind;
import org.eclipse.lsp4j.Command;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.ShowDocumentParams;
import org.springframework.ide.vscode.boot.validation.generations.json.Generation;
import org.springframework.ide.vscode.boot.validation.generations.json.ResolvedSpringProject;
import org.springframework.ide.vscode.boot.validation.generations.preferences.VersionValidationProblemType;
Expand All @@ -26,6 +31,8 @@

public class GenerationsValidator extends AbstractDiagnosticValidator {

private static String SPRING_COMMERCIAL_URL = "https://tanzu.vmware.com/spring-runtime";

private SpringProjectsProvider provider;

public GenerationsValidator(DiagnosticSeverityProvider diagnosticSeverityProvider, SpringProjectsProvider provider) {
Expand Down Expand Up @@ -55,6 +62,9 @@ public Collection<Diagnostic> validate(IJavaProject javaProject, Version javaPro
Generation javaProjectGen = getGenerationForJavaProject(javaProject, springProject);
ImmutableList.Builder<Diagnostic> b = ImmutableList.builder();

boolean validCommercialSupport = VersionValidationUtils.isCommercialValid(javaProjectGen);


if (VersionValidationUtils.isOssValid(javaProjectGen)) {
StringBuilder message = new StringBuilder();
message.append("OSS support for Spring Boot ");
Expand All @@ -75,14 +85,22 @@ public Collection<Diagnostic> validate(IJavaProject javaProject, Version javaPro
message.append(javaProjectGen.getName());
message.append(" no longer available, ended on: ");
message.append(javaProjectGen.getOssSupportEndDate());
if (validCommercialSupport) {
message.append(", get commercial support until ");
message.append(javaProjectGen.getCommercialSupportEndDate());
message.append(" via Tanzu Spring Runtime at https://tanzu.vmware.com/spring-runtime");
}
}
Diagnostic d = createDiagnostic(VersionValidationProblemType.UNSUPPORTED_OSS_VERSION, message.toString());
if (validCommercialSupport) {
d.setData(List.of(getCommercialSupportCodeAction()));
}
if (d != null) {
b.add(d);
}
}

if (VersionValidationUtils.isCommercialValid(javaProjectGen)) {
if (validCommercialSupport) {
StringBuilder message = new StringBuilder();
message.append("Commercial support for Spring Boot ");
message.append(javaProjectGen.getName());
Expand Down Expand Up @@ -121,5 +139,19 @@ public boolean isEnabled() {
VersionValidationProblemType.UNSUPPORTED_COMMERCIAL_VERSION
);
}

private static CodeAction getCommercialSupportCodeAction() {
CodeAction commercialSupportLink = new CodeAction();
commercialSupportLink.setKind(CodeActionKind.QuickFix);
commercialSupportLink.setTitle("Get commercial Spring Boot support via Tanzu Spring Runtime");
ShowDocumentParams showDocumentParams = new ShowDocumentParams(SPRING_COMMERCIAL_URL);
showDocumentParams.setExternal(true);
showDocumentParams.setTakeFocus(true);
showDocumentParams.setSelection(new Range());
commercialSupportLink.setCommand(new Command("Get commercial Spring Boot support via Tanzu Spring Runtime", "sts/show/document",
ImmutableList.of(showDocumentParams)));
return commercialSupportLink;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.validation.generations.preferences;

import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.HINT;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.IGNORE;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.INFO;
import static org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity.WARNING;
Expand All @@ -24,9 +23,9 @@ public enum VersionValidationProblemType implements ProblemType {

SUPPORTED_OSS_VERSION(IGNORE, "Supported OSS Boot Version", "Supported OSS Boot Version"),

UNSUPPORTED_OSS_VERSION(HINT, "Unsupported OSS Version", "Unsupported OSS Version"),
UNSUPPORTED_OSS_VERSION(WARNING, "Unsupported OSS Version", "Unsupported OSS Version"),

UNSUPPORTED_COMMERCIAL_VERSION(HINT, "Unsupported Commercial Version", "Unsupported Commercial Version"),
UNSUPPORTED_COMMERCIAL_VERSION(WARNING, "Unsupported Commercial Version", "Unsupported Commercial Version"),

SUPPORTED_COMMERCIAL_VERSION(IGNORE, "Supported Commercial Version", "Supported Commercial Version"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@
"code": "UNSUPPORTED_OSS_VERSION",
"label": "Unsupported OSS Version",
"description": "Unsupported OSS Version",
"defaultSeverity": "HINT"
"defaultSeverity": "WARNING"
},
{
"code": "UNSUPPORTED_COMMERCIAL_VERSION",
"label": "Unsupported Commercial Version",
"description": "Unsupported Commercial Version",
"defaultSeverity": "HINT"
"defaultSeverity": "WARNING"
},
{
"code": "SUPPORTED_COMMERCIAL_VERSION",
Expand Down
6 changes: 3 additions & 3 deletions vscode-extensions/vscode-spring-boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@
},
"spring-boot.ls.problem.version-validation.UNSUPPORTED_OSS_VERSION": {
"type": "string",
"default": "HINT",
"default": "WARNING",
"description": "Unsupported OSS Version",
"enum": [
"IGNORE",
Expand All @@ -936,7 +936,7 @@
},
"spring-boot.ls.problem.version-validation.UNSUPPORTED_COMMERCIAL_VERSION": {
"type": "string",
"default": "HINT",
"default": "WARNING",
"description": "Unsupported Commercial Version",
"enum": [
"IGNORE",
Expand Down Expand Up @@ -1038,4 +1038,4 @@
"extensionDependencies": [
"redhat.java"
]
}
}

0 comments on commit 387e8b1

Please sign in to comment.