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:
@@ -2,13 +2,13 @@ import type { FunctionData } from '@/application/collections/';
|
||||
import { sequenceEqual } from '@/application/Common/Array';
|
||||
import type { ISharedFunctionCollection } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunctionCollection';
|
||||
import type { SharedFunctionsParser } from '@/application/Parser/Executable/Script/Compiler/Function/SharedFunctionsParser';
|
||||
import type { ILanguageSyntax } from '@/application/Parser/Executable/Script/Validation/Syntax/ILanguageSyntax';
|
||||
import type { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import { SharedFunctionCollectionStub } from './SharedFunctionCollectionStub';
|
||||
|
||||
export function createSharedFunctionsParserStub() {
|
||||
const callHistory = new Array<{
|
||||
readonly functions: readonly FunctionData[],
|
||||
readonly syntax: ILanguageSyntax,
|
||||
readonly language: ScriptingLanguage,
|
||||
}>();
|
||||
|
||||
const setupResults = new Array<{
|
||||
@@ -26,11 +26,11 @@ export function createSharedFunctionsParserStub() {
|
||||
|
||||
const parser: SharedFunctionsParser = (
|
||||
functions: readonly FunctionData[],
|
||||
syntax: ILanguageSyntax,
|
||||
language: ScriptingLanguage,
|
||||
) => {
|
||||
callHistory.push({
|
||||
functions: Array.from(functions),
|
||||
syntax,
|
||||
language,
|
||||
});
|
||||
const result = findResult(functions);
|
||||
return result || new SharedFunctionCollectionStub();
|
||||
|
||||
Reference in New Issue
Block a user