Remove generations and their preferences
This commit is contained in:
@@ -16,7 +16,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
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.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.java.SpringProjectUtil;
|
||||
@@ -47,18 +46,10 @@ public class ProjectVersionDiagnosticProvider {
|
||||
throw new Exception("Unable to resolve version for project: " + javaProject.getLocationUri().toString());
|
||||
}
|
||||
|
||||
Generation javaProjectGeneration = getGenerationForJavaProject(javaProject, springProject);
|
||||
|
||||
if (javaProjectGeneration == null) {
|
||||
throw new Exception(
|
||||
"Unable to find Spring Project Generation for project: " + javaProjectVersion.toString());
|
||||
}
|
||||
|
||||
List<Diagnostic> diagnostics = new ArrayList<Diagnostic>();
|
||||
|
||||
for (VersionValidator validator : validators.getValidators()) {
|
||||
Diagnostic diagnostic = validator.validate(springProject, javaProject, javaProjectGeneration,
|
||||
javaProjectVersion);
|
||||
Diagnostic diagnostic = validator.validate(springProject, javaProject, javaProjectVersion);
|
||||
if (diagnostic != null) {
|
||||
diagnostics.add(diagnostic);
|
||||
}
|
||||
@@ -67,31 +58,11 @@ public class ProjectVersionDiagnosticProvider {
|
||||
return new DiagnosticResult(buildFileUri, diagnostics);
|
||||
}
|
||||
|
||||
private Generation getGenerationForJavaProject(IJavaProject javaProject, ResolvedSpringProject springProject)
|
||||
throws Exception {
|
||||
List<Generation> genList = springProject.getGenerations();
|
||||
Version javaProjectVersion = SpringProjectUtil.getDependencyVersion(javaProject, springProject.getSlug());
|
||||
|
||||
// Find the generation belonging to the dependency
|
||||
for (Generation gen : genList) {
|
||||
Version genVersion = getVersion(gen);
|
||||
if (genVersion.getMajor() == javaProjectVersion.getMajor()
|
||||
&& genVersion.getMinor() == javaProjectVersion.getMinor()) {
|
||||
return gen;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected File getSpringBootDependency(IJavaProject project) {
|
||||
List<File> libs = SpringProjectUtil.getLibrariesOnClasspath(project, "spring-boot");
|
||||
return libs != null && libs.size() > 0 ? libs.get(0) : null;
|
||||
}
|
||||
|
||||
protected Version getVersion(Generation generation) throws Exception {
|
||||
return SpringProjectUtil.getVersionFromGeneration(generation.getName());
|
||||
}
|
||||
|
||||
public static class DiagnosticResult {
|
||||
|
||||
private final URI documentUri;
|
||||
|
||||
@@ -11,14 +11,13 @@
|
||||
package org.springframework.ide.vscode.boot.validation.generations;
|
||||
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
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.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.java.Version;
|
||||
|
||||
public interface VersionValidator {
|
||||
|
||||
Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject, Generation javaProjectGen, Version javaProjectVersion)
|
||||
Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject, Version javaProjectVersion)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.boot.validation.generations;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.lsp4j.CodeAction;
|
||||
import org.eclipse.lsp4j.CodeActionKind;
|
||||
import org.eclipse.lsp4j.Command;
|
||||
@@ -22,6 +23,7 @@ import org.springframework.ide.vscode.boot.validation.generations.json.Generatio
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.ResolvedSpringProject;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.preferences.VersionValidationProblemType;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.java.SpringProjectUtil;
|
||||
import org.springframework.ide.vscode.commons.java.Version;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.DiagnosticSeverityProvider;
|
||||
|
||||
@@ -47,99 +49,126 @@ public class VersionValidators {
|
||||
public List<VersionValidator> getValidators() {
|
||||
return Arrays.asList(this.validators);
|
||||
}
|
||||
|
||||
private static class SupportedOssValidator extends AbstractDiagnosticValidator {
|
||||
|
||||
public SupportedOssValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
super(diagnosticSeverityProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
|
||||
if (VersionValidationUtils.isOssValid(javaProjectGen)) {
|
||||
VersionValidationProblemType problemType = VersionValidationProblemType.SUPPORTED_OSS_VERSION;
|
||||
|
||||
StringBuffer message = new StringBuffer();
|
||||
message.append("OSS support for Spring Boot " + javaProjectGen.getName() + " ends on: ");
|
||||
message.append(javaProjectGen.getOssSupportEndDate());
|
||||
|
||||
return createDiagnostic(problemType, message.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SupportedCommercialValidator extends AbstractDiagnosticValidator {
|
||||
|
||||
public SupportedCommercialValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
super(diagnosticSeverityProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
|
||||
if (VersionValidationUtils.isCommercialValid(javaProjectGen)) {
|
||||
|
||||
VersionValidationProblemType problemType = VersionValidationProblemType.SUPPORTED_COMMERCIAL_VERSION;
|
||||
|
||||
StringBuffer message = new StringBuffer();
|
||||
message.append("Commercial support for Spring Boot " + javaProjectGen.getName() + " ends on: ");
|
||||
message.append(javaProjectGen.getCommercialSupportEndDate());
|
||||
|
||||
return createDiagnostic(problemType, message.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnsupportedOssValidator extends AbstractDiagnosticValidator {
|
||||
|
||||
public UnsupportedOssValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
super(diagnosticSeverityProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
if (!VersionValidationUtils.isOssValid(javaProjectGen)) {
|
||||
|
||||
VersionValidationProblemType problemType = VersionValidationProblemType.UNSUPPORTED_OSS_VERSION;
|
||||
|
||||
StringBuffer message = new StringBuffer();
|
||||
message.append("OSS support for Spring Boot " + javaProjectGen.getName() + " no longer available, ended on: ");
|
||||
message.append(javaProjectGen.getOssSupportEndDate());
|
||||
|
||||
return createDiagnostic(problemType, message.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnsupportedCommercialValidator extends AbstractDiagnosticValidator {
|
||||
|
||||
public UnsupportedCommercialValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
super(diagnosticSeverityProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
if (!VersionValidationUtils.isCommercialValid(javaProjectGen)) {
|
||||
|
||||
VersionValidationProblemType problemType = VersionValidationProblemType.UNSUPPORTED_COMMERCIAL_VERSION;
|
||||
|
||||
StringBuffer message = new StringBuffer();
|
||||
message.append("Commercial support for Spring Boot " + javaProjectGen.getName() + " no longer available, ended on: ");
|
||||
message.append(javaProjectGen.getCommercialSupportEndDate());
|
||||
|
||||
return createDiagnostic(problemType, message.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// private static Generation getGenerationForJavaProject(IJavaProject javaProject, ResolvedSpringProject springProject)
|
||||
// throws Exception {
|
||||
// List<Generation> genList = springProject.getGenerations();
|
||||
// Version javaProjectVersion = SpringProjectUtil.getDependencyVersion(javaProject, springProject.getSlug());
|
||||
//
|
||||
// // Find the generation belonging to the dependency
|
||||
// for (Generation gen : genList) {
|
||||
// Version genVersion = SpringProjectUtil.getVersionFromGeneration(gen.getName());
|
||||
// if (genVersion.getMajor() == javaProjectVersion.getMajor()
|
||||
// && genVersion.getMinor() == javaProjectVersion.getMinor()) {
|
||||
// return gen;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// private static class SupportedOssValidator extends AbstractDiagnosticValidator {
|
||||
//
|
||||
// public SupportedOssValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
// super(diagnosticSeverityProvider);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
// Version javaProjectVersion) throws Exception {
|
||||
//
|
||||
// Generation javaProjectGen = getGenerationForJavaProject(javaProject, springProject);
|
||||
// Assert.isLegal(javaProjectGen != null, "Unable to find Spring Project Generation for project: " + javaProjectVersion.toString());
|
||||
// if (VersionValidationUtils.isOssValid(javaProjectGen)) {
|
||||
// VersionValidationProblemType problemType = VersionValidationProblemType.SUPPORTED_OSS_VERSION;
|
||||
//
|
||||
// StringBuffer message = new StringBuffer();
|
||||
// message.append("OSS support for Spring Boot " + javaProjectGen.getName() + " ends on: ");
|
||||
// message.append(javaProjectGen.getOssSupportEndDate());
|
||||
//
|
||||
// return createDiagnostic(problemType, message.toString());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class SupportedCommercialValidator extends AbstractDiagnosticValidator {
|
||||
//
|
||||
// public SupportedCommercialValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
// super(diagnosticSeverityProvider);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
// Version javaProjectVersion) throws Exception {
|
||||
//
|
||||
// Generation javaProjectGen = getGenerationForJavaProject(javaProject, springProject);
|
||||
// Assert.isLegal(javaProjectGen != null, "Unable to find Spring Project Generation for project: " + javaProjectVersion.toString());
|
||||
//
|
||||
// if (VersionValidationUtils.isCommercialValid(javaProjectGen)) {
|
||||
//
|
||||
// VersionValidationProblemType problemType = VersionValidationProblemType.SUPPORTED_COMMERCIAL_VERSION;
|
||||
//
|
||||
// StringBuffer message = new StringBuffer();
|
||||
// message.append("Commercial support for Spring Boot " + javaProjectGen.getName() + " ends on: ");
|
||||
// message.append(javaProjectGen.getCommercialSupportEndDate());
|
||||
//
|
||||
// return createDiagnostic(problemType, message.toString());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class UnsupportedOssValidator extends AbstractDiagnosticValidator {
|
||||
//
|
||||
// public UnsupportedOssValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
// super(diagnosticSeverityProvider);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
// Version javaProjectVersion) throws Exception {
|
||||
// Generation javaProjectGen = getGenerationForJavaProject(javaProject, springProject);
|
||||
// Assert.isLegal(javaProjectGen != null, "Unable to find Spring Project Generation for project: " + javaProjectVersion.toString());
|
||||
//
|
||||
// if (!VersionValidationUtils.isOssValid(javaProjectGen)) {
|
||||
//
|
||||
// VersionValidationProblemType problemType = VersionValidationProblemType.UNSUPPORTED_OSS_VERSION;
|
||||
//
|
||||
// StringBuffer message = new StringBuffer();
|
||||
// message.append("OSS support for Spring Boot " + javaProjectGen.getName() + " no longer available, ended on: ");
|
||||
// message.append(javaProjectGen.getOssSupportEndDate());
|
||||
//
|
||||
// return createDiagnostic(problemType, message.toString());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class UnsupportedCommercialValidator extends AbstractDiagnosticValidator {
|
||||
//
|
||||
// public UnsupportedCommercialValidator(DiagnosticSeverityProvider diagnosticSeverityProvider) {
|
||||
// super(diagnosticSeverityProvider);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
// Version javaProjectVersion) throws Exception {
|
||||
// Generation javaProjectGen = getGenerationForJavaProject(javaProject, springProject);
|
||||
// Assert.isLegal(javaProjectGen != null, "Unable to find Spring Project Generation for project: " + javaProjectVersion.toString());
|
||||
//
|
||||
// if (!VersionValidationUtils.isCommercialValid(javaProjectGen)) {
|
||||
//
|
||||
// VersionValidationProblemType problemType = VersionValidationProblemType.UNSUPPORTED_COMMERCIAL_VERSION;
|
||||
//
|
||||
// StringBuffer message = new StringBuffer();
|
||||
// message.append("Commercial support for Spring Boot " + javaProjectGen.getName() + " no longer available, ended on: ");
|
||||
// message.append(javaProjectGen.getCommercialSupportEndDate());
|
||||
//
|
||||
// return createDiagnostic(problemType, message.toString());
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
private static class UpdateLatestPatchVersion extends AbstractDiagnosticValidator {
|
||||
|
||||
@@ -149,7 +178,7 @@ public class VersionValidators {
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
Version javaProjectVersion) throws Exception {
|
||||
Version latest = VersionValidationUtils.getNewerLatestPatchRelease(springProject.getReleases(), javaProjectVersion);
|
||||
|
||||
if (latest != null) {
|
||||
@@ -181,7 +210,7 @@ public class VersionValidators {
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
Version javaProjectVersion) throws Exception {
|
||||
Version latest = VersionValidationUtils.getNewerLatestMinorRelease(springProject.getReleases(), javaProjectVersion);
|
||||
|
||||
if (latest != null) {
|
||||
@@ -213,7 +242,7 @@ public class VersionValidators {
|
||||
|
||||
@Override
|
||||
public Diagnostic validate(ResolvedSpringProject springProject, IJavaProject javaProject,
|
||||
Generation javaProjectGen, Version javaProjectVersion) throws Exception {
|
||||
Version javaProjectVersion) throws Exception {
|
||||
Version latest = VersionValidationUtils.getNewerLatestMajorRelease(springProject.getReleases(), javaProjectVersion);
|
||||
|
||||
if (latest != null) {
|
||||
|
||||
@@ -20,13 +20,13 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemTy
|
||||
|
||||
public enum VersionValidationProblemType implements ProblemType {
|
||||
|
||||
SUPPORTED_OSS_VERSION(HINT, "Supported OSS Boot Version", "Supported OSS Boot Version"),
|
||||
|
||||
UNSUPPORTED_OSS_VERSION(ERROR, "Unsupported OSS Version", "Unsupported OSS Version"),
|
||||
|
||||
UNSUPPORTED_COMMERCIAL_VERSION(ERROR, "Unsupported Commercial Version", "Unsupported Commercial Version"),
|
||||
|
||||
SUPPORTED_COMMERCIAL_VERSION(HINT, "Supported Commercial Version", "Supported Commercial Version"),
|
||||
// SUPPORTED_OSS_VERSION(HINT, "Supported OSS Boot Version", "Supported OSS Boot Version"),
|
||||
//
|
||||
// UNSUPPORTED_OSS_VERSION(ERROR, "Unsupported OSS Version", "Unsupported OSS Version"),
|
||||
//
|
||||
// UNSUPPORTED_COMMERCIAL_VERSION(ERROR, "Unsupported Commercial Version", "Unsupported Commercial Version"),
|
||||
//
|
||||
// SUPPORTED_COMMERCIAL_VERSION(HINT, "Supported Commercial Version", "Supported Commercial Version"),
|
||||
|
||||
UPDATE_LATEST_MAJOR_VERSION(HINT, "Update to Latest Major Version", "Update to Latest Major Version"),
|
||||
|
||||
|
||||
@@ -303,30 +303,6 @@
|
||||
},
|
||||
"order": 7,
|
||||
"problemTypes": [
|
||||
{
|
||||
"code": "SUPPORTED_OSS_VERSION",
|
||||
"label": "Supported OSS Boot Version",
|
||||
"description": "Supported OSS Boot Version",
|
||||
"defaultSeverity": "HINT"
|
||||
},
|
||||
{
|
||||
"code": "UNSUPPORTED_OSS_VERSION",
|
||||
"label": "Unsupported OSS Version",
|
||||
"description": "Unsupported OSS Version",
|
||||
"defaultSeverity": "ERROR"
|
||||
},
|
||||
{
|
||||
"code": "UNSUPPORTED_COMMERCIAL_VERSION",
|
||||
"label": "Unsupported Commercial Version",
|
||||
"description": "Unsupported Commercial Version",
|
||||
"defaultSeverity": "ERROR"
|
||||
},
|
||||
{
|
||||
"code": "SUPPORTED_COMMERCIAL_VERSION",
|
||||
"label": "Supported Commercial Version",
|
||||
"description": "Supported Commercial Version",
|
||||
"defaultSeverity": "HINT"
|
||||
},
|
||||
{
|
||||
"code": "UPDATE_LATEST_MAJOR_VERSION",
|
||||
"label": "Update to Latest Major Version",
|
||||
|
||||
@@ -814,54 +814,6 @@
|
||||
"ON"
|
||||
]
|
||||
},
|
||||
"spring-boot.ls.problem.version-validation.SUPPORTED_OSS_VERSION": {
|
||||
"type": "string",
|
||||
"default": "HINT",
|
||||
"description": "Supported OSS Boot Version",
|
||||
"enum": [
|
||||
"IGNORE",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"HINT",
|
||||
"ERROR"
|
||||
]
|
||||
},
|
||||
"spring-boot.ls.problem.version-validation.UNSUPPORTED_OSS_VERSION": {
|
||||
"type": "string",
|
||||
"default": "ERROR",
|
||||
"description": "Unsupported OSS Version",
|
||||
"enum": [
|
||||
"IGNORE",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"HINT",
|
||||
"ERROR"
|
||||
]
|
||||
},
|
||||
"spring-boot.ls.problem.version-validation.UNSUPPORTED_COMMERCIAL_VERSION": {
|
||||
"type": "string",
|
||||
"default": "ERROR",
|
||||
"description": "Unsupported Commercial Version",
|
||||
"enum": [
|
||||
"IGNORE",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"HINT",
|
||||
"ERROR"
|
||||
]
|
||||
},
|
||||
"spring-boot.ls.problem.version-validation.SUPPORTED_COMMERCIAL_VERSION": {
|
||||
"type": "string",
|
||||
"default": "HINT",
|
||||
"description": "Supported Commercial Version",
|
||||
"enum": [
|
||||
"IGNORE",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"HINT",
|
||||
"ERROR"
|
||||
]
|
||||
},
|
||||
"spring-boot.ls.problem.version-validation.UPDATE_LATEST_MAJOR_VERSION": {
|
||||
"type": "string",
|
||||
"default": "HINT",
|
||||
|
||||
Reference in New Issue
Block a user