Refactor to unify scripts/categories as Executable

This commit consolidates scripts and categories under a unified
'Executable' concept. This simplifies the architecture and improves code
readability.

- Introduce subfolders within `src/domain` to segregate domain elements.
- Update class and interface names by removing the 'I' prefix in
  alignment with new coding standards.
- Replace 'Node' with 'Executable' to clarify usage; reserve 'Node'
  exclusively for the UI's tree component.
This commit is contained in:
undergroundwires
2024-06-12 12:36:40 +02:00
parent 8becc7dbc4
commit c138f74460
230 changed files with 1120 additions and 1039 deletions

View File

@@ -1,6 +1,6 @@
import type { FunctionCallCompilationContext } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { ArgumentCompiler } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/SingleCall/Strategies/Argument/ArgumentCompiler';
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
import type { FunctionCallCompilationContext } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { ArgumentCompiler } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/SingleCall/Strategies/Argument/ArgumentCompiler';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import { FunctionCallStub } from './FunctionCallStub';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';

View File

@@ -1,21 +0,0 @@
import type { ICategoryCollectionParseContext } from '@/application/Parser/Script/ICategoryCollectionParseContext';
import type { IScriptCompiler } from '@/application/Parser/Script/Compiler/IScriptCompiler';
import type { ILanguageSyntax } from '@/application/Parser/Script/Validation/Syntax/ILanguageSyntax';
import { ScriptCompilerStub } from './ScriptCompilerStub';
import { LanguageSyntaxStub } from './LanguageSyntaxStub';
export class CategoryCollectionParseContextStub implements ICategoryCollectionParseContext {
public compiler: IScriptCompiler = new ScriptCompilerStub();
public syntax: ILanguageSyntax = new LanguageSyntaxStub();
public withCompiler(compiler: IScriptCompiler) {
this.compiler = compiler;
return this;
}
public withSyntax(syntax: ILanguageSyntax) {
this.syntax = syntax;
return this;
}
}

View File

@@ -0,0 +1,22 @@
import type { IScriptCompiler } from '@/application/Parser/Executable/Script/Compiler/IScriptCompiler';
import type { ILanguageSyntax } from '@/application/Parser/Executable/Script/Validation/Syntax/ILanguageSyntax';
import type { CategoryCollectionSpecificUtilities } from '@/application/Parser/Executable/CategoryCollectionSpecificUtilities';
import { ScriptCompilerStub } from './ScriptCompilerStub';
import { LanguageSyntaxStub } from './LanguageSyntaxStub';
export class CategoryCollectionSpecificUtilitiesStub
implements CategoryCollectionSpecificUtilities {
public compiler: IScriptCompiler = new ScriptCompilerStub();
public syntax: ILanguageSyntax = new LanguageSyntaxStub();
public withCompiler(compiler: IScriptCompiler) {
this.compiler = compiler;
return this;
}
public withSyntax(syntax: ILanguageSyntax) {
this.syntax = syntax;
return this;
}
}

View File

@@ -1,7 +1,7 @@
import type { IApplicationCode } from '@/application/Context/State/Code/IApplicationCode';
import type { ICategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
import { OperatingSystem } from '@/domain/OperatingSystem';
import type { IScript } from '@/domain/IScript';
import type { Script } from '@/domain/Executables/Script/Script';
import { ScriptStub } from '@tests/unit/shared/Stubs/ScriptStub';
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
import type { UserSelection } from '@/application/Context/State/Selection/UserSelection';
@@ -27,7 +27,7 @@ export class CategoryCollectionStateStub implements ICategoryCollectionState {
public selection: UserSelection = new UserSelectionStub();
constructor(readonly allScripts: IScript[] = [new ScriptStub('script-id')]) {
constructor(readonly allScripts: Script[] = [new ScriptStub('script-id')]) {
this.selection = new UserSelectionStub()
.withScripts(new ScriptSelectionStub());
this.collection = new CategoryCollectionStub()

View File

@@ -1,9 +1,9 @@
import { OperatingSystem } from '@/domain/OperatingSystem';
import type { IScriptingDefinition } from '@/domain/IScriptingDefinition';
import type { IScript } from '@/domain/IScript';
import type { ICategory } from '@/domain/ICategory';
import type { Script } from '@/domain/Executables/Script/Script';
import type { Category } from '@/domain/Executables/Category/Category';
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
import { RecommendationLevel } from '@/domain/RecommendationLevel';
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
import { ScriptStub } from './ScriptStub';
import { ScriptingDefinitionStub } from './ScriptingDefinitionStub';
import { CategoryStub } from './CategoryStub';
@@ -13,13 +13,13 @@ export class CategoryCollectionStub implements ICategoryCollection {
public os = OperatingSystem.Linux;
public initialScript: IScript = new ScriptStub('55');
public initialScript: Script = new ScriptStub('55');
public totalScripts = 0;
public totalCategories = 0;
public readonly actions = new Array<ICategory>();
public readonly actions = new Array<Category>();
public withSomeActions(): this {
this.withAction(new CategoryStub(1));
@@ -28,12 +28,12 @@ export class CategoryCollectionStub implements ICategoryCollection {
return this;
}
public withAction(category: ICategory): this {
public withAction(category: Category): this {
this.actions.push(category);
return this;
}
public withActions(...actions: readonly ICategory[]): this {
public withActions(...actions: readonly Category[]): this {
for (const action of actions) {
this.withAction(action);
}
@@ -50,7 +50,7 @@ export class CategoryCollectionStub implements ICategoryCollection {
return this;
}
public withInitialScript(script: IScript): this {
public withInitialScript(script: Script): this {
this.initialScript = script;
return this;
}
@@ -60,41 +60,41 @@ export class CategoryCollectionStub implements ICategoryCollection {
return this;
}
public getCategory(categoryId: number): ICategory {
public getCategory(categoryId: number): Category {
return this.getAllCategories()
.find((category) => category.id === categoryId)
?? new CategoryStub(categoryId);
}
public getScriptsByLevel(level: RecommendationLevel): readonly IScript[] {
public getScriptsByLevel(level: RecommendationLevel): readonly Script[] {
return this.getAllScripts()
.filter((script) => script.level !== undefined && script.level <= level);
}
public getScript(scriptId: string): IScript {
public getScript(scriptId: string): Script {
return this.getAllScripts()
.find((script) => scriptId === script.id)
?? new ScriptStub(scriptId);
}
public getAllScripts(): ReadonlyArray<IScript> {
public getAllScripts(): ReadonlyArray<Script> {
return this.actions.flatMap((category) => getScriptsRecursively(category));
}
public getAllCategories(): ReadonlyArray<ICategory> {
public getAllCategories(): ReadonlyArray<Category> {
return this.actions.flatMap(
(category) => [category, ...getSubCategoriesRecursively(category)],
);
}
}
function getSubCategoriesRecursively(category: ICategory): ReadonlyArray<ICategory> {
function getSubCategoriesRecursively(category: Category): ReadonlyArray<Category> {
return (category.subCategories || []).flatMap(
(subCategory) => [subCategory, ...getSubCategoriesRecursively(subCategory)],
);
}
function getScriptsRecursively(category: ICategory): ReadonlyArray<IScript> {
function getScriptsRecursively(category: Category): ReadonlyArray<Script> {
return [
...(category.scripts || []),
...(category.subCategories || []).flatMap(

View File

@@ -1,14 +1,14 @@
import type { CategoryData, CategoryOrScriptData, DocumentationData } from '@/application/collections/';
import type { CategoryData, ExecutableData, DocumentationData } from '@/application/collections/';
import { createScriptDataWithCode } from '@tests/unit/shared/Stubs/ScriptDataStub';
export class CategoryDataStub implements CategoryData {
public children: readonly CategoryOrScriptData[] = [createScriptDataWithCode()];
public children: readonly ExecutableData[] = [createScriptDataWithCode()];
public category = 'category name';
public docs?: DocumentationData;
public withChildren(children: readonly CategoryOrScriptData[]) {
public withChildren(children: readonly ExecutableData[]) {
this.children = children;
return this;
}

View File

@@ -1,13 +1,13 @@
import type { CategoryFactory } from '@/application/Parser/CategoryParser';
import type { CategoryInitParameters } from '@/domain/Category';
import type { ICategory } from '@/domain/ICategory';
import type { CategoryFactory } from '@/application/Parser/Executable/CategoryParser';
import type { CategoryInitParameters } from '@/domain/Executables/Category/CollectionCategory';
import type { Category } from '@/domain/Executables/Category/Category';
import { CategoryStub } from './CategoryStub';
export function createCategoryFactorySpy(): {
readonly categoryFactorySpy: CategoryFactory;
getInitParameters: (category: ICategory) => CategoryInitParameters | undefined;
getInitParameters: (category: Category) => CategoryInitParameters | undefined;
} {
const createdCategories = new Map<ICategory, CategoryInitParameters>();
const createdCategories = new Map<Category, CategoryInitParameters>();
return {
categoryFactorySpy: (parameters) => {
const category = new CategoryStub(55);

View File

@@ -1,28 +1,29 @@
import { BaseEntity } from '@/infrastructure/Entity/BaseEntity';
import type { ICategory, IScript } from '@/domain/ICategory';
import { RecommendationLevel } from '@/domain/RecommendationLevel';
import type { Category } from '@/domain/Executables/Category/Category';
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
import type { Script } from '@/domain/Executables/Script/Script';
import { ScriptStub } from './ScriptStub';
export class CategoryStub extends BaseEntity<number> implements ICategory {
export class CategoryStub extends BaseEntity<number> implements Category {
public name = `category-with-id-${this.id}`;
public readonly subCategories = new Array<ICategory>();
public readonly subCategories = new Array<Category>();
public readonly scripts = new Array<IScript>();
public readonly scripts = new Array<Script>();
public docs: readonly string[] = new Array<string>();
private allScriptsRecursively: (readonly IScript[]) | undefined;
private allScriptsRecursively: (readonly Script[]) | undefined;
public constructor(id: number) {
super(id);
}
public includes(script: IScript): boolean {
public includes(script: Script): boolean {
return this.getAllScriptsRecursively().some((s) => s.id === script.id);
}
public getAllScriptsRecursively(): readonly IScript[] {
public getAllScriptsRecursively(): readonly Script[] {
if (this.allScriptsRecursively === undefined) {
return [
...this.scripts,
@@ -38,7 +39,7 @@ export class CategoryStub extends BaseEntity<number> implements ICategory {
);
}
public withScripts(...scripts: IScript[]): this {
public withScripts(...scripts: Script[]): this {
for (const script of scripts) {
this.withScript(script);
}
@@ -49,7 +50,7 @@ export class CategoryStub extends BaseEntity<number> implements ICategory {
return this.withAllScriptsRecursively(...scriptIds.map((id) => new ScriptStub(id)));
}
public withAllScriptsRecursively(...scripts: IScript[]): this {
public withAllScriptsRecursively(...scripts: Script[]): this {
this.allScriptsRecursively = [...scripts];
return this;
}
@@ -61,19 +62,19 @@ export class CategoryStub extends BaseEntity<number> implements ICategory {
.withScript(new ScriptStub(`[${CategoryStub.name}] script-3`).withLevel(undefined));
}
public withCategories(...categories: ICategory[]): this {
public withCategories(...categories: Category[]): this {
for (const category of categories) {
this.withCategory(category);
}
return this;
}
public withCategory(category: ICategory): this {
public withCategory(category: Category): this {
this.subCategories.push(category);
return this;
}
public withScript(script: IScript): this {
public withScript(script: Script): this {
this.scripts.push(script);
return this;
}

View File

@@ -1,15 +1,15 @@
import type { ICodeChangedEvent } from '@/application/Context/State/Code/Event/ICodeChangedEvent';
import type { ICodePosition } from '@/application/Context/State/Code/Position/ICodePosition';
import type { IScript } from '@/domain/IScript';
import type { Script } from '@/domain/Executables/Script/Script';
export class CodeChangedEventStub implements ICodeChangedEvent {
public code: string;
public addedScripts: readonly IScript[];
public addedScripts: readonly Script[];
public removedScripts: readonly IScript[];
public removedScripts: readonly Script[];
public changedScripts: readonly IScript[];
public changedScripts: readonly Script[];
public isEmpty(): boolean {
throw new Error('Method not implemented.');

View File

@@ -1,5 +1,5 @@
import type { CodeSegmentMerger } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/CodeSegmentJoin/CodeSegmentMerger';
import type { CompiledCode } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { CodeSegmentMerger } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/CodeSegmentJoin/CodeSegmentMerger';
import type { CompiledCode } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/CompiledCode';
import { CompiledCodeStub } from './CompiledCodeStub';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';

View File

@@ -1,5 +1,5 @@
import type { ICodeLine } from '@/application/Parser/Script/Validation/ICodeLine';
import type { ICodeValidationRule, IInvalidCodeLine } from '@/application/Parser/Script/Validation/ICodeValidationRule';
import type { ICodeLine } from '@/application/Parser/Executable/Script/Validation/ICodeLine';
import type { ICodeValidationRule, IInvalidCodeLine } from '@/application/Parser/Executable/Script/Validation/ICodeValidationRule';
export class CodeValidationRuleStub implements ICodeValidationRule {
public readonly receivedLines = new Array<readonly ICodeLine[]>();

View File

@@ -1,7 +1,7 @@
import { expect } from 'vitest';
import type { Constructible } from '@/TypeHelpers';
import type { ICodeValidationRule } from '@/application/Parser/Script/Validation/ICodeValidationRule';
import type { ICodeValidator } from '@/application/Parser/Script/Validation/ICodeValidator';
import type { ICodeValidationRule } from '@/application/Parser/Executable/Script/Validation/ICodeValidationRule';
import type { ICodeValidator } from '@/application/Parser/Executable/Script/Validation/ICodeValidator';
export class CodeValidatorStub implements ICodeValidator {
public callHistory = new Array<{

View File

@@ -1,7 +1,7 @@
import type {
CategoryData, ScriptData, CollectionData, ScriptingDefinitionData, FunctionData,
} from '@/application/collections/';
import { RecommendationLevel } from '@/domain/RecommendationLevel';
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
import { createScriptDataWithCode } from './ScriptDataStub';

View File

@@ -1,4 +1,4 @@
import type { CompiledCode } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { CompiledCode } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/CompiledCode';
export class CompiledCodeStub implements CompiledCode {
public code = `${CompiledCodeStub.name}: code`;

View File

@@ -0,0 +1,11 @@
import type { ExecutableErrorContext } from '@/application/Parser/Executable/Validation/ExecutableErrorContext';
import { ExecutableType } from '@/application/Parser/Executable/Validation/ExecutableType';
import { CategoryDataStub } from './CategoryDataStub';
export function createExecutableErrorContextStub(): ExecutableErrorContext {
return {
type: ExecutableType.Category,
self: new CategoryDataStub(),
parentCategory: new CategoryDataStub(),
};
}

View File

@@ -1,13 +1,13 @@
import type { NodeData } from '@/application/Parser/NodeValidation/NodeData';
import type { NodeDataValidator, NodeDataValidatorFactory } from '@/application/Parser/NodeValidation/NodeDataValidator';
import type { ExecutableData } from '@/application/collections/';
import type { ExecutableValidator, ExecutableValidatorFactory } from '@/application/Parser/Executable/Validation/ExecutableValidator';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
export const createNodeDataValidatorFactoryStub
: NodeDataValidatorFactory = () => new NodeDataValidatorStub();
export const createExecutableValidatorFactoryStub
: ExecutableValidatorFactory = () => new ExecutableValidatorStub();
export class NodeDataValidatorStub
extends StubWithObservableMethodCalls<NodeDataValidator>
implements NodeDataValidator {
export class ExecutableValidatorStub
extends StubWithObservableMethodCalls<ExecutableValidator>
implements ExecutableValidator {
private assertThrowsOnFalseCondition = true;
public withAssertThrowsOnFalseCondition(enableAssertThrows: boolean): this {
@@ -23,10 +23,10 @@ export class NodeDataValidatorStub
return this;
}
public assertDefined(node: NodeData): this {
public assertDefined(data: ExecutableData): this {
this.registerMethodCall({
methodName: 'assertDefined',
args: [node],
args: [data],
});
return this;
}
@@ -41,7 +41,7 @@ export class NodeDataValidatorStub
});
if (this.assertThrowsOnFalseCondition) {
if (!validationPredicate()) {
throw new Error(`[${NodeDataValidatorStub.name}] Assert validation failed: ${errorMessage}`);
throw new Error(`[${ExecutableValidatorStub.name}] Assert validation failed: ${errorMessage}`);
}
}
return this;
@@ -52,6 +52,6 @@ export class NodeDataValidatorStub
methodName: 'createContextualErrorMessage',
args: [errorMessage],
});
return `${NodeDataValidatorStub.name}: ${errorMessage}`;
return `${ExecutableValidatorStub.name}: ${errorMessage}`;
}
}

View File

@@ -1,6 +1,6 @@
import type { IExpressionEvaluationContext } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionEvaluationContext';
import type { IPipelineCompiler } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipelineCompiler';
import type { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
import type { IExpressionEvaluationContext } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/ExpressionEvaluationContext';
import type { IPipelineCompiler } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/IPipelineCompiler';
import type { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
import { FunctionCallArgumentCollectionStub } from './FunctionCallArgumentCollectionStub';
import { PipelineCompilerStub } from './PipelineCompilerStub';

View File

@@ -1,5 +1,5 @@
import type { IExpression } from '@/application/Parser/Script/Compiler/Expressions/Expression/IExpression';
import type { IExpressionParser } from '@/application/Parser/Script/Compiler/Expressions/Parser/IExpressionParser';
import type { IExpression } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/IExpression';
import type { IExpressionParser } from '@/application/Parser/Executable/Script/Compiler/Expressions/Parser/IExpressionParser';
export class ExpressionParserStub implements IExpressionParser {
public callHistory = new Array<string>();

View File

@@ -1,7 +1,7 @@
import { ExpressionPosition } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionPosition';
import type { IExpression } from '@/application/Parser/Script/Compiler/Expressions/Expression/IExpression';
import type { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
import type { IExpressionEvaluationContext } from '@/application/Parser/Script/Compiler/Expressions/Expression/ExpressionEvaluationContext';
import { ExpressionPosition } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/ExpressionPosition';
import type { IExpression } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/IExpression';
import type { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
import type { IExpressionEvaluationContext } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/ExpressionEvaluationContext';
import { FunctionParameterCollectionStub } from './FunctionParameterCollectionStub';
export class ExpressionStub implements IExpression {

View File

@@ -1,7 +1,7 @@
import type { IExpressionsCompiler } from '@/application/Parser/Script/Compiler/Expressions/IExpressionsCompiler';
import type { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
import type { IExpressionsCompiler } from '@/application/Parser/Executable/Script/Compiler/Expressions/IExpressionsCompiler';
import type { IReadOnlyFunctionCallArgumentCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
import { scrambledEqual } from '@/application/Common/Array';
import { FunctionBodyType, type ISharedFunction } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
import { FunctionBodyType, type ISharedFunction } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunction';
import { FunctionCallArgumentCollectionStub } from '@tests/unit/shared/Stubs/FunctionCallArgumentCollectionStub';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';

View File

@@ -1,13 +1,13 @@
import type { ICategory } from '@/domain/ICategory';
import type { IScript } from '@/domain/IScript';
import type { Category } from '@/domain/Executables/Category/Category';
import type { Script } from '@/domain/Executables/Script/Script';
import type { FilterResult } from '@/application/Context/State/Filter/Result/FilterResult';
import { CategoryStub } from './CategoryStub';
import { ScriptStub } from './ScriptStub';
export class FilterResultStub implements FilterResult {
public categoryMatches: readonly ICategory[] = [];
public categoryMatches: readonly Category[] = [];
public scriptMatches: readonly IScript[] = [];
public scriptMatches: readonly Script[] = [];
public query = '';
@@ -23,12 +23,12 @@ export class FilterResultStub implements FilterResult {
.withScriptMatches([new ScriptStub('script-2')]);
}
public withCategoryMatches(matches: readonly ICategory[]) {
public withCategoryMatches(matches: readonly Category[]) {
this.categoryMatches = matches;
return this;
}
public withScriptMatches(matches: readonly IScript[]) {
public withScriptMatches(matches: readonly Script[]) {
this.scriptMatches = matches;
return this;
}

View File

@@ -1,5 +1,5 @@
import type { IFunctionCallArgument } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgument';
import type { IFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
import type { IFunctionCallArgument } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Argument/IFunctionCallArgument';
import type { IFunctionCallArgumentCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection';
import { FunctionCallArgumentStub } from './FunctionCallArgumentStub';
export class FunctionCallArgumentCollectionStub implements IFunctionCallArgumentCollection {

View File

@@ -1,4 +1,4 @@
import type { IFunctionCallArgument } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgument';
import type { IFunctionCallArgument } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Argument/IFunctionCallArgument';
export class FunctionCallArgumentStub implements IFunctionCallArgument {
public parameterName = 'stub-parameter-name';

View File

@@ -1,7 +1,7 @@
import type { FunctionCallCompilationContext } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { SingleCallCompiler } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompiler';
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
import type { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
import type { FunctionCallCompilationContext } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { SingleCallCompiler } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompiler';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import type { ISharedFunctionCollection } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunctionCollection';
import { SingleCallCompilerStub } from './SingleCallCompilerStub';
import { FunctionCallStub } from './FunctionCallStub';
import { SharedFunctionCollectionStub } from './SharedFunctionCollectionStub';

View File

@@ -1,7 +1,7 @@
import type { CompiledCode } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { FunctionCallCompiler } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompiler';
import type { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
import type { CompiledCode } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { FunctionCallCompiler } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/FunctionCallCompiler';
import type { ISharedFunctionCollection } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunctionCollection';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import { CompiledCodeStub } from './CompiledCodeStub';
interface FunctionCallCompilationTestScenario {

View File

@@ -1,4 +1,4 @@
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import { FunctionCallArgumentCollectionStub } from './FunctionCallArgumentCollectionStub';
export class FunctionCallStub implements FunctionCall {

View File

@@ -1,4 +1,4 @@
import type { IFunctionCode } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
import type { IFunctionCode } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunction';
export class FunctionCodeStub implements IFunctionCode {
public execute = 'execute code (function-code-stub)';

View File

@@ -1,5 +1,5 @@
import type { IFunctionParameter } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameter';
import type { IFunctionParameterCollection } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
import type { IFunctionParameter } from '@/application/Parser/Executable/Script/Compiler/Function/Parameter/IFunctionParameter';
import type { IFunctionParameterCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
import { FunctionParameterStub } from './FunctionParameterStub';
export class FunctionParameterCollectionStub implements IFunctionParameterCollection {

View File

@@ -1,4 +1,4 @@
import type { IFunctionParameter } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameter';
import type { IFunctionParameter } from '@/application/Parser/Executable/Script/Compiler/Function/Parameter/IFunctionParameter';
export class FunctionParameterStub implements IFunctionParameter {
public name = 'function-parameter-stub';

View File

@@ -1,4 +1,4 @@
import type { ILanguageSyntax } from '@/application/Parser/Script/Validation/Syntax/ILanguageSyntax';
import type { ILanguageSyntax } from '@/application/Parser/Executable/Script/Validation/Syntax/ILanguageSyntax';
export class LanguageSyntaxStub implements ILanguageSyntax {
public commentDelimiters: string[] = [];

View File

@@ -1,11 +0,0 @@
import type { NodeDataErrorContext } from '@/application/Parser/NodeValidation/NodeDataErrorContext';
import { NodeDataType } from '@/application/Parser/NodeValidation/NodeDataType';
import { CategoryDataStub } from './CategoryDataStub';
export function createNodeDataErrorContextStub(): NodeDataErrorContext {
return {
type: NodeDataType.Category,
selfNode: new CategoryDataStub(),
parentNode: new CategoryDataStub(),
};
}

View File

@@ -1,5 +1,5 @@
import type { IPipe } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipe';
import type { IPipeFactory } from '@/application/Parser/Script/Compiler/Expressions/Pipes/PipeFactory';
import type { IPipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/IPipe';
import type { IPipeFactory } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/PipeFactory';
export class PipeFactoryStub implements IPipeFactory {
private readonly pipes = new Array<IPipe>();

View File

@@ -1,4 +1,4 @@
import type { IPipe } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipe';
import type { IPipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/IPipe';
export class PipeStub implements IPipe {
public name = 'pipeStub';

View File

@@ -1,4 +1,4 @@
import type { IPipelineCompiler } from '@/application/Parser/Script/Compiler/Expressions/Pipes/IPipelineCompiler';
import type { IPipelineCompiler } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/IPipelineCompiler';
export class PipelineCompilerStub implements IPipelineCompiler {
public compileHistory: Array<{ value: string, pipeline: string }> = [];

View File

@@ -1,5 +1,5 @@
import type { ScriptCodeFactory } from '@/domain/ScriptCodeFactory';
import type { IScriptCode } from '@/domain/IScriptCode';
import type { ScriptCodeFactory } from '@/domain/Executables/Script/Code/ScriptCodeFactory';
import type { ScriptCode } from '@/domain/Executables/Script/Code/ScriptCode';
import { ScriptCodeStub } from './ScriptCodeStub';
export function createScriptCodeFactoryStub(
@@ -17,6 +17,6 @@ export function createScriptCodeFactoryStub(
}
interface StubOptions {
readonly scriptCode?: IScriptCode;
readonly scriptCode?: ScriptCode;
readonly defaultCodePrefix?: string;
}

View File

@@ -1,6 +1,6 @@
import type { IScriptCode } from '@/domain/IScriptCode';
import type { ScriptCode } from '@/domain/Executables/Script/Code/ScriptCode';
export class ScriptCodeStub implements IScriptCode {
export class ScriptCodeStub implements ScriptCode {
public execute = `[${ScriptCodeStub.name}] default execute code`;
public revert = `[${ScriptCodeStub.name}] default revert code`;

View File

@@ -1,16 +1,16 @@
import type { ScriptData } from '@/application/collections/';
import type { IScriptCompiler } from '@/application/Parser/Script/Compiler/IScriptCompiler';
import type { IScriptCode } from '@/domain/IScriptCode';
import type { IScriptCompiler } from '@/application/Parser/Executable/Script/Compiler/IScriptCompiler';
import type { ScriptCode } from '@/domain/Executables/Script/Code/ScriptCode';
import { ScriptCodeStub } from './ScriptCodeStub';
export class ScriptCompilerStub implements IScriptCompiler {
public compilableScripts = new Map<ScriptData, IScriptCode>();
public compilableScripts = new Map<ScriptData, ScriptCode>();
public canCompile(script: ScriptData): boolean {
return this.compilableScripts.has(script);
}
public compile(script: ScriptData): IScriptCode {
public compile(script: ScriptData): ScriptCode {
const foundCode = this.compilableScripts.get(script);
if (foundCode) {
return foundCode;
@@ -18,7 +18,7 @@ export class ScriptCompilerStub implements IScriptCompiler {
return new ScriptCodeStub();
}
public withCompileAbility(script: ScriptData, result?: IScriptCode): this {
public withCompileAbility(script: ScriptData, result?: ScriptCode): this {
this.compilableScripts.set(
script,
result ?? { execute: `compiled code of ${script.name}`, revert: `compiled revert code of ${script.name}` },

View File

@@ -1,7 +1,7 @@
import type {
FunctionCallData, CallScriptData, CodeScriptData,
} from '@/application/collections/';
import { RecommendationLevel } from '@/domain/RecommendationLevel';
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
import { FunctionCallDataStub } from '@tests/unit/shared/Stubs/FunctionCallDataStub';
export function createScriptDataWithCode(): ScriptDataStub & CodeScriptData {

View File

@@ -1,13 +1,13 @@
import type { ScriptFactory } from '@/application/Parser/Script/ScriptParser';
import type { IScript } from '@/domain/IScript';
import type { ScriptInitParameters } from '@/domain/Script';
import type { ScriptFactory } from '@/application/Parser/Executable/Script/ScriptParser';
import type { Script } from '@/domain/Executables/Script/Script';
import type { ScriptInitParameters } from '@/domain/Executables/Script/CollectionScript';
import { ScriptStub } from './ScriptStub';
export function createScriptFactorySpy(): {
readonly scriptFactorySpy: ScriptFactory;
getInitParameters: (category: IScript) => ScriptInitParameters | undefined;
getInitParameters: (category: Script) => ScriptInitParameters | undefined;
} {
const createdScripts = new Map<IScript, ScriptInitParameters>();
const createdScripts = new Map<Script, ScriptInitParameters>();
return {
scriptFactorySpy: (parameters) => {
const script = new ScriptStub('script from factory stub');

View File

@@ -1,12 +1,12 @@
import type { ScriptParser } from '@/application/Parser/Script/ScriptParser';
import type { IScript } from '@/domain/IScript';
import type { ScriptParser } from '@/application/Parser/Executable/Script/ScriptParser';
import type { Script } from '@/domain/Executables/Script/Script';
import type { ScriptData } from '@/application/collections/';
import { ScriptStub } from './ScriptStub';
export class ScriptParserStub {
private readonly parsedScripts = new Map<IScript, Parameters<ScriptParser>>();
private readonly parsedScripts = new Map<Script, Parameters<ScriptParser>>();
private readonly setupScripts = new Map<ScriptData, IScript>();
private readonly setupScripts = new Map<ScriptData, Script>();
public get(): ScriptParser {
return (...parameters) => {
@@ -21,7 +21,7 @@ export class ScriptParserStub {
}
public getParseParameters(
script: IScript,
script: Script,
): Parameters<ScriptParser> {
const parameters = this.parsedScripts.get(script);
if (!parameters) {
@@ -30,7 +30,7 @@ export class ScriptParserStub {
return parameters;
}
public setupParsedResultForData(scriptData: ScriptData, parsedResult: IScript): this {
public setupParsedResultForData(scriptData: ScriptData, parsedResult: Script): this {
this.setupScripts.set(scriptData, parsedResult);
return this;
}

View File

@@ -1,7 +1,7 @@
import { expect } from 'vitest';
import type { ScriptSelection } from '@/application/Context/State/Selection/Script/ScriptSelection';
import type { SelectedScript } from '@/application/Context/State/Selection/Script/SelectedScript';
import type { IScript } from '@/domain/IScript';
import type { Script } from '@/domain/Executables/Script/Script';
import type { ScriptSelectionChange, ScriptSelectionChangeCommand } from '@/application/Context/State/Selection/Script/ScriptSelectionChange';
import { formatAssertionMessage } from '@tests/shared/FormatAssertionMessage';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
@@ -58,7 +58,7 @@ export class ScriptSelectionStub
});
}
public selectOnly(scripts: ReadonlyArray<IScript>): void {
public selectOnly(scripts: ReadonlyArray<Script>): void {
this.registerMethodCall({
methodName: 'selectOnly',
args: [scripts],

View File

@@ -1,13 +1,13 @@
import { BaseEntity } from '@/infrastructure/Entity/BaseEntity';
import type { IScript } from '@/domain/IScript';
import { RecommendationLevel } from '@/domain/RecommendationLevel';
import type { IScriptCode } from '@/domain/IScriptCode';
import type { Script } from '@/domain/Executables/Script/Script';
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
import type { ScriptCode } from '@/domain/Executables/Script/Code/ScriptCode';
import { SelectedScriptStub } from './SelectedScriptStub';
export class ScriptStub extends BaseEntity<string> implements IScript {
export class ScriptStub extends BaseEntity<string> implements Script {
public name = `name${this.id}`;
public code: IScriptCode = {
public code: ScriptCode = {
execute: `REM execute-code (${this.id})`,
revert: `REM revert-code (${this.id})`,
};

View File

@@ -1,15 +1,15 @@
import type { SelectedScript } from '@/application/Context/State/Selection/Script/SelectedScript';
import type { IScript } from '@/domain/IScript';
import type { Script } from '@/domain/Executables/Script/Script';
export class SelectedScriptStub implements SelectedScript {
public readonly script: IScript;
public readonly script: Script;
public readonly id: string;
public revert: boolean;
constructor(
script: IScript,
script: Script,
) {
this.id = script.id;
this.script = script;

View File

@@ -1,5 +1,5 @@
import type { ISharedFunction } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
import type { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
import type { ISharedFunction } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunction';
import type { ISharedFunctionCollection } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunctionCollection';
import { createSharedFunctionStubWithCode } from './SharedFunctionStub';
export class SharedFunctionCollectionStub implements ISharedFunctionCollection {

View File

@@ -1,8 +1,8 @@
import {
type ISharedFunction, FunctionBodyType, type CallFunctionBody, type CodeFunctionBody,
} from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
import type { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
} from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunction';
import type { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import { FunctionParameterCollectionStub } from './FunctionParameterCollectionStub';
import { FunctionCallStub } from './FunctionCallStub';
import { FunctionCodeStub } from './FunctionCodeStub';

View File

@@ -1,8 +1,8 @@
import type { FunctionData } from '@/application/collections/';
import { sequenceEqual } from '@/application/Common/Array';
import type { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
import type { ISharedFunctionsParser } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionsParser';
import type { ILanguageSyntax } from '@/application/Parser/Script/Validation/Syntax/ILanguageSyntax';
import type { ISharedFunctionCollection } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunctionCollection';
import type { ISharedFunctionsParser } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunctionsParser';
import type { ILanguageSyntax } from '@/application/Parser/Executable/Script/Validation/Syntax/ILanguageSyntax';
import { SharedFunctionCollectionStub } from './SharedFunctionCollectionStub';
export class SharedFunctionsParserStub implements ISharedFunctionsParser {

View File

@@ -1,8 +1,8 @@
import type { CompiledCode } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { FunctionCallCompilationContext } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { SingleCallCompilerStrategy } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompilerStrategy';
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
import type { ISharedFunction } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
import type { CompiledCode } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { FunctionCallCompilationContext } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { SingleCallCompilerStrategy } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompilerStrategy';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import type { ISharedFunction } from '@/application/Parser/Executable/Script/Compiler/Function/ISharedFunction';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
import { CompiledCodeStub } from './CompiledCodeStub';

View File

@@ -1,7 +1,7 @@
import type { CompiledCode } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { FunctionCallCompilationContext } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { SingleCallCompiler } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompiler';
import type { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
import type { CompiledCode } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/CompiledCode';
import type { FunctionCallCompilationContext } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
import type { SingleCallCompiler } from '@/application/Parser/Executable/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompiler';
import type { FunctionCall } from '@/application/Parser/Executable/Script/Compiler/Function/Call/FunctionCall';
import { StubWithObservableMethodCalls } from './StubWithObservableMethodCalls';
import { CompiledCodeStub } from './CompiledCodeStub';

View File

@@ -0,0 +1,18 @@
import type { ILanguageSyntax } from '@/application/Parser/Executable/Script/Validation/Syntax/ILanguageSyntax';
import type { ISyntaxFactory } from '@/application/Parser/Executable/Script/Validation/Syntax/ISyntaxFactory';
import type { ScriptingLanguage } from '@/domain/ScriptingLanguage';
import { LanguageSyntaxStub } from './LanguageSyntaxStub';
export function createSyntaxFactoryStub(
expectedLanguage?: ScriptingLanguage,
result?: ILanguageSyntax,
): ISyntaxFactory {
return {
create: (language: ScriptingLanguage) => {
if (expectedLanguage !== undefined && language !== expectedLanguage) {
throw new Error('unexpected language');
}
return result ?? new LanguageSyntaxStub();
},
};
}