Skip to content

Commit 11dd515

Browse files
committed
Runtime-Based MicroProfile Config Validation for LSP4MP
Fixes #511 Signed-off-by: azerr <[email protected]>
1 parent e3a39e2 commit 11dd515

File tree

74 files changed

+4078
-1001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4078
-1001
lines changed

microprofile.jdt/org.eclipse.lsp4mp.jdt.core/build.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ bin.includes = plugin.xml,\
66
plugin.properties,\
77
schema/,\
88
static-properties/,\
9-
about.html
9+
about.html,\
10+
runtimes/
1011
src.includes = about.html
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/MicroProfileJavaDiagnosticsSettings.java

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,91 @@
1616
import java.util.Collections;
1717
import java.util.List;
1818

19+
import org.eclipse.lsp4j.DiagnosticSeverity;
20+
1921
/**
20-
* Represents settings used by the MicroProfile JDT component while validating
21-
* Java class files
22+
* Settings controlling how MicroProfile Java diagnostics validate the values of
23+
* configuration properties declared in Java sources.
24+
* <p>
25+
* These settings are specifically used when inspecting annotations such as
26+
* {@code @ConfigProperty(defaultValue = "...")}, and when applying
27+
* MicroProfile-compatible converters to validate that the provided default
28+
* values can be converted to the expected type.
29+
* </p>
30+
*
31+
* <h2>Ignored Properties</h2> The {@link #patterns} list contains a set of
32+
* string patterns that match against the <strong>property name</strong>
33+
* declared in {@code @ConfigProperty(name = "…")}. If a property name matches
34+
* one of these patterns, then its default value is <strong>excluded from
35+
* validation</strong>.
36+
*
37+
* <h2>Diagnostics Severity</h2> {@link #validationValueSeverity} controls the
38+
* severity used when reporting validation issues:
39+
* <ul>
40+
* <li>value not convertible using MicroProfile converters</li>
41+
* <li>invalid format (e.g., list, map, boolean, integer, etc.)</li>
42+
* <li>other type-related validation problems</li>
43+
* </ul>
2244
*
45+
* This enables fine-grained control over how strict the tooling should be when
46+
* validating default values defined in Java code.
2347
*/
2448
public class MicroProfileJavaDiagnosticsSettings {
2549

26-
public MicroProfileJavaDiagnosticsSettings(List<String> patterns) {
50+
/**
51+
* List of patterns used to determine which configuration properties should be
52+
* ignored during value validation.
53+
* <p>
54+
* Each pattern is matched against the {@code name} attribute of
55+
* {@code @ConfigProperty}. If the property name matches any pattern, its
56+
* {@code defaultValue} will not be validated.
57+
* </p>
58+
*/
59+
private List<String> patterns;
60+
61+
/**
62+
* The severity level used when reporting validation diagnostics for property
63+
* values that cannot be converted using MicroProfile converters.
64+
*/
65+
private DiagnosticSeverity validationValueSeverity;
66+
67+
/**
68+
* Creates new diagnostics settings for validating Java-based MicroProfile
69+
* configuration property values.
70+
*
71+
* @param patterns the list of patterns applied to the property
72+
* name to determine whether its default value
73+
* should be excluded from validation (may be
74+
* {@code null})
75+
* @param validationValueSeverity the severity to use when reporting invalid
76+
* default values
77+
*/
78+
public MicroProfileJavaDiagnosticsSettings(List<String> patterns, DiagnosticSeverity validationValueSeverity) {
2779
this.patterns = patterns;
80+
this.validationValueSeverity = validationValueSeverity;
2881
}
2982

30-
private List<String> patterns;
31-
3283
/**
33-
* Returns a list of patterns representing the properties to ignore validation
34-
* when adding diagnostics for properties without values.
84+
* Returns the list of patterns used to disable validation for certain
85+
* configuration property names.
86+
* <p>
87+
* If the list is {@code null}, an empty list is returned.
88+
* </p>
3589
*
36-
* @return a list of patterns representing the properties to ignore validation
37-
* when adding diagnostics for properties without values.
90+
* @return an unmodifiable list of patterns determining which property names
91+
* should be excluded from validation
3892
*/
3993
public List<String> getPatterns() {
4094
return patterns == null ? Collections.emptyList() : this.patterns;
4195
}
4296

97+
/**
98+
* Returns the severity level to use when reporting diagnostics for invalid
99+
* configuration property values.
100+
*
101+
* @return the severity used for reporting value validation errors
102+
*/
103+
public DiagnosticSeverity getValidationValueSeverity() {
104+
return validationValueSeverity;
105+
}
43106
}

microprofile.jdt/org.eclipse.lsp4mp.jdt.core/src/main/java/org/eclipse/lsp4mp/commons/MicroProfileProjectInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.eclipse.lsp4mp.commons;
1515

1616
import java.util.Collections;
17+
import java.util.Set;
1718

1819
import org.eclipse.lsp4mp.commons.metadata.ConfigurationMetadata;
1920

@@ -37,6 +38,8 @@ public class MicroProfileProjectInfo extends ConfigurationMetadata {
3738
private String projectURI;
3839

3940
private ClasspathKind classpathKind;
41+
42+
private Set<String> classpath;
4043

4144
/**
4245
* Returns the project URI.
@@ -74,4 +77,11 @@ public void setClasspathKind(ClasspathKind classpathKind) {
7477
this.classpathKind = classpathKind;
7578
}
7679

80+
public Set<String> getClasspath() {
81+
return classpath;
82+
}
83+
84+
public void setClasspath(Set<String> classpath) {
85+
this.classpath = classpath;
86+
}
7787
}

0 commit comments

Comments
 (0)