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.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { CategoryParser } from '@/application/Parser/Executable/CategoryParser';
|
|
import type { CategoryData } from '@/application/collections/';
|
|
import type { Category } from '@/domain/Executables/Category/Category';
|
|
import type { CategoryCollectionContext } from '@/application/Parser/Executable/CategoryCollectionContext';
|
|
import { CategoryStub } from './CategoryStub';
|
|
|
|
export class CategoryParserStub {
|
|
private configuredParseResults = new Map<CategoryData, Category>();
|
|
|
|
private usedUtilities = new Array<CategoryCollectionContext>();
|
|
|
|
public get(): CategoryParser {
|
|
return (category, utilities) => {
|
|
const result = this.configuredParseResults.get(category);
|
|
this.usedUtilities.push(utilities);
|
|
if (result) {
|
|
return result;
|
|
}
|
|
return new CategoryStub(`[${CategoryParserStub.name}]-parsed-category`);
|
|
};
|
|
}
|
|
|
|
public withConfiguredParseResult(
|
|
givenCategory: CategoryData,
|
|
parsedCategory: Category,
|
|
): this {
|
|
this.configuredParseResults.set(givenCategory, parsedCategory);
|
|
return this;
|
|
}
|
|
|
|
public getUsedContext(): readonly CategoryCollectionContext[] {
|
|
return this.usedUtilities;
|
|
}
|
|
}
|