Add validation for max line length in compiler
This commit adds validation logic in compiler to check for max allowed characters per line for scripts. This allows preventing bugs caused by limitation of terminal emulators. Other supporting changes: - Rename/refactor related code for clarity and better maintainability. - Drop `I` prefix from interfaces to align with latest convention. - Refactor CodeValidator to be functional rather than object-oriented for simplicity. - Refactor syntax definition construction to be functional and be part of rule for better separation of concerns. - Refactored validation logic to use an enum-based factory pattern for improved maintainability and scalability.
This commit is contained in:
23
tests/unit/shared/Stubs/CodeValidationAnalyzerStub.ts
Normal file
23
tests/unit/shared/Stubs/CodeValidationAnalyzerStub.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { CodeLine, InvalidCodeLine, CodeValidationAnalyzer } from '@/application/Parser/Executable/Script/Validation/Analyzers/CodeValidationAnalyzer';
|
||||
import type { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
|
||||
export class CodeValidationAnalyzerStub {
|
||||
public readonly receivedLines = new Array<readonly CodeLine[]>();
|
||||
|
||||
public readonly receivedLanguages = new Array<ScriptingLanguage>();
|
||||
|
||||
private returnValue: InvalidCodeLine[] = [];
|
||||
|
||||
public withReturnValue(lines: readonly InvalidCodeLine[]) {
|
||||
this.returnValue = [...lines];
|
||||
return this;
|
||||
}
|
||||
|
||||
public get(): CodeValidationAnalyzer {
|
||||
return (lines, language) => {
|
||||
this.receivedLines.push(...[lines]);
|
||||
this.receivedLanguages.push(language);
|
||||
return this.returnValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user