This commit improves the validation logic in parser, corrects Windows collection files to adhere to expected structure. This validation helps catch errors that previously led to incomplete generated code in scripts for disabling VSCEIP and location settings. Changes: - Add type validation for function call structures in the parser/compiler. This helps prevent runtime errors by ensuring that only correctly structured data is processed. - Fix scripts in the Windows collection that previoulsy had incomplete `code` or `revertCode` values. These corrections ensure that the scripts function as intended. - Refactor related logic within the compiler/parser to improve testability and maintainability.
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import type { IScriptingDefinition } from '@/domain/IScriptingDefinition';
|
|
import type { FunctionData } from '@/application/collections/';
|
|
import { ScriptCompiler } from './Script/Compiler/ScriptCompiler';
|
|
import { SyntaxFactory } from './Script/Validation/Syntax/SyntaxFactory';
|
|
import type { IScriptCompiler } from './Script/Compiler/IScriptCompiler';
|
|
import type { ILanguageSyntax } from './Script/Validation/Syntax/ILanguageSyntax';
|
|
import type { ISyntaxFactory } from './Script/Validation/Syntax/ISyntaxFactory';
|
|
|
|
export interface CategoryCollectionSpecificUtilities {
|
|
readonly compiler: IScriptCompiler;
|
|
readonly syntax: ILanguageSyntax;
|
|
}
|
|
|
|
export const createCollectionUtilities: CategoryCollectionSpecificUtilitiesFactory = (
|
|
functionsData: ReadonlyArray<FunctionData> | undefined,
|
|
scripting: IScriptingDefinition,
|
|
syntaxFactory: ISyntaxFactory = new SyntaxFactory(),
|
|
) => {
|
|
const syntax = syntaxFactory.create(scripting.language);
|
|
return {
|
|
compiler: new ScriptCompiler({
|
|
functions: functionsData ?? [],
|
|
syntax,
|
|
}),
|
|
syntax,
|
|
};
|
|
};
|
|
|
|
export interface CategoryCollectionSpecificUtilitiesFactory {
|
|
(
|
|
functionsData: ReadonlyArray<FunctionData> | undefined,
|
|
scripting: IScriptingDefinition,
|
|
syntaxFactory?: ISyntaxFactory,
|
|
): CategoryCollectionSpecificUtilities;
|
|
}
|