Skip to content

Commit

Permalink
fix: formatting around commas of type argument, parameter, result, an…
Browse files Browse the repository at this point in the history
…d type parameter lists
  • Loading branch information
lars-reimann committed Jul 4, 2023
1 parent 361d2a1 commit 5fb3c57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions DSL/src/language-server/formatting/safe-ds-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}
}

Expand All @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5fb3c57

Please sign in to comment.