From e9e9fca5fae84e27dc11a1ed799794960ee16259 Mon Sep 17 00:00:00 2001 From: Georg Schwarz Date: Tue, 16 Jan 2024 10:36:21 +0100 Subject: [PATCH] Simplify checking for incorrect extractor and loader blocks --- .../lib/validation/checks/block-definition.ts | 18 ------------------ .../lib/validation/checks/pipe-definition.ts | 10 ++++------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/libs/language-server/src/lib/validation/checks/block-definition.ts b/libs/language-server/src/lib/validation/checks/block-definition.ts index 87da1ae64..010308784 100644 --- a/libs/language-server/src/lib/validation/checks/block-definition.ts +++ b/libs/language-server/src/lib/validation/checks/block-definition.ts @@ -40,24 +40,6 @@ function checkPipesOfBlock( const blockType = new BlockTypeWrapper(block?.type); const pipes = collectPipes(block, whatToCheck); - const isStartOrEnd = - (whatToCheck === 'input' && !blockType.hasInput()) || - (whatToCheck === 'output' && !blockType.hasOutput()); - if (isStartOrEnd) { - if (pipes.length > 0) { - for (const pipe of pipes) { - context.accept( - 'error', - `Blocks of type ${blockType.type} do not have an ${whatToCheck}`, - whatToCheck === 'input' - ? pipe.getToDiagnostic() - : pipe.getFromDiagnostic(), - ); - } - } - return; - } - const hasMultipleInputPorts = pipes.length > 1 && whatToCheck === 'input'; if (hasMultipleInputPorts) { for (const pipe of pipes) { diff --git a/libs/language-server/src/lib/validation/checks/pipe-definition.ts b/libs/language-server/src/lib/validation/checks/pipe-definition.ts index 76f24acbe..9c1b6abb0 100644 --- a/libs/language-server/src/lib/validation/checks/pipe-definition.ts +++ b/libs/language-server/src/lib/validation/checks/pipe-definition.ts @@ -37,12 +37,10 @@ function checkBlockCompatibility( const fromBlockType = new BlockTypeWrapper(fromBlockTypeDefinition); const toBlockType = new BlockTypeWrapper(toBlockTypeDefinition); - if (fromBlockType.hasOutput() && toBlockType.hasInput()) { - if (!fromBlockType.canBeConnectedTo(toBlockType)) { - const errorMessage = `The output type "${fromBlockType.outputType}" of ${fromBlockType.type} is incompatible with the input type "${toBlockType.inputType}" of ${toBlockType.type}`; - context.accept('error', errorMessage, pipeWrapper.getFromDiagnostic()); - context.accept('error', errorMessage, pipeWrapper.getToDiagnostic()); - } + if (!fromBlockType.canBeConnectedTo(toBlockType)) { + const errorMessage = `The output type "${fromBlockType.outputType}" of ${fromBlockType.type} is incompatible with the input type "${toBlockType.inputType}" of ${toBlockType.type}`; + context.accept('error', errorMessage, pipeWrapper.getFromDiagnostic()); + context.accept('error', errorMessage, pipeWrapper.getToDiagnostic()); } } }