From 5fb3c577c36f9c4ed2c8ff62303cddede5265981 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Tue, 4 Jul 2023 17:49:48 +0200 Subject: [PATCH] fix: formatting around commas of type argument, parameter, result, and type parameter lists --- .../formatting/safe-ds-formatter.ts | 24 +++++++++++-------- mkdocs.yml | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/DSL/src/language-server/formatting/safe-ds-formatter.ts b/DSL/src/language-server/formatting/safe-ds-formatter.ts index e3726886d..cb28836db 100644 --- a/DSL/src/language-server/formatting/safe-ds-formatter.ts +++ b/DSL/src/language-server/formatting/safe-ds-formatter.ts @@ -498,13 +498,14 @@ export class SafeDSFormatter extends AbstractFormatter { parameters.length >= 3 || parameters.some((it) => annotationCallsOrEmpty(it).length > 0 || this.isComplexType(it.type)) ) { + formatter.nodes(...parameters).prepend(indent()); + formatter.keywords(',').prepend(noSpace()); closingParenthesis.prepend(newLine()); - formatter.interior(openingParenthesis, closingParenthesis).prepend(indent()); - formatter.keywords(',').prepend(noSpace()).append(newLine()); } else { openingParenthesis.append(noSpace()); + formatter.nodes(...parameters.slice(1)).prepend(oneSpace()); + formatter.keywords(',').prepend(noSpace()); closingParenthesis.prepend(noSpace()); - formatter.keywords(',').prepend(noSpace()).append(oneSpace()); } } @@ -538,11 +539,12 @@ export class SafeDSFormatter extends AbstractFormatter { results.some((it) => annotationCallsOrEmpty(it).length > 0 || this.isComplexType(it.type)) ) { formatter.nodes(...results).prepend(indent()); - formatter.keywords(',').prepend(noSpace()).append(newLine()); + formatter.keywords(',').prepend(noSpace()); closingParenthesis.prepend(newLine()); } else { openingParenthesis.append(noSpace()); - formatter.keywords(',').prepend(noSpace()).append(oneSpace()); + formatter.nodes(...results.slice(1)).prepend(oneSpace()); + formatter.keywords(',').prepend(noSpace()); closingParenthesis.prepend(noSpace()); } } @@ -761,15 +763,16 @@ export class SafeDSFormatter extends AbstractFormatter { const typeParameters = node.typeParameters ?? []; if (typeParameters.length >= 3 || typeParameters.some((it) => annotationCallsOrEmpty(it).length > 0)) { - closingBracket.prepend(newLine()); formatter.nodes(...typeParameters).prepend(indent()); - formatter.keywords(',').prepend(noSpace()).append(newLine()); + formatter.keywords(',').prepend(noSpace()); + closingBracket.prepend(newLine()); } else { - closingBracket.prepend(noSpace()); if (typeParameters.length > 0) { formatter.node(typeParameters[0]).prepend(noSpace()); + formatter.nodes(...typeParameters.slice(1)).prepend(oneSpace()); } - formatter.keywords(',').prepend(noSpace()).append(oneSpace()); + formatter.keywords(',').prepend(noSpace()); + closingBracket.prepend(noSpace()); } } @@ -793,9 +796,10 @@ export class SafeDSFormatter extends AbstractFormatter { if (typeArguments.length > 0) { formatter.node(typeArguments[0]).prepend(noSpace()); + formatter.nodes(...typeArguments.slice(1)).prepend(oneSpace()); } - formatter.keywords(',').prepend(noSpace()).append(oneSpace()); + formatter.keywords(',').prepend(noSpace()); formatter.keyword('>').prepend(noSpace()); } diff --git a/mkdocs.yml b/mkdocs.yml index 18e672bae..6ccfa4e9e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,7 +10,7 @@ nav: - Pipeline Language: - language/pipeline-language/README.md - Pipelines: language/pipeline-language/pipelines.md - - Steps: language/pipeline-language/segments.md + - Segments: language/pipeline-language/segments.md - Statements: language/pipeline-language/statements.md - Expressions: language/pipeline-language/expressions.md - Common: