Alias would remove unnecessary repetitions and less relative paths make changes easier when moving around files. This commit cleans also up some relative paths ('../../../') by using the alias and orders imports. It updates both path alias in tsconfig and module alias in Vue CLI's bundler (vuejs/vue-cli#2398).
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { sequenceEqual } from '@/application/Common/Array';
|
|
import { IFunctionCompiler } from '@/application/Parser/Script/Compiler/Function/IFunctionCompiler';
|
|
import { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
|
|
import { FunctionData } from 'js-yaml-loader!@/*';
|
|
import { SharedFunctionCollectionStub } from './SharedFunctionCollectionStub';
|
|
|
|
export class FunctionCompilerStub implements IFunctionCompiler {
|
|
private setupResults = new Array<{
|
|
functions: readonly FunctionData[],
|
|
result: ISharedFunctionCollection,
|
|
}>();
|
|
|
|
public setup(functions: readonly FunctionData[], result: ISharedFunctionCollection) {
|
|
this.setupResults.push( { functions, result });
|
|
}
|
|
|
|
public compileFunctions(functions: readonly FunctionData[]): ISharedFunctionCollection {
|
|
const result = this.findResult(functions);
|
|
return result || new SharedFunctionCollectionStub();
|
|
}
|
|
|
|
private findResult(functions: readonly FunctionData[]): ISharedFunctionCollection {
|
|
for (const result of this.setupResults) {
|
|
if (sequenceEqual(result.functions, functions)) {
|
|
return result.result;
|
|
}
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|