Use different error messages for allowed vs suggested validation errors

This commit is contained in:
Christopher Schleiden
2022-11-28 16:23:25 -08:00
parent 4d930dfc4e
commit aa0103ba56
2 changed files with 18 additions and 7 deletions
+2 -2
View File
@@ -75,7 +75,7 @@ jobs:
expect(result.length).toBe(1);
expect(result[0]).toEqual({
message: "Value 'does-not-exist' is not valid",
message: "Value 'does-not-exist' might not be valid",
severity: DiagnosticSeverity.Warning,
range: {
end: {
@@ -108,7 +108,7 @@ jobs:
expect(result.length).toBe(1);
expect(result[0]).toEqual({
message: "Value 'does-not-exist' is not valid",
message: "Value 'does-not-exist' might not be valid",
severity: DiagnosticSeverity.Warning,
range: {
end: {
+16 -5
View File
@@ -157,11 +157,22 @@ async function additionalValidations(
}
function invalidValue(diagnostics: Diagnostic[], token: StringToken, kind: ValueProviderKind) {
diagnostics.push({
message: `Value '${token.value}' is not valid`,
severity: kind === ValueProviderKind.AllowedValues ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,
range: mapRange(token.range)
});
switch (kind) {
case ValueProviderKind.AllowedValues:
diagnostics.push({
message: `Value '${token.value}' is not valid`,
severity: DiagnosticSeverity.Error,
range: mapRange(token.range)
});
break;
case ValueProviderKind.SuggestedValues:
diagnostics.push({
message: `Value '${token.value}' might not be valid`,
severity: DiagnosticSeverity.Warning,
range: mapRange(token.range)
});
}
}
function getProviderContext(