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.
21 lines
842 B
TypeScript
21 lines
842 B
TypeScript
import type { ScriptCompilerFactory, ScriptCompilerInitParameters } from '@/application/Parser/Executable/Script/Compiler/ScriptCompilerFactory';
|
|
import type { ScriptCompiler } from '@/application/Parser/Executable/Script/Compiler/ScriptCompiler';
|
|
import { ScriptCompilerStub } from './ScriptCompilerStub';
|
|
|
|
export function createScriptCompilerFactorySpy(): {
|
|
readonly instance: ScriptCompilerFactory;
|
|
getInitParameters: (
|
|
compiler: ScriptCompiler,
|
|
) => ScriptCompilerInitParameters | undefined;
|
|
} {
|
|
const createdCompilers = new Map<ScriptCompiler, ScriptCompilerInitParameters>();
|
|
return {
|
|
instance: (parameters) => {
|
|
const compiler = new ScriptCompilerStub();
|
|
createdCompilers.set(compiler, parameters);
|
|
return compiler;
|
|
},
|
|
getInitParameters: (category) => createdCompilers.get(category),
|
|
};
|
|
}
|