Requirents... more syntax validator

This commit is contained in:
2025-09-07 15:50:35 +02:00
parent f8feee5fd7
commit 1ba6fe4c3f
3 changed files with 46 additions and 14 deletions

View File

@@ -275,7 +275,7 @@ Based on the Escoria core documentation, ASHES supports the following language f
**FR-9.6: Indentation Validation**
- The extension MUST enforce tab-based indentation (not spaces) as required by ASHES
- The extension MUST detect mixed tabs and spaces
- The extension MUST warn about excessive indentation (more than 3 levels)
- The extension MUST allow deep indentation for complex nested structures
- The extension MUST validate proper indentation for control flow blocks
- The extension MUST validate that events are at the top level (no indentation)
- The extension MUST validate proper indentation for dialog blocks and choices

View File

@@ -386,10 +386,14 @@ export class ASHESSyntaxValidator {
const conditionText = conditionMatch[2].trim();
// Check for proper inventory check patterns: "item" in inventory
const inventoryMatch = conditionText.match(/([^"]*)\s+in\s+inventory/);
const inventoryMatch = conditionText.match(/"([^"]*)"\s+in\s+inventory/);
if (inventoryMatch) {
const itemPart = inventoryMatch[1].trim();
if (!itemPart.startsWith('"') || !itemPart.endsWith('"')) {
// The pattern already matches quoted strings, so this is valid
// No need to check for quotes since the regex already requires them
} else {
// Check if there's an inventory check without proper quotes
const unquotedInventoryMatch = conditionText.match(/([^"]*)\s+in\s+inventory/);
if (unquotedInventoryMatch) {
const inventoryIndex = conditionText.indexOf('in inventory');
diagnostics.push({
range: new vscode.Range(lineNumber, line.indexOf(conditionText) + inventoryIndex, lineNumber, line.indexOf(conditionText) + inventoryIndex + 'in inventory'.length),
@@ -608,15 +612,15 @@ export class ASHESSyntaxValidator {
if (prevIndentMatch) {
const prevIndent = prevIndentMatch[1].length;
// Check for excessive indentation (more than 3 levels deep)
if (currentIndent > 3) {
diagnostics.push({
range: new vscode.Range(lineNumber, 0, lineNumber, currentIndent),
message: "Excessive indentation detected (more than 3 levels)",
severity: vscode.DiagnosticSeverity.Warning,
code: 'excessive-indentation'
});
}
// Note: Removed excessive indentation limit to allow deeper nesting
// if (currentIndent > 3) {
// diagnostics.push({
// range: new vscode.Range(lineNumber, 0, lineNumber, currentIndent),
// message: "Excessive indentation detected (more than 3 levels)",
// severity: vscode.DiagnosticSeverity.Warning,
// code: 'excessive-indentation'
// });
// }
}
}

View File

@@ -286,11 +286,39 @@
},
{
"include": "#numbers"
},
{
"include": "#keywords"
},
{
"include": "#variables"
},
{
"include": "#conditional-expressions"
}
]
}
]
},
"conditional-expressions": {
"patterns": [
{
"name": "meta.conditional-expression.ashes",
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(==|!=|<=|>=|<|>)\\s*([a-zA-Z_][a-zA-Z0-9_]*|\\d+)\\b",
"captures": {
"1": {
"name": "variable.other.conditional.ashes"
},
"2": {
"name": "keyword.operator.comparison.ashes"
},
"3": {
"name": "variable.other.conditional.ashes"
}
}
}
]
},
"strings": {
"patterns": [
{
@@ -361,7 +389,7 @@
},
{
"name": "keyword.other.ashes",
"match": "\\b(in|is|active)\\b"
"match": "\\b(in|is|active|inventory)\\b"
}
]
},