From ea4a9bad93ee22c56dd539628c403a7fd1c3ccd7 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Sun, 8 Oct 2023 21:40:29 +0200 Subject: [PATCH] feat: `const` modifier to replace `@Constant` annotation (#618) Closes #558 ### Summary of Changes Add a `const` modifier for parameters to indicate that they only accept values that can be evaluated to a constant expression at compile-time. This replaces the original `@Constant` annotation. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> --- src/language/formatting/safe-ds-formatter.ts | 14 ++-- src/language/grammar/safe-ds.langium | 3 +- .../other/declarations/annotations.ts | 17 +++++ .../validation/other/expressions/lambdas.ts | 17 +++++ .../validation/other/types/callableTypes.ts | 16 ++++ src/language/validation/safe-ds-validator.ts | 20 ++++- .../safeds/lang/coreAnnotations.sdsstub | 4 - tests/language/formatting/creator.ts | 7 ++ tests/language/grammar/creator.ts | 7 ++ tests/language/grammar/testGrammar.test.ts | 4 +- .../annotations/multiple parameters.sdstest | 72 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...ith const typed variadic parameter.sdstest | 9 +++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...h const untyped variadic parameter.sdstest | 9 +++ .../methods/multiple parameters.sdstest | 73 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 9 +++ ...ith const typed required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 13 ++++ ...ith const typed variadic parameter.sdstest | 12 +++ ...h const untyped optional parameter.sdstest | 9 +++ ...h const untyped required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 13 ++++ ...h const untyped variadic parameter.sdstest | 13 ++++ .../classes/multiple parameters.sdstest | 73 ++++++++++++++---- .../multiple parameters.sdstest | 72 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 9 +++ ...ith const typed required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 13 ++++ ...ith const typed variadic parameter.sdstest | 13 ++++ ...h const untyped optional parameter.sdstest | 9 +++ ...h const untyped required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 13 ++++ ...h const untyped variadic parameter.sdstest | 13 ++++ .../variants/multiple parameters.sdstest | 73 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 13 ++++ ...ith const typed required parameter.sdstest | 13 ++++ ...dic parameter (with default value).sdstest | 17 +++++ ...ith const typed variadic parameter.sdstest | 17 +++++ ...h const untyped optional parameter.sdstest | 13 ++++ ...h const untyped required parameter.sdstest | 13 ++++ ...dic parameter (with default value).sdstest | 17 +++++ ...h const untyped variadic parameter.sdstest | 17 +++++ ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...ith const typed variadic parameter.sdstest | 9 +++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...h const untyped variadic parameter.sdstest | 9 +++ .../variants/multiple parameters.sdstest | 73 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 9 +++ ...ith const typed required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 13 ++++ ...ith const typed variadic parameter.sdstest | 13 ++++ ...h const untyped optional parameter.sdstest | 9 +++ ...h const untyped required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 13 ++++ ...h const untyped variadic parameter.sdstest | 13 ++++ .../functions/multiple parameters.sdstest | 73 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...ith const typed variadic parameter.sdstest | 9 +++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...h const untyped variadic parameter.sdstest | 9 +++ .../segments/multiple parameters.sdstest | 73 ++++++++++++++---- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...ith const typed variadic parameter.sdstest | 9 +++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 9 +++ ...h const untyped variadic parameter.sdstest | 9 +++ .../block lambdas/multiple parameters.sdstest | 74 +++++++++++++++---- ...ith const typed optional parameter.sdstest | 9 +++ ...ith const typed required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 11 +++ ...ith const typed variadic parameter.sdstest | 11 +++ ...h const untyped optional parameter.sdstest | 9 +++ ...h const untyped required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 11 +++ ...h const untyped variadic parameter.sdstest | 11 +++ .../const typed optional parameter.sdstest | 9 +++ .../const typed required parameter.sdstest | 9 +++ .../const typed variadic parameter.sdstest | 11 +++ .../const untyped optional parameter.sdstest | 9 +++ .../const untyped required parameter.sdstest | 9 +++ .../const untyped variadic parameter.sdstest | 11 +++ .../multiple parameters.sdstest | 73 ++++++++++++++---- ...rameter (with const default value).sdstest | 11 +++ ...rameter (with const default value).sdstest | 11 +++ ...ith const typed optional parameter.sdstest | 9 +++ ...ith const typed required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 11 +++ ...ith const typed variadic parameter.sdstest | 11 +++ ...h const untyped optional parameter.sdstest | 9 +++ ... const untyped required parameter.sdstest} | 4 +- ...dic parameter (with default value).sdstest | 11 +++ ...h const untyped variadic parameter.sdstest | 11 +++ .../with multiple parameters.sdstest | 73 ++++++++++++++---- .../with typed optional parameter.sdstest | 9 +++ .../with typed required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 9 +++ .../with typed variadic parameter.sdstest | 9 +++ .../with untyped optional parameter.sdstest | 9 +++ .../with untyped required parameter.sdstest | 9 +++ ...dic parameter (with default value).sdstest | 9 +++ .../with untyped variadic parameter.sdstest | 9 +++ ...double const modifier on parameter.sdstest | 3 + ...ouble vararg modifier on parameter.sdstest | 3 + .../good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 3 + ...ith const typed required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...ith const typed variadic parameter.sdstest | 4 + ...h const untyped optional parameter.sdstest | 3 + ...h const untyped required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...h const untyped variadic parameter.sdstest | 4 + ...double const modifier on parameter.sdstest | 3 + ...ouble vararg modifier on parameter.sdstest | 3 + .../classes/good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 3 + ...ith const typed required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...ith const typed variadic parameter.sdstest | 4 + ...h const untyped optional parameter.sdstest | 3 + ...h const untyped required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...h const untyped variadic parameter.sdstest | 4 + ...double const modifier on parameter.sdstest | 5 ++ ...ouble vararg modifier on parameter.sdstest | 5 ++ .../methods/good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...ith const typed variadic parameter.sdstest | 6 ++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...h const untyped variadic parameter.sdstest | 6 ++ ...double const modifier on parameter.sdstest | 5 ++ ...ouble vararg modifier on parameter.sdstest | 5 ++ .../good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...ith const typed variadic parameter.sdstest | 6 ++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...h const untyped variadic parameter.sdstest | 6 ++ ...double const modifier on parameter.sdstest | 7 ++ ...ouble vararg modifier on parameter.sdstest | 7 ++ .../variants/good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 7 ++ ...ith const typed required parameter.sdstest | 7 ++ ...dic parameter (with default value).sdstest | 8 ++ ...ith const typed variadic parameter.sdstest | 8 ++ ...h const untyped optional parameter.sdstest | 7 ++ ...h const untyped required parameter.sdstest | 7 ++ ...dic parameter (with default value).sdstest | 8 ++ ...h const untyped variadic parameter.sdstest | 8 ++ ...double const modifier on parameter.sdstest | 5 ++ ...ouble vararg modifier on parameter.sdstest | 5 ++ .../variants/good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...ith const typed variadic parameter.sdstest | 6 ++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...h const untyped variadic parameter.sdstest | 6 ++ ...double const modifier on parameter.sdstest | 3 + ...ouble vararg modifier on parameter.sdstest | 3 + .../good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 3 + ...ith const typed required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...ith const typed variadic parameter.sdstest | 4 + ...h const untyped optional parameter.sdstest | 3 + ...h const untyped required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...h const untyped variadic parameter.sdstest | 4 + ...double const modifier on parameter.sdstest | 3 + ...ouble vararg modifier on parameter.sdstest | 3 + .../segments/good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 3 + ...ith const typed required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...ith const typed variadic parameter.sdstest | 4 + ...h const untyped optional parameter.sdstest | 3 + ...h const untyped required parameter.sdstest | 3 + ...dic parameter (with default value).sdstest | 4 + ...h const untyped variadic parameter.sdstest | 4 + ...double const modifier on parameter.sdstest | 5 ++ ...ouble vararg modifier on parameter.sdstest | 5 ++ .../good-multiple parameters.sdstest | 30 ++++++-- ...ith const typed optional parameter.sdstest | 5 ++ ...ith const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...ith const typed variadic parameter.sdstest | 6 ++ ...h const untyped optional parameter.sdstest | 5 ++ ...h const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...h const untyped variadic parameter.sdstest | 6 ++ ...double const modifier on parameter.sdstest | 5 ++ ...ouble vararg modifier on parameter.sdstest | 5 ++ ...ood-const typed optional parameter.sdstest | 5 ++ ...ood-const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...ood-const typed variadic parameter.sdstest | 6 ++ ...d-const untyped optional parameter.sdstest | 5 ++ ...d-const untyped required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...d-const untyped variadic parameter.sdstest | 6 ++ .../good-multiple parameters.sdstest | 30 ++++++-- .../good-typed optional parameter.sdstest | 2 +- .../good-untyped optional parameter.sdstest | 2 +- .../bad-unescaped const.sdstest | 3 + .../good-escapedKeywords.sdstest | 1 + ...ood-const typed optional parameter.sdstest | 5 ++ ...ood-const typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 6 ++ ...ood-const typed variadic parameter.sdstest | 6 ++ ...d-const untyped optional parameter.sdstest | 5 ++ ...-const untyped required parameter.sdstest} | 2 +- ...dic parameter (with default value).sdstest | 6 ++ ...d-const untyped variadic parameter.sdstest | 6 ++ .../good-typed optional parameter.sdstest | 5 ++ .../good-typed required parameter.sdstest | 5 ++ ...dic parameter (with default value).sdstest | 5 ++ .../good-typed variadic parameter.sdstest | 5 ++ .../good-untyped optional parameter.sdstest | 5 ++ ...> good-untyped required parameter.sdstest} | 2 +- ...dic parameter (with default value).sdstest | 5 ++ .../good-untyped variadic parameter.sdstest | 5 ++ .../good-with multiple parameters.sdstest | 30 ++++++-- .../parameters/const modifier/main.sdstest | 37 ++++++++++ .../optional.sdstest | 2 +- .../required.sdstest | 2 +- .../variadic optional.sdstest | 2 +- .../variadic required.sdstest | 2 +- .../main.sdstest | 2 +- .../must have type arguments/main.sdstest | 2 +- 255 files changed, 2477 insertions(+), 293 deletions(-) create mode 100644 src/language/validation/other/declarations/annotations.ts create mode 100644 src/language/validation/other/expressions/lambdas.ts create mode 100644 tests/resources/formatting/declarations/annotations/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/annotations/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/classes/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/functions/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/declarations/segments/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/const typed required parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/const untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/const untyped required parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/typed variadic parameter (with const default value).sdstest create mode 100644 tests/resources/formatting/expressions/expression lambdas/untyped variadic parameter (with const default value).sdstest create mode 100644 tests/resources/formatting/types/callable types/with const typed optional parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with const typed required parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/types/callable types/with const typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with const untyped optional parameter.sdstest rename tests/resources/formatting/types/callable types/{with one typed parameter.sdstest => with const untyped required parameter.sdstest} (68%) create mode 100644 tests/resources/formatting/types/callable types/with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/types/callable types/with const untyped variadic parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with typed optional parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with typed required parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/types/callable types/with typed variadic parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with untyped optional parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with untyped required parameter.sdstest create mode 100644 tests/resources/formatting/types/callable types/with untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/formatting/types/callable types/with untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const typed required parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/bad-double const modifier on parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/bad-double vararg modifier on parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const typed required parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const untyped optional parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const untyped required parameter.sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/keywords as names/bad-unescaped const.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-const typed optional parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-const typed required parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-const typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/types/callable types/good-const typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-const untyped optional parameter.sdstest rename tests/resources/grammar/types/callable types/{good-with one typed parameter.sdstest => good-const untyped required parameter.sdstest} (66%) create mode 100644 tests/resources/grammar/types/callable types/good-const untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/types/callable types/good-const untyped variadic parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-typed optional parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-typed required parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-typed variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/types/callable types/good-typed variadic parameter.sdstest create mode 100644 tests/resources/grammar/types/callable types/good-untyped optional parameter.sdstest rename tests/resources/grammar/types/callable types/{good-with one untyped parameter.sdstest => good-untyped required parameter.sdstest} (70%) create mode 100644 tests/resources/grammar/types/callable types/good-untyped variadic parameter (with default value).sdstest create mode 100644 tests/resources/grammar/types/callable types/good-untyped variadic parameter.sdstest create mode 100644 tests/resources/validation/other/declarations/parameters/const modifier/main.sdstest diff --git a/src/language/formatting/safe-ds-formatter.ts b/src/language/formatting/safe-ds-formatter.ts index f9c58c5c9..86e31d406 100644 --- a/src/language/formatting/safe-ds-formatter.ts +++ b/src/language/formatting/safe-ds-formatter.ts @@ -9,12 +9,13 @@ import { isAstNode, } from 'langium'; import * as ast from '../generated/ast.js'; +import { annotationCallsOrEmpty, literalsOrEmpty, typeArgumentsOrEmpty } from '../helpers/nodeProperties.js'; +import { last } from 'radash'; import noSpace = Formatting.noSpace; import newLine = Formatting.newLine; import newLines = Formatting.newLines; import oneSpace = Formatting.oneSpace; import indent = Formatting.indent; -import { annotationCallsOrEmpty, literalsOrEmpty, typeArgumentsOrEmpty } from '../helpers/nodeProperties.js'; const newLinesWithIndent = function (count: number, options?: FormattingActionOptions): FormattingAction { return { @@ -549,14 +550,13 @@ export class SafeDsFormatter extends AbstractFormatter { private formatSdsParameter(node: ast.SdsParameter): void { const formatter = this.getNodeFormatter(node); - if (annotationCallsOrEmpty(node).length === 0) { - if (node.isVariadic) { - formatter.property('name').prepend(oneSpace()); - } - } else { - formatter.property('name').prepend(newLine()); + const lastAnnotationCall = last(annotationCallsOrEmpty(node)); + if (lastAnnotationCall) { + formatter.node(lastAnnotationCall).append(newLine()); } + formatter.keyword('const').append(oneSpace()); + formatter.keyword('vararg').append(oneSpace()); formatter.keyword(':').prepend(noSpace()).append(oneSpace()); formatter.keyword('=').surround(oneSpace()); } diff --git a/src/language/grammar/safe-ds.langium b/src/language/grammar/safe-ds.langium index 6806c5f2b..a2ee7fa81 100644 --- a/src/language/grammar/safe-ds.langium +++ b/src/language/grammar/safe-ds.langium @@ -416,6 +416,7 @@ SdsParameterList returns SdsParameterList: ; interface SdsParameter extends SdsLocalVariable { + isConstant: boolean isVariadic: boolean ^type?: SdsType defaultValue?: SdsExpression @@ -423,7 +424,7 @@ interface SdsParameter extends SdsLocalVariable { SdsParameter returns SdsParameter: annotationCalls+=SdsAnnotationCall* - isVariadic?='vararg'? + (isConstant?='const' & isVariadic?='vararg') name=ID (':' ^type=SdsType)? ('=' defaultValue=SdsExpression)? diff --git a/src/language/validation/other/declarations/annotations.ts b/src/language/validation/other/declarations/annotations.ts new file mode 100644 index 000000000..10816a726 --- /dev/null +++ b/src/language/validation/other/declarations/annotations.ts @@ -0,0 +1,17 @@ +import { SdsAnnotation } from '../../../generated/ast.js'; +import { ValidationAcceptor } from 'langium'; +import { parametersOrEmpty } from '../../../helpers/nodeProperties.js'; + +export const CODE_ANNOTATION_PARAMETER_CONST_MODIFIER = 'annotation/parameter-const-modifier'; + +export const annotationParameterShouldNotHaveConstModifier = (node: SdsAnnotation, accept: ValidationAcceptor) => { + for (const parameter of parametersOrEmpty(node)) { + if (parameter.isConstant) { + accept('info', 'Parameters of annotations implicitly have the const modifier.', { + node: parameter, + property: 'name', + code: CODE_ANNOTATION_PARAMETER_CONST_MODIFIER, + }); + } + } +}; diff --git a/src/language/validation/other/expressions/lambdas.ts b/src/language/validation/other/expressions/lambdas.ts new file mode 100644 index 000000000..a2b68f200 --- /dev/null +++ b/src/language/validation/other/expressions/lambdas.ts @@ -0,0 +1,17 @@ +import { SdsLambda } from '../../../generated/ast.js'; +import { ValidationAcceptor } from 'langium'; +import { parametersOrEmpty } from '../../../helpers/nodeProperties.js'; + +export const CODE_LAMBDA_CONST_MODIFIER = 'lambda/const-modifier'; + +export const lambdaParameterMustNotHaveConstModifier = (node: SdsLambda, accept: ValidationAcceptor): void => { + for (const parameter of parametersOrEmpty(node)) { + if (parameter.isConstant) { + accept('error', 'The const modifier is not applicable to parameters of lambdas.', { + node: parameter, + property: 'name', + code: CODE_LAMBDA_CONST_MODIFIER, + }); + } + } +}; diff --git a/src/language/validation/other/types/callableTypes.ts b/src/language/validation/other/types/callableTypes.ts index 0ed896090..6b593fcea 100644 --- a/src/language/validation/other/types/callableTypes.ts +++ b/src/language/validation/other/types/callableTypes.ts @@ -3,8 +3,24 @@ import { ValidationAcceptor } from 'langium'; import { parametersOrEmpty } from '../../../helpers/nodeProperties.js'; +export const CODE_CALLABLE_TYPE_CONST_MODIFIER = 'callable-type/const-modifier'; export const CODE_CALLABLE_TYPE_NO_OPTIONAL_PARAMETERS = 'callable-type/no-optional-parameters'; +export const callableTypeParameterMustNotHaveConstModifier = ( + node: SdsCallableType, + accept: ValidationAcceptor, +): void => { + for (const parameter of parametersOrEmpty(node)) { + if (parameter.isConstant) { + accept('error', 'The const modifier is not applicable to parameters of callable types.', { + node: parameter, + property: 'name', + code: CODE_CALLABLE_TYPE_CONST_MODIFIER, + }); + } + } +}; + export const callableTypeMustNotHaveOptionalParameters = (node: SdsCallableType, accept: ValidationAcceptor): void => { for (const parameter of parametersOrEmpty(node)) { if (parameter.defaultValue && !parameter.isVariadic) { diff --git a/src/language/validation/safe-ds-validator.ts b/src/language/validation/safe-ds-validator.ts index 221dd1660..1b0e40bb5 100644 --- a/src/language/validation/safe-ds-validator.ts +++ b/src/language/validation/safe-ds-validator.ts @@ -42,7 +42,10 @@ import { parameterListVariadicParameterMustBeLast, } from './other/declarations/parameterLists.js'; import { unionTypeMustHaveTypeArguments } from './other/types/unionTypes.js'; -import { callableTypeMustNotHaveOptionalParameters } from './other/types/callableTypes.js'; +import { + callableTypeMustNotHaveOptionalParameters, + callableTypeParameterMustNotHaveConstModifier, +} 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'; @@ -63,6 +66,8 @@ import { } from './builtins/experimental.js'; import { placeholderShouldBeUsed } from './other/declarations/placeholders.js'; import { segmentParameterShouldBeUsed, segmentResultMustBeAssignedExactlyOnce } from './other/declarations/segments.js'; +import { annotationParameterShouldNotHaveConstModifier } from './other/declarations/annotations.js'; +import { lambdaParameterMustNotHaveConstModifier } from './other/expressions/lambdas.js'; /** * Register custom validation checks. @@ -75,7 +80,11 @@ export const registerValidationChecks = function (services: SafeDsServices) { assigneeAssignedResultShouldNotBeExperimental(services), ], SdsAssignment: [assignmentShouldHaveMoreThanWildcardsAsAssignees], - SdsAnnotation: [annotationMustContainUniqueNames, annotationParameterListShouldNotBeEmpty], + SdsAnnotation: [ + annotationMustContainUniqueNames, + annotationParameterListShouldNotBeEmpty, + annotationParameterShouldNotHaveConstModifier, + ], SdsAnnotationCall: [ annotationCallAnnotationShouldNotBeDeprecated(services), annotationCallAnnotationShouldNotBeExperimental(services), @@ -89,7 +98,11 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsAttribute: [attributeMustHaveTypeHint], SdsBlockLambda: [blockLambdaMustContainUniqueNames], SdsCall: [callArgumentListShouldBeNeeded(services)], - SdsCallableType: [callableTypeMustContainUniqueNames, callableTypeMustNotHaveOptionalParameters], + SdsCallableType: [ + callableTypeMustContainUniqueNames, + callableTypeMustNotHaveOptionalParameters, + callableTypeParameterMustNotHaveConstModifier, + ], SdsClass: [classMustContainUniqueNames], SdsClassBody: [classBodyShouldNotBeEmpty], SdsConstraintList: [constraintListShouldNotBeEmpty], @@ -99,6 +112,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsEnumVariant: [enumVariantMustContainUniqueNames, enumVariantParameterListShouldNotBeEmpty], SdsExpressionLambda: [expressionLambdaMustContainUniqueNames], SdsFunction: [functionMustContainUniqueNames, functionResultListShouldNotBeEmpty], + SdsLambda: [lambdaParameterMustNotHaveConstModifier], SdsMemberAccess: [memberAccessNullSafetyShouldBeNeeded(services)], SdsModule: [moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage], SdsNamedType: [ diff --git a/src/resources/builtins/safeds/lang/coreAnnotations.sdsstub b/src/resources/builtins/safeds/lang/coreAnnotations.sdsstub index c634b7e1a..b4bc9c7b7 100644 --- a/src/resources/builtins/safeds/lang/coreAnnotations.sdsstub +++ b/src/resources/builtins/safeds/lang/coreAnnotations.sdsstub @@ -97,7 +97,3 @@ annotation Pure @Description("The function has no side effects.") @Target(AnnotationTarget.Function) annotation NoSideEffects - -@Description("Values assigned to this parameter must be constant.") -@Target(AnnotationTarget.Parameter) -annotation Constant diff --git a/tests/language/formatting/creator.ts b/tests/language/formatting/creator.ts index 35679050b..4d1f6e380 100644 --- a/tests/language/formatting/creator.ts +++ b/tests/language/formatting/creator.ts @@ -44,6 +44,7 @@ const createFormattingTest = async (uri: URI): Promise => { testName: `[${shortenedResourceName}] should be formatted correctly`, originalCode, expectedFormattedCode, + uri, }; }; @@ -59,6 +60,7 @@ const invalidTest = (uri: URI, error: Error): FormattingTest => { testName: `INVALID TEST FILE [${shortenedResourceName}]`, originalCode: '', expectedFormattedCode: '', + uri: URI.file(''), error, }; }; @@ -86,6 +88,11 @@ interface FormattingTest extends TestDescription { * The expected formatted code. */ expectedFormattedCode: string; + + /** + * The URI of the corresponding file. + */ + uri: URI; } /** diff --git a/tests/language/grammar/creator.ts b/tests/language/grammar/creator.ts index 8543cf448..2718482fc 100644 --- a/tests/language/grammar/creator.ts +++ b/tests/language/grammar/creator.ts @@ -44,6 +44,7 @@ const createGrammarTest = (uri: URI): GrammarTest => { testName, code, expectedResult: comment, + uri, }; }; @@ -59,6 +60,7 @@ const invalidTest = (uri: URI, error: Error): GrammarTest => { testName: `INVALID TEST FILE [${shortenedResourceName}]`, code: '', expectedResult: 'invalid', + uri: URI.file(''), error, }; }; @@ -76,6 +78,11 @@ interface GrammarTest extends TestDescription { * The expected result after parsing the program. */ expectedResult: 'syntax_error' | 'no_syntax_error' | 'invalid'; + + /** + * The URI of the corresponding file. + */ + uri: URI; } /** diff --git a/tests/language/grammar/testGrammar.test.ts b/tests/language/grammar/testGrammar.test.ts index 7bc53801c..793e82577 100644 --- a/tests/language/grammar/testGrammar.test.ts +++ b/tests/language/grammar/testGrammar.test.ts @@ -26,7 +26,7 @@ describe('grammar', () => { if (test.expectedResult === 'syntax_error') { if (actualSyntaxErrors.length === 0) { throw new AssertionError({ - message: 'Expected syntax errors but found none.', + message: `Expected syntax errors in ${test.uri} but found none.`, actual: actualSyntaxErrors, expected: [], }); @@ -37,7 +37,7 @@ describe('grammar', () => { else if (test.expectedResult === 'no_syntax_error') { if (actualSyntaxErrors.length > 0) { throw new AssertionError({ - message: 'Expected no syntax errors but found some.', + message: `Expected no syntax errors in ${test.uri} but found some.`, actual: actualSyntaxErrors, expected: [], }); diff --git a/tests/resources/formatting/declarations/annotations/multiple parameters.sdstest b/tests/resources/formatting/declarations/annotations/multiple parameters.sdstest index d853a481c..df20ca8c9 100644 --- a/tests/resources/formatting/declarations/annotations/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/annotations/multiple parameters.sdstest @@ -1,33 +1,73 @@ annotation MyAnnotation ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) // ----------------------------------------------------------------------------- annotation MyAnnotation( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) diff --git a/tests/resources/formatting/declarations/annotations/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/annotations/with const typed optional parameter.sdstest new file mode 100644 index 000000000..7683ec43e --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +annotation MyAnnotation ( const a : Int = 1 ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation(const a: Int = 1) diff --git a/tests/resources/formatting/declarations/annotations/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/annotations/with const typed required parameter.sdstest new file mode 100644 index 000000000..071d0bc58 --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +annotation MyAnnotation ( const a : Int ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation(const a: Int) diff --git a/tests/resources/formatting/declarations/annotations/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/annotations/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..3cf9ee6a0 --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +annotation MyAnnotation1 ( const vararg a : Int = 1 ) + +annotation MyAnnotation2 ( vararg const a : Int = 1 ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation1(const vararg a: Int = 1) + +annotation MyAnnotation2(vararg const a: Int = 1) diff --git a/tests/resources/formatting/declarations/annotations/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/annotations/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..66a958a6d --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const typed variadic parameter.sdstest @@ -0,0 +1,9 @@ +annotation MyAnnotation1 ( const vararg a : Int ) + +annotation MyAnnotation2 ( vararg const a : Int ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation1(const vararg a: Int) + +annotation MyAnnotation2(vararg const a: Int) diff --git a/tests/resources/formatting/declarations/annotations/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/annotations/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..511b63460 --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +annotation MyAnnotation ( const a = 1 ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation(const a = 1) diff --git a/tests/resources/formatting/declarations/annotations/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/annotations/with const untyped required parameter.sdstest new file mode 100644 index 000000000..30af2bb31 --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +annotation MyAnnotation ( const a ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation(const a) diff --git a/tests/resources/formatting/declarations/annotations/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/annotations/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..e9466ff5e --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +annotation MyAnnotation1 ( const vararg a = 1 ) + +annotation MyAnnotation2 ( vararg const a = 1 ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation1(const vararg a = 1) + +annotation MyAnnotation2(vararg const a = 1) diff --git a/tests/resources/formatting/declarations/annotations/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/annotations/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..862b47f26 --- /dev/null +++ b/tests/resources/formatting/declarations/annotations/with const untyped variadic parameter.sdstest @@ -0,0 +1,9 @@ +annotation MyAnnotation1 ( const vararg a ) + +annotation MyAnnotation2 ( vararg const a ) + +// ----------------------------------------------------------------------------- + +annotation MyAnnotation1(const vararg a) + +annotation MyAnnotation2(vararg const a) diff --git a/tests/resources/formatting/declarations/classes/methods/multiple parameters.sdstest b/tests/resources/formatting/declarations/classes/methods/multiple parameters.sdstest index 712dec1e3..20cbf524a 100644 --- a/tests/resources/formatting/declarations/classes/methods/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/classes/methods/multiple parameters.sdstest @@ -1,21 +1,47 @@ class MyClass { fun myFunction ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) } @@ -24,13 +50,28 @@ class MyClass { class MyClass { fun myFunction( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } diff --git a/tests/resources/formatting/declarations/classes/methods/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/classes/methods/with const typed optional parameter.sdstest new file mode 100644 index 000000000..69aee1f15 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const typed optional parameter.sdstest @@ -0,0 +1,9 @@ +class MyClass { + fun myFunction ( const a : Int = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction(const a: Int = 1) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/classes/methods/with const typed required parameter.sdstest new file mode 100644 index 000000000..ccbd4565d --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const typed required parameter.sdstest @@ -0,0 +1,9 @@ +class MyClass { + fun myFunction ( const a : Int ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction(const a: Int) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..86aeeed9d --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,13 @@ +class MyClass { + fun myFunction1 ( const vararg a : Int = 1 ) + + fun myFunction2 ( vararg const a : Int = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction1(const vararg a: Int = 1) + + fun myFunction2(vararg const a: Int = 1) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..d9717e07a --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const typed variadic parameter.sdstest @@ -0,0 +1,12 @@ +class MyClass { + fun myFunction1 ( const vararg a : Int ) + fun myFunction2 ( vararg const a : Int ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction1(const vararg a: Int) + + fun myFunction2(vararg const a: Int) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/classes/methods/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..de5c4a565 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +class MyClass { + fun myFunction ( const a = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction(const a = 1) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/classes/methods/with const untyped required parameter.sdstest new file mode 100644 index 000000000..17164af81 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const untyped required parameter.sdstest @@ -0,0 +1,9 @@ +class MyClass { + fun myFunction ( const a ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction(const a) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..7948b5ddc --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,13 @@ +class MyClass { + fun myFunction1 ( const vararg a = 1 ) + + fun myFunction2 ( vararg const a = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction1(const vararg a = 1) + + fun myFunction2(vararg const a = 1) +} diff --git a/tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..75a0d1be7 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/methods/with const untyped variadic parameter.sdstest @@ -0,0 +1,13 @@ +class MyClass { + fun myFunction1 ( const vararg a ) + + fun myFunction2 ( vararg const a ) +} + +// ----------------------------------------------------------------------------- + +class MyClass { + fun myFunction1(const vararg a) + + fun myFunction2(vararg const a) +} diff --git a/tests/resources/formatting/declarations/classes/multiple parameters.sdstest b/tests/resources/formatting/declarations/classes/multiple parameters.sdstest index 04a9448d7..7f59bcc44 100644 --- a/tests/resources/formatting/declarations/classes/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/classes/multiple parameters.sdstest @@ -1,20 +1,46 @@ class MyClass ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) @@ -22,12 +48,27 @@ class MyClass ( class MyClass( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) diff --git a/tests/resources/formatting/declarations/classes/nested classes/multiple parameters.sdstest b/tests/resources/formatting/declarations/classes/nested classes/multiple parameters.sdstest index 5518f008e..9d6cd479f 100644 --- a/tests/resources/formatting/declarations/classes/nested classes/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/classes/nested classes/multiple parameters.sdstest @@ -1,22 +1,47 @@ class MyOuterClass { class MyClass ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) } @@ -25,13 +50,28 @@ class MyOuterClass { class MyOuterClass { class MyClass( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const typed optional parameter.sdstest new file mode 100644 index 000000000..074e3289c --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const typed optional parameter.sdstest @@ -0,0 +1,9 @@ +class MyOuterClass { + class MyClass ( const a : Int = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass(const a: Int = 1) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const typed required parameter.sdstest new file mode 100644 index 000000000..75a4c5ae1 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const typed required parameter.sdstest @@ -0,0 +1,9 @@ +class MyOuterClass { + class MyClass ( const a : Int ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass(const a: Int) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..20d6ad8ba --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,13 @@ +class MyOuterClass { + class MyClass1 ( const vararg a : Int = 1 ) + + class MyClass2 ( vararg const a : Int = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass1(const vararg a: Int = 1) + + class MyClass2(vararg const a: Int = 1) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..2d311d22b --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const typed variadic parameter.sdstest @@ -0,0 +1,13 @@ +class MyOuterClass { + class MyClass1 ( const vararg a : Int ) + + class MyClass2 ( vararg const a : Int ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass1(const vararg a: Int) + + class MyClass2(vararg const a: Int) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..77a24ee83 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +class MyOuterClass { + class MyClass ( const a = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass(const a = 1) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const untyped required parameter.sdstest new file mode 100644 index 000000000..380276c04 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const untyped required parameter.sdstest @@ -0,0 +1,9 @@ +class MyOuterClass { + class MyClass ( const a ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass(const a) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..45c2d3531 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,13 @@ +class MyOuterClass { + class MyClass1 ( const vararg a = 1 ) + + class MyClass2 ( vararg const a = 1 ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass1(const vararg a = 1) + + class MyClass2(vararg const a = 1) +} diff --git a/tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..0b4c710f4 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested classes/with const untyped variadic parameter.sdstest @@ -0,0 +1,13 @@ +class MyOuterClass { + class MyClass1 ( const vararg a ) + + class MyClass2 ( vararg const a ) +} + +// ----------------------------------------------------------------------------- + +class MyOuterClass { + class MyClass1(const vararg a) + + class MyClass2(vararg const a) +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/multiple parameters.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/multiple parameters.sdstest index 9b6dfe9f6..1aeb935ae 100644 --- a/tests/resources/formatting/declarations/classes/nested enums/variants/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/multiple parameters.sdstest @@ -2,21 +2,47 @@ class MyClass { enum MyEnum { MyEnumVariant ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) } } @@ -27,14 +53,29 @@ class MyClass { enum MyEnum { MyEnumVariant( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } } diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed optional parameter.sdstest new file mode 100644 index 000000000..a4dfb647c --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed optional parameter.sdstest @@ -0,0 +1,13 @@ +class MyClass { + enum MyEnum { + MyEnumVariant ( const a : Int = 1 ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant(const a: Int = 1) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed required parameter.sdstest new file mode 100644 index 000000000..8297bb617 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed required parameter.sdstest @@ -0,0 +1,13 @@ +class MyClass { + enum MyEnum { + MyEnumVariant ( const a : Int ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant(const a: Int) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..a4273424d --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,17 @@ +class MyClass { + enum MyEnum { + MyEnumVariant1 ( const vararg a : Int = 1 ) + + MyEnumVariant2 ( vararg const a : Int = 1 ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a: Int = 1) + + MyEnumVariant2(vararg const a: Int = 1) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..6a1dd665c --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const typed variadic parameter.sdstest @@ -0,0 +1,17 @@ +class MyClass { + enum MyEnum { + MyEnumVariant1 ( const vararg a : Int ) + + MyEnumVariant2 ( vararg const a : Int ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a: Int) + + MyEnumVariant2(vararg const a: Int) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..0bc669dc9 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped optional parameter.sdstest @@ -0,0 +1,13 @@ +class MyClass { + enum MyEnum { + MyEnumVariant ( const a = 1 ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant(const a = 1) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped required parameter.sdstest new file mode 100644 index 000000000..f3d5dd14b --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped required parameter.sdstest @@ -0,0 +1,13 @@ +class MyClass { + enum MyEnum { + MyEnumVariant ( const a ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant(const a) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..3899d1ed7 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,17 @@ +class MyClass { + enum MyEnum { + MyEnumVariant1 ( const vararg a = 1 ) + + MyEnumVariant2 ( vararg const a = 1 ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a = 1) + + MyEnumVariant2(vararg const a = 1) + } +} diff --git a/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..a01e581c0 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/nested enums/variants/with const untyped variadic parameter.sdstest @@ -0,0 +1,17 @@ +class MyClass { + enum MyEnum { + MyEnumVariant1 ( const vararg a ) + + MyEnumVariant2 ( vararg const a ) + } +} + +// ----------------------------------------------------------------------------- + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a) + + MyEnumVariant2(vararg const a) + } +} diff --git a/tests/resources/formatting/declarations/classes/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/classes/with const typed optional parameter.sdstest new file mode 100644 index 000000000..138065d24 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +class MyClass ( const a : Int = 1 ) + +// ----------------------------------------------------------------------------- + +class MyClass(const a: Int = 1) diff --git a/tests/resources/formatting/declarations/classes/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/classes/with const typed required parameter.sdstest new file mode 100644 index 000000000..6f4f7252f --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +class MyClass ( const a : Int ) + +// ----------------------------------------------------------------------------- + +class MyClass(const a: Int) diff --git a/tests/resources/formatting/declarations/classes/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..30b8ce30f --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +class MyClass1 ( const vararg a : Int = 1 ) + +class MyClass2 ( vararg const a : Int = 1 ) + +// ----------------------------------------------------------------------------- + +class MyClass1(const vararg a: Int = 1) + +class MyClass2(vararg const a: Int = 1) diff --git a/tests/resources/formatting/declarations/classes/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..8d4d44abe --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const typed variadic parameter.sdstest @@ -0,0 +1,9 @@ +class MyClass1 ( const vararg a : Int ) + +class MyClass2 ( vararg const a : Int ) + +// ----------------------------------------------------------------------------- + +class MyClass1(const vararg a: Int) + +class MyClass2(vararg const a: Int) diff --git a/tests/resources/formatting/declarations/classes/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/classes/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..021895fa2 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +class MyClass ( const a = 1 ) + +// ----------------------------------------------------------------------------- + +class MyClass(const a = 1) diff --git a/tests/resources/formatting/declarations/classes/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/classes/with const untyped required parameter.sdstest new file mode 100644 index 000000000..32bd23aa5 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +class MyClass ( const a ) + +// ----------------------------------------------------------------------------- + +class MyClass(const a) diff --git a/tests/resources/formatting/declarations/classes/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/classes/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..6af6fa7a4 --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +class MyClass1 ( const vararg a = 1 ) + +class MyClass2 ( vararg const a = 1 ) + +// ----------------------------------------------------------------------------- + +class MyClass1(const vararg a = 1) + +class MyClass2(vararg const a = 1) diff --git a/tests/resources/formatting/declarations/classes/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/classes/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..fa9d9f94e --- /dev/null +++ b/tests/resources/formatting/declarations/classes/with const untyped variadic parameter.sdstest @@ -0,0 +1,9 @@ +class MyClass1 ( const vararg a ) + +class MyClass2 ( vararg const a ) + +// ----------------------------------------------------------------------------- + +class MyClass1(const vararg a) + +class MyClass2(vararg const a) diff --git a/tests/resources/formatting/declarations/enums/variants/multiple parameters.sdstest b/tests/resources/formatting/declarations/enums/variants/multiple parameters.sdstest index da483aa5a..9a1f0a452 100644 --- a/tests/resources/formatting/declarations/enums/variants/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/enums/variants/multiple parameters.sdstest @@ -1,21 +1,47 @@ enum MyEnum { MyEnumVariant ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) } @@ -25,13 +51,28 @@ enum MyEnum { enum MyEnum { MyEnumVariant( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } diff --git a/tests/resources/formatting/declarations/enums/variants/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/enums/variants/with const typed optional parameter.sdstest new file mode 100644 index 000000000..976a51fb4 --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const typed optional parameter.sdstest @@ -0,0 +1,9 @@ +enum MyEnum { + MyEnumVariant ( const a : Int = 1 ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant(const a: Int = 1) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/enums/variants/with const typed required parameter.sdstest new file mode 100644 index 000000000..a3bdfdf8f --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const typed required parameter.sdstest @@ -0,0 +1,9 @@ +enum MyEnum { + MyEnumVariant ( const a : Int ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant(const a: Int) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..8472d2a40 --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,13 @@ +enum MyEnum { + MyEnumVariant1 ( const vararg a : Int = 1 ) + + MyEnumVariant2 ( vararg const a : Int = 1 ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant1(const vararg a: Int = 1) + + MyEnumVariant2(vararg const a: Int = 1) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..987e211ab --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const typed variadic parameter.sdstest @@ -0,0 +1,13 @@ +enum MyEnum { + MyEnumVariant1 ( const vararg a : Int ) + + MyEnumVariant2 ( vararg const a : Int ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant1(const vararg a: Int) + + MyEnumVariant2(vararg const a: Int) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/enums/variants/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..45656583f --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +enum MyEnum { + MyEnumVariant ( const a = 1 ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant(const a = 1) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/enums/variants/with const untyped required parameter.sdstest new file mode 100644 index 000000000..69f7826ee --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const untyped required parameter.sdstest @@ -0,0 +1,9 @@ +enum MyEnum { + MyEnumVariant ( const a ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant(const a) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..601cd9f19 --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,13 @@ +enum MyEnum { + MyEnumVariant1 (const vararg a = 1 ) + + MyEnumVariant2 (vararg const a = 1 ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant1(const vararg a = 1) + + MyEnumVariant2(vararg const a = 1) +} diff --git a/tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..b4cd44b1c --- /dev/null +++ b/tests/resources/formatting/declarations/enums/variants/with const untyped variadic parameter.sdstest @@ -0,0 +1,13 @@ +enum MyEnum { + MyEnumVariant1 ( const vararg a ) + + MyEnumVariant2 ( vararg const a ) +} + +// ----------------------------------------------------------------------------- + +enum MyEnum { + MyEnumVariant1(const vararg a) + + MyEnumVariant2(vararg const a) +} diff --git a/tests/resources/formatting/declarations/functions/multiple parameters.sdstest b/tests/resources/formatting/declarations/functions/multiple parameters.sdstest index b605bc789..acfeb8d16 100644 --- a/tests/resources/formatting/declarations/functions/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/functions/multiple parameters.sdstest @@ -1,32 +1,73 @@ fun myFunction ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) // ----------------------------------------------------------------------------- fun myFunction( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) diff --git a/tests/resources/formatting/declarations/functions/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/functions/with const typed optional parameter.sdstest new file mode 100644 index 000000000..f883e6205 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction ( const a : Int = 1 ) + +// ----------------------------------------------------------------------------- + +fun myFunction(const a: Int = 1) diff --git a/tests/resources/formatting/declarations/functions/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/functions/with const typed required parameter.sdstest new file mode 100644 index 000000000..93e6cde35 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction ( const a : Int ) + +// ----------------------------------------------------------------------------- + +fun myFunction(const a: Int) diff --git a/tests/resources/formatting/declarations/functions/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/functions/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..b1e03ed3c --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +fun myFunction1 ( const vararg a : Int = 1 ) + +fun myFunction2 ( vararg const a : Int = 1 ) + +// ----------------------------------------------------------------------------- + +fun myFunction1(const vararg a: Int = 1) + +fun myFunction2(vararg const a: Int = 1) diff --git a/tests/resources/formatting/declarations/functions/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/functions/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..582d02671 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const typed variadic parameter.sdstest @@ -0,0 +1,9 @@ +fun myFunction1 ( const vararg a : Int ) + +fun myFunction2 ( vararg const a : Int ) + +// ----------------------------------------------------------------------------- + +fun myFunction1(const vararg a: Int) + +fun myFunction2(vararg const a: Int) diff --git a/tests/resources/formatting/declarations/functions/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/functions/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..c5a2e7024 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction ( const a = 1 ) + +// ----------------------------------------------------------------------------- + +fun myFunction(const a = 1) diff --git a/tests/resources/formatting/declarations/functions/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/functions/with const untyped required parameter.sdstest new file mode 100644 index 000000000..dec04ab09 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +fun myFunction ( const a ) + +// ----------------------------------------------------------------------------- + +fun myFunction(const a) diff --git a/tests/resources/formatting/declarations/functions/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/functions/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..489f10e75 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +fun myFunction1 ( const vararg a = 1 ) + +fun myFunction2 ( vararg const a = 1 ) + +// ----------------------------------------------------------------------------- + +fun myFunction1(const vararg a = 1) + +fun myFunction2(vararg const a = 1) diff --git a/tests/resources/formatting/declarations/functions/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/functions/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..212fff051 --- /dev/null +++ b/tests/resources/formatting/declarations/functions/with const untyped variadic parameter.sdstest @@ -0,0 +1,9 @@ +fun myFunction1 ( const vararg a ) + +fun myFunction2 ( vararg const a ) + +// ----------------------------------------------------------------------------- + +fun myFunction1(const vararg a) + +fun myFunction2(vararg const a) diff --git a/tests/resources/formatting/declarations/segments/multiple parameters.sdstest b/tests/resources/formatting/declarations/segments/multiple parameters.sdstest index a6ab6484b..8365dbb24 100644 --- a/tests/resources/formatting/declarations/segments/multiple parameters.sdstest +++ b/tests/resources/formatting/declarations/segments/multiple parameters.sdstest @@ -1,32 +1,73 @@ segment mySegment ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) { } // ----------------------------------------------------------------------------- segment mySegment( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) {} diff --git a/tests/resources/formatting/declarations/segments/with const typed optional parameter.sdstest b/tests/resources/formatting/declarations/segments/with const typed optional parameter.sdstest new file mode 100644 index 000000000..2e50b1bbf --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +segment mySegment ( const a : Int = 1 ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment(const a: Int = 1) {} diff --git a/tests/resources/formatting/declarations/segments/with const typed required parameter.sdstest b/tests/resources/formatting/declarations/segments/with const typed required parameter.sdstest new file mode 100644 index 000000000..dfa305f09 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +segment mySegment ( const a : Int ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment(const a: Int) {} diff --git a/tests/resources/formatting/declarations/segments/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/segments/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..8e73ddba6 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +segment mySegment1 ( const vararg a : Int = 1 ) { } + +segment mySegment2 ( vararg const a : Int = 1 ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment1(const vararg a: Int = 1) {} + +segment mySegment2(vararg const a: Int = 1) {} diff --git a/tests/resources/formatting/declarations/segments/with const typed variadic parameter.sdstest b/tests/resources/formatting/declarations/segments/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..326ddf817 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const typed variadic parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment1 ( const vararg a : Int ) { } + +segment mySegment2 ( vararg const a : Int ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment1(const vararg a: Int) {} + +segment mySegment2(vararg const a: Int) {} diff --git a/tests/resources/formatting/declarations/segments/with const untyped optional parameter.sdstest b/tests/resources/formatting/declarations/segments/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..248583181 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +segment mySegment ( const a = 1 ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment(const a = 1) {} diff --git a/tests/resources/formatting/declarations/segments/with const untyped required parameter.sdstest b/tests/resources/formatting/declarations/segments/with const untyped required parameter.sdstest new file mode 100644 index 000000000..0a97cd6c9 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +segment mySegment ( const a ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment(const a) {} diff --git a/tests/resources/formatting/declarations/segments/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/declarations/segments/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..f6584a258 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +segment mySegment1 ( const vararg a = 1 ) { } + +segment mySegment2 ( vararg const a = 1 ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment1(const vararg a = 1) {} + +segment mySegment2(vararg const a = 1) {} diff --git a/tests/resources/formatting/declarations/segments/with const untyped variadic parameter.sdstest b/tests/resources/formatting/declarations/segments/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..4c06127a3 --- /dev/null +++ b/tests/resources/formatting/declarations/segments/with const untyped variadic parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment1 ( const vararg a ) { } + +segment mySegment2 ( vararg const a ) { } + +// ----------------------------------------------------------------------------- + +segment mySegment1(const vararg a) {} + +segment mySegment2(vararg const a) {} diff --git a/tests/resources/formatting/expressions/block lambdas/multiple parameters.sdstest b/tests/resources/formatting/expressions/block lambdas/multiple parameters.sdstest index 4c0f151e9..3d9a4b36c 100644 --- a/tests/resources/formatting/expressions/block lambdas/multiple parameters.sdstest +++ b/tests/resources/formatting/expressions/block lambdas/multiple parameters.sdstest @@ -1,20 +1,47 @@ pipeline myPipeline { ( - @Annotation a , - b = 0 , + @Annotation a1 , - vararg c , + b1 = 0 , - vararg d : Int = 1 , + vararg c1 , - e : Int , + vararg d1 : Int = 1 , - f : Int = 2 , + e1 : Int , - vararg g : Int , + f1 : Int = 2 , - vararg h : Int = 3 + vararg g1 : Int , + + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) { }; } @@ -24,13 +51,28 @@ pipeline myPipeline { pipeline myPipeline { ( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) {}; } diff --git a/tests/resources/formatting/expressions/block lambdas/with const typed optional parameter.sdstest b/tests/resources/formatting/expressions/block lambdas/with const typed optional parameter.sdstest new file mode 100644 index 000000000..3879d94ce --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const typed optional parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a : Int = 1 ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a: Int = 1) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const typed required parameter.sdstest b/tests/resources/formatting/expressions/block lambdas/with const typed required parameter.sdstest new file mode 100644 index 000000000..1768637ba --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const typed required parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a : Int ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a: Int) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..d6ec28c44 --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a : Int = 1 ) { }; + ( vararg const a : Int = 1 ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a: Int = 1) {}; + (vararg const a: Int = 1) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter.sdstest b/tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..ae439e03b --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const typed variadic parameter.sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a : Int ) { }; + ( vararg const a : Int ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a: Int) {}; + (vararg const a: Int) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const untyped optional parameter.sdstest b/tests/resources/formatting/expressions/block lambdas/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..36d978825 --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a = 1 ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a = 1) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const untyped required parameter.sdstest b/tests/resources/formatting/expressions/block lambdas/with const untyped required parameter.sdstest new file mode 100644 index 000000000..e91492f8b --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const untyped required parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..cbe42f209 --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a = 1 ) { }; + ( vararg const a = 1 ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a = 1) {}; + (vararg const a = 1) {}; +} diff --git a/tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter.sdstest b/tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..8242d435f --- /dev/null +++ b/tests/resources/formatting/expressions/block lambdas/with const untyped variadic parameter.sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a ) { }; + ( vararg const a ) { }; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a) {}; + (vararg const a) {}; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/const typed optional parameter.sdstest b/tests/resources/formatting/expressions/expression lambdas/const typed optional parameter.sdstest new file mode 100644 index 000000000..776166a00 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/const typed optional parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a = 1 ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a = 1) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/const typed required parameter.sdstest b/tests/resources/formatting/expressions/expression lambdas/const typed required parameter.sdstest new file mode 100644 index 000000000..3145dbcb3 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/const typed required parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a : Int ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a: Int) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/const typed variadic parameter.sdstest b/tests/resources/formatting/expressions/expression lambdas/const typed variadic parameter.sdstest new file mode 100644 index 000000000..7ee6c993d --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/const typed variadic parameter.sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a : Int ) -> 1; + ( vararg const a : Int ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a: Int) -> 1; + (vararg const a: Int) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/const untyped optional parameter.sdstest b/tests/resources/formatting/expressions/expression lambdas/const untyped optional parameter.sdstest new file mode 100644 index 000000000..0e284b901 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/const untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a : Int = 1 ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a: Int = 1) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/const untyped required parameter.sdstest b/tests/resources/formatting/expressions/expression lambdas/const untyped required parameter.sdstest new file mode 100644 index 000000000..9a99bb026 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/const untyped required parameter.sdstest @@ -0,0 +1,9 @@ +pipeline myPipeline { + ( const a ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const a) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/const untyped variadic parameter.sdstest b/tests/resources/formatting/expressions/expression lambdas/const untyped variadic parameter.sdstest new file mode 100644 index 000000000..1646dada6 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/const untyped variadic parameter.sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a ) -> 1; + ( vararg const a ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a) -> 1; + (vararg const a) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/multiple parameters.sdstest b/tests/resources/formatting/expressions/expression lambdas/multiple parameters.sdstest index b47c9d17e..b4c6f3f07 100644 --- a/tests/resources/formatting/expressions/expression lambdas/multiple parameters.sdstest +++ b/tests/resources/formatting/expressions/expression lambdas/multiple parameters.sdstest @@ -1,21 +1,47 @@ pipeline myPipeline { ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) -> 4; } @@ -25,13 +51,28 @@ pipeline myPipeline { pipeline myPipeline { ( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) -> 4; } diff --git a/tests/resources/formatting/expressions/expression lambdas/typed variadic parameter (with const default value).sdstest b/tests/resources/formatting/expressions/expression lambdas/typed variadic parameter (with const default value).sdstest new file mode 100644 index 000000000..d354b1033 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/typed variadic parameter (with const default value).sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a : Int = 1 ) -> 1; + ( vararg const a : Int = 1 ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a: Int = 1) -> 1; + (vararg const a: Int = 1) -> 1; +} diff --git a/tests/resources/formatting/expressions/expression lambdas/untyped variadic parameter (with const default value).sdstest b/tests/resources/formatting/expressions/expression lambdas/untyped variadic parameter (with const default value).sdstest new file mode 100644 index 000000000..27d205750 --- /dev/null +++ b/tests/resources/formatting/expressions/expression lambdas/untyped variadic parameter (with const default value).sdstest @@ -0,0 +1,11 @@ +pipeline myPipeline { + ( const vararg a = 1 ) -> 1; + ( vararg const a = 1 ) -> 1; +} + +// ----------------------------------------------------------------------------- + +pipeline myPipeline { + (const vararg a = 1) -> 1; + (vararg const a = 1) -> 1; +} diff --git a/tests/resources/formatting/types/callable types/with const typed optional parameter.sdstest b/tests/resources/formatting/types/callable types/with const typed optional parameter.sdstest new file mode 100644 index 000000000..3754505c2 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const typed optional parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( const a : Int = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const a: Int = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with const typed required parameter.sdstest b/tests/resources/formatting/types/callable types/with const typed required parameter.sdstest new file mode 100644 index 000000000..1cceaf019 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const typed required parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( const a : Int ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const a: Int) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with const typed variadic parameter (with default value).sdstest b/tests/resources/formatting/types/callable types/with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..314d9de52 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,11 @@ +segment mySegment( + f: ( const vararg a : Int = 1 ) -> ( ), + g: ( vararg const a : Int = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const vararg a: Int = 1) -> (), + g: (vararg const a: Int = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with const typed variadic parameter.sdstest b/tests/resources/formatting/types/callable types/with const typed variadic parameter.sdstest new file mode 100644 index 000000000..8573c773f --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const typed variadic parameter.sdstest @@ -0,0 +1,11 @@ +segment mySegment( + f: ( const vararg a : Int ) -> ( ), + g: ( vararg const a : Int ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const vararg a: Int) -> (), + g: (vararg const a: Int) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with const untyped optional parameter.sdstest b/tests/resources/formatting/types/callable types/with const untyped optional parameter.sdstest new file mode 100644 index 000000000..3754505c2 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( const a : Int = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const a: Int = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with one typed parameter.sdstest b/tests/resources/formatting/types/callable types/with const untyped required parameter.sdstest similarity index 68% rename from tests/resources/formatting/types/callable types/with one typed parameter.sdstest rename to tests/resources/formatting/types/callable types/with const untyped required parameter.sdstest index b6bd6dfea..173c1e95a 100644 --- a/tests/resources/formatting/types/callable types/with one typed parameter.sdstest +++ b/tests/resources/formatting/types/callable types/with const untyped required parameter.sdstest @@ -1,9 +1,9 @@ segment mySegment( - f: ( param : Int ) -> ( ) + f: ( const a ) -> ( ) ) {} // ----------------------------------------------------------------------------- segment mySegment( - f: (param: Int) -> () + f: (const a) -> () ) {} diff --git a/tests/resources/formatting/types/callable types/with const untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/types/callable types/with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..c05d2a2f2 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,11 @@ +segment mySegment( + f: ( const vararg a = 1 ) -> ( ), + g: ( vararg const a = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const vararg a = 1) -> (), + g: (vararg const a = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with const untyped variadic parameter.sdstest b/tests/resources/formatting/types/callable types/with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..21688048e --- /dev/null +++ b/tests/resources/formatting/types/callable types/with const untyped variadic parameter.sdstest @@ -0,0 +1,11 @@ +segment mySegment( + f: ( const vararg a ) -> ( ), + g: ( vararg const a ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (const vararg a) -> (), + g: (vararg const a) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with multiple parameters.sdstest b/tests/resources/formatting/types/callable types/with multiple parameters.sdstest index e48bda244..ddc505033 100644 --- a/tests/resources/formatting/types/callable types/with multiple parameters.sdstest +++ b/tests/resources/formatting/types/callable types/with multiple parameters.sdstest @@ -1,21 +1,47 @@ segment mySegment( f: ( - @Annotation a , + @Annotation a1 , - b = 0 , + b1 = 0 , - vararg c , + vararg c1 , - vararg d : Int = 1 , + vararg d1 : Int = 1 , - e : Int , + e1 : Int , - f : Int = 2 , + f1 : Int = 2 , - vararg g : Int , + vararg g1 : Int , - vararg h : Int = 3 + vararg h1 : Int = 3 , + + @Annotation const a2 , + + const b2 = 0 , + + const vararg c2 , + + const vararg d2 : Int = 1 , + + const e2 : Int , + + const f2 : Int = 2 , + + const vararg g2 : Int , + + const vararg h2 : Int = 3 , + +@Annotation vararg const a3 , + + vararg const c3 , + + vararg const d3 : Int = 1 , + + vararg const g3 : Int , + + vararg const h3 : Int = 3 ) -> ( ) ) {} @@ -25,13 +51,28 @@ segment mySegment( segment mySegment( f: ( @Annotation - a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + @Annotation + const a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + @Annotation + vararg const a3, + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) -> () ) {} diff --git a/tests/resources/formatting/types/callable types/with typed optional parameter.sdstest b/tests/resources/formatting/types/callable types/with typed optional parameter.sdstest new file mode 100644 index 000000000..e19c7ef29 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with typed optional parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( a : Int = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (a: Int = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with typed required parameter.sdstest b/tests/resources/formatting/types/callable types/with typed required parameter.sdstest new file mode 100644 index 000000000..26411d9e7 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with typed required parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( a : Int ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (a: Int) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with typed variadic parameter (with default value).sdstest b/tests/resources/formatting/types/callable types/with typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..646221917 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with typed variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( vararg a : Int = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (vararg a: Int = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with typed variadic parameter.sdstest b/tests/resources/formatting/types/callable types/with typed variadic parameter.sdstest new file mode 100644 index 000000000..a31d40a0d --- /dev/null +++ b/tests/resources/formatting/types/callable types/with typed variadic parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( vararg a : Int ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (vararg a: Int) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with untyped optional parameter.sdstest b/tests/resources/formatting/types/callable types/with untyped optional parameter.sdstest new file mode 100644 index 000000000..e19c7ef29 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with untyped optional parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( a : Int = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (a: Int = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with untyped required parameter.sdstest b/tests/resources/formatting/types/callable types/with untyped required parameter.sdstest new file mode 100644 index 000000000..434e234d5 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with untyped required parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( a ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (a) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with untyped variadic parameter (with default value).sdstest b/tests/resources/formatting/types/callable types/with untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..d817dfde9 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with untyped variadic parameter (with default value).sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( vararg a = 1 ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (vararg a = 1) -> () +) {} diff --git a/tests/resources/formatting/types/callable types/with untyped variadic parameter.sdstest b/tests/resources/formatting/types/callable types/with untyped variadic parameter.sdstest new file mode 100644 index 000000000..832e79dd7 --- /dev/null +++ b/tests/resources/formatting/types/callable types/with untyped variadic parameter.sdstest @@ -0,0 +1,9 @@ +segment mySegment( + f: ( vararg a ) -> ( ) +) {} + +// ----------------------------------------------------------------------------- + +segment mySegment( + f: (vararg a) -> () +) {} diff --git a/tests/resources/grammar/declarations/annotations/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/annotations/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..10699f3d4 --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/bad-double const modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +annotation MyAnnotation(const const a: String) diff --git a/tests/resources/grammar/declarations/annotations/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/annotations/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..381d145b3 --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +annotation MyAnnotation(vararg vararg a: String) diff --git a/tests/resources/grammar/declarations/annotations/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/annotations/good-multiple parameters.sdstest index 81899746c..7b0a5fea8 100644 --- a/tests/resources/grammar/declarations/annotations/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/annotations/good-multiple parameters.sdstest @@ -1,12 +1,26 @@ // $TEST$ no_syntax_error annotation MyAnnotation( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) diff --git a/tests/resources/grammar/declarations/annotations/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/annotations/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..e1a0718dc --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const typed optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation(const a: Int = 1) diff --git a/tests/resources/grammar/declarations/annotations/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/annotations/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..c2a89f75a --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const typed required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation(const a: Int) diff --git a/tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..e21a2fe73 --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation1(const vararg a: Int = 1) +annotation MyAnnotation2(vararg const a: Int = 1) diff --git a/tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..128c6560d --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const typed variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation1(const vararg a: Int) +annotation MyAnnotation2(vararg const a: Int) diff --git a/tests/resources/grammar/declarations/annotations/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/annotations/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..f86193f23 --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const untyped optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation(const a = 1) diff --git a/tests/resources/grammar/declarations/annotations/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/annotations/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..5ba0d7556 --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const untyped required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation(const a) diff --git a/tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..4f5c91259 --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation1(const vararg a = 1) +annotation MyAnnotation2(vararg const a = 1) diff --git a/tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..b148d266a --- /dev/null +++ b/tests/resources/grammar/declarations/annotations/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +annotation MyAnnotation1(const vararg a) +annotation MyAnnotation2(vararg const a) diff --git a/tests/resources/grammar/declarations/classes/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..8b2109050 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/bad-double const modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +class MyClass(const const a: String) diff --git a/tests/resources/grammar/declarations/classes/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..af2cba212 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +class MyClass(vararg vararg a: String) diff --git a/tests/resources/grammar/declarations/classes/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/classes/good-multiple parameters.sdstest index 0378c142c..f2098a136 100644 --- a/tests/resources/grammar/declarations/classes/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/classes/good-multiple parameters.sdstest @@ -1,12 +1,26 @@ // $TEST$ no_syntax_error class MyClass( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) diff --git a/tests/resources/grammar/declarations/classes/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/classes/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..7a9b687cf --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const typed optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +class MyClass(const a: Int = 1) diff --git a/tests/resources/grammar/declarations/classes/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/classes/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..7de3e2657 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const typed required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +class MyClass(const a: Int) diff --git a/tests/resources/grammar/declarations/classes/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..672ad428b --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +class MyClass1(const vararg a: Int = 1) +class MyClass2(vararg const a: Int = 1) diff --git a/tests/resources/grammar/declarations/classes/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..6a67e3a8e --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const typed variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +class MyClass1(const vararg a: Int) +class MyClass2(vararg const a: Int) diff --git a/tests/resources/grammar/declarations/classes/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/classes/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..acda4390c --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const untyped optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +class MyClass(const a = 1) diff --git a/tests/resources/grammar/declarations/classes/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/classes/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..5bc30a4a8 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const untyped required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +class MyClass(const a) diff --git a/tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..833c7962c --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +class MyClass1(const vararg a = 1) +class MyClass2(vararg const a = 1) diff --git a/tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..22ceac251 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +class MyClass1(const vararg a) +class MyClass2(vararg const a) diff --git a/tests/resources/grammar/declarations/classes/methods/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..ef8c3a7a0 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/bad-double const modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +class MyClass { + fun myFunction(const const a: String) +} diff --git a/tests/resources/grammar/declarations/classes/methods/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..b6d8413d9 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +class MyClass { + fun myFunction(vararg vararg a: String) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/classes/methods/good-multiple parameters.sdstest index 2e94b1976..ad66eb930 100644 --- a/tests/resources/grammar/declarations/classes/methods/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/classes/methods/good-multiple parameters.sdstest @@ -2,13 +2,27 @@ class MyClass { fun myFunction( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..0b65b90bd --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction(const a: Int = 1) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..02af3261f --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction(const a: Int) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..984896442 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction1(const vararg a: Int = 1) + fun myFunction2(vararg const a: Int = 1) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..64940ed4c --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const typed variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction1(const vararg a: Int) + fun myFunction2(vararg const a: Int) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..2afa5321a --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction(const a = 1) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..12a6cc4bd --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction(const a) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..5fc0c1bcc --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction1(const vararg a = 1) + fun myFunction2(vararg const a = 1) +} diff --git a/tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..566b4654b --- /dev/null +++ b/tests/resources/grammar/declarations/classes/methods/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyClass { + fun myFunction1(const vararg a) + fun myFunction2(vararg const a) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..da5783933 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/bad-double const modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +class MyOuterClass { + class MyClass(const const a: String) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..4e144fffe --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +class MyOuterClass { + class MyClass(vararg vararg a: String) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-multiple parameters.sdstest index d1cf4eec3..599cb0fce 100644 --- a/tests/resources/grammar/declarations/classes/nested classes/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/classes/nested classes/good-multiple parameters.sdstest @@ -2,13 +2,27 @@ class MyOuterClass { class MyClass( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..9675d3bc8 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass(const a: Int = 1) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..6c95eff1c --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass(const a: Int) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..a8fae1885 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass1(const vararg a: Int = 1) + class MyClass2(vararg const a: Int = 1) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..4e3340db5 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const typed variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass1(const vararg a: Int) + class MyClass2(vararg const a: Int) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..247a6565f --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass(const a = 1) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..3394b0196 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass(const a) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..04811e7ec --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass1(const vararg a = 1) + class MyClass2(vararg const a = 1) +} diff --git a/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..3bc707988 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested classes/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +class MyOuterClass { + class MyClass1(const vararg a) + class MyClass2(vararg const a) +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..b5b7e49af --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/bad-double const modifier on parameter.sdstest @@ -0,0 +1,7 @@ +// $TEST$ syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant(const const a: String) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..e7f2af9fa --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,7 @@ +// $TEST$ syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant(vararg vararg a: String) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-multiple parameters.sdstest index d549a77cc..180759e5e 100644 --- a/tests/resources/grammar/declarations/classes/nested enums/variants/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-multiple parameters.sdstest @@ -3,14 +3,28 @@ class MyClass { enum MyEnum { MyEnumVariant( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } } diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..0ef2aabb3 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed optional parameter.sdstest @@ -0,0 +1,7 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant(const a: Int = 1) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..d9c65771a --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed required parameter.sdstest @@ -0,0 +1,7 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant(const a: Int) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..dcb3f22cc --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,8 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a: Int = 1) + MyEnumVariant2(vararg const a: Int = 1) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..a13461748 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const typed variadic parameter.sdstest @@ -0,0 +1,8 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a: Int) + MyEnumVariant2(vararg const a: Int) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..22e8db4c7 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped optional parameter.sdstest @@ -0,0 +1,7 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant(const a = 1) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..8be5b9795 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped required parameter.sdstest @@ -0,0 +1,7 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant(const a) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..350398740 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,8 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a = 1) + MyEnumVariant2(vararg const a = 1) + } +} diff --git a/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..22dd382f1 --- /dev/null +++ b/tests/resources/grammar/declarations/classes/nested enums/variants/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,8 @@ +// $TEST$ no_syntax_error + +class MyClass { + enum MyEnum { + MyEnumVariant1(const vararg a) + MyEnumVariant2(vararg const a) + } +} diff --git a/tests/resources/grammar/declarations/enums/variants/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..e4d5a9a95 --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/bad-double const modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +enum MyEnum { + MyEnumVariant(const const a: String) +} diff --git a/tests/resources/grammar/declarations/enums/variants/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..62f21d306 --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +enum MyEnum { + MyEnumVariant(vararg vararg a: String) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/enums/variants/good-multiple parameters.sdstest index 8a7f2fb10..30b3bdda7 100644 --- a/tests/resources/grammar/declarations/enums/variants/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/enums/variants/good-multiple parameters.sdstest @@ -2,13 +2,27 @@ enum MyEnum { MyEnumVariant( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) } diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..4f200ea3f --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant(const a: Int = 1) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..822624d19 --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant(const a: Int) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..16993b05d --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant1(const vararg a: Int = 1) + MyEnumVariant2(vararg const a: Int = 1) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..c2b1bb216 --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const typed variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant1(const vararg a: Int) + MyEnumVariant2(vararg const a: Int) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..cc5c98ce8 --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant(const a = 1) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..68f7d945a --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant(const a) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..2c868af15 --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant1(const vararg a = 1) + MyEnumVariant2(vararg const a = 1) +} diff --git a/tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..c49ccefda --- /dev/null +++ b/tests/resources/grammar/declarations/enums/variants/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +enum MyEnum { + MyEnumVariant1(const vararg a) + MyEnumVariant2(vararg const a) +} diff --git a/tests/resources/grammar/declarations/functions/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/functions/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..3ace63aa9 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/bad-double const modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +fun myFunction(const const a: String) diff --git a/tests/resources/grammar/declarations/functions/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/functions/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..eda3810b4 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +fun myFunction(vararg vararg a: String) diff --git a/tests/resources/grammar/declarations/functions/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/functions/good-multiple parameters.sdstest index b0d409e92..73d9b3644 100644 --- a/tests/resources/grammar/declarations/functions/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/functions/good-multiple parameters.sdstest @@ -1,12 +1,26 @@ // $TEST$ no_syntax_error fun myFunction( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) diff --git a/tests/resources/grammar/declarations/functions/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/functions/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..8497ce507 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const typed optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction(const a: Int = 1) diff --git a/tests/resources/grammar/declarations/functions/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/functions/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..6dd3415f6 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const typed required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction(const a: Int) diff --git a/tests/resources/grammar/declarations/functions/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/functions/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..240beaede --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +fun myFunction1(const vararg a: Int = 1) +fun myFunction2(vararg const a: Int = 1) diff --git a/tests/resources/grammar/declarations/functions/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/functions/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..71ba6e960 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const typed variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +fun myFunction1(const vararg a: Int) +fun myFunction2(vararg const a: Int) diff --git a/tests/resources/grammar/declarations/functions/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/functions/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..72abbe3f6 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const untyped optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction(const a = 1) diff --git a/tests/resources/grammar/declarations/functions/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/functions/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..773db3a66 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const untyped required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +fun myFunction(const a) diff --git a/tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..1062d11aa --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +fun myFunction1(const vararg a = 1) +fun myFunction2(vararg const a = 1) diff --git a/tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..14a6f4ea1 --- /dev/null +++ b/tests/resources/grammar/declarations/functions/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +fun myFunction1(const vararg a) +fun myFunction2(vararg const a) diff --git a/tests/resources/grammar/declarations/segments/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/declarations/segments/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..ceeff53c7 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/bad-double const modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +segment mySegment(const const a: String) diff --git a/tests/resources/grammar/declarations/segments/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/declarations/segments/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..b46500405 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +segment mySegment(vararg vararg a: String) diff --git a/tests/resources/grammar/declarations/segments/good-multiple parameters.sdstest b/tests/resources/grammar/declarations/segments/good-multiple parameters.sdstest index 0b6c721ad..7550d78b9 100644 --- a/tests/resources/grammar/declarations/segments/good-multiple parameters.sdstest +++ b/tests/resources/grammar/declarations/segments/good-multiple parameters.sdstest @@ -1,12 +1,26 @@ // $TEST$ no_syntax_error segment mySegment( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const typed optional parameter.sdstest b/tests/resources/grammar/declarations/segments/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..c9111a833 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const typed optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +segment mySegment(const a: Int = 1) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const typed required parameter.sdstest b/tests/resources/grammar/declarations/segments/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..63dd852cd --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const typed required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +segment mySegment(const a: Int) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/segments/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..6dd126ece --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +segment mySegment1(const vararg a: Int = 1) {} +segment mySegment2(vararg const a: Int = 1) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/declarations/segments/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..1b61af18b --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const typed variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +segment mySegment1(const vararg a: Int) {} +segment mySegment2(vararg const a: Int) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/declarations/segments/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..ab3218199 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const untyped optional parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +segment mySegment(const a = 1) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const untyped required parameter.sdstest b/tests/resources/grammar/declarations/segments/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..d4ef056f1 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const untyped required parameter.sdstest @@ -0,0 +1,3 @@ +// $TEST$ no_syntax_error + +segment mySegment(const a) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..b4be72ef8 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +segment mySegment1(const vararg a = 1) {} +segment mySegment2(vararg const a = 1) {} diff --git a/tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..eb3cbd153 --- /dev/null +++ b/tests/resources/grammar/declarations/segments/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,4 @@ +// $TEST$ no_syntax_error + +segment mySegment1(const vararg a) {} +segment mySegment2(vararg const a) {} diff --git a/tests/resources/grammar/expressions/block lambdas/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..6ec43bb5d --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/bad-double const modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +pipeline myPipeline { + (const const a: String) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..303bc51a2 --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +pipeline myPipeline { + (vararg vararg a: String) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-multiple parameters.sdstest b/tests/resources/grammar/expressions/block lambdas/good-multiple parameters.sdstest index 05cf07fd3..46d08ccd1 100644 --- a/tests/resources/grammar/expressions/block lambdas/good-multiple parameters.sdstest +++ b/tests/resources/grammar/expressions/block lambdas/good-multiple parameters.sdstest @@ -2,13 +2,27 @@ pipeline myPipeline { ( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) {}; } diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const typed optional parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const typed optional parameter.sdstest new file mode 100644 index 000000000..3de8f14fe --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a: Int = 1) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const typed required parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const typed required parameter.sdstest new file mode 100644 index 000000000..d3ccd2c1d --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a: Int) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..c81ac436b --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a: Int = 1) {}; + (vararg const a: Int = 1) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter.sdstest new file mode 100644 index 000000000..d3bc00304 --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const typed variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a: Int) {}; + (vararg const a: Int) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const untyped optional parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const untyped optional parameter.sdstest new file mode 100644 index 000000000..1e9f3240f --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a = 1) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const untyped required parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const untyped required parameter.sdstest new file mode 100644 index 000000000..cf97ccc6b --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..c493afeaf --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a = 1) {}; + (vararg const a = 1) {}; +} diff --git a/tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter.sdstest b/tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter.sdstest new file mode 100644 index 000000000..a0e83ba1a --- /dev/null +++ b/tests/resources/grammar/expressions/block lambdas/good-with const untyped variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a) {}; + (vararg const a) {}; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/bad-double const modifier on parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/bad-double const modifier on parameter.sdstest new file mode 100644 index 000000000..6cc3daec3 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/bad-double const modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +pipeline myPipeline { + (const const a: String) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/bad-double vararg modifier on parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/bad-double vararg modifier on parameter.sdstest new file mode 100644 index 000000000..c9b58ce41 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/bad-double vararg modifier on parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ syntax_error + +pipeline myPipeline { + (vararg vararg a: String) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const typed optional parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const typed optional parameter.sdstest new file mode 100644 index 000000000..5d2da7878 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a: Int = 1) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const typed required parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const typed required parameter.sdstest new file mode 100644 index 000000000..69204fabf --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a: Int) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..ab35e1a7c --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a: Int = 1) -> 1; + (vararg const a: Int = 1) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter.sdstest new file mode 100644 index 000000000..50c2dbce8 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const typed variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a: Int) -> 1; + (vararg const a: Int) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const untyped optional parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const untyped optional parameter.sdstest new file mode 100644 index 000000000..ea90d0891 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a = 1) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const untyped required parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const untyped required parameter.sdstest new file mode 100644 index 000000000..5ef2af27b --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const untyped required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const a) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..56a900341 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a = 1) -> 1; + (vararg const a = 1) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter.sdstest new file mode 100644 index 000000000..539d77317 --- /dev/null +++ b/tests/resources/grammar/expressions/expression lambdas/good-const untyped variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +pipeline myPipeline { + (const vararg a) -> 1; + (vararg const a) -> 1; +} diff --git a/tests/resources/grammar/expressions/expression lambdas/good-multiple parameters.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-multiple parameters.sdstest index a6769ce03..9970d6f6d 100644 --- a/tests/resources/grammar/expressions/expression lambdas/good-multiple parameters.sdstest +++ b/tests/resources/grammar/expressions/expression lambdas/good-multiple parameters.sdstest @@ -2,13 +2,27 @@ pipeline myPipeline { ( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) -> 4; } diff --git a/tests/resources/grammar/expressions/expression lambdas/good-typed optional parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-typed optional parameter.sdstest index f158ef73e..20a884559 100644 --- a/tests/resources/grammar/expressions/expression lambdas/good-typed optional parameter.sdstest +++ b/tests/resources/grammar/expressions/expression lambdas/good-typed optional parameter.sdstest @@ -1,5 +1,5 @@ // $TEST$ no_syntax_error pipeline myPipeline { - (a = 1) -> 1; + (a: Int = 1) -> 1; } diff --git a/tests/resources/grammar/expressions/expression lambdas/good-untyped optional parameter.sdstest b/tests/resources/grammar/expressions/expression lambdas/good-untyped optional parameter.sdstest index 20a884559..f158ef73e 100644 --- a/tests/resources/grammar/expressions/expression lambdas/good-untyped optional parameter.sdstest +++ b/tests/resources/grammar/expressions/expression lambdas/good-untyped optional parameter.sdstest @@ -1,5 +1,5 @@ // $TEST$ no_syntax_error pipeline myPipeline { - (a: Int = 1) -> 1; + (a = 1) -> 1; } diff --git a/tests/resources/grammar/keywords as names/bad-unescaped const.sdstest b/tests/resources/grammar/keywords as names/bad-unescaped const.sdstest new file mode 100644 index 000000000..b310364a2 --- /dev/null +++ b/tests/resources/grammar/keywords as names/bad-unescaped const.sdstest @@ -0,0 +1,3 @@ +// $TEST$ syntax_error + +class const diff --git a/tests/resources/grammar/keywords as names/good-escapedKeywords.sdstest b/tests/resources/grammar/keywords as names/good-escapedKeywords.sdstest index ad259c144..2067b68fd 100644 --- a/tests/resources/grammar/keywords as names/good-escapedKeywords.sdstest +++ b/tests/resources/grammar/keywords as names/good-escapedKeywords.sdstest @@ -6,6 +6,7 @@ class `annotation` class `as` class `attr` class `class` +class `const` class `enum` class `false` class `fun` diff --git a/tests/resources/grammar/types/callable types/good-const typed optional parameter.sdstest b/tests/resources/grammar/types/callable types/good-const typed optional parameter.sdstest new file mode 100644 index 000000000..d5c5ba521 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const a: Int = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-const typed required parameter.sdstest b/tests/resources/grammar/types/callable types/good-const typed required parameter.sdstest new file mode 100644 index 000000000..df251d9b6 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const a: Int) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-const typed variadic parameter (with default value).sdstest b/tests/resources/grammar/types/callable types/good-const typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..1aee60858 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const typed variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const vararg a: Int = 1) -> (), + g: (vararg const a: Int = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-const typed variadic parameter.sdstest b/tests/resources/grammar/types/callable types/good-const typed variadic parameter.sdstest new file mode 100644 index 000000000..f12d78c43 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const typed variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const vararg a: Int) -> (), + g: (vararg const a: Int) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-const untyped optional parameter.sdstest b/tests/resources/grammar/types/callable types/good-const untyped optional parameter.sdstest new file mode 100644 index 000000000..d5c5ba521 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const a: Int = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-with one typed parameter.sdstest b/tests/resources/grammar/types/callable types/good-const untyped required parameter.sdstest similarity index 66% rename from tests/resources/grammar/types/callable types/good-with one typed parameter.sdstest rename to tests/resources/grammar/types/callable types/good-const untyped required parameter.sdstest index d96db7f9e..0fa269508 100644 --- a/tests/resources/grammar/types/callable types/good-with one typed parameter.sdstest +++ b/tests/resources/grammar/types/callable types/good-const untyped required parameter.sdstest @@ -1,5 +1,5 @@ // $TEST$ no_syntax_error segment mySegment( - f: (param: Int) -> () + f: (const a) -> () ) {} diff --git a/tests/resources/grammar/types/callable types/good-const untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/types/callable types/good-const untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..b6aa1e22f --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const untyped variadic parameter (with default value).sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const vararg a = 1) -> (), + g: (vararg const a = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-const untyped variadic parameter.sdstest b/tests/resources/grammar/types/callable types/good-const untyped variadic parameter.sdstest new file mode 100644 index 000000000..fed425d67 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-const untyped variadic parameter.sdstest @@ -0,0 +1,6 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (const vararg a) -> (), + g: (vararg const a) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-typed optional parameter.sdstest b/tests/resources/grammar/types/callable types/good-typed optional parameter.sdstest new file mode 100644 index 000000000..031f09e1c --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-typed optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (a: Int = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-typed required parameter.sdstest b/tests/resources/grammar/types/callable types/good-typed required parameter.sdstest new file mode 100644 index 000000000..56063576c --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-typed required parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (a: Int) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-typed variadic parameter (with default value).sdstest b/tests/resources/grammar/types/callable types/good-typed variadic parameter (with default value).sdstest new file mode 100644 index 000000000..0fa1b4e5f --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-typed variadic parameter (with default value).sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (vararg a: Int = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-typed variadic parameter.sdstest b/tests/resources/grammar/types/callable types/good-typed variadic parameter.sdstest new file mode 100644 index 000000000..d8e29465c --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-typed variadic parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (vararg a: Int) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-untyped optional parameter.sdstest b/tests/resources/grammar/types/callable types/good-untyped optional parameter.sdstest new file mode 100644 index 000000000..031f09e1c --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-untyped optional parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (a: Int = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-with one untyped parameter.sdstest b/tests/resources/grammar/types/callable types/good-untyped required parameter.sdstest similarity index 70% rename from tests/resources/grammar/types/callable types/good-with one untyped parameter.sdstest rename to tests/resources/grammar/types/callable types/good-untyped required parameter.sdstest index a0a171320..63d391694 100644 --- a/tests/resources/grammar/types/callable types/good-with one untyped parameter.sdstest +++ b/tests/resources/grammar/types/callable types/good-untyped required parameter.sdstest @@ -1,5 +1,5 @@ // $TEST$ no_syntax_error segment mySegment( - f: (param) -> () + f: (a) -> () ) {} diff --git a/tests/resources/grammar/types/callable types/good-untyped variadic parameter (with default value).sdstest b/tests/resources/grammar/types/callable types/good-untyped variadic parameter (with default value).sdstest new file mode 100644 index 000000000..27fc9f99b --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-untyped variadic parameter (with default value).sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (vararg a = 1) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-untyped variadic parameter.sdstest b/tests/resources/grammar/types/callable types/good-untyped variadic parameter.sdstest new file mode 100644 index 000000000..c676991f8 --- /dev/null +++ b/tests/resources/grammar/types/callable types/good-untyped variadic parameter.sdstest @@ -0,0 +1,5 @@ +// $TEST$ no_syntax_error + +segment mySegment( + f: (vararg a) -> () +) {} diff --git a/tests/resources/grammar/types/callable types/good-with multiple parameters.sdstest b/tests/resources/grammar/types/callable types/good-with multiple parameters.sdstest index fd772f0fc..4636eff12 100644 --- a/tests/resources/grammar/types/callable types/good-with multiple parameters.sdstest +++ b/tests/resources/grammar/types/callable types/good-with multiple parameters.sdstest @@ -2,13 +2,27 @@ segment mySegment( f: ( - @Annotation a, - b = 0, - vararg c, - vararg d: Int = 1, - e: Int, - f: Int = 2, - vararg g: Int, - vararg h: Int = 3 + @Annotation a1, + b1 = 0, + vararg c1, + vararg d1: Int = 1, + e1: Int, + f1: Int = 2, + vararg g1: Int, + vararg h1: Int = 3, + + @Annotation a2, + const b2 = 0, + const vararg c2, + const vararg d2: Int = 1, + const e2: Int, + const f2: Int = 2, + const vararg g2: Int, + const vararg h2: Int = 3, + + vararg const c3, + vararg const d3: Int = 1, + vararg const g3: Int, + vararg const h3: Int = 3 ) -> () ) {} diff --git a/tests/resources/validation/other/declarations/parameters/const modifier/main.sdstest b/tests/resources/validation/other/declarations/parameters/const modifier/main.sdstest new file mode 100644 index 000000000..f09637711 --- /dev/null +++ b/tests/resources/validation/other/declarations/parameters/const modifier/main.sdstest @@ -0,0 +1,37 @@ +package tests.validation.other.declarations.parameters.illegalConstModifier + +annotation MyAnnotation( + // $TEST$ info "Parameters of annotations implicitly have the const modifier." + const »p1«: Int, + + // $TEST$ no info "Parameters of annotations implicitly have the const modifier." + »p2«: Int, +) + +fun f( + g: ( + // $TEST$ error "The const modifier is not applicable to parameters of callable types." + const »p1«: Int, + + // $TEST$ no error "The const modifier is not applicable to parameters of callable types." + »p2«: Int, + ) -> () +) + +pipeline myPipeline { + ( + // $TEST$ error "The const modifier is not applicable to parameters of lambdas." + const »p1«: Int, + + // $TEST$ no error "The const modifier is not applicable to parameters of lambdas." + »p2«: Int, + ) {}; + + ( + // $TEST$ error "The const modifier is not applicable to parameters of lambdas." + const »p1«: Int, + + // $TEST$ no error "The const modifier is not applicable to parameters of lambdas." + »p2«: Int, + ) -> 1; +} diff --git a/tests/resources/validation/other/types/callable types/must not have optional parameters/optional.sdstest b/tests/resources/validation/other/types/callable types/must not have optional parameters/optional.sdstest index a8709f658..b7e137982 100644 --- a/tests/resources/validation/other/types/callable types/must not have optional parameters/optional.sdstest +++ b/tests/resources/validation/other/types/callable types/must not have optional parameters/optional.sdstest @@ -1,4 +1,4 @@ -package tests.validation.types.callableTypes.mustNotHaveOptionalParameters +package tests.validation.other.types.callableTypes.mustNotHaveOptionalParameters fun f( g: ( diff --git a/tests/resources/validation/other/types/callable types/must not have optional parameters/required.sdstest b/tests/resources/validation/other/types/callable types/must not have optional parameters/required.sdstest index 794be82b1..a70ae8c01 100644 --- a/tests/resources/validation/other/types/callable types/must not have optional parameters/required.sdstest +++ b/tests/resources/validation/other/types/callable types/must not have optional parameters/required.sdstest @@ -1,4 +1,4 @@ -package tests.validation.types.callableTypes.mustNotHaveOptionalParameters +package tests.validation.other.types.callableTypes.mustNotHaveOptionalParameters fun f( g: ( diff --git a/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic optional.sdstest b/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic optional.sdstest index d7972bdc6..267ae8215 100644 --- a/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic optional.sdstest +++ b/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic optional.sdstest @@ -1,4 +1,4 @@ -package tests.validation.types.callableTypes.mustNotHaveOptionalParameters +package tests.validation.other.types.callableTypes.mustNotHaveOptionalParameters fun f( g: ( diff --git a/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic required.sdstest b/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic required.sdstest index 614ea95e0..268a73697 100644 --- a/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic required.sdstest +++ b/tests/resources/validation/other/types/callable types/must not have optional parameters/variadic required.sdstest @@ -1,4 +1,4 @@ -package tests.validation.types.callableTypes.mustNotHaveOptionalParameters +package tests.validation.types.other.callableTypes.mustNotHaveOptionalParameters fun f( g: ( diff --git a/tests/resources/validation/other/types/type argument lists/must not have positional type argument after named type argument/main.sdstest b/tests/resources/validation/other/types/type argument lists/must not have positional type argument after named type argument/main.sdstest index 07fd351f0..c6237952a 100644 --- a/tests/resources/validation/other/types/type argument lists/must not have positional type argument after named type argument/main.sdstest +++ b/tests/resources/validation/other/types/type argument lists/must not have positional type argument after named type argument/main.sdstest @@ -1,4 +1,4 @@ -package tests.validation.types.typeArgumentLists.mustNotHavePositionalTypeArgumentAfterNamedTypeArgument +package tests.validation.other.types.typeArgumentLists.mustNotHavePositionalTypeArgumentAfterNamedTypeArgument // $TEST$ no error "After the first named type argument all type arguments must be named." // $TEST$ no error "After the first named type argument all type arguments must be named." diff --git a/tests/resources/validation/other/types/union types/must have type arguments/main.sdstest b/tests/resources/validation/other/types/union types/must have type arguments/main.sdstest index faface2c1..9568c20ce 100644 --- a/tests/resources/validation/other/types/union types/must have type arguments/main.sdstest +++ b/tests/resources/validation/other/types/union types/must have type arguments/main.sdstest @@ -1,4 +1,4 @@ -package tests.validation.types.unionTypes.mustHaveTypeArguments +package tests.validation.other.types.unionTypes.mustHaveTypeArguments // $TEST$ error "A union type must have least one type argument." segment mySegment1(