mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-12 22:03:30 +08:00
feat(config): 添加配置 schema 诊断和 VS Code 扩展工具
- 实现了配置 schema 代码生成相关的诊断功能 - 添加了 VS Code 扩展工具用于配置文件管理和验证 - 提供配置文件树视图和表单预览功能 - 实现配置文件的批量编辑功能 - 集成 schema 验证和错误提示机制 - 支持配置文件的引用导航和快速访问 - 添加多语言本地化支持
This commit is contained in:
parent
1b3140a0dc
commit
594dffdd50
@ -107,4 +107,15 @@ public static class ConfigSchemaDiagnostics
|
|||||||
SourceGeneratorsConfigCategory,
|
SourceGeneratorsConfigCategory,
|
||||||
DiagnosticSeverity.Error,
|
DiagnosticSeverity.Error,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// schema 对象节点的 dependentRequired 元数据无效。
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DiagnosticDescriptor InvalidDependentRequiredMetadata = new(
|
||||||
|
"GF_ConfigSchema_010",
|
||||||
|
"Config schema uses invalid dependentRequired metadata",
|
||||||
|
"Property '{1}' in schema file '{0}' uses invalid 'dependentRequired' metadata: {2}",
|
||||||
|
SourceGeneratorsConfigCategory,
|
||||||
|
DiagnosticSeverity.Error,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1578,7 +1578,7 @@ function getScalarArrayValue(yamlNode) {
|
|||||||
/**
|
/**
|
||||||
* Render human-facing metadata hints for one schema field.
|
* Render human-facing metadata hints for one schema field.
|
||||||
*
|
*
|
||||||
* @param {{type?: string, description?: string, defaultValue?: string, constValue?: string, constDisplayValue?: string, minimum?: number, exclusiveMinimum?: number, maximum?: number, exclusiveMaximum?: number, multipleOf?: number, minLength?: number, maxLength?: number, pattern?: string, format?: string, minItems?: number, maxItems?: number, minContains?: number, maxContains?: number, minProperties?: number, maxProperties?: number, uniqueItems?: boolean, enumValues?: string[], contains?: {type?: string, enumValues?: string[], constValue?: string, constDisplayValue?: string, pattern?: string, format?: string, refTable?: string}, items?: {enumValues?: string[], constValue?: string, constDisplayValue?: string, minimum?: number, exclusiveMinimum?: number, maximum?: number, exclusiveMaximum?: number, multipleOf?: number, minLength?: number, maxLength?: number, pattern?: string, format?: string}, refTable?: string}} propertySchema Property schema metadata.
|
* @param {{type?: string, description?: string, defaultValue?: string, constValue?: string, constDisplayValue?: string, minimum?: number, exclusiveMinimum?: number, maximum?: number, exclusiveMaximum?: number, multipleOf?: number, minLength?: number, maxLength?: number, pattern?: string, format?: string, minItems?: number, maxItems?: number, minContains?: number, maxContains?: number, minProperties?: number, maxProperties?: number, dependentRequired?: Record<string, string[]>, uniqueItems?: boolean, enumValues?: string[], contains?: {type?: string, enumValues?: string[], constValue?: string, constDisplayValue?: string, pattern?: string, format?: string, refTable?: string}, items?: {enumValues?: string[], constValue?: string, constDisplayValue?: string, minimum?: number, exclusiveMinimum?: number, maximum?: number, exclusiveMaximum?: number, multipleOf?: number, minLength?: number, maxLength?: number, pattern?: string, format?: string}, refTable?: string}} propertySchema Property schema metadata.
|
||||||
* @param {boolean} isArrayField Whether the field is an array.
|
* @param {boolean} isArrayField Whether the field is an array.
|
||||||
* @param {boolean} includeDescription Whether description text should be included in the hint output.
|
* @param {boolean} includeDescription Whether description text should be included in the hint output.
|
||||||
* @returns {string} HTML fragment.
|
* @returns {string} HTML fragment.
|
||||||
@ -1653,6 +1653,21 @@ function renderFieldHint(propertySchema, isArrayField, includeDescription = true
|
|||||||
hints.push(escapeHtml(localizer.t("webview.hint.maxProperties", {value: propertySchema.maxProperties})));
|
hints.push(escapeHtml(localizer.t("webview.hint.maxProperties", {value: propertySchema.maxProperties})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (propertySchema.type === "object" &&
|
||||||
|
propertySchema.dependentRequired &&
|
||||||
|
typeof propertySchema.dependentRequired === "object") {
|
||||||
|
for (const [trigger, dependencies] of Object.entries(propertySchema.dependentRequired)) {
|
||||||
|
if (!Array.isArray(dependencies) || dependencies.length === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
hints.push(escapeHtml(localizer.t("webview.hint.dependentRequired", {
|
||||||
|
trigger,
|
||||||
|
dependencies: dependencies.join(", ")
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isArrayField && typeof propertySchema.minItems === "number") {
|
if (isArrayField && typeof propertySchema.minItems === "number") {
|
||||||
hints.push(escapeHtml(localizer.t("webview.hint.minItems", {value: propertySchema.minItems})));
|
hints.push(escapeHtml(localizer.t("webview.hint.minItems", {value: propertySchema.minItems})));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,6 +139,7 @@ const enMessages = {
|
|||||||
"webview.unsupported.objectArrayMixed": "Object-array items must be mappings. Use raw YAML if the current file mixes scalar and object items.",
|
"webview.unsupported.objectArrayMixed": "Object-array items must be mappings. Use raw YAML if the current file mixes scalar and object items.",
|
||||||
"webview.unsupported.nestedObjectArray": "Nested object-array fields are currently raw-YAML-only inside the object-array editor.",
|
"webview.unsupported.nestedObjectArray": "Nested object-array fields are currently raw-YAML-only inside the object-array editor.",
|
||||||
[ValidationMessageKeys.constMismatch]: "Property '{displayPath}' must match constant value {value}.",
|
[ValidationMessageKeys.constMismatch]: "Property '{displayPath}' must match constant value {value}.",
|
||||||
|
[ValidationMessageKeys.dependentRequiredViolation]: "Property '{displayPath}' is required when sibling property '{triggerProperty}' is present.",
|
||||||
[ValidationMessageKeys.exclusiveMaximumViolation]: "Property '{displayPath}' must be less than {value}.",
|
[ValidationMessageKeys.exclusiveMaximumViolation]: "Property '{displayPath}' must be less than {value}.",
|
||||||
[ValidationMessageKeys.exclusiveMinimumViolation]: "Property '{displayPath}' must be greater than {value}.",
|
[ValidationMessageKeys.exclusiveMinimumViolation]: "Property '{displayPath}' must be greater than {value}.",
|
||||||
[ValidationMessageKeys.maximumViolation]: "Property '{displayPath}' must be less than or equal to {value}.",
|
[ValidationMessageKeys.maximumViolation]: "Property '{displayPath}' must be less than or equal to {value}.",
|
||||||
@ -258,6 +259,7 @@ const zhCnMessages = {
|
|||||||
"webview.unsupported.objectArrayMixed": "对象数组中的每一项都必须是映射对象。如果当前文件混用了标量项和对象项,请改用原始 YAML。",
|
"webview.unsupported.objectArrayMixed": "对象数组中的每一项都必须是映射对象。如果当前文件混用了标量项和对象项,请改用原始 YAML。",
|
||||||
"webview.unsupported.nestedObjectArray": "对象数组编辑器内暂不支持更深层的对象数组字段,请改用原始 YAML。",
|
"webview.unsupported.nestedObjectArray": "对象数组编辑器内暂不支持更深层的对象数组字段,请改用原始 YAML。",
|
||||||
[ValidationMessageKeys.constMismatch]: "属性“{displayPath}”必须匹配固定值 {value}。",
|
[ValidationMessageKeys.constMismatch]: "属性“{displayPath}”必须匹配固定值 {value}。",
|
||||||
|
[ValidationMessageKeys.dependentRequiredViolation]: "属性“{triggerProperty}”存在时,必须同时声明属性“{displayPath}”。",
|
||||||
[ValidationMessageKeys.exclusiveMaximumViolation]: "属性“{displayPath}”必须小于 {value}。",
|
[ValidationMessageKeys.exclusiveMaximumViolation]: "属性“{displayPath}”必须小于 {value}。",
|
||||||
[ValidationMessageKeys.exclusiveMinimumViolation]: "属性“{displayPath}”必须大于 {value}。",
|
[ValidationMessageKeys.exclusiveMinimumViolation]: "属性“{displayPath}”必须大于 {value}。",
|
||||||
[ValidationMessageKeys.maximumViolation]: "属性“{displayPath}”必须小于或等于 {value}。",
|
[ValidationMessageKeys.maximumViolation]: "属性“{displayPath}”必须小于或等于 {value}。",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user