diff --git a/src/language/validation/other/expressions/memberAccesses.ts b/src/language/validation/other/expressions/memberAccesses.ts index 7cf5fc578..7a4d19066 100644 --- a/src/language/validation/other/expressions/memberAccesses.ts +++ b/src/language/validation/other/expressions/memberAccesses.ts @@ -1,26 +1,26 @@ -import {SafeDsServices} from "../../../safe-ds-module.js"; -import {SdsMemberAccess} from "../../../generated/ast.js"; -import {ValidationAcceptor} from "langium"; -import {UnknownType} from "../../../typing/model.js"; +import { SafeDsServices } from '../../../safe-ds-module.js'; +import { SdsMemberAccess } from '../../../generated/ast.js'; +import { ValidationAcceptor } from 'langium'; +import { UnknownType } from '../../../typing/model.js'; export const CODE_MEMBER_ACCESS_MISSING_NULL_SAFETY = 'member-access/missing-null-safety'; export const memberAccessMustBeNullSafeIfReceiverIsNullable = (services: SafeDsServices) => - (node: SdsMemberAccess, accept: ValidationAcceptor): void => { - if (node.isNullSafe) { - return; - } + (node: SdsMemberAccess, accept: ValidationAcceptor): void => { + if (node.isNullSafe) { + return; + } - const receiverType = services.types.TypeComputer.computeType(node.receiver); - if (receiverType === UnknownType) { - return; - } + const receiverType = services.types.TypeComputer.computeType(node.receiver); + if (receiverType === UnknownType) { + return; + } - if (receiverType.isNullable) { - accept('error', "The receiver can be null so a safe access must be used.", { - node, - code: CODE_MEMBER_ACCESS_MISSING_NULL_SAFETY, - }); - } - }; + if (receiverType.isNullable) { + accept('error', 'The receiver can be null so a safe access must be used.', { + node, + code: CODE_MEMBER_ACCESS_MISSING_NULL_SAFETY, + }); + } + }; diff --git a/src/language/validation/safe-ds-validator.ts b/src/language/validation/safe-ds-validator.ts index 0fddf3313..f6d837666 100644 --- a/src/language/validation/safe-ds-validator.ts +++ b/src/language/validation/safe-ds-validator.ts @@ -71,7 +71,7 @@ import { callableTypeResultsMustNotBeAnnotated, lambdaParametersMustNotBeAnnotated, } from './other/declarations/annotationCalls.js'; -import {memberAccessMustBeNullSafeIfReceiverIsNullable} from "./other/expressions/memberAccesses.js"; +import { memberAccessMustBeNullSafeIfReceiverIsNullable } from './other/expressions/memberAccesses.js'; /** * Register custom validation checks. @@ -122,7 +122,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsLambda: [lambdaParametersMustNotBeAnnotated, lambdaParameterMustNotHaveConstModifier], SdsMemberAccess: [ memberAccessMustBeNullSafeIfReceiverIsNullable(services), - memberAccessNullSafetyShouldBeNeeded(services) + memberAccessNullSafetyShouldBeNeeded(services), ], SdsModule: [moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage], SdsNamedType: [