From 7a2ce1bbece62bb176df7a2472e85e3e77be9dce Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sun, 8 Oct 2023 16:49:02 +0200 Subject: [PATCH 1/4] feat: error if nothing or multiple values are assigned to a result --- src/language/helpers/nodeProperties.ts | 12 ++++- .../other/declarations/parameters.ts | 20 +------- .../validation/other/declarations/segments.ts | 50 +++++++++++++++++++ src/language/validation/safe-ds-validator.ts | 12 +++-- .../in same file/to modules/main.sdstest | 6 +++ .../main.sdstest | 0 .../unused/main.sdstest | 2 +- .../segments/duplicate yield/main.sdstest | 20 ++++++++ .../segments/unassigned result/main.sdstest | 17 +++++++ .../unused parameter}/main.sdstest | 2 +- 10 files changed, 114 insertions(+), 27 deletions(-) create mode 100644 src/language/validation/other/declarations/segments.ts create mode 100644 tests/resources/scoping/references/in same file/to modules/main.sdstest rename tests/resources/validation/other/declarations/{parameter => parameters}/variadic must not be optional/main.sdstest (100%) rename tests/resources/validation/other/declarations/{placeholder => placeholders}/unused/main.sdstest (95%) create mode 100644 tests/resources/validation/other/declarations/segments/duplicate yield/main.sdstest create mode 100644 tests/resources/validation/other/declarations/segments/unassigned result/main.sdstest rename tests/resources/validation/other/declarations/{parameter/unused => segments/unused parameter}/main.sdstest (95%) diff --git a/src/language/helpers/nodeProperties.ts b/src/language/helpers/nodeProperties.ts index f7a98aca5..df5af4412 100644 --- a/src/language/helpers/nodeProperties.ts +++ b/src/language/helpers/nodeProperties.ts @@ -13,7 +13,7 @@ import { isSdsModuleMember, isSdsPlaceholder, isSdsSegment, - isSdsTypeParameterList, + isSdsTypeParameterList, isSdsYield, SdsAbstractCall, SdsAbstractResult, SdsAnnotatedObject, @@ -46,7 +46,7 @@ import { SdsTypeArgument, SdsTypeArgumentList, SdsTypeParameter, - SdsTypeParameterList, + SdsTypeParameterList, SdsYield, } from '../generated/ast.js'; import { AstNode, getContainerOfType, stream } from 'langium'; @@ -202,3 +202,11 @@ export const typeParametersOrEmpty = ( return []; } /* c8 ignore stop */ }; + +export const yieldsOrEmpty = (node: SdsBlock | undefined): SdsYield[] => { + return stream(statementsOrEmpty(node)) + .filter(isSdsAssignment) + .flatMap(assigneesOrEmpty) + .filter(isSdsYield) + .toArray(); +}; diff --git a/src/language/validation/other/declarations/parameters.ts b/src/language/validation/other/declarations/parameters.ts index 9a2b3763e..473db1763 100644 --- a/src/language/validation/other/declarations/parameters.ts +++ b/src/language/validation/other/declarations/parameters.ts @@ -1,9 +1,6 @@ -import { SdsParameter, SdsSegment } from '../../../generated/ast.js'; +import { SdsParameter } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; -import { parametersOrEmpty } from '../../../helpers/nodeProperties.js'; -import { SafeDsServices } from '../../../safe-ds-module.js'; -export const CODE_PARAMETER_UNUSED = 'parameter/unused'; export const CODE_PARAMETER_VARIADIC_AND_OPTIONAL = 'parameter/variadic-and-optional'; export const parameterMustNotBeVariadicAndOptional = (node: SdsParameter, accept: ValidationAcceptor) => { @@ -15,18 +12,3 @@ export const parameterMustNotBeVariadicAndOptional = (node: SdsParameter, accept }); } }; - -export const segmentParameterShouldBeUsed = - (services: SafeDsServices) => (node: SdsSegment, accept: ValidationAcceptor) => { - for (const parameter of parametersOrEmpty(node)) { - const usages = services.helpers.NodeMapper.parameterToReferences(parameter); - - if (usages.isEmpty()) { - accept('warning', 'This parameter is unused and can be removed.', { - node: parameter, - property: 'name', - code: CODE_PARAMETER_UNUSED, - }); - } - } - }; diff --git a/src/language/validation/other/declarations/segments.ts b/src/language/validation/other/declarations/segments.ts new file mode 100644 index 000000000..95d210c5f --- /dev/null +++ b/src/language/validation/other/declarations/segments.ts @@ -0,0 +1,50 @@ +import { SdsSegment } from '../../../generated/ast.js'; +import { ValidationAcceptor } from 'langium'; +import { parametersOrEmpty, resultsOrEmpty, yieldsOrEmpty } from '../../../helpers/nodeProperties.js'; +import { SafeDsServices } from '../../../safe-ds-module.js'; +import { duplicatesBy } from '../../../helpers/collectionUtils.js'; + +export const CODE_SEGMENT_DUPLICATE_YIELD = 'segment/duplicate-yield'; +export const CODE_SEGMENT_UNASSIGNED_RESULT = 'segment/unassigned-result'; +export const CODE_SEGMENT_UNUSED_PARAMETER = 'segment/unused-parameter'; + +export const segmentResultMustOnlyBeAssignedOnce = (node: SdsSegment, accept: ValidationAcceptor) => { + const yields = yieldsOrEmpty(node.body); + for (const duplicate of duplicatesBy(yields, (it) => it.result?.ref)) { + accept('error', `The result '${duplicate.result?.$refText}' has been assigned already.`, { + node: duplicate, + property: 'result', + code: CODE_SEGMENT_DUPLICATE_YIELD, + }); + } +}; + +export const segmentResultMustBeAssigned = + (services: SafeDsServices) => (node: SdsSegment, accept: ValidationAcceptor) => { + const results = resultsOrEmpty(node.resultList); + for (const result of results) { + const yields = services.helpers.NodeMapper.resultToYields(result); + if (yields.isEmpty()) { + accept('error', 'Nothing is assigned to this result.', { + node: result, + property: 'name', + code: CODE_SEGMENT_UNASSIGNED_RESULT, + }); + } + } + }; + +export const segmentParameterShouldBeUsed = + (services: SafeDsServices) => (node: SdsSegment, accept: ValidationAcceptor) => { + for (const parameter of parametersOrEmpty(node)) { + const usages = services.helpers.NodeMapper.parameterToReferences(parameter); + + if (usages.isEmpty()) { + accept('warning', 'This parameter is unused and can be removed.', { + node: parameter, + property: 'name', + code: CODE_SEGMENT_UNUSED_PARAMETER, + }); + } + } + }; diff --git a/src/language/validation/safe-ds-validator.ts b/src/language/validation/safe-ds-validator.ts index 4ed3dc78d..65a31bde0 100644 --- a/src/language/validation/safe-ds-validator.ts +++ b/src/language/validation/safe-ds-validator.ts @@ -45,10 +45,7 @@ import { unionTypeMustHaveTypeArguments } from './other/types/unionTypes.js'; import { callableTypeMustNotHaveOptionalParameters } from './other/types/callableTypes.js'; import { typeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments } from './other/types/typeArgumentLists.js'; import { argumentListMustNotHavePositionalArgumentsAfterNamedArguments } from './other/argumentLists.js'; -import { - parameterMustNotBeVariadicAndOptional, - segmentParameterShouldBeUsed, -} from './other/declarations/parameters.js'; +import { parameterMustNotBeVariadicAndOptional } from './other/declarations/parameters.js'; import { referenceTargetMustNotBeAnnotationPipelineOrSchema } from './other/expressions/references.js'; import { annotationCallAnnotationShouldNotBeDeprecated, @@ -65,6 +62,11 @@ import { referenceTargetShouldNotExperimental, } from './builtins/experimental.js'; import { placeholderShouldBeUsed } from './other/declarations/placeholders.js'; +import { + segmentParameterShouldBeUsed, + segmentResultMustBeAssigned, + segmentResultMustOnlyBeAssignedOnce, +} from './other/declarations/segments.js'; /** * Register custom validation checks. @@ -125,6 +127,8 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsSegment: [ segmentMustContainUniqueNames, segmentParameterShouldBeUsed(services), + segmentResultMustBeAssigned(services), + segmentResultMustOnlyBeAssignedOnce, segmentResultListShouldNotBeEmpty, ], SdsTemplateString: [templateStringMustHaveExpressionBetweenTwoStringParts], diff --git a/tests/resources/scoping/references/in same file/to modules/main.sdstest b/tests/resources/scoping/references/in same file/to modules/main.sdstest new file mode 100644 index 000000000..2904f0e21 --- /dev/null +++ b/tests/resources/scoping/references/in same file/to modules/main.sdstest @@ -0,0 +1,6 @@ +package tests + +pipeline myPipeline { + // $TEST$ unresolved + »tests«; +} diff --git a/tests/resources/validation/other/declarations/parameter/variadic must not be optional/main.sdstest b/tests/resources/validation/other/declarations/parameters/variadic must not be optional/main.sdstest similarity index 100% rename from tests/resources/validation/other/declarations/parameter/variadic must not be optional/main.sdstest rename to tests/resources/validation/other/declarations/parameters/variadic must not be optional/main.sdstest diff --git a/tests/resources/validation/other/declarations/placeholder/unused/main.sdstest b/tests/resources/validation/other/declarations/placeholders/unused/main.sdstest similarity index 95% rename from tests/resources/validation/other/declarations/placeholder/unused/main.sdstest rename to tests/resources/validation/other/declarations/placeholders/unused/main.sdstest index 49dde3b9d..1527cb7ac 100644 --- a/tests/resources/validation/other/declarations/placeholder/unused/main.sdstest +++ b/tests/resources/validation/other/declarations/placeholders/unused/main.sdstest @@ -1,4 +1,4 @@ -package tests.validation.declarations.placeholders.unused +package tests.validation.other.declarations.placeholders.unused fun f() -> (r1: Int, r2: Int) diff --git a/tests/resources/validation/other/declarations/segments/duplicate yield/main.sdstest b/tests/resources/validation/other/declarations/segments/duplicate yield/main.sdstest new file mode 100644 index 000000000..f6677b703 --- /dev/null +++ b/tests/resources/validation/other/declarations/segments/duplicate yield/main.sdstest @@ -0,0 +1,20 @@ +package tests.validation.other.declarations.segments.duplicateYield + +segment mySegment() -> (a: Int, b: Int, c: Int) { + // $TEST$ no error r"The result '\w*' has been assigned already\." + yield »a« = 1; + + // $TEST$ no error r"The result '\w*' has been assigned already\." + yield »b« = 1; + // $TEST$ error "The result 'b' has been assigned already." + yield »b« = 1; + + // $TEST$ no error r"The result '\w*' has been assigned already\." + // $TEST$ error "The result 'c' has been assigned already." + yield »c«, yield »c« = 1; + + // $TEST$ no error r"The result '\w*' has been assigned already\." + yield »unresolved« = 1; + // $TEST$ no error r"The result '\w*' has been assigned already\." + yield »unresolved« = 1; +} diff --git a/tests/resources/validation/other/declarations/segments/unassigned result/main.sdstest b/tests/resources/validation/other/declarations/segments/unassigned result/main.sdstest new file mode 100644 index 000000000..f4ef66806 --- /dev/null +++ b/tests/resources/validation/other/declarations/segments/unassigned result/main.sdstest @@ -0,0 +1,17 @@ +package tests.validation.other.declarations.segments.unassignedResult + +// $TEST$ no error "Nothing is assigned to this result." +// $TEST$ no error "Nothing is assigned to this result." +// $TEST$ no error "Nothing is assigned to this result." +// $TEST$ no error "Nothing is assigned to this result." +// $TEST$ error "Nothing is assigned to this result." +segment mySegment() -> (»a«: Int, »b«: Int, »c«: Int, »d«: Int, »e«: Int) { + yield b = 1; + yield a = 1; + + yield c = 1; + yield c = 1; + + // While nothing is assigned to d, the programmer still states their intention to do so. We already show another error for this. + _, yield d = 1; +} diff --git a/tests/resources/validation/other/declarations/parameter/unused/main.sdstest b/tests/resources/validation/other/declarations/segments/unused parameter/main.sdstest similarity index 95% rename from tests/resources/validation/other/declarations/parameter/unused/main.sdstest rename to tests/resources/validation/other/declarations/segments/unused parameter/main.sdstest index 205dca661..6dc16013e 100644 --- a/tests/resources/validation/other/declarations/parameter/unused/main.sdstest +++ b/tests/resources/validation/other/declarations/segments/unused parameter/main.sdstest @@ -1,4 +1,4 @@ -package tests.validation.declarations.parameters.unused +package tests.validation.other.declarations.segments.unusedParameters segment mySegment( // $TEST$ warning "This parameter is unused and can be removed." From 76354e513eb6d43f3e456280c2d216c1b34950b6 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sun, 8 Oct 2023 16:53:32 +0200 Subject: [PATCH 2/4] perf: combine into a single function --- .../validation/other/declarations/segments.ts | 26 ++++++------ src/language/validation/safe-ds-validator.ts | 41 +++++++++---------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/language/validation/other/declarations/segments.ts b/src/language/validation/other/declarations/segments.ts index 95d210c5f..7ad9d978e 100644 --- a/src/language/validation/other/declarations/segments.ts +++ b/src/language/validation/other/declarations/segments.ts @@ -1,25 +1,13 @@ import { SdsSegment } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; -import { parametersOrEmpty, resultsOrEmpty, yieldsOrEmpty } from '../../../helpers/nodeProperties.js'; +import { parametersOrEmpty, resultsOrEmpty } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; -import { duplicatesBy } from '../../../helpers/collectionUtils.js'; export const CODE_SEGMENT_DUPLICATE_YIELD = 'segment/duplicate-yield'; export const CODE_SEGMENT_UNASSIGNED_RESULT = 'segment/unassigned-result'; export const CODE_SEGMENT_UNUSED_PARAMETER = 'segment/unused-parameter'; -export const segmentResultMustOnlyBeAssignedOnce = (node: SdsSegment, accept: ValidationAcceptor) => { - const yields = yieldsOrEmpty(node.body); - for (const duplicate of duplicatesBy(yields, (it) => it.result?.ref)) { - accept('error', `The result '${duplicate.result?.$refText}' has been assigned already.`, { - node: duplicate, - property: 'result', - code: CODE_SEGMENT_DUPLICATE_YIELD, - }); - } -}; - -export const segmentResultMustBeAssigned = +export const segmentResultMustBeAssignedExactlyOnce = (services: SafeDsServices) => (node: SdsSegment, accept: ValidationAcceptor) => { const results = resultsOrEmpty(node.resultList); for (const result of results) { @@ -30,6 +18,16 @@ export const segmentResultMustBeAssigned = property: 'name', code: CODE_SEGMENT_UNASSIGNED_RESULT, }); + continue; + } + + const duplicateYields = yields.tail(1) + for (const duplicate of duplicateYields) { + accept('error', `The result '${result.name}' has been assigned already.`, { + node: duplicate, + property: 'result', + code: CODE_SEGMENT_DUPLICATE_YIELD, + }); } } }; diff --git a/src/language/validation/safe-ds-validator.ts b/src/language/validation/safe-ds-validator.ts index 65a31bde0..609c699c8 100644 --- a/src/language/validation/safe-ds-validator.ts +++ b/src/language/validation/safe-ds-validator.ts @@ -1,6 +1,6 @@ -import { ValidationChecks } from 'langium'; -import { SafeDsAstType } from '../generated/ast.js'; -import type { SafeDsServices } from '../safe-ds-module.js'; +import {ValidationChecks} from 'langium'; +import {SafeDsAstType} from '../generated/ast.js'; +import type {SafeDsServices} from '../safe-ds-module.js'; import { annotationMustContainUniqueNames, blockLambdaMustContainUniqueNames, @@ -31,22 +31,24 @@ import { typeParameterListShouldNotBeEmpty, unionTypeShouldNotHaveASingularTypeArgument, } from './style.js'; -import { templateStringMustHaveExpressionBetweenTwoStringParts } from './other/expressions/templateStrings.js'; -import { yieldMustNotBeUsedInPipeline } from './other/statements/assignments.js'; -import { attributeMustHaveTypeHint, parameterMustHaveTypeHint, resultMustHaveTypeHint } from './types.js'; -import { moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage } from './other/modules.js'; -import { typeParameterConstraintLeftOperandMustBeOwnTypeParameter } from './other/declarations/typeParameterConstraints.js'; +import {templateStringMustHaveExpressionBetweenTwoStringParts} from './other/expressions/templateStrings.js'; +import {yieldMustNotBeUsedInPipeline} from './other/statements/assignments.js'; +import {attributeMustHaveTypeHint, parameterMustHaveTypeHint, resultMustHaveTypeHint} from './types.js'; +import {moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage} from './other/modules.js'; +import { + typeParameterConstraintLeftOperandMustBeOwnTypeParameter +} from './other/declarations/typeParameterConstraints.js'; import { parameterListMustNotHaveOptionalAndVariadicParameters, parameterListMustNotHaveRequiredParametersAfterOptionalParameters, parameterListVariadicParameterMustBeLast, } from './other/declarations/parameterLists.js'; -import { unionTypeMustHaveTypeArguments } from './other/types/unionTypes.js'; -import { callableTypeMustNotHaveOptionalParameters } from './other/types/callableTypes.js'; -import { typeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments } from './other/types/typeArgumentLists.js'; -import { argumentListMustNotHavePositionalArgumentsAfterNamedArguments } from './other/argumentLists.js'; -import { parameterMustNotBeVariadicAndOptional } from './other/declarations/parameters.js'; -import { referenceTargetMustNotBeAnnotationPipelineOrSchema } from './other/expressions/references.js'; +import {unionTypeMustHaveTypeArguments} from './other/types/unionTypes.js'; +import {callableTypeMustNotHaveOptionalParameters} from './other/types/callableTypes.js'; +import {typeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments} from './other/types/typeArgumentLists.js'; +import {argumentListMustNotHavePositionalArgumentsAfterNamedArguments} from './other/argumentLists.js'; +import {parameterMustNotBeVariadicAndOptional} from './other/declarations/parameters.js'; +import {referenceTargetMustNotBeAnnotationPipelineOrSchema} from './other/expressions/references.js'; import { annotationCallAnnotationShouldNotBeDeprecated, argumentCorrespondingParameterShouldNotBeDeprecated, @@ -61,12 +63,8 @@ import { namedTypeDeclarationShouldNotBeExperimental, referenceTargetShouldNotExperimental, } from './builtins/experimental.js'; -import { placeholderShouldBeUsed } from './other/declarations/placeholders.js'; -import { - segmentParameterShouldBeUsed, - segmentResultMustBeAssigned, - segmentResultMustOnlyBeAssignedOnce, -} from './other/declarations/segments.js'; +import {placeholderShouldBeUsed} from './other/declarations/placeholders.js'; +import {segmentParameterShouldBeUsed, segmentResultMustBeAssignedExactlyOnce} from './other/declarations/segments.js'; /** * Register custom validation checks. @@ -127,8 +125,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsSegment: [ segmentMustContainUniqueNames, segmentParameterShouldBeUsed(services), - segmentResultMustBeAssigned(services), - segmentResultMustOnlyBeAssignedOnce, + segmentResultMustBeAssignedExactlyOnce(services), segmentResultListShouldNotBeEmpty, ], SdsTemplateString: [templateStringMustHaveExpressionBetweenTwoStringParts], From ba775cf306f5002ac8a7207761b36861dfa94ca0 Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Sun, 8 Oct 2023 15:00:12 +0000 Subject: [PATCH 3/4] style: apply automated linter fixes --- src/language/helpers/nodeProperties.ts | 6 ++-- .../validation/other/declarations/segments.ts | 2 +- src/language/validation/safe-ds-validator.ts | 34 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/language/helpers/nodeProperties.ts b/src/language/helpers/nodeProperties.ts index df5af4412..819691d47 100644 --- a/src/language/helpers/nodeProperties.ts +++ b/src/language/helpers/nodeProperties.ts @@ -13,7 +13,8 @@ import { isSdsModuleMember, isSdsPlaceholder, isSdsSegment, - isSdsTypeParameterList, isSdsYield, + isSdsTypeParameterList, + isSdsYield, SdsAbstractCall, SdsAbstractResult, SdsAnnotatedObject, @@ -46,7 +47,8 @@ import { SdsTypeArgument, SdsTypeArgumentList, SdsTypeParameter, - SdsTypeParameterList, SdsYield, + SdsTypeParameterList, + SdsYield, } from '../generated/ast.js'; import { AstNode, getContainerOfType, stream } from 'langium'; diff --git a/src/language/validation/other/declarations/segments.ts b/src/language/validation/other/declarations/segments.ts index 7ad9d978e..8c0bf1ffc 100644 --- a/src/language/validation/other/declarations/segments.ts +++ b/src/language/validation/other/declarations/segments.ts @@ -21,7 +21,7 @@ export const segmentResultMustBeAssignedExactlyOnce = continue; } - const duplicateYields = yields.tail(1) + const duplicateYields = yields.tail(1); for (const duplicate of duplicateYields) { accept('error', `The result '${result.name}' has been assigned already.`, { node: duplicate, diff --git a/src/language/validation/safe-ds-validator.ts b/src/language/validation/safe-ds-validator.ts index 609c699c8..221dd1660 100644 --- a/src/language/validation/safe-ds-validator.ts +++ b/src/language/validation/safe-ds-validator.ts @@ -1,6 +1,6 @@ -import {ValidationChecks} from 'langium'; -import {SafeDsAstType} from '../generated/ast.js'; -import type {SafeDsServices} from '../safe-ds-module.js'; +import { ValidationChecks } from 'langium'; +import { SafeDsAstType } from '../generated/ast.js'; +import type { SafeDsServices } from '../safe-ds-module.js'; import { annotationMustContainUniqueNames, blockLambdaMustContainUniqueNames, @@ -31,24 +31,22 @@ import { typeParameterListShouldNotBeEmpty, unionTypeShouldNotHaveASingularTypeArgument, } from './style.js'; -import {templateStringMustHaveExpressionBetweenTwoStringParts} from './other/expressions/templateStrings.js'; -import {yieldMustNotBeUsedInPipeline} from './other/statements/assignments.js'; -import {attributeMustHaveTypeHint, parameterMustHaveTypeHint, resultMustHaveTypeHint} from './types.js'; -import {moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage} from './other/modules.js'; -import { - typeParameterConstraintLeftOperandMustBeOwnTypeParameter -} from './other/declarations/typeParameterConstraints.js'; +import { templateStringMustHaveExpressionBetweenTwoStringParts } from './other/expressions/templateStrings.js'; +import { yieldMustNotBeUsedInPipeline } from './other/statements/assignments.js'; +import { attributeMustHaveTypeHint, parameterMustHaveTypeHint, resultMustHaveTypeHint } from './types.js'; +import { moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage } from './other/modules.js'; +import { typeParameterConstraintLeftOperandMustBeOwnTypeParameter } from './other/declarations/typeParameterConstraints.js'; import { parameterListMustNotHaveOptionalAndVariadicParameters, parameterListMustNotHaveRequiredParametersAfterOptionalParameters, parameterListVariadicParameterMustBeLast, } from './other/declarations/parameterLists.js'; -import {unionTypeMustHaveTypeArguments} from './other/types/unionTypes.js'; -import {callableTypeMustNotHaveOptionalParameters} from './other/types/callableTypes.js'; -import {typeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments} from './other/types/typeArgumentLists.js'; -import {argumentListMustNotHavePositionalArgumentsAfterNamedArguments} from './other/argumentLists.js'; -import {parameterMustNotBeVariadicAndOptional} from './other/declarations/parameters.js'; -import {referenceTargetMustNotBeAnnotationPipelineOrSchema} from './other/expressions/references.js'; +import { unionTypeMustHaveTypeArguments } from './other/types/unionTypes.js'; +import { callableTypeMustNotHaveOptionalParameters } from './other/types/callableTypes.js'; +import { typeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments } from './other/types/typeArgumentLists.js'; +import { argumentListMustNotHavePositionalArgumentsAfterNamedArguments } from './other/argumentLists.js'; +import { parameterMustNotBeVariadicAndOptional } from './other/declarations/parameters.js'; +import { referenceTargetMustNotBeAnnotationPipelineOrSchema } from './other/expressions/references.js'; import { annotationCallAnnotationShouldNotBeDeprecated, argumentCorrespondingParameterShouldNotBeDeprecated, @@ -63,8 +61,8 @@ import { namedTypeDeclarationShouldNotBeExperimental, referenceTargetShouldNotExperimental, } from './builtins/experimental.js'; -import {placeholderShouldBeUsed} from './other/declarations/placeholders.js'; -import {segmentParameterShouldBeUsed, segmentResultMustBeAssignedExactlyOnce} from './other/declarations/segments.js'; +import { placeholderShouldBeUsed } from './other/declarations/placeholders.js'; +import { segmentParameterShouldBeUsed, segmentResultMustBeAssignedExactlyOnce } from './other/declarations/segments.js'; /** * Register custom validation checks. From 78b42dabd973b3ab5cafc063f5bb1e6b7b46684c Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sun, 8 Oct 2023 17:04:00 +0200 Subject: [PATCH 4/4] refactor: remove unused function --- src/language/helpers/nodeProperties.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/language/helpers/nodeProperties.ts b/src/language/helpers/nodeProperties.ts index 819691d47..f7a98aca5 100644 --- a/src/language/helpers/nodeProperties.ts +++ b/src/language/helpers/nodeProperties.ts @@ -14,7 +14,6 @@ import { isSdsPlaceholder, isSdsSegment, isSdsTypeParameterList, - isSdsYield, SdsAbstractCall, SdsAbstractResult, SdsAnnotatedObject, @@ -48,7 +47,6 @@ import { SdsTypeArgumentList, SdsTypeParameter, SdsTypeParameterList, - SdsYield, } from '../generated/ast.js'; import { AstNode, getContainerOfType, stream } from 'langium'; @@ -204,11 +202,3 @@ export const typeParametersOrEmpty = ( return []; } /* c8 ignore stop */ }; - -export const yieldsOrEmpty = (node: SdsBlock | undefined): SdsYield[] => { - return stream(statementsOrEmpty(node)) - .filter(isSdsAssignment) - .flatMap(assigneesOrEmpty) - .filter(isSdsYield) - .toArray(); -};