diff --git a/packages/safe-ds-lang/src/language/lsp/safe-ds-formatter.ts b/packages/safe-ds-lang/src/language/lsp/safe-ds-formatter.ts index 11f75ba83..b4b5112b7 100644 --- a/packages/safe-ds-lang/src/language/lsp/safe-ds-formatter.ts +++ b/packages/safe-ds-lang/src/language/lsp/safe-ds-formatter.ts @@ -915,6 +915,7 @@ export class SafeDsFormatter extends AbstractFormatter { } formatter.property('variance').append(oneSpace()); + formatter.keyword('sub').surround(oneSpace()); formatter.keyword('=').surround(oneSpace()); } diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant optional type parameter.sdstest new file mode 100644 index 000000000..1116629c6 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant optional type parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction< in T sub Int = Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant required type parameter.sdstest new file mode 100644 index 000000000..149652aaa --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant required type parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction< in T sub Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant type parameter with annotation call.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant type parameter with annotation call.sdstest new file mode 100644 index 000000000..30d427696 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded contravariant type parameter with annotation call.sdstest @@ -0,0 +1,8 @@ +fun myFunction< @Annotation in T sub Int > ( ) + +// ----------------------------------------------------------------------------- + +fun myFunction< + @Annotation + in T sub Int +>() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant optional type parameter.sdstest new file mode 100644 index 000000000..b094ae5ef --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant optional type parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction< out T sub Int = Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant required type parameter.sdstest new file mode 100644 index 000000000..21fd25627 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant required type parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction< out T sub Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant type parameter with annotation call.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant type parameter with annotation call.sdstest new file mode 100644 index 000000000..dad5d360d --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded covariant type parameter with annotation call.sdstest @@ -0,0 +1,8 @@ +fun myFunction< @Annotation out T sub Int > ( ) + +// ----------------------------------------------------------------------------- + +fun myFunction< + @Annotation + out T sub Int +>() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant optional type parameter.sdstest new file mode 100644 index 000000000..ad13a8277 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant optional type parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction< T sub Int = Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant required type parameter.sdstest new file mode 100644 index 000000000..5693a20b0 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant required type parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction< T sub Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant type parameter with annotation call.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant type parameter with annotation call.sdstest new file mode 100644 index 000000000..9935c0278 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/bounded invariant type parameter with annotation call.sdstest @@ -0,0 +1,8 @@ +fun myFunction< @Annotation T sub Int >() + +// ----------------------------------------------------------------------------- + +fun myFunction< + @Annotation + T sub Int +>() diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/contravariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded contravariant optional type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/contravariant optional type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded contravariant optional type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/contravariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded contravariant required type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/contravariant required type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded contravariant required type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/contravariant type parameter with annotation call.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded contravariant type parameter with annotation call.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/contravariant type parameter with annotation call.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded contravariant type parameter with annotation call.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/covariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded covariant optional type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/covariant optional type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded covariant optional type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/covariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded covariant required type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/covariant required type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded covariant required type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/covariant type parameter with annotation call.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded covariant type parameter with annotation call.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/covariant type parameter with annotation call.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded covariant type parameter with annotation call.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/invariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded invariant optional type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/invariant optional type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded invariant optional type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/invariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded invariant required type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/invariant required type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded invariant required type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/invariant type parameter with annotation call.sdstest b/packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded invariant type parameter with annotation call.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/invariant type parameter with annotation call.sdstest rename to packages/safe-ds-lang/tests/resources/formatting/declarations/type parameters/unbounded invariant type parameter with annotation call.sdstest diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded contravariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded contravariant optional type parameter.sdstest new file mode 100644 index 000000000..243f63661 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded contravariant optional type parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded contravariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded contravariant required type parameter.sdstest new file mode 100644 index 000000000..68af9baf8 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded contravariant required type parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded covariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded covariant optional type parameter.sdstest new file mode 100644 index 000000000..0e364d12c --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded covariant optional type parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded covariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded covariant required type parameter.sdstest new file mode 100644 index 000000000..613f0926f --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded covariant required type parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded invariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded invariant optional type parameter.sdstest new file mode 100644 index 000000000..93a5eb3db --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded invariant optional type parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded invariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded invariant required type parameter.sdstest new file mode 100644 index 000000000..e7ce31827 --- /dev/null +++ b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-bounded invariant required type parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction() diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-contravariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded contravariant optional type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-contravariant optional type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded contravariant optional type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-contravariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded contravariant required type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-contravariant required type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded contravariant required type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-covariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded covariant optional type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-covariant optional type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded covariant optional type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-covariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded covariant required type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-covariant required type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded covariant required type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-invariant optional type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded invariant optional type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-invariant optional type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded invariant optional type parameter.sdstest diff --git a/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-invariant required type parameter.sdstest b/packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded invariant required type parameter.sdstest similarity index 100% rename from packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-invariant required type parameter.sdstest rename to packages/safe-ds-lang/tests/resources/grammar/declarations/type parameters/good-unbounded invariant required type parameter.sdstest