Fix PowerShell code block inlining in compiler
This commit enhances the compiler's ability to inline PowerShell code
blocks. Previously, the compiler attempted to inline all lines ending
with brackets (`}` and `{`) using semicolons, which leads to syntax
errors. This improvement allows for more flexible PowerShell code
writing with reliable outcomes.
Key Changes:
- Update InlinePowerShell pipe to handle code blocks specifically
- Extend unit tests for the InlinePowerShell pipe
Other supporting changes:
- Refactor InlinePowerShell tests for improved scalability
- Enhance pipe unit test running with regex support
- Expand test coverage for various PowerShell syntax used in
privacy.sexy
- Update related interfaces to align with new code conventions, dropping
`I` prefix
- Optimize line merging to skip lines already ending with semicolons
- Increase timeout in E2E tests to accommodate for slower application
load caused by more processing introduced in this commit.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { IPipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/IPipe';
|
||||
import type { Pipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/Pipe';
|
||||
import type { IPipeFactory } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/PipeFactory';
|
||||
|
||||
export class PipeFactoryStub implements IPipeFactory {
|
||||
private readonly pipes = new Array<IPipe>();
|
||||
private readonly pipes = new Array<Pipe>();
|
||||
|
||||
public get(pipeName: string): IPipe {
|
||||
public get(pipeName: string): Pipe {
|
||||
const result = this.pipes.find((pipe) => pipe.name === pipeName);
|
||||
if (!result) {
|
||||
throw new Error(`pipe not registered: "${pipeName}"`);
|
||||
@@ -12,12 +12,12 @@ export class PipeFactoryStub implements IPipeFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
public withPipe(pipe: IPipe) {
|
||||
public withPipe(pipe: Pipe) {
|
||||
this.pipes.push(pipe);
|
||||
return this;
|
||||
}
|
||||
|
||||
public withPipes(pipes: IPipe[]) {
|
||||
public withPipes(pipes: Pipe[]) {
|
||||
for (const pipe of pipes) {
|
||||
this.withPipe(pipe);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IPipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/IPipe';
|
||||
import type { Pipe } from '@/application/Parser/Executable/Script/Compiler/Expressions/Pipes/Pipe';
|
||||
|
||||
export class PipeStub implements IPipe {
|
||||
export class PipeStub implements Pipe {
|
||||
public name = 'pipeStub';
|
||||
|
||||
public apply(raw: string): string {
|
||||
|
||||
Reference in New Issue
Block a user