Skip to content

Commit

Permalink
Simplify checking for incorrect extractor and loader blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-schwarz committed Jan 16, 2024
1 parent 00867cd commit e9e9fca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
18 changes: 0 additions & 18 deletions libs/language-server/src/lib/validation/checks/block-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit e9e9fca

Please sign in to comment.