Requirents... more syntax validator
This commit is contained in:
@@ -275,7 +275,7 @@ Based on the Escoria core documentation, ASHES supports the following language f
|
|||||||
**FR-9.6: Indentation Validation**
|
**FR-9.6: Indentation Validation**
|
||||||
- The extension MUST enforce tab-based indentation (not spaces) as required by ASHES
|
- The extension MUST enforce tab-based indentation (not spaces) as required by ASHES
|
||||||
- The extension MUST detect mixed tabs and spaces
|
- 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 proper indentation for control flow blocks
|
||||||
- The extension MUST validate that events are at the top level (no indentation)
|
- The extension MUST validate that events are at the top level (no indentation)
|
||||||
- The extension MUST validate proper indentation for dialog blocks and choices
|
- The extension MUST validate proper indentation for dialog blocks and choices
|
||||||
|
|||||||
@@ -386,10 +386,14 @@ export class ASHESSyntaxValidator {
|
|||||||
const conditionText = conditionMatch[2].trim();
|
const conditionText = conditionMatch[2].trim();
|
||||||
|
|
||||||
// Check for proper inventory check patterns: "item" in inventory
|
// 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) {
|
if (inventoryMatch) {
|
||||||
const itemPart = inventoryMatch[1].trim();
|
// The pattern already matches quoted strings, so this is valid
|
||||||
if (!itemPart.startsWith('"') || !itemPart.endsWith('"')) {
|
// 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');
|
const inventoryIndex = conditionText.indexOf('in inventory');
|
||||||
diagnostics.push({
|
diagnostics.push({
|
||||||
range: new vscode.Range(lineNumber, line.indexOf(conditionText) + inventoryIndex, lineNumber, line.indexOf(conditionText) + inventoryIndex + 'in inventory'.length),
|
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) {
|
if (prevIndentMatch) {
|
||||||
const prevIndent = prevIndentMatch[1].length;
|
const prevIndent = prevIndentMatch[1].length;
|
||||||
|
|
||||||
// Check for excessive indentation (more than 3 levels deep)
|
// Note: Removed excessive indentation limit to allow deeper nesting
|
||||||
if (currentIndent > 3) {
|
// if (currentIndent > 3) {
|
||||||
diagnostics.push({
|
// diagnostics.push({
|
||||||
range: new vscode.Range(lineNumber, 0, lineNumber, currentIndent),
|
// range: new vscode.Range(lineNumber, 0, lineNumber, currentIndent),
|
||||||
message: "Excessive indentation detected (more than 3 levels)",
|
// message: "Excessive indentation detected (more than 3 levels)",
|
||||||
severity: vscode.DiagnosticSeverity.Warning,
|
// severity: vscode.DiagnosticSeverity.Warning,
|
||||||
code: 'excessive-indentation'
|
// code: 'excessive-indentation'
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -286,11 +286,39 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"include": "#numbers"
|
"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": {
|
"strings": {
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
@@ -361,7 +389,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "keyword.other.ashes",
|
"name": "keyword.other.ashes",
|
||||||
"match": "\\b(in|is|active)\\b"
|
"match": "\\b(in|is|active|inventory)\\b"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user