From 1fae28aec734517f11c46e09ddaac3098956098a Mon Sep 17 00:00:00 2001 From: Robin <91134475+robmeth@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:01:04 +0200 Subject: [PATCH] feat: expand syntax (#24) Add the new language syntax. --- docs/development/call-graph-testing.md | 2 +- docs/development/formatting-testing.md | 4 +- docs/development/generation-testing.md | 2 +- docs/development/grammar-testing.md | 2 +- .../development/partial-evaluation-testing.md | 2 +- docs/development/scoping-testing.md | 2 +- docs/development/typing-testing.md | 2 +- docs/development/validation-testing.md | 2 +- docs/pyproject.toml | 2 +- package-lock.json | 6 +- packages/ttsl-cli/tests/cli/main.test.ts | 20 +- .../tests/helpers/diagnostics.test.ts | 14 +- .../ttsl-cli/tests/helpers/documents.test.ts | 32 +- packages/ttsl-cli/tests/helpers/files.test.ts | 2 +- packages/ttsl-lang/langium-config.json | 2 +- .../language/builtins/safe-ds-annotations.ts | 76 +- .../src/language/builtins/safe-ds-classes.ts | 30 +- .../src/language/builtins/safe-ds-enums.ts | 34 +- .../builtins/safe-ds-module-members.ts | 6 +- .../documentation/safe-ds-comment-provider.ts | 24 +- .../safe-ds-documentation-provider.ts | 26 +- packages/ttsl-lang/src/language/flow/model.ts | 8 +- .../flow/safe-ds-call-graph-computer.ts | 84 +- .../generation/safe-ds-python-generator.ts | 318 ++--- .../src/language/grammar/safe-ds.langium | 1195 ++++++++++------- .../src/language/helpers/fileExtensions.ts | 10 +- .../src/language/helpers/nodeProperties.ts | 308 ++--- .../language/helpers/safe-ds-node-mapper.ts | 116 +- .../lsp/safe-ds-call-hierarchy-provider.ts | 24 +- .../lsp/safe-ds-document-symbol-provider.ts | 28 +- .../src/language/lsp/safe-ds-formatter.ts | 380 +++--- .../lsp/safe-ds-inlay-hint-provider.ts | 6 +- .../lsp/safe-ds-node-info-provider.ts | 8 +- .../lsp/safe-ds-node-kind-provider.ts | 66 +- .../language/lsp/safe-ds-rename-provider.ts | 6 +- .../lsp/safe-ds-semantic-token-provider.ts | 98 +- .../lsp/safe-ds-signature-help-provider.ts | 10 +- .../lsp/safe-ds-type-hierarchy-provider.ts | 34 +- .../src/language/partialEvaluation/model.ts | 40 +- .../safe-ds-partial-evaluator.ts | 228 ++-- .../ttsl-lang/src/language/purity/model.ts | 14 +- .../purity/safe-ds-purity-computer.ts | 88 +- .../src/language/runner/safe-ds-runner.ts | 26 +- .../scoping/safe-ds-scope-computation.ts | 98 +- .../scoping/safe-ds-scope-provider.ts | 208 +-- .../ttsl-lang/src/language/typing/model.ts | 58 +- .../typing/safe-ds-class-hierarchy.ts | 22 +- .../src/language/typing/safe-ds-core-types.ts | 4 +- .../language/typing/safe-ds-type-checker.ts | 10 +- .../language/typing/safe-ds-type-computer.ts | 302 ++--- .../language/typing/safe-ds-type-factory.ts | 36 +- .../validation/builtins/deprecated.ts | 36 +- .../validation/builtins/experimental.ts | 32 +- .../language/validation/builtins/expert.ts | 4 +- .../validation/builtins/pythonCall.ts | 6 +- .../validation/builtins/pythonModule.ts | 4 +- .../validation/builtins/pythonName.ts | 6 +- .../validation/builtins/repeatable.ts | 4 +- .../language/validation/builtins/target.ts | 66 +- .../experimentalLanguageFeatures.ts | 24 +- .../src/language/validation/inheritance.ts | 26 +- .../src/language/validation/names.ts | 118 +- .../validation/other/argumentLists.ts | 18 +- .../other/declarations/annotationCalls.ts | 30 +- .../other/declarations/parameterBounds.ts | 22 +- .../other/declarations/parameterLists.ts | 4 +- .../other/declarations/parameters.ts | 14 +- .../other/declarations/placeholders.ts | 28 +- .../validation/other/declarations/segments.ts | 8 +- .../other/declarations/typeParameterLists.ts | 4 +- .../other/declarations/typeParameters.ts | 66 +- .../validation/other/expressions/calls.ts | 6 +- .../other/expressions/chainedExpressions.ts | 10 +- .../other/expressions/indexedAccess.ts | 4 +- .../other/expressions/infixOperations.ts | 4 +- .../validation/other/expressions/lambdas.ts | 12 +- .../other/expressions/memberAccesses.ts | 8 +- .../other/expressions/references.ts | 50 +- .../other/expressions/templateStrings.ts | 6 +- .../src/language/validation/other/imports.ts | 6 +- .../src/language/validation/other/modules.ts | 18 +- .../other/statements/assignments.ts | 12 +- .../validation/other/statements/statements.ts | 4 +- .../validation/other/types/callableTypes.ts | 18 +- .../validation/other/types/literalTypes.ts | 14 +- .../validation/other/types/namedTypes.ts | 8 +- .../validation/other/types/unionTypes.ts | 34 +- .../src/language/validation/purity.ts | 22 +- .../language/validation/safe-ds-validator.ts | 100 +- .../src/language/validation/style.ts | 86 +- .../src/language/validation/types.ts | 90 +- .../workspace/safe-ds-package-manager.ts | 4 +- .../__snapshots__/nodeFinder.test.ts.snap | 2 +- .../ttsl-lang/tests/helpers/diagnostics.ts | 2 +- .../ttsl-lang/tests/helpers/locations.test.ts | 20 +- .../tests/helpers/nodeFinder.test.ts | 20 +- .../ttsl-lang/tests/helpers/nodeFinder.ts | 6 +- .../tests/helpers/testChecks.test.ts | 2 +- .../tests/helpers/testResources.test.ts | 20 +- .../safe-ds-comment-provider.test.ts | 62 +- .../safe-ds-documentation-provider.test.ts | 40 +- .../tests/language/flow/model.test.ts | 10 +- .../flow/safe-ds-call-graph-computer.test.ts | 24 +- .../grammar/safe-ds-value-converter.test.ts | 36 +- .../argumentToParameter.test.ts | 14 +- .../assigneeToAssignedObject.test.ts | 32 +- .../callToCallable.test.ts | 86 +- .../callToParameterValue.test.ts | 20 +- .../parameterToReferences.test.ts | 14 +- .../parametersToArguments.test.ts | 22 +- .../placeholdersToReferences.test.ts | 12 +- .../resultToYields.test.ts | 8 +- .../typeArgumentToTypeParameter.test.ts | 22 +- .../lsp/safe-ds-inlay-hint-provider.test.ts | 2 +- .../lsp/safe-ds-rename-provider.test.ts | 8 +- .../canBeValueOfConstantParameter.test.ts | 4 +- .../language/partialEvaluation/model.test.ts | 32 +- .../tests/language/purity/model.test.ts | 4 +- .../purity/safe-ds-purity-computer.test.ts | 18 +- .../language/runner/safe-ds-runner.test.ts | 14 +- .../tests/language/scoping/scoping.test.ts | 8 +- .../tests/language/typing/model.test.ts | 18 +- .../typing/safe-ds-class-hierarchy.test.ts | 50 +- .../canBeTypeOfConstantParameter.test.ts | 8 +- .../type checker/isSubOrSupertypeOf.test.ts | 36 +- .../type computer/computeUpperBound.test.ts | 8 +- .../type computer/streamSupertypes.test.ts | 4 +- .../workspace/safe-ds-package-manager.test.ts | 4 +- .../generator/emptyPipeline/gen_input.py.map | 2 +- .../generator/emptySegment/gen_input.py.map | 2 +- .../parameterWithPythonName/gen_input.py.map | 2 +- .../pipelineWithPythonName/gen_input.py.map | 2 +- .../segmentWithPythonName/gen_input.py.map | 2 +- .../generator/twoPipelines/gen_input.py.map | 2 +- .../generator/twoSegments/gen_input.py.map | 2 +- .../blockLambdaResult/gen_input.py.map | 2 +- .../generator/blockLambda/gen_input.py.map | 2 +- .../tests/generator/call/gen_input.py.map | 2 +- .../tests/generator/constant/gen_input.py.map | 2 +- .../enumVariantCall/gen_input.py.map | 2 +- .../expressionLambda/gen_input.py.map | 2 +- .../generator/indexedAccess/gen_input.py.map | 2 +- .../generator/infixOperation/gen_input.py.map | 2 +- .../tests/generator/lists/gen_input.py.map | 2 +- .../tests/generator/literals/gen_input.py.map | 2 +- .../tests/generator/maps/gen_input.py.map | 2 +- .../generator/memberAccess/gen_input.py.map | 2 +- .../parenthesizedExpression/gen_input.py.map | 2 +- .../prefixOperation/gen_input.py.map | 2 +- .../generator/reference/gen_input.py.map | 2 +- .../generator/sideEffects/gen_input.py.map | 2 +- .../generator/templateString/gen_input.py.map | 2 +- .../imports/gen_context_same_package.py.map | 2 +- .../tests/generator/imports/gen_input.py.map | 2 +- .../tests/generator/wildcard/gen_input.py.map | 2 +- .../gen_input.py.map | 2 +- .../gen_input.py.map | 2 +- .../partialImpureDependency/gen_input.py.map | 2 +- .../partialPureDependency/gen_input.py.map | 2 +- .../partialRedundantImpurity/gen_input.py.map | 2 +- .../generated/special_module/gen_input.py.map | 2 +- .../gen_input.py.map | 2 +- .../gen_input.py.map | 2 +- .../gen_context_same_package.py.map | 2 +- .../gen_input.py.map | 2 +- .../gen_input.py.map | 2 +- .../gen_input.py.map | 2 +- .../generator/assignment/gen_input.py.map | 2 +- .../expressionStatement/gen_input.py.map | 2 +- .../statementWithoutEffect/gen_input.py.map | 2 +- .../img/safe-ds_file_icon_light.svg | 2 +- .../ttsl-vscode/src/extension/mainClient.ts | 20 +- 172 files changed, 3070 insertions(+), 2889 deletions(-) diff --git a/docs/development/call-graph-testing.md b/docs/development/call-graph-testing.md index ef73c0d7..5c497fce 100644 --- a/docs/development/call-graph-testing.md +++ b/docs/development/call-graph-testing.md @@ -5,7 +5,7 @@ graph test. ## Adding a call graph test -1. Create a new file with the extension `.sdstest` in the `tests/resources/call graph` directory or any subdirectory. +1. Create a new file with the extension `.Tsltest` in the `tests/resources/call graph` directory or any subdirectory. Give the file a descriptive name, since the file name becomes part of the test name. !!! tip "Skipping a test" diff --git a/docs/development/formatting-testing.md b/docs/development/formatting-testing.md index 5d1d066c..faad08d6 100644 --- a/docs/development/formatting-testing.md +++ b/docs/development/formatting-testing.md @@ -5,7 +5,7 @@ formatting test. ## Adding a formatting test -1. Create a new file with the extension `.sdstest` in the `tests/resources/formatting` directory or any subdirectory. +1. Create a new file with the extension `.Tsltest` in the `tests/resources/formatting` directory or any subdirectory. Give the file a descriptive name, since the file name becomes part of the test name. !!! tip "Skipping a test" @@ -14,7 +14,7 @@ formatting test. 2. Add the original unformatted Safe-DS code to the top of the file. The code must be syntactically valid. 3. Add the following separator to the file: - ```sds + ```Tsl // ----------------------------------------------------------------------------- ``` 4. Add the expected formatted Safe-DS code to the file below the separator. diff --git a/docs/development/generation-testing.md b/docs/development/generation-testing.md index 6d5fa070..5bb97e77 100644 --- a/docs/development/generation-testing.md +++ b/docs/development/generation-testing.md @@ -14,7 +14,7 @@ generation test. If you want to skip a test, add the prefix `skip-` to the folder name. -2. Add files with the extension `.sdstest`, `.sdspipe`, or `.sdsstub` **directly inside the folder**. All files in a +2. Add files with the extension `.Tsltest`, `.Tslpipe`, or `.Tslstub` **directly inside the folder**. All files in a folder will be loaded into the same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so they cannot reference each other. Generation will be triggered for all files in the folder. diff --git a/docs/development/grammar-testing.md b/docs/development/grammar-testing.md index 823182aa..99bfe195 100644 --- a/docs/development/grammar-testing.md +++ b/docs/development/grammar-testing.md @@ -5,7 +5,7 @@ test. ## Adding a grammar test -1. Create a new file with the extension `.sdstest` in the `tests/resources/grammar` directory or any subdirectory. Give +1. Create a new file with the extension `.Tsltest` in the `tests/resources/grammar` directory or any subdirectory. Give the file a descriptive name, since the file name becomes part of the test name. !!! note "Naming convention" diff --git a/docs/development/partial-evaluation-testing.md b/docs/development/partial-evaluation-testing.md index b4a43e1f..aae92008 100644 --- a/docs/development/partial-evaluation-testing.md +++ b/docs/development/partial-evaluation-testing.md @@ -12,7 +12,7 @@ partial evaluation test. If you want to skip a test, add the prefix `skip-` to the folder name. -2. Add files with the extension `.sdstest` **directly inside the folder**. All files in a folder will be loaded into the +2. Add files with the extension `.Tsltest` **directly inside the folder**. All files in a folder will be loaded into the same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so they cannot reference each other. 3. Add the Safe-DS code that you want to test to the files. diff --git a/docs/development/scoping-testing.md b/docs/development/scoping-testing.md index 223b82d8..854b1fcb 100644 --- a/docs/development/scoping-testing.md +++ b/docs/development/scoping-testing.md @@ -12,7 +12,7 @@ test. If you want to skip a test, add the prefix `skip-` to the folder name. -2. Add files with the extension `.sdstest` **directly inside +2. Add files with the extension `.Tsltest` **directly inside the folder**. All files in a folder will be loaded into the same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so they cannot reference each other. 3. Add the Safe-DS code that you want to test to the files. diff --git a/docs/development/typing-testing.md b/docs/development/typing-testing.md index 82af528f..6f5405bb 100644 --- a/docs/development/typing-testing.md +++ b/docs/development/typing-testing.md @@ -12,7 +12,7 @@ test. If you want to skip a test, add the prefix `skip-` to the folder name. -2. Add files with the extension `.sdstest` **directly inside the folder**. All files in a folder will be loaded into the +2. Add files with the extension `.Tsltest` **directly inside the folder**. All files in a folder will be loaded into the same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so they cannot reference each other. 3. Add the Safe-DS code that you want to test to the files. diff --git a/docs/development/validation-testing.md b/docs/development/validation-testing.md index 28086535..7b8b5be3 100644 --- a/docs/development/validation-testing.md +++ b/docs/development/validation-testing.md @@ -12,7 +12,7 @@ validation test. If you want to skip a test, add the prefix `skip-` to the folder name. -2. Add files with the extension `.sdstest`, `.sdspipe`, or `.sdsstub` **directly inside the folder**. All files in a +2. Add files with the extension `.Tsltest`, `.Tslpipe`, or `.Tslstub` **directly inside the folder**. All files in a folder will be loaded into the same workspace, so they can reference each other. Files in different folders are loaded into different workspaces, so they cannot reference each other. 3. Add the Safe-DS code that you want to test to the files. diff --git a/docs/pyproject.toml b/docs/pyproject.toml index 63156791..b732809c 100644 --- a/docs/pyproject.toml +++ b/docs/pyproject.toml @@ -17,7 +17,7 @@ mkdocs-same-dir = "^0.1.3" pygments = "^2.17.2" [tool.poetry.plugins."pygments.lexers"] -sds = "ttsl_lexer:TTSLLexer" +Tsl = "ttsl_lexer:TTSLLexer" [build-system] requires = ["poetry-core"] diff --git a/package-lock.json b/package-lock.json index 60edff9f..bb5dd0a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4287,7 +4287,7 @@ "node_modules/es-define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzTslGIrl8NFpT2gQ==", "dev": true, "dependencies": { "get-intrinsic": "^1.2.4" @@ -5200,7 +5200,7 @@ "node_modules/find-up-simple": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/find-up-simple/-/find-up-simple-1.0.0.tgz", - "integrity": "sha512-q7Us7kcjj2VMePAa02hDAF6d+MzsdsAWEwYyOpwUtlerRBkOEPBCRZrAV4XfcSN8fHAgaD0hP7miwoay6DCprw==", + "integrity": "sha512-q7Us7kcjj2VMePAa02hDAF6d+MzTslAWEwYyOpwUtlerRBkOEPBCRZrAV4XfcSN8fHAgaD0hP7miwoay6DCprw==", "dev": true, "engines": { "node": ">=18" @@ -6272,7 +6272,7 @@ "node_modules/is-typed-array": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", - "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", + "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYTslMw==", "dev": true, "dependencies": { "which-typed-array": "^1.1.14" diff --git a/packages/ttsl-cli/tests/cli/main.test.ts b/packages/ttsl-cli/tests/cli/main.test.ts index 2e8832c5..9b24f29e 100644 --- a/packages/ttsl-cli/tests/cli/main.test.ts +++ b/packages/ttsl-cli/tests/cli/main.test.ts @@ -63,25 +63,25 @@ describe('safe-ds', () => { }); it('should show not show errors in correct files', () => { - const process = spawnCheckProcess([], ['correct.sdstest']); + const process = spawnCheckProcess([], ['correct.Tsltest']); expect(process.stdout.toString()).toContain('No errors found.'); expect(process.status).toBe(ExitCode.Success); }); it('should handle references to builtins', () => { - const process = spawnCheckProcess([], ['references builtins.sdstest']); + const process = spawnCheckProcess([], ['references builtins.Tsltest']); expect(process.stdout.toString()).toContain('No errors found.'); expect(process.status).toBe(ExitCode.Success); }); it('should treat warnings as errors in strict mode', () => { - const process = spawnCheckProcess(['-s'], ['contains warnings.sdstest']); + const process = spawnCheckProcess(['-s'], ['contains warnings.Tsltest']); expect(process.stderr.toString()).toMatch(/Found \d+ errors?\./u); expect(process.status).toBe(ExitCode.FileHasErrors); }); it('should show an error if the file does not exist', () => { - const process = spawnCheckProcess([], ['missing.sdstest']); + const process = spawnCheckProcess([], ['missing.Tsltest']); expect(process.stderr.toString()).toMatch(/Path .* does not exist\./u); expect(process.status).toBe(ExitCode.MissingPath); }); @@ -121,13 +121,13 @@ describe('safe-ds', () => { }); it('should show not show errors in correct files', () => { - const process = spawnFormatProcess([], ['correct.sdstest']); + const process = spawnFormatProcess([], ['correct.Tsltest']); expect(process.stdout.toString()).toContain('Safe-DS code formatted successfully.'); expect(process.status).toBe(ExitCode.Success); }); it('should show an error if the file does not exist', () => { - const process = spawnFormatProcess([], ['missing.sdstest']); + const process = spawnFormatProcess([], ['missing.Tsltest']); expect(process.stderr.toString()).toMatch(/Path .* does not exist\./u); expect(process.status).toBe(ExitCode.MissingPath); }); @@ -165,19 +165,19 @@ describe('safe-ds', () => { }); it('should generate Python code', () => { - const process = spawnGenerateProcess([], ['correct.sdstest']); + const process = spawnGenerateProcess([], ['correct.Tsltest']); expect(process.stdout.toString()).toContain('Python code generated successfully.'); expect(process.status).toBe(ExitCode.Success); }); it('should generate Python code (Safe-DS code references builtins)', () => { - const process = spawnGenerateProcess([], ['references builtins.sdstest']); + const process = spawnGenerateProcess([], ['references builtins.Tsltest']); expect(process.stdout.toString()).toContain('Python code generated successfully.'); expect(process.status).toBe(ExitCode.Success); }); it('should show an error if the file does not exist', () => { - const process = spawnGenerateProcess([], ['missing.sdstest']); + const process = spawnGenerateProcess([], ['missing.Tsltest']); expect(process.stderr.toString()).toMatch(/Path .* does not exist./u); expect(process.status).toBe(ExitCode.MissingPath); }); @@ -191,7 +191,7 @@ describe('safe-ds', () => { it('should show an error if a Safe-DS file has errors', () => { const process = spawnGenerateProcess([], ['.']); expect(process.stderr.toString()).toContain( - "Could not resolve reference to SdsNamedTypeDeclaration named 'Unresolved'", + "Could not resolve reference to TslNamedTypeDeclaration named 'Unresolved'", ); expect(process.status).toBe(ExitCode.FileHasErrors); }); diff --git a/packages/ttsl-cli/tests/helpers/diagnostics.test.ts b/packages/ttsl-cli/tests/helpers/diagnostics.test.ts index 7ec9e6d7..085a3403 100644 --- a/packages/ttsl-cli/tests/helpers/diagnostics.test.ts +++ b/packages/ttsl-cli/tests/helpers/diagnostics.test.ts @@ -26,7 +26,7 @@ describe('diagnosticToString', () => { range, message, }, - expected: chalk.red(`test.sdstest:1:1: [error] message`), + expected: chalk.red(`test.Tsltest:1:1: [error] message`), }, { testName: 'warning', @@ -35,7 +35,7 @@ describe('diagnosticToString', () => { range, message, }, - expected: chalk.yellow(`test.sdstest:1:1: [warning] message`), + expected: chalk.yellow(`test.Tsltest:1:1: [warning] message`), }, { testName: 'warning (strict)', @@ -47,7 +47,7 @@ describe('diagnosticToString', () => { options: { strict: true, }, - expected: chalk.red(`test.sdstest:1:1: [warning] message`), + expected: chalk.red(`test.Tsltest:1:1: [warning] message`), }, { testName: 'info', @@ -56,7 +56,7 @@ describe('diagnosticToString', () => { range, message, }, - expected: chalk.blue(`test.sdstest:1:1: [info] message`), + expected: chalk.blue(`test.Tsltest:1:1: [info] message`), }, { testName: 'hint', @@ -65,7 +65,7 @@ describe('diagnosticToString', () => { range, message, }, - expected: chalk.gray(`test.sdstest:1:1: [hint] message`), + expected: chalk.gray(`test.Tsltest:1:1: [hint] message`), }, { testName: 'with code', @@ -75,12 +75,12 @@ describe('diagnosticToString', () => { message, code: 'CODE', }, - expected: chalk.red(`test.sdstest:1:1: [error] message (CODE)`), + expected: chalk.red(`test.Tsltest:1:1: [error] message (CODE)`), }, ]; it.each(tests)('$testName', ({ diagnostic, options, expected }) => { - const uri = URI.file(path.join(process.cwd(), 'test.sdstest')); + const uri = URI.file(path.join(process.cwd(), 'test.Tsltest')); const actual = diagnosticToString(uri, diagnostic, options); expect(actual).toBe(expected); }); diff --git a/packages/ttsl-cli/tests/helpers/documents.test.ts b/packages/ttsl-cli/tests/helpers/documents.test.ts index 3afdb958..354fba54 100644 --- a/packages/ttsl-cli/tests/helpers/documents.test.ts +++ b/packages/ttsl-cli/tests/helpers/documents.test.ts @@ -14,39 +14,39 @@ describe('processPaths', async () => { const tests: ProcessPathsTest[] = [ { testName: 'pipe file', - paths: ['a.sdspipe'], - expected: Result.ok(['a.sdspipe']), + paths: ['a.Tslpipe'], + expected: Result.ok(['a.Tslpipe']), }, { testName: 'stub file', - paths: ['b.sdsstub'], - expected: Result.ok(['b.sdsstub']), + paths: ['b.Tslstub'], + expected: Result.ok(['b.Tslstub']), }, { testName: 'test file', - paths: ['c.sdstest'], - expected: Result.ok(['c.sdstest']), + paths: ['c.Tsltest'], + expected: Result.ok(['c.Tsltest']), }, { testName: 'multiple files', - paths: ['a.sdspipe', 'b.sdsstub', 'c.sdstest'], - expected: Result.ok(['a.sdspipe', 'b.sdsstub', 'c.sdstest']), + paths: ['a.Tslpipe', 'b.Tslstub', 'c.Tsltest'], + expected: Result.ok(['a.Tslpipe', 'b.Tslstub', 'c.Tsltest']), }, { testName: 'duplicates', - paths: ['a.sdspipe', 'a.sdspipe'], - expected: Result.ok(['a.sdspipe']), + paths: ['a.Tslpipe', 'a.Tslpipe'], + expected: Result.ok(['a.Tslpipe']), }, { testName: 'directory', paths: ['.'], expected: Result.ok([ - 'a.sdspipe', - 'b.sdsstub', - 'c.sdstest', - 'nested/a.sdspipe', - 'nested/b.sdsstub', - 'nested/c.sdstest', + 'a.Tslpipe', + 'b.Tslstub', + 'c.Tsltest', + 'nested/a.Tslpipe', + 'nested/b.Tslstub', + 'nested/c.Tsltest', ]), }, { diff --git a/packages/ttsl-cli/tests/helpers/files.test.ts b/packages/ttsl-cli/tests/helpers/files.test.ts index e61bd76b..e7a9bfee 100644 --- a/packages/ttsl-cli/tests/helpers/files.test.ts +++ b/packages/ttsl-cli/tests/helpers/files.test.ts @@ -5,7 +5,7 @@ import { uriToRelativePath } from '../../src/helpers/files.js'; describe('uriToRelativePath', () => { it('should return a path that is relative to the current working directory', () => { - const fileName = 'test.sdstest'; + const fileName = 'test.Tsltest'; const uri = URI.file(path.join(process.cwd(), fileName)); expect(uriToRelativePath(uri)).toBe(fileName); diff --git a/packages/ttsl-lang/langium-config.json b/packages/ttsl-lang/langium-config.json index 5efc33ce..6ddc905e 100644 --- a/packages/ttsl-lang/langium-config.json +++ b/packages/ttsl-lang/langium-config.json @@ -4,7 +4,7 @@ { "id": "safe-ds", "grammar": "src/language/grammar/safe-ds.langium", - "fileExtensions": [".sdspipe", ".sdsstub", ".sdstest"] + "fileExtensions": [".tsl", ".tsltest"] } ], "out": "src/language/generated" diff --git a/packages/ttsl-lang/src/language/builtins/safe-ds-annotations.ts b/packages/ttsl-lang/src/language/builtins/safe-ds-annotations.ts index 25568662..a439dcfe 100644 --- a/packages/ttsl-lang/src/language/builtins/safe-ds-annotations.ts +++ b/packages/ttsl-lang/src/language/builtins/safe-ds-annotations.ts @@ -1,13 +1,13 @@ import { EMPTY_STREAM, Stream, stream, URI } from 'langium'; import { resourceNameToUri } from '../../helpers/resources.js'; import { - isSdsAnnotation, - SdsAnnotatedObject, - SdsAnnotation, - SdsEnumVariant, - SdsFunction, - SdsModule, - SdsParameter, + isTslAnnotation, + TslAnnotatedObject, + TslAnnotation, + TslEnumVariant, + TslFunction, + TslModule, + TslParameter, } from '../generated/ast.js'; import { findFirstAnnotationCallOf, getEnumVariants, hasAnnotationCallOf } from '../helpers/nodeProperties.js'; import { SafeDsNodeMapper } from '../helpers/safe-ds-node-mapper.js'; @@ -23,13 +23,13 @@ import { SafeDsServices } from '../safe-ds-module.js'; import { SafeDsEnums } from './safe-ds-enums.js'; import { SafeDsModuleMembers } from './safe-ds-module-members.js'; -const ANNOTATION_USAGE_URI = resourceNameToUri('builtins/safeds/lang/annotationUsage.sdsstub'); -const CODE_GENERATION_URI = resourceNameToUri('builtins/safeds/lang/codeGeneration.sdsstub'); -const IDE_INTEGRATION_URI = resourceNameToUri('builtins/safeds/lang/ideIntegration.sdsstub'); -const MATURITY_URI = resourceNameToUri('builtins/safeds/lang/maturity.sdsstub'); -const PURITY_URI = resourceNameToUri('builtins/safeds/lang/purity.sdsstub'); +const ANNOTATION_USAGE_URI = resourceNameToUri('builtins/safeds/lang/annotationUsage.Tslstub'); +const CODE_GENERATION_URI = resourceNameToUri('builtins/safeds/lang/codeGeneration.Tslstub'); +const IDE_INTEGRATION_URI = resourceNameToUri('builtins/safeds/lang/ideIntegration.Tslstub'); +const MATURITY_URI = resourceNameToUri('builtins/safeds/lang/maturity.Tslstub'); +const PURITY_URI = resourceNameToUri('builtins/safeds/lang/purity.Tslstub'); -export class SafeDsAnnotations extends SafeDsModuleMembers { +export class SafeDsAnnotations extends SafeDsModuleMembers { private readonly builtinEnums: SafeDsEnums; private readonly nodeMapper: SafeDsNodeMapper; private readonly partialEvaluator: SafeDsPartialEvaluator; @@ -42,35 +42,35 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { this.partialEvaluator = services.evaluation.PartialEvaluator; } - callsDeprecated(node: SdsAnnotatedObject | undefined): boolean { + callsDeprecated(node: TslAnnotatedObject | undefined): boolean { return hasAnnotationCallOf(node, this.Deprecated); } - private get Deprecated(): SdsAnnotation | undefined { + private get Deprecated(): TslAnnotation | undefined { return this.getAnnotation(MATURITY_URI, 'Deprecated'); } - callsExperimental(node: SdsAnnotatedObject | undefined): boolean { + callsExperimental(node: TslAnnotatedObject | undefined): boolean { return hasAnnotationCallOf(node, this.Experimental); } - private get Experimental(): SdsAnnotation | undefined { + private get Experimental(): TslAnnotation | undefined { return this.getAnnotation(MATURITY_URI, 'Experimental'); } - callsExpert(node: SdsParameter | undefined): boolean { + callsExpert(node: TslParameter | undefined): boolean { return hasAnnotationCallOf(node, this.Expert); } - private get Expert(): SdsAnnotation | undefined { + private get Expert(): TslAnnotation | undefined { return this.getAnnotation(IDE_INTEGRATION_URI, 'Expert'); } - callsImpure(node: SdsFunction | undefined): boolean { + callsImpure(node: TslFunction | undefined): boolean { return hasAnnotationCallOf(node, this.Impure); } - streamImpurityReasons(node: SdsFunction | undefined): Stream { + streamImpurityReasons(node: TslFunction | undefined): Stream { // If allReasons are specified, but we could not evaluate them to a list, no reasons apply const value = this.getParameterValue(node, this.Impure, 'allReasons'); if (!(value instanceof EvaluatedList)) { @@ -81,19 +81,19 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { return stream(value.elements).filter(this.builtinEnums.isEvaluatedImpurityReason); } - get Impure(): SdsAnnotation | undefined { + get Impure(): TslAnnotation | undefined { return this.getAnnotation(PURITY_URI, 'Impure'); } - callsPure(node: SdsFunction | undefined): boolean { + callsPure(node: TslFunction | undefined): boolean { return hasAnnotationCallOf(node, this.Pure); } - get Pure(): SdsAnnotation | undefined { + get Pure(): TslAnnotation | undefined { return this.getAnnotation(PURITY_URI, 'Pure'); } - getPythonCall(node: SdsFunction | undefined): string | undefined { + getPythonCall(node: TslFunction | undefined): string | undefined { const value = this.getParameterValue(node, this.PythonCall, 'callSpecification'); if (value instanceof StringConstant) { return value.value; @@ -102,11 +102,11 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { } } - get PythonCall(): SdsAnnotation | undefined { + get PythonCall(): TslAnnotation | undefined { return this.getAnnotation(CODE_GENERATION_URI, 'PythonCall'); } - getPythonModule(node: SdsModule | undefined): string | undefined { + getPythonModule(node: TslModule | undefined): string | undefined { const value = this.getParameterValue(node, this.PythonModule, 'qualifiedName'); if (value instanceof StringConstant) { return value.value; @@ -115,11 +115,11 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { } } - get PythonModule(): SdsAnnotation | undefined { + get PythonModule(): TslAnnotation | undefined { return this.getAnnotation(CODE_GENERATION_URI, 'PythonModule'); } - getPythonName(node: SdsAnnotatedObject | undefined): string | undefined { + getPythonName(node: TslAnnotatedObject | undefined): string | undefined { const value = this.getParameterValue(node, this.PythonName, 'name'); if (value instanceof StringConstant) { return value.value; @@ -128,19 +128,19 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { } } - get PythonName(): SdsAnnotation | undefined { + get PythonName(): TslAnnotation | undefined { return this.getAnnotation(CODE_GENERATION_URI, 'PythonName'); } - callsRepeatable(node: SdsAnnotation | undefined): boolean { + callsRepeatable(node: TslAnnotation | undefined): boolean { return hasAnnotationCallOf(node, this.Repeatable); } - private get Repeatable(): SdsAnnotation | undefined { + private get Repeatable(): TslAnnotation | undefined { return this.getAnnotation(ANNOTATION_USAGE_URI, 'Repeatable'); } - streamValidTargets(node: SdsAnnotation | undefined): Stream { + streamValidTargets(node: TslAnnotation | undefined): Stream { // If no targets are specified, every target is valid if (!hasAnnotationCallOf(node, this.Target)) { return stream(getEnumVariants(this.builtinEnums.AnnotationTarget)); @@ -158,12 +158,12 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { .map((it) => it.variant); } - get Target(): SdsAnnotation | undefined { + get Target(): TslAnnotation | undefined { return this.getAnnotation(ANNOTATION_USAGE_URI, 'Target'); } - private getAnnotation(uri: URI, name: string): SdsAnnotation | undefined { - return this.getModuleMember(uri, name, isSdsAnnotation); + private getAnnotation(uri: URI, name: string): TslAnnotation | undefined { + return this.getModuleMember(uri, name, isTslAnnotation); } /** @@ -171,8 +171,8 @@ export class SafeDsAnnotations extends SafeDsModuleMembers { * parameter with the given name. */ private getParameterValue( - node: SdsAnnotatedObject | undefined, - annotation: SdsAnnotation | undefined, + node: TslAnnotatedObject | undefined, + annotation: TslAnnotation | undefined, parameterName: string, ): EvaluatedNode { const annotationCall = findFirstAnnotationCallOf(node, annotation); diff --git a/packages/ttsl-lang/src/language/builtins/safe-ds-classes.ts b/packages/ttsl-lang/src/language/builtins/safe-ds-classes.ts index ea7d96f8..d4663744 100644 --- a/packages/ttsl-lang/src/language/builtins/safe-ds-classes.ts +++ b/packages/ttsl-lang/src/language/builtins/safe-ds-classes.ts @@ -1,50 +1,50 @@ -import { isSdsClass, SdsClass } from '../generated/ast.js'; +import { isTslClass, TslClass } from '../generated/ast.js'; import { SafeDsModuleMembers } from './safe-ds-module-members.js'; import { resourceNameToUri } from '../../helpers/resources.js'; -const CORE_CLASSES_URI = resourceNameToUri('builtins/safeds/lang/coreClasses.sdsstub'); +const CORE_CLASSES_URI = resourceNameToUri('builtins/safeds/lang/coreClasses.Tslstub'); -export class SafeDsClasses extends SafeDsModuleMembers { - get Any(): SdsClass | undefined { +export class SafeDsClasses extends SafeDsModuleMembers { + get Any(): TslClass | undefined { return this.getClass('Any'); } - get Boolean(): SdsClass | undefined { + get Boolean(): TslClass | undefined { return this.getClass('Boolean'); } - get Float(): SdsClass | undefined { + get Float(): TslClass | undefined { return this.getClass('Float'); } - get Int(): SdsClass | undefined { + get Int(): TslClass | undefined { return this.getClass('Int'); } - get List(): SdsClass | undefined { + get List(): TslClass | undefined { return this.getClass('List'); } - get Map(): SdsClass | undefined { + get Map(): TslClass | undefined { return this.getClass('Map'); } - get Nothing(): SdsClass | undefined { + get Nothing(): TslClass | undefined { return this.getClass('Nothing'); } - get Number(): SdsClass | undefined { + get Number(): TslClass | undefined { return this.getClass('Number'); } - get String(): SdsClass | undefined { + get String(): TslClass | undefined { return this.getClass('String'); } /** * Returns whether the given node is a builtin class. */ - isBuiltinClass(node: SdsClass | undefined): boolean { + isBuiltinClass(node: TslClass | undefined): boolean { return ( Boolean(node) && [ @@ -61,7 +61,7 @@ export class SafeDsClasses extends SafeDsModuleMembers { ); } - private getClass(name: string): SdsClass | undefined { - return this.getModuleMember(CORE_CLASSES_URI, name, isSdsClass); + private getClass(name: string): TslClass | undefined { + return this.getModuleMember(CORE_CLASSES_URI, name, isTslClass); } } diff --git a/packages/ttsl-lang/src/language/builtins/safe-ds-enums.ts b/packages/ttsl-lang/src/language/builtins/safe-ds-enums.ts index 0d19c8c1..caf1dabb 100644 --- a/packages/ttsl-lang/src/language/builtins/safe-ds-enums.ts +++ b/packages/ttsl-lang/src/language/builtins/safe-ds-enums.ts @@ -1,33 +1,33 @@ import { AstUtils, URI } from 'langium'; import { resourceNameToUri } from '../../helpers/resources.js'; -import { isSdsEnum, SdsEnum, type SdsEnumVariant } from '../generated/ast.js'; +import { isTslEnum, TslEnum, type TslEnumVariant } from '../generated/ast.js'; import { getEnumVariants } from '../helpers/nodeProperties.js'; import { EvaluatedEnumVariant, EvaluatedNode } from '../partialEvaluation/model.js'; import type { SafeDsServices } from '../safe-ds-module.js'; import { SafeDsModuleMembers } from './safe-ds-module-members.js'; -const ANNOTATION_USAGE_URI = resourceNameToUri('builtins/safeds/lang/annotationUsage.sdsstub'); -const PURITY_URI = resourceNameToUri('builtins/safeds/lang/purity.sdsstub'); +const ANNOTATION_USAGE_URI = resourceNameToUri('builtins/safeds/lang/annotationUsage.Tslstub'); +const PURITY_URI = resourceNameToUri('builtins/safeds/lang/purity.Tslstub'); -export class SafeDsEnums extends SafeDsModuleMembers { - get AnnotationTarget(): SdsEnum | undefined { +export class SafeDsEnums extends SafeDsModuleMembers { + get AnnotationTarget(): TslEnum | undefined { return this.getEnum(ANNOTATION_USAGE_URI, 'AnnotationTarget'); } isEvaluatedAnnotationTarget = (node: EvaluatedNode): node is EvaluatedEnumVariant => node instanceof EvaluatedEnumVariant && - AstUtils.getContainerOfType(node.variant, isSdsEnum) === this.AnnotationTarget; + AstUtils.getContainerOfType(node.variant, isTslEnum) === this.AnnotationTarget; - get ImpurityReason(): SdsEnum | undefined { + get ImpurityReason(): TslEnum | undefined { return this.getEnum(PURITY_URI, 'ImpurityReason'); } isEvaluatedImpurityReason = (node: EvaluatedNode): node is EvaluatedEnumVariant => node instanceof EvaluatedEnumVariant && - AstUtils.getContainerOfType(node.variant, isSdsEnum) === this.ImpurityReason; + AstUtils.getContainerOfType(node.variant, isTslEnum) === this.ImpurityReason; - private getEnum(uri: URI, name: string): SdsEnum | undefined { - return this.getModuleMember(uri, name, isSdsEnum); + private getEnum(uri: URI, name: string): TslEnum | undefined { + return this.getModuleMember(uri, name, isTslEnum); } } @@ -38,31 +38,31 @@ export class SafeDsImpurityReasons { this.builtinEnums = services.builtins.Enums; } - get FileReadFromConstantPath(): SdsEnumVariant | undefined { + get FileReadFromConstantPath(): TslEnumVariant | undefined { return this.getEnumVariant('FileReadFromConstantPath'); } - get FileReadFromParameterizedPath(): SdsEnumVariant | undefined { + get FileReadFromParameterizedPath(): TslEnumVariant | undefined { return this.getEnumVariant('FileReadFromParameterizedPath'); } - get FileWriteToConstantPath(): SdsEnumVariant | undefined { + get FileWriteToConstantPath(): TslEnumVariant | undefined { return this.getEnumVariant('FileWriteToConstantPath'); } - get FileWriteToParameterizedPath(): SdsEnumVariant | undefined { + get FileWriteToParameterizedPath(): TslEnumVariant | undefined { return this.getEnumVariant('FileWriteToParameterizedPath'); } - get PotentiallyImpureParameterCall(): SdsEnumVariant | undefined { + get PotentiallyImpureParameterCall(): TslEnumVariant | undefined { return this.getEnumVariant('PotentiallyImpureParameterCall'); } - get Other(): SdsEnumVariant | undefined { + get Other(): TslEnumVariant | undefined { return this.getEnumVariant('Other'); } - private getEnumVariant(name: string): SdsEnumVariant | undefined { + private getEnumVariant(name: string): TslEnumVariant | undefined { return getEnumVariants(this.builtinEnums.ImpurityReason).find((variant) => variant.name === name); } } diff --git a/packages/ttsl-lang/src/language/builtins/safe-ds-module-members.ts b/packages/ttsl-lang/src/language/builtins/safe-ds-module-members.ts index b7c3233d..2bb95c8e 100644 --- a/packages/ttsl-lang/src/language/builtins/safe-ds-module-members.ts +++ b/packages/ttsl-lang/src/language/builtins/safe-ds-module-members.ts @@ -1,9 +1,9 @@ import { SafeDsServices } from '../safe-ds-module.js'; -import { isSdsModule, SdsModuleMember } from '../generated/ast.js'; +import { isTslModule, TslModuleMember } from '../generated/ast.js'; import { LangiumDocuments, URI, WorkspaceCache } from 'langium'; import { getModuleMembers } from '../helpers/nodeProperties.js'; -export abstract class SafeDsModuleMembers { +export abstract class SafeDsModuleMembers { private readonly langiumDocuments: LangiumDocuments; private readonly cache: WorkspaceCache; @@ -26,7 +26,7 @@ export abstract class SafeDsModuleMembers { } const root = document.parseResult.value; - if (!isSdsModule(root)) { + if (!isTslModule(root)) { /* c8 ignore next 2 */ return undefined; } diff --git a/packages/ttsl-lang/src/language/documentation/safe-ds-comment-provider.ts b/packages/ttsl-lang/src/language/documentation/safe-ds-comment-provider.ts index bb6b7d77..7a493dd0 100644 --- a/packages/ttsl-lang/src/language/documentation/safe-ds-comment-provider.ts +++ b/packages/ttsl-lang/src/language/documentation/safe-ds-comment-provider.ts @@ -1,12 +1,12 @@ import { AstNode, DefaultCommentProvider, isAstNodeWithComment } from 'langium'; import { MarkupContent } from 'vscode-languageserver'; import { - isSdsBlockLambdaResult, - isSdsDeclaration, - isSdsParameter, - isSdsPlaceholder, - isSdsResult, - isSdsTypeParameter, + isTslBlockLambdaResult, + isTslDeclaration, + isTslParameter, + isTslPlaceholder, + isTslResult, + isTslTypeParameter, } from '../generated/ast.js'; export class SafeDsCommentProvider extends DefaultCommentProvider { @@ -14,12 +14,12 @@ export class SafeDsCommentProvider extends DefaultCommentProvider { /* c8 ignore start */ if (isAstNodeWithComment(node)) { return node.$comment; } /* c8 ignore stop */ else if ( - !isSdsDeclaration(node) || - isSdsBlockLambdaResult(node) || - isSdsParameter(node) || - isSdsPlaceholder(node) || - isSdsResult(node) || - isSdsTypeParameter(node) + !isTslDeclaration(node) || + isTslBlockLambdaResult(node) || + isTslParameter(node) || + isTslPlaceholder(node) || + isTslResult(node) || + isTslTypeParameter(node) ) { return undefined; } diff --git a/packages/ttsl-lang/src/language/documentation/safe-ds-documentation-provider.ts b/packages/ttsl-lang/src/language/documentation/safe-ds-documentation-provider.ts index 778aee1f..a7029479 100644 --- a/packages/ttsl-lang/src/language/documentation/safe-ds-documentation-provider.ts +++ b/packages/ttsl-lang/src/language/documentation/safe-ds-documentation-provider.ts @@ -9,13 +9,13 @@ import { parseJSDoc, } from 'langium'; import { - isSdsCallable, - isSdsParameter, - isSdsResult, - isSdsTypeParameter, - SdsParameter, - SdsResult, - SdsTypeParameter, + isTslCallable, + isTslParameter, + isTslResult, + isTslTypeParameter, + TslParameter, + TslResult, + TslTypeParameter, } from '../generated/ast.js'; const PARAM_TAG = 'param'; @@ -24,8 +24,8 @@ const TYPE_PARAM_TAG = 'typeParam'; export class SafeDsDocumentationProvider extends JSDocDocumentationProvider { override getDocumentation(node: AstNode): string | undefined { - if (isSdsParameter(node) || isSdsResult(node) || isSdsTypeParameter(node)) { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); + if (isTslParameter(node) || isTslResult(node) || isTslTypeParameter(node)) { + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); /* c8 ignore start */ if (!containingCallable) { return undefined; @@ -64,7 +64,7 @@ export class SafeDsDocumentationProvider extends JSDocDocumentationProvider { private getMatchingTagContent( comment: JSDocComment, - node: SdsParameter | SdsResult | SdsTypeParameter, + node: TslParameter | TslResult | TslTypeParameter, ): string | undefined { const name = node.name; /* c8 ignore start */ @@ -83,10 +83,10 @@ export class SafeDsDocumentationProvider extends JSDocDocumentationProvider { ?.match(matchRegex)?.groups?.content; } - private getTagName(node: SdsParameter | SdsResult | SdsTypeParameter): string { - if (isSdsParameter(node)) { + private getTagName(node: TslParameter | TslResult | TslTypeParameter): string { + if (isTslParameter(node)) { return PARAM_TAG; - } else if (isSdsResult(node)) { + } else if (isTslResult(node)) { return RESULT_TAG; } else { return TYPE_PARAM_TAG; diff --git a/packages/ttsl-lang/src/language/flow/model.ts b/packages/ttsl-lang/src/language/flow/model.ts index 6a460e8e..faa8f37a 100644 --- a/packages/ttsl-lang/src/language/flow/model.ts +++ b/packages/ttsl-lang/src/language/flow/model.ts @@ -1,9 +1,9 @@ -import { SdsCallable, SdsParameter } from '../generated/ast.js'; +import { TslCallable, TslParameter } from '../generated/ast.js'; import { stream, Stream } from 'langium'; export class CallGraph { constructor( - readonly root: SdsCallable | SdsParameter | undefined, + readonly root: TslCallable | TslParameter | undefined, readonly children: CallGraph[], readonly isRecursive: boolean = false, ) {} @@ -12,11 +12,11 @@ export class CallGraph { * Traverses the call graph depth-first in pre-order and returns a stream of all callables that are called directly * or indirectly. */ - streamCalledCallables(): Stream { + streamCalledCallables(): Stream { return stream(this.streamCalledCallablesGenerator()); } - private *streamCalledCallablesGenerator(): Generator { + private *streamCalledCallablesGenerator(): Generator { yield this.root; for (const child of this.children) { diff --git a/packages/ttsl-lang/src/language/flow/safe-ds-call-graph-computer.ts b/packages/ttsl-lang/src/language/flow/safe-ds-call-graph-computer.ts index aaa5e98b..686ad0b3 100644 --- a/packages/ttsl-lang/src/language/flow/safe-ds-call-graph-computer.ts +++ b/packages/ttsl-lang/src/language/flow/safe-ds-call-graph-computer.ts @@ -1,25 +1,25 @@ import { AstNode, type AstNodeLocator, AstUtils, stream, WorkspaceCache } from 'langium'; import { - isSdsBlockLambda, - isSdsCall, - isSdsCallable, - isSdsClass, - isSdsEnumVariant, - isSdsExpressionLambda, - isSdsFunction, - isSdsParameter, - isSdsSegment, - SdsArgument, - SdsBlockLambda, - SdsCall, - SdsCallable, - SdsClass, - SdsEnumVariant, - SdsExpression, - SdsExpressionLambda, - SdsFunction, - SdsParameter, - SdsSegment, + isTslBlockLambda, + isTslCall, + isTslCallable, + isTslClass, + isTslEnumVariant, + isTslExpressionLambda, + isTslFunction, + isTslParameter, + isTslSegment, + TslArgument, + TslBlockLambda, + TslCall, + TslCallable, + TslClass, + TslEnumVariant, + TslExpression, + TslExpressionLambda, + TslFunction, + TslParameter, + TslSegment, } from '../generated/ast.js'; import type { SafeDsNodeMapper } from '../helpers/safe-ds-node-mapper.js'; import type { SafeDsServices } from '../safe-ds-module.js'; @@ -47,7 +47,7 @@ export class SafeDsCallGraphComputer { /** * Stores the calls inside the node with the given ID. */ - private readonly callCache: WorkspaceCache; + private readonly callCache: WorkspaceCache; /** * Stores the call graph for the callable with the given ID if it is called without substitutions. @@ -74,7 +74,7 @@ export class SafeDsCallGraphComputer { * The parameter substitutions to use. These are **not** the argument of the call, but the values of the parameters * of any containing callables, i.e. the context of the call. */ - isRecursive(node: SdsCall, substitutions: ParameterSubstitutions = NO_SUBSTITUTIONS): boolean { + isRecursive(node: TslCall, substitutions: ParameterSubstitutions = NO_SUBSTITUTIONS): boolean { return this.getCallGraph(node, substitutions).isRecursive; } @@ -91,7 +91,7 @@ export class SafeDsCallGraphComputer { * The parameter substitutions to use. These are **not** the argument of the call, but the values of the parameters * of any containing callables, i.e. the context of the call/callable. */ - getCallGraph(node: SdsCall | SdsCallable, substitutions: ParameterSubstitutions = NO_SUBSTITUTIONS): CallGraph { + getCallGraph(node: TslCall | TslCallable, substitutions: ParameterSubstitutions = NO_SUBSTITUTIONS): CallGraph { // Cache the result if no substitutions are given if (isEmpty(substitutions)) { const key = this.getNodeId(node); @@ -104,8 +104,8 @@ export class SafeDsCallGraphComputer { } } - private doGetCallGraph(node: SdsCall | SdsCallable, substitutions: ParameterSubstitutions): CallGraph { - if (isSdsCall(node)) { + private doGetCallGraph(node: TslCall | TslCallable, substitutions: ParameterSubstitutions): CallGraph { + if (isTslCall(node)) { const call = this.createSyntheticCallForCall(node, substitutions); return this.getCallGraphWithRecursionCheck(call, []); } else { @@ -153,12 +153,12 @@ export class SafeDsCallGraphComputer { } private getExecutedCallsInCallable( - callable: SdsCallable | SdsParameter, + callable: TslCallable | TslParameter, substitutions: ParameterSubstitutions, ): SyntheticCall[] { - if (isSdsBlockLambda(callable) || isSdsExpressionLambda(callable) || isSdsSegment(callable)) { + if (isTslBlockLambda(callable) || isTslExpressionLambda(callable) || isTslSegment(callable)) { return this.getExecutedCallsInPipelineCallable(callable, substitutions); - } else if (isSdsClass(callable) || isSdsEnumVariant(callable) || isSdsFunction(callable)) { + } else if (isTslClass(callable) || isTslEnumVariant(callable) || isTslFunction(callable)) { return this.getExecutedCallsInStubCallable(callable, substitutions); } else { /* c8 ignore next 2 */ @@ -167,7 +167,7 @@ export class SafeDsCallGraphComputer { } private getExecutedCallsInPipelineCallable( - callable: SdsBlockLambda | SdsExpressionLambda | SdsSegment, + callable: TslBlockLambda | TslExpressionLambda | TslSegment, substitutions: ParameterSubstitutions, ): SyntheticCall[] { const callsInDefaultValues = getParameters(callable).flatMap((it) => { @@ -179,22 +179,22 @@ export class SafeDsCallGraphComputer { } }); - let callsInBody: SdsCall[]; - if (isSdsBlockLambda(callable)) { + let callsInBody: TslCall[]; + if (isTslBlockLambda(callable)) { callsInBody = this.getAllContainedCalls(callable.body); - } else if (isSdsExpressionLambda(callable)) { + } else if (isTslExpressionLambda(callable)) { callsInBody = this.getAllContainedCalls(callable.result); } else { callsInBody = this.getAllContainedCalls(callable.body); } return [...callsInDefaultValues, ...callsInBody] - .filter((it) => AstUtils.getContainerOfType(it, isSdsCallable) === callable) + .filter((it) => AstUtils.getContainerOfType(it, isTslCallable) === callable) .map((it) => this.createSyntheticCallForCall(it, substitutions)); } private getExecutedCallsInStubCallable( - callable: SdsClass | SdsEnumVariant | SdsFunction, + callable: TslClass | TslEnumVariant | TslFunction, substitutions: ParameterSubstitutions, ): SyntheticCall[] { const callsInDefaultValues = getParameters(callable).flatMap((parameter) => { @@ -227,7 +227,7 @@ export class SafeDsCallGraphComputer { return [...callsInDefaultValues, ...callablesInSubstitutions]; } - private createSyntheticCallForCall(call: SdsCall, substitutions: ParameterSubstitutions): SyntheticCall { + private createSyntheticCallForCall(call: TslCall, substitutions: ParameterSubstitutions): SyntheticCall { const evaluatedCallable = this.getEvaluatedCallable(call.receiver, substitutions); const newSubstitutions = this.getParameterSubstitutionsAfterCall( evaluatedCallable, @@ -242,7 +242,7 @@ export class SafeDsCallGraphComputer { } private getEvaluatedCallable( - expression: SdsExpression | undefined, + expression: TslExpression | undefined, substitutions: ParameterSubstitutions, ): EvaluatedCallable | undefined { if (!expression) { @@ -270,9 +270,9 @@ export class SafeDsCallGraphComputer { } const parameterOrCallable = nonNullType.parameter ?? nonNullType.callable; - if (isSdsParameter(parameterOrCallable)) { + if (isTslParameter(parameterOrCallable)) { return new NamedCallable(parameterOrCallable); - } else if (isSdsFunction(parameterOrCallable)) { + } else if (isTslFunction(parameterOrCallable)) { // Needed for instance methods return new NamedCallable(parameterOrCallable); } @@ -282,10 +282,10 @@ export class SafeDsCallGraphComputer { private getParameterSubstitutionsAfterCall( callable: EvaluatedCallable | undefined, - args: SdsArgument[], + args: TslArgument[], substitutions: ParameterSubstitutions, ): ParameterSubstitutions { - if (!callable || isSdsParameter(callable.callable)) { + if (!callable || isTslParameter(callable.callable)) { return NO_SUBSTITUTIONS; } @@ -319,14 +319,14 @@ export class SafeDsCallGraphComputer { /** * Returns all calls inside the given node. If the given node is a call, it is included as well. */ - getAllContainedCalls(node: AstNode | undefined): SdsCall[] { + getAllContainedCalls(node: AstNode | undefined): TslCall[] { if (!node) { /* c8 ignore next 2 */ return []; } const key = this.getNodeId(node); - return this.callCache.get(key, () => AstUtils.streamAst(node).filter(isSdsCall).toArray()); + return this.callCache.get(key, () => AstUtils.streamAst(node).filter(isTslCall).toArray()); } private getNodeId(node: AstNode) { diff --git a/packages/ttsl-lang/src/language/generation/safe-ds-python-generator.ts b/packages/ttsl-lang/src/language/generation/safe-ds-python-generator.ts index 774b4364..b1da0c3f 100644 --- a/packages/ttsl-lang/src/language/generation/safe-ds-python-generator.ts +++ b/packages/ttsl-lang/src/language/generation/safe-ds-python-generator.ts @@ -16,56 +16,56 @@ import { TextDocument } from 'vscode-languageserver-textdocument'; import { groupBy, isEmpty } from '../../helpers/collections.js'; import { SafeDsAnnotations } from '../builtins/safe-ds-annotations.js'; import { - isSdsAbstractCall, - isSdsAbstractResult, - isSdsAssignment, - isSdsBlockLambda, - isSdsBlockLambdaResult, - isSdsCall, - isSdsCallable, - isSdsClass, - isSdsDeclaration, - isSdsEnumVariant, - isSdsExpressionLambda, - isSdsExpressionStatement, - isSdsFunction, - isSdsIndexedAccess, - isSdsInfixOperation, - isSdsList, - isSdsMap, - isSdsMemberAccess, - isSdsModule, - isSdsParameter, - isSdsParenthesizedExpression, - isSdsPipeline, - isSdsPlaceholder, - isSdsPrefixOperation, - isSdsQualifiedImport, - isSdsReference, - isSdsSegment, - isSdsTemplateString, - isSdsTemplateStringEnd, - isSdsTemplateStringInner, - isSdsTemplateStringPart, - isSdsTemplateStringStart, - isSdsWildcard, - isSdsWildcardImport, - isSdsYield, - SdsArgument, - SdsAssignee, - SdsAssignment, - SdsBlock, - SdsBlockLambda, - SdsCall, - SdsDeclaration, - SdsExpression, - SdsModule, - SdsParameter, - SdsParameterList, - SdsPipeline, - SdsPlaceholder, - SdsSegment, - SdsStatement, + isTslAbstractCall, + isTslAbstractResult, + isTslAssignment, + isTslBlockLambda, + isTslBlockLambdaResult, + isTslCall, + isTslCallable, + isTslClass, + isTslDeclaration, + isTslEnumVariant, + isTslExpressionLambda, + isTslExpressionStatement, + isTslFunction, + isTslIndexedAccess, + isTslInfixOperation, + isTslList, + isTslDictionary, + isTslMemberAccess, + isTslModule, + isTslParameter, + isTslParenthesizedExpression, + isTslPipeline, + isTslPlaceholder, + isTslPrefixOperation, + isTslQualifiedImport, + isTslReference, + isTslSegment, + isTslTemplateString, + isTslTemplateStringEnd, + isTslTemplateStringInner, + isTslTemplateStringPart, + isTslTemplateStringStart, + isTslWildcard, + isTslWildcardImport, + isTslYield, + TslArgument, + TslAssignee, + TslAssignment, + TslBlock, + TslBlockLambda, + TslCall, + TslDeclaration, + TslExpression, + TslModule, + TslParameter, + TslParameterList, + TslPipeline, + TslPlaceholder, + TslSegment, + TslStatement, } from '../generated/ast.js'; import { isInStubFile, isStubFile } from '../helpers/fileExtensions.js'; import { IdManager } from '../helpers/idManager.js'; @@ -186,7 +186,7 @@ export class SafeDsPythonGenerator { const node = document.parseResult.value; // Do not generate stub files - if (isStubFile(document) || !isSdsModule(node)) { + if (isStubFile(document) || !isTslModule(node)) { return []; } @@ -206,7 +206,7 @@ export class SafeDsPythonGenerator { ); } generatedFiles.set(pythonOutputPath, text); - for (const pipeline of getModuleMembers(node).filter(isSdsPipeline)) { + for (const pipeline of getModuleMembers(node).filter(isTslPipeline)) { const entryPointFilename = `${path.join( parentDirectoryPath, `${this.formatGeneratedFileName(name)}_${this.getPythonNameOrDefault(pipeline)}`, @@ -286,26 +286,26 @@ export class SafeDsPythonGenerator { return mapper.toString(); } - private getPythonModuleOrDefault(object: SdsModule) { + private getPythonModuleOrDefault(object: TslModule) { return this.builtinAnnotations.getPythonModule(object) || object.name; } - private getPythonNameOrDefault(object: SdsDeclaration) { + private getPythonNameOrDefault(object: TslDeclaration) { return this.builtinAnnotations.getPythonName(object) || object.name; } - private getQualifiedNamePythonCompatible(node: SdsDeclaration | undefined): string | undefined { + private getQualifiedNamePythonCompatible(node: TslDeclaration | undefined): string | undefined { const segments = []; - let current: SdsDeclaration | undefined = node; + let current: TslDeclaration | undefined = node; while (current) { - const currentName = isSdsModule(current) + const currentName = isTslModule(current) ? this.getPythonModuleOrDefault(current) : this.getPythonNameOrDefault(current); if (currentName) { segments.unshift(currentName); } - current = AstUtils.getContainerOfType(current.$container, isSdsDeclaration); + current = AstUtils.getContainerOfType(current.$container, isTslDeclaration); } return segments.join('.'); @@ -319,15 +319,15 @@ export class SafeDsPythonGenerator { return moduleName.replaceAll('%2520', '_').replaceAll(/[ .-]/gu, '_').replaceAll(/\\W/gu, ''); } - private generateModule(module: SdsModule, generateOptions: GenerateOptions): CompositeGeneratorNode { + private generateModule(module: TslModule, generateOptions: GenerateOptions): CompositeGeneratorNode { const importSet = new Map(); const utilitySet = new Set(); const typeVariableSet = new Set(); const segments = getModuleMembers(module) - .filter(isSdsSegment) + .filter(isTslSegment) .map((segment) => this.generateSegment(segment, importSet, utilitySet, typeVariableSet, generateOptions)); const pipelines = getModuleMembers(module) - .filter(isSdsPipeline) + .filter(isTslPipeline) .map((pipeline) => this.generatePipeline(pipeline, importSet, utilitySet, typeVariableSet, generateOptions), ); @@ -379,7 +379,7 @@ export class SafeDsPythonGenerator { } private generateSegment( - segment: SdsSegment, + segment: TslSegment, importSet: Map, utilitySet: Set, typeVariableSet: Set, @@ -414,7 +414,7 @@ export class SafeDsPythonGenerator { } private generateParameters( - parameters: SdsParameterList | undefined, + parameters: TslParameterList | undefined, frame: GenerationInfoFrame, ): CompositeGeneratorNode | undefined { if (!parameters) { @@ -429,7 +429,7 @@ export class SafeDsPythonGenerator { } private generateParameter( - parameter: SdsParameter, + parameter: TslParameter, frame: GenerationInfoFrame, defaultValue: boolean = true, ): CompositeGeneratorNode { @@ -441,7 +441,7 @@ export class SafeDsPythonGenerator { } private generatePipeline( - pipeline: SdsPipeline, + pipeline: TslPipeline, importSet: Map, utilitySet: Set, typeVariableSet: Set, @@ -500,7 +500,7 @@ export class SafeDsPythonGenerator { } private generateBlock( - block: SdsBlock, + block: TslBlock, frame: GenerationInfoFrame, generateLambda: boolean = false, ): CompositeGeneratorNode { @@ -522,25 +522,25 @@ export class SafeDsPythonGenerator { } private getStatementsNeededForPartialExecution( - targetPlaceholder: SdsPlaceholder, - statementsWithEffect: SdsStatement[], - ): SdsStatement[] { + targetPlaceholder: TslPlaceholder, + statementsWithEffect: TslStatement[], + ): TslStatement[] { // Find assignment of placeholder, to search used placeholders and impure dependencies - const assignment = AstUtils.getContainerOfType(targetPlaceholder, isSdsAssignment); + const assignment = AstUtils.getContainerOfType(targetPlaceholder, isTslAssignment); if (!assignment || !assignment.expression) { /* c8 ignore next 2 */ throw new Error(`No assignment for placeholder: ${targetPlaceholder.name}`); } // All collected referenced placeholders that are needed for calculating the target placeholder. An expression in the assignment will always exist here - const referencedPlaceholders = new Set( + const referencedPlaceholders = new Set( AstUtils.streamAllContents(assignment.expression!) - .filter(isSdsReference) - .filter((reference) => isSdsPlaceholder(reference.target.ref)) - .map((reference) => reference.target.ref!) + .filter(isTslReference) + .filter((reference) => isTslPlaceholder(reference.target.ref)) + .map((reference) => reference.target.ref!) .toArray(), ); const impurityReasons = new Set(this.purityComputer.getImpurityReasonsForStatement(assignment)); - const collectedStatements: SdsStatement[] = [assignment]; + const collectedStatements: TslStatement[] = [assignment]; for (const prevStatement of statementsWithEffect.reverse()) { // Statements after the target assignment can always be skipped if (prevStatement.$containerIndex! >= assignment.$containerIndex!) { @@ -550,9 +550,9 @@ export class SafeDsPythonGenerator { this.purityComputer.getImpurityReasonsForStatement(prevStatement); if ( // Placeholder is relevant - (isSdsAssignment(prevStatement) && + (isTslAssignment(prevStatement) && getAssignees(prevStatement) - .filter(isSdsPlaceholder) + .filter(isTslPlaceholder) .some((prevPlaceholder) => referencedPlaceholders.has(prevPlaceholder))) || // Impurity is relevant prevStmtImpurityReasons.some((pastReason) => @@ -563,11 +563,11 @@ export class SafeDsPythonGenerator { ) { collectedStatements.push(prevStatement); // Collect all referenced placeholders - if (isSdsExpressionStatement(prevStatement) || isSdsAssignment(prevStatement)) { + if (isTslExpressionStatement(prevStatement) || isTslAssignment(prevStatement)) { AstUtils.streamAllContents(prevStatement.expression!) - .filter(isSdsReference) - .filter((reference) => isSdsPlaceholder(reference.target.ref)) - .map((reference) => reference.target.ref!) + .filter(isTslReference) + .filter((reference) => isTslPlaceholder(reference.target.ref)) + .map((reference) => reference.target.ref!) .forEach((prevPlaceholder) => { referencedPlaceholders.add(prevPlaceholder); }); @@ -583,14 +583,14 @@ export class SafeDsPythonGenerator { } private generateStatement( - statement: SdsStatement, + statement: TslStatement, frame: GenerationInfoFrame, generateLambda: boolean, ): CompositeGeneratorNode { const blockLambdaCode: CompositeGeneratorNode[] = []; - if (isSdsAssignment(statement)) { + if (isTslAssignment(statement)) { if (statement.expression) { - for (const lambda of AstUtils.streamAllContents(statement.expression).filter(isSdsBlockLambda)) { + for (const lambda of AstUtils.streamAllContents(statement.expression).filter(isTslBlockLambda)) { blockLambdaCode.push(this.generateBlockLambda(lambda, frame)); } } @@ -598,8 +598,8 @@ export class SafeDsPythonGenerator { return joinTracedToNode(statement)(blockLambdaCode, (stmt) => stmt, { separator: NL, })!; - } else if (isSdsExpressionStatement(statement)) { - for (const lambda of AstUtils.streamAllContents(statement.expression).filter(isSdsBlockLambda)) { + } else if (isTslExpressionStatement(statement)) { + for (const lambda of AstUtils.streamAllContents(statement.expression).filter(isTslBlockLambda)) { blockLambdaCode.push(this.generateBlockLambda(lambda, frame)); } blockLambdaCode.push(this.generateExpression(statement.expression, frame)); @@ -608,20 +608,20 @@ export class SafeDsPythonGenerator { })!; } /* c8 ignore next 2 */ - throw new Error(`Unknown SdsStatement: ${statement}`); + throw new Error(`Unknown TslStatement: ${statement}`); } private generateAssignment( - assignment: SdsAssignment, + assignment: TslAssignment, frame: GenerationInfoFrame, generateLambda: boolean, ): CompositeGeneratorNode { - const requiredAssignees = isSdsCall(assignment.expression) + const requiredAssignees = isTslCall(assignment.expression) ? getAbstractResults(this.nodeMapper.callToCallable(assignment.expression)).length : /* c8 ignore next */ 1; const assignees = getAssignees(assignment); - if (assignees.some((value) => !isSdsWildcard(value))) { + if (assignees.some((value) => !isTslWildcard(value))) { const actualAssignees = assignees.map(this.generateAssignee); const assignmentStatements = []; if (requiredAssignees === actualAssignees.length) { @@ -641,8 +641,8 @@ export class SafeDsPythonGenerator { ); } if (frame.isInsidePipeline && !generateLambda && !frame.disableRunnerIntegration) { - for (const savableAssignment of assignees.filter(isSdsPlaceholder)) { - // should always be SdsPlaceholder + for (const savableAssignment of assignees.filter(isTslPlaceholder)) { + // should always be TslPlaceholder frame.addImport({ importPath: RUNNER_PACKAGE }); assignmentStatements.push( expandTracedToNode( @@ -659,27 +659,27 @@ export class SafeDsPythonGenerator { } } - private generateAssignee(assignee: SdsAssignee): CompositeGeneratorNode { - if (isSdsBlockLambdaResult(assignee)) { + private generateAssignee(assignee: TslAssignee): CompositeGeneratorNode { + if (isTslBlockLambdaResult(assignee)) { return expandTracedToNode(assignee)`${BLOCK_LAMBDA_RESULT_PREFIX}${traceToNode( assignee, 'name', )(assignee.name)}`; - } else if (isSdsPlaceholder(assignee)) { + } else if (isTslPlaceholder(assignee)) { return traceToNode(assignee)(assignee.name); - } else if (isSdsWildcard(assignee)) { + } else if (isTslWildcard(assignee)) { return traceToNode(assignee)('_'); - } else if (isSdsYield(assignee)) { + } else if (isTslYield(assignee)) { return expandTracedToNode(assignee)`${YIELD_PREFIX}${traceToNode( assignee, 'result', )(assignee.result?.ref?.name!)}`; } /* c8 ignore next 2 */ - throw new Error(`Unknown SdsAssignment: ${assignee.$type}`); + throw new Error(`Unknown TslAssignment: ${assignee.$type}`); } - private generateBlockLambda(blockLambda: SdsBlockLambda, frame: GenerationInfoFrame): CompositeGeneratorNode { + private generateBlockLambda(blockLambda: TslBlockLambda, frame: GenerationInfoFrame): CompositeGeneratorNode { const results = streamBlockLambdaResults(blockLambda).toArray(); const lambdaBlock = this.generateBlock(blockLambda.body, frame, true); if (results.length !== 0) { @@ -706,13 +706,13 @@ export class SafeDsPythonGenerator { }); } - private generateExpression(expression: SdsExpression, frame: GenerationInfoFrame): CompositeGeneratorNode { - if (isSdsTemplateStringPart(expression)) { - if (isSdsTemplateStringStart(expression)) { + private generateExpression(expression: TslExpression, frame: GenerationInfoFrame): CompositeGeneratorNode { + if (isTslTemplateStringPart(expression)) { + if (isTslTemplateStringStart(expression)) { return expandTracedToNode(expression)`${this.formatStringSingleLine(expression.value)}{ `; - } else if (isSdsTemplateStringInner(expression)) { + } else if (isTslTemplateStringInner(expression)) { return expandTracedToNode(expression)` }${this.formatStringSingleLine(expression.value)}{ `; - } else if (isSdsTemplateStringEnd(expression)) { + } else if (isTslTemplateStringEnd(expression)) { return expandTracedToNode(expression)` }${this.formatStringSingleLine(expression.value)}`; } } @@ -733,14 +733,14 @@ export class SafeDsPythonGenerator { } } - // Handled after constant expressions: EnumVariant, List, Map - if (isSdsTemplateString(expression)) { + // Handled after constant expressions: EnumVariant, List, Dictionary + if (isTslTemplateString(expression)) { return expandTracedToNode(expression)`f'${joinTracedToNode(expression, 'expressions')( expression.expressions, (expr) => this.generateExpression(expr, frame), { separator: '' }, )}'`; - } else if (isSdsMap(expression)) { + } else if (isTslDictionary(expression)) { return expandTracedToNode(expression)`{${joinTracedToNode(expression, 'entries')( expression.entries, (entry) => @@ -753,27 +753,27 @@ export class SafeDsPythonGenerator { )(this.generateExpression(entry.value, frame))}`, { separator: ', ' }, )}}`; - } else if (isSdsList(expression)) { + } else if (isTslList(expression)) { return expandTracedToNode(expression)`[${joinTracedToNode(expression, 'elements')( expression.elements, (value) => this.generateExpression(value, frame), { separator: ', ' }, )}]`; - } else if (isSdsBlockLambda(expression)) { + } else if (isTslBlockLambda(expression)) { return traceToNode(expression)(frame.getUniqueLambdaBlockName(expression)); - } else if (isSdsCall(expression)) { + } else if (isTslCall(expression)) { const callable = this.nodeMapper.callToCallable(expression); const sortedArgs = this.sortArguments(getArguments(expression)); const receiver = this.generateExpression(expression.receiver, frame); let call: CompositeGeneratorNode | undefined = undefined; // Memoize constructor or function call - if (isSdsFunction(callable) || isSdsClass(callable)) { - if (isSdsFunction(callable)) { + if (isTslFunction(callable) || isTslClass(callable)) { + if (isTslFunction(callable)) { const pythonCall = this.builtinAnnotations.getPythonCall(callable); if (pythonCall) { let thisParam: CompositeGeneratorNode | undefined = undefined; - if (isSdsMemberAccess(expression.receiver)) { + if (isTslMemberAccess(expression.receiver)) { thisParam = this.generateExpression(expression.receiver.receiver, frame); } const argumentsMap = this.getArgumentsMap(getArguments(expression), frame); @@ -782,7 +782,7 @@ export class SafeDsPythonGenerator { } if (!call && this.isMemoizableCall(expression) && !frame.disableRunnerIntegration) { let thisParam: CompositeGeneratorNode | undefined = undefined; - if (isSdsMemberAccess(expression.receiver)) { + if (isTslMemberAccess(expression.receiver)) { thisParam = this.generateExpression(expression.receiver.receiver, frame); } call = this.generateMemoizedCall(expression, sortedArgs, frame, thisParam); @@ -802,12 +802,12 @@ export class SafeDsPythonGenerator { } else { return call; } - } else if (isSdsExpressionLambda(expression)) { + } else if (isTslExpressionLambda(expression)) { return expandTracedToNode(expression)`lambda ${this.generateParameters( expression.parameterList, frame, )}: ${this.generateExpression(expression.result, frame)}`; - } else if (isSdsInfixOperation(expression)) { + } else if (isTslInfixOperation(expression)) { const leftOperand = this.generateExpression(expression.leftOperand, frame); const rightOperand = this.generateExpression(expression.rightOperand, frame); switch (expression.operator) { @@ -845,7 +845,7 @@ export class SafeDsPythonGenerator { 'operator', )(expression.operator)} (${rightOperand})`; } - } else if (isSdsIndexedAccess(expression)) { + } else if (isTslIndexedAccess(expression)) { if (expression.isNullSafe) { frame.addUtility(UTILITY_NULL_SAFE_INDEXED_ACCESS); return expandTracedToNode(expression)`${traceToNode( @@ -861,15 +861,15 @@ export class SafeDsPythonGenerator { frame, )}[${this.generateExpression(expression.index, frame)}]`; } - } else if (isSdsMemberAccess(expression)) { + } else if (isTslMemberAccess(expression)) { const member = expression.member?.target.ref!; const receiver = this.generateExpression(expression.receiver, frame); - if (isSdsEnumVariant(member)) { + if (isTslEnumVariant(member)) { const enumMember = this.generateExpression(expression.member!, frame); - const suffix = isSdsCall(expression.$container) ? '' : '()'; + const suffix = isTslCall(expression.$container) ? '' : '()'; return expandTracedToNode(expression)`${receiver}.${enumMember}${suffix}`; - } else if (isSdsAbstractResult(member)) { - const resultList = getAbstractResults(AstUtils.getContainerOfType(member, isSdsCallable)); + } else if (isTslAbstractResult(member)) { + const resultList = getAbstractResults(AstUtils.getContainerOfType(member, isTslCallable)); if (resultList.length === 1) { return traceToNode(expression)(receiver); } @@ -889,9 +889,9 @@ export class SafeDsPythonGenerator { return expandTracedToNode(expression)`${receiver}.${memberExpression}`; } } - } else if (isSdsParenthesizedExpression(expression)) { + } else if (isTslParenthesizedExpression(expression)) { return expandTracedToNode(expression)`${this.generateExpression(expression.expression, frame)}`; - } else if (isSdsPrefixOperation(expression)) { + } else if (isTslPrefixOperation(expression)) { const operand = this.generateExpression(expression.operand, frame); switch (expression.operator) { case 'not': @@ -899,7 +899,7 @@ export class SafeDsPythonGenerator { case '-': return expandTracedToNode(expression)`${traceToNode(expression, 'operator')('-')}(${operand})`; } - } else if (isSdsReference(expression)) { + } else if (isTslReference(expression)) { const declaration = expression.target.ref!; const referenceImport = this.getExternalReferenceNeededImport(expression, declaration) || @@ -912,8 +912,8 @@ export class SafeDsPythonGenerator { } private generatePlainCall( - expression: SdsCall, - sortedArgs: SdsArgument[], + expression: TslCall, + sortedArgs: TslArgument[], frame: GenerationInfoFrame, ): CompositeGeneratorNode { return expandTracedToNode(expression)`${this.generateExpression(expression.receiver, frame)}(${joinTracedToNode( @@ -923,7 +923,7 @@ export class SafeDsPythonGenerator { } private generatePythonCall( - expression: SdsCall, + expression: TslCall, pythonCall: string, argumentsMap: Map, frame: GenerationInfoFrame, @@ -966,7 +966,7 @@ export class SafeDsPythonGenerator { )}], [${joinToNode(hiddenParameters, (param) => param, { separator: ', ' })}])`; } - private isMemoizableCall(expression: SdsCall): boolean { + private isMemoizableCall(expression: TslCall): boolean { const impurityReasons = this.purityComputer.getImpurityReasonsForExpression(expression); // If the file is not known, the call is not memoizable return ( @@ -975,11 +975,11 @@ export class SafeDsPythonGenerator { ); } - private doesCallContainLambdaReferencingSegment(expression: SdsCall): boolean { + private doesCallContainLambdaReferencingSegment(expression: TslCall): boolean { return getArguments(expression).some((arg) => { - if (isSdsExpressionLambda(arg.value)) { + if (isTslExpressionLambda(arg.value)) { return this.containsSegmentCall(arg.value.result); - } else if (isSdsBlockLambda(arg.value)) { + } else if (isTslBlockLambda(arg.value)) { return this.containsSegmentCall(arg.value.body); } else { /* c8 ignore next 2 */ @@ -994,16 +994,16 @@ export class SafeDsPythonGenerator { return false; } return AstUtils.streamAst(node) - .filter(isSdsAbstractCall) + .filter(isTslAbstractCall) .some((call) => { const callable = this.nodeMapper.callToCallable(call); - return isSdsSegment(callable); + return isTslSegment(callable); }); } private generateMemoizedCall( - expression: SdsCall, - sortedArgs: SdsArgument[], + expression: TslCall, + sortedArgs: TslArgument[], frame: GenerationInfoFrame, thisParam: CompositeGeneratorNode | undefined = undefined, ): CompositeGeneratorNode { @@ -1014,7 +1014,7 @@ export class SafeDsPythonGenerator { (parameter) => this.nodeMapper.callToParameterValue(expression, parameter)!, ); // For a static function, the thisParam would be the class containing the function. We do not need to generate it in this case - const generateThisParam = !isSdsFunction(callable) || (!callable.isStatic && thisParam); + const generateThisParam = !isTslFunction(callable) || (!callable.isStatic && thisParam); const containsOptionalArgs = sortedArgs.some((arg) => Parameter.isOptional(this.nodeMapper.argumentToParameter(arg)), ); @@ -1024,7 +1024,7 @@ export class SafeDsPythonGenerator { }${ containsOptionalArgs ? this.generatePlainCall(expression, sortedArgs, frame) - : isSdsMemberAccess(expression.receiver) && isSdsCall(expression.receiver.receiver) + : isTslMemberAccess(expression.receiver) && isTslCall(expression.receiver.receiver) ? expandTracedToNode(expression.receiver)`${this.generateExpression( expression.receiver.receiver.receiver, frame, @@ -1041,7 +1041,7 @@ export class SafeDsPythonGenerator { )}], [${joinToNode(hiddenParameters, (param) => param, { separator: ', ' })}])`; } - private getMemoizedCallHiddenParameters(expression: SdsCall, frame: GenerationInfoFrame): CompositeGeneratorNode[] { + private getMemoizedCallHiddenParameters(expression: TslCall, frame: GenerationInfoFrame): CompositeGeneratorNode[] { const impurityReasons = this.purityComputer.getImpurityReasonsForExpression(expression); const hiddenParameters: CompositeGeneratorNode[] = []; for (const reason of impurityReasons) { @@ -1050,7 +1050,7 @@ export class SafeDsPythonGenerator { hiddenParameters.push( expandTracedToNode(expression)`${RUNNER_PACKAGE}.file_mtime('${reason.path}')`, ); - } else if (isSdsParameter(reason.path)) { + } else if (isTslParameter(reason.path)) { const argument = this.nodeMapper .parametersToArguments([reason.path], getArguments(expression)) .get(reason.path); @@ -1072,9 +1072,9 @@ export class SafeDsPythonGenerator { return hiddenParameters; } - private generateFullyQualifiedFunctionName(expression: SdsCall): string { + private generateFullyQualifiedFunctionName(expression: TslCall): string { const callable = this.nodeMapper.callToCallable(expression); - if (isSdsDeclaration(callable)) { + if (isTslDeclaration(callable)) { const fullyQualifiedReferenceName = this.getQualifiedNamePythonCompatible(callable); if (fullyQualifiedReferenceName) { return fullyQualifiedReferenceName; @@ -1085,7 +1085,7 @@ export class SafeDsPythonGenerator { } private getArgumentsMap( - argumentList: SdsArgument[], + argumentList: TslArgument[], frame: GenerationInfoFrame, ): Map { const argumentsMap = new Map(); @@ -1096,7 +1096,7 @@ export class SafeDsPythonGenerator { return argumentsMap; } - private sortArguments(argumentList: SdsArgument[]): SdsArgument[] { + private sortArguments(argumentList: TslArgument[]): TslArgument[] { // $containerIndex contains the index of the parameter in the receivers parameter list const parameters = argumentList.map((argument) => { return { par: this.nodeMapper.argumentToParameter(argument), arg: argument }; @@ -1111,7 +1111,7 @@ export class SafeDsPythonGenerator { } private generateArgument( - argument: SdsArgument, + argument: TslArgument, frame: GenerationInfoFrame, generateOptionalParameterName: boolean = true, ): CompositeGeneratorNode { @@ -1124,8 +1124,8 @@ export class SafeDsPythonGenerator { } private getExternalReferenceNeededImport( - expression: SdsExpression | undefined, - declaration: SdsDeclaration | undefined, + expression: TslExpression | undefined, + declaration: TslDeclaration | undefined, ): ImportData | undefined { if (!expression || !declaration) { /* c8 ignore next 2 */ @@ -1133,14 +1133,14 @@ export class SafeDsPythonGenerator { } // Root Node is always a module. - const currentModule = AstUtils.findRootNode(expression); - const targetModule = AstUtils.findRootNode(declaration); + const currentModule = AstUtils.findRootNode(expression); + const targetModule = AstUtils.findRootNode(declaration); for (const value of getImports(currentModule)) { // Verify same package if (value.package !== targetModule.name) { continue; } - if (isSdsQualifiedImport(value)) { + if (isTslQualifiedImport(value)) { const importedDeclarations = getImportedDeclarations(value); for (const importedDeclaration of importedDeclarations) { if (declaration === importedDeclaration.declaration?.ref) { @@ -1159,7 +1159,7 @@ export class SafeDsPythonGenerator { } } } - if (isSdsWildcardImport(value)) { + if (isTslWildcardImport(value)) { return { importPath: this.getPythonModuleOrDefault(targetModule), declarationName: declaration.name, @@ -1170,12 +1170,12 @@ export class SafeDsPythonGenerator { } private getInternalReferenceNeededImport( - expression: SdsExpression, - declaration: SdsDeclaration, + expression: TslExpression, + declaration: TslDeclaration, ): ImportData | undefined { // Root Node is always a module. - const currentModule = AstUtils.findRootNode(expression); - const targetModule = AstUtils.findRootNode(declaration); + const currentModule = AstUtils.findRootNode(expression); + const targetModule = AstUtils.findRootNode(declaration); if (currentModule !== targetModule && !isInStubFile(targetModule)) { return { importPath: `${this.getPythonModuleOrDefault(targetModule)}.${this.formatGeneratedFileName( @@ -1187,7 +1187,7 @@ export class SafeDsPythonGenerator { return undefined; } - private getModuleFileBaseName(module: SdsModule): string { + private getModuleFileBaseName(module: TslModule): string { const filePath = AstUtils.getDocument(module).uri.fsPath; return path.basename(filePath, path.extname(filePath)); } @@ -1211,7 +1211,7 @@ interface ImportData { } class GenerationInfoFrame { - private readonly blockLambdaManager: IdManager; + private readonly blockLambdaManager: IdManager; private readonly importSet: Map; private readonly utilitySet: Set; private readonly typeVariableSet: Set; @@ -1227,7 +1227,7 @@ class GenerationInfoFrame { targetPlaceholder: string | undefined = undefined, disableRunnerIntegration: boolean = false, ) { - this.blockLambdaManager = new IdManager(); + this.blockLambdaManager = new IdManager(); this.importSet = importSet; this.utilitySet = utilitySet; this.typeVariableSet = typeVariableSet; @@ -1263,7 +1263,7 @@ class GenerationInfoFrame { } } - getUniqueLambdaBlockName(lambda: SdsBlockLambda): string { + getUniqueLambdaBlockName(lambda: TslBlockLambda): string { return `${BLOCK_LAMBDA_PREFIX}${this.blockLambdaManager.assignId(lambda)}`; } } diff --git a/packages/ttsl-lang/src/language/grammar/safe-ds.langium b/packages/ttsl-lang/src/language/grammar/safe-ds.langium index 1e134bed..79698e7a 100644 --- a/packages/ttsl-lang/src/language/grammar/safe-ds.langium +++ b/packages/ttsl-lang/src/language/grammar/safe-ds.langium @@ -1,101 +1,104 @@ -grammar SafeDs +grammar TSL // ----------------------------------------------------------------------------- // Base interfaces // ----------------------------------------------------------------------------- -interface SdsObject {} +interface TslObject {} -interface SdsAnnotatedObject extends SdsObject { - annotationCalls?: SdsAnnotationCall[] +interface TslAnnotatedObject extends TslObject { + annotationCalls?: TslAnnotationCall[] } -interface SdsAbstractCall extends SdsObject { - argumentList: SdsArgumentList +interface TslAbstractCall extends TslObject { + argumentList: TslArgumentList } -interface SdsDeclaration extends SdsAnnotatedObject { - annotationCallList?: SdsAnnotationCallList +interface TslDeclaration extends TslAnnotatedObject { + annotationCallList?: TslAnnotationCallList name: string } -interface SdsLocalVariable extends SdsDeclaration {} - +interface TslLocalVariable extends TslDeclaration { + groupedBy?: TslGroupedBy + type: TslType + value?: TslExpression +} // ----------------------------------------------------------------------------- // Module // ----------------------------------------------------------------------------- -interface SdsModule extends SdsDeclaration { - imports: SdsImport[]; - members: SdsAnnotatedObject[] +interface TslModule extends TslDeclaration { + imports: TslImport[]; + members: TslAnnotatedObject[] } -entry SdsModule returns SdsModule: - {SdsModule} - annotationCalls+=SdsAnnotationCall* +entry TslModule returns TslModule: + {TslModule} + annotationCalls+=TslAnnotationCall* ( ('package' name=QualifiedName) - imports+=SdsImport* - members+=(SdsAnnotatedModuleMember | SdsUnannotatedModuleMember)* + imports+=TslImport* + members+=(TslAnnotatedModuleMember | TslUnannotatedModuleMember)* - | imports+=SdsImport+ - members+=(SdsAnnotatedModuleMember | SdsUnannotatedModuleMember)* + | imports+=TslImport+ + members+=(TslAnnotatedModuleMember | TslUnannotatedModuleMember)* - | members+=SdsUnannotatedModuleMember - members+=(SdsAnnotatedModuleMember | SdsUnannotatedModuleMember)* + | members+=TslUnannotatedModuleMember + members+=(TslAnnotatedModuleMember | TslUnannotatedModuleMember)* )? ; -interface SdsImport extends SdsObject { +interface TslImport extends TslObject { package: string; } -SdsImport returns SdsImport: - SdsQualifiedImport - | SdsWildcardImport +TslImport returns TslImport: + TslQualifiedImport + | TslWildcardImport ; -interface SdsQualifiedImport extends SdsImport { - importedDeclarationList: SdsImportedDeclarationList; +interface TslQualifiedImport extends TslImport { + importedDeclarationList: TslImportedDeclarationList; } -SdsQualifiedImport returns SdsQualifiedImport: +TslQualifiedImport returns TslQualifiedImport: 'from' package=QualifiedName 'import' - importedDeclarationList=SdsImportedDeclarationList + importedDeclarationList=TslImportedDeclarationList ; -interface SdsImportedDeclarationList extends SdsObject { - importedDeclarations: SdsImportedDeclaration[] +interface TslImportedDeclarationList extends TslObject { + importedDeclarations: TslImportedDeclaration[] } -SdsImportedDeclarationList returns SdsImportedDeclarationList: - importedDeclarations+=SdsImportedDeclaration (',' importedDeclarations+=SdsImportedDeclaration)* ','? +TslImportedDeclarationList returns TslImportedDeclarationList: + importedDeclarations+=TslImportedDeclaration (',' importedDeclarations+=TslImportedDeclaration)* ','? ; -interface SdsImportedDeclaration extends SdsObject { - declaration?: @SdsModuleMember; - alias?: SdsImportedDeclarationAlias; +interface TslImportedDeclaration extends TslObject { + declaration?: @TslModuleMember; + alias?: TslImportedDeclarationAlias; } -SdsImportedDeclaration returns SdsImportedDeclaration: - declaration=[SdsModuleMember:ID] alias=SdsImportedDeclarationAlias? +TslImportedDeclaration returns TslImportedDeclaration: + declaration=[TslModuleMember:ID] alias=TslImportedDeclarationAlias? ; -interface SdsImportedDeclarationAlias extends SdsObject { +interface TslImportedDeclarationAlias extends TslObject { alias: string; } -SdsImportedDeclarationAlias returns SdsImportedDeclarationAlias: - {SdsImportedDeclarationAlias} 'as' alias=ID +TslImportedDeclarationAlias returns TslImportedDeclarationAlias: + {TslImportedDeclarationAlias} 'as' alias=ID ; -interface SdsWildcardImport extends SdsImport {} +interface TslWildcardImport extends TslImport {} -SdsWildcardImport returns SdsWildcardImport: +TslWildcardImport returns TslWildcardImport: 'from' package=QualifiedName 'import' @@ -111,227 +114,288 @@ QualifiedName returns string: // Declarations // ----------------------------------------------------------------------------- -interface SdsModuleMember extends SdsDeclaration {} +interface TslModuleMember extends TslDeclaration { + visibility?: TslVisibility +} -SdsAnnotatedModuleMember returns SdsModuleMember: - {SdsAnnotationCallList} - annotationCalls+=SdsAnnotationCall+ +TslAnnotatedModuleMember returns TslModuleMember: + {TslAnnotationCallList} + annotationCalls+=TslAnnotationCall+ ( - {SdsAnnotation.annotationCallList=current} - SdsAnnotationFragment + {TslAnnotation.annotationCallList=current} + TslAnnotationFragment - | {SdsClass.annotationCallList=current} - SdsClassFragment + | {TslClass.annotationCallList=current} + TslClassFragment - | {SdsEnum.annotationCallList=current} - SdsEnumFragment + | {TslEnum.annotationCallList=current} + TslEnumFragment - | {SdsFunction.annotationCallList=current} - SdsFunctionFragment + | {TslFunction.annotationCallList=current} + TslFunctionFragment - | {SdsSchema.annotationCallList=current} - SdsSchemaFragment + | {TslSchema.annotationCallList=current} + TslSchemaFragment - | {SdsPipeline.annotationCallList=current} - SdsPipelineFragment + | {TslPipeline.annotationCallList=current} + TslPipelineFragment - | {SdsSegment.annotationCallList=current} - SdsSegmentFragment + | {TslSegment.annotationCallList=current} + TslSegmentFragment ) ; -SdsUnannotatedModuleMember returns SdsModuleMember: - {SdsAnnotation} - SdsAnnotationFragment +TslUnannotatedModuleMember returns TslModuleMember: + {TslAnnotation} + TslAnnotationFragment + + | {TslClass} + TslClassFragment + + | {TslEnum} + TslEnumFragment - | {SdsClass} - SdsClassFragment + | {TslFunction} + TslFunctionFragment - | {SdsEnum} - SdsEnumFragment + | {TslConstant} + TslConstantFragment - | {SdsFunction} - SdsFunctionFragment + | {TslData} + TslDataFragment - | {SdsSchema} - SdsSchemaFragment + | {TslSchema} + TslSchemaFragment - | {SdsPipeline} - SdsPipelineFragment + | {TslPipeline} + TslPipelineFragment - | {SdsSegment} - SdsSegmentFragment + | {TslSegment} + TslSegmentFragment ; -interface SdsAnnotation extends SdsCallable, SdsModuleMember { - constraintList?: SdsConstraintList +interface TslAnnotation extends TslCallable, TslModuleMember { + constraintList?: TslConstraintList } -fragment SdsAnnotationFragment: +fragment TslAnnotationFragment: 'annotation' name=ID - parameterList=SdsParameterList? - constraintList=SdsConstraintList? + parameterList=TslParameterList? + constraintList=TslConstraintList? ; -interface SdsClass extends SdsCallable, SdsClassMember, SdsModuleMember, SdsNamedTypeDeclaration { - typeParameterList?: SdsTypeParameterList - parentTypeList?: SdsParentTypeList - constraintList?: SdsConstraintList - body?: SdsClassBody +interface TslClass extends TslCallable, TslClassMember, TslModuleMember, TslNamedTypeDeclaration { + typeParameterList?: TslTypeParameterList + parentTypeList?: TslParentTypeList + constraintList?: TslConstraintList + body?: TslClassBody } -fragment SdsClassFragment: +fragment TslClassFragment: 'class' name=ID - typeParameterList=SdsTypeParameterList? - parameterList=SdsParameterList? - parentTypeList=SdsParentTypeList? - constraintList=SdsConstraintList? - body=SdsClassBody? + typeParameterList=TslTypeParameterList? + parameterList=TslParameterList? + parentTypeList=TslParentTypeList? + constraintList=TslConstraintList? + body=TslClassBody? ; -interface SdsParentTypeList extends SdsObject { - parentTypes: SdsType[] +interface TslParentTypeList extends TslObject { + parentTypes: TslType[] } -SdsParentTypeList returns SdsParentTypeList: +TslParentTypeList returns TslParentTypeList: 'sub' - parentTypes+=SdsParentType - (',' parentTypes+=SdsParentType)* + parentTypes+=TslParentType + (',' parentTypes+=TslParentType)* ','? ; -interface SdsClassBody extends SdsObject { - members: SdsClassMember[] +interface TslClassBody extends TslObject { + members: TslClassMember[] } -SdsClassBody returns SdsClassBody: - {SdsClassBody} '{' members+=SdsClassMember* '}' +TslClassBody returns TslClassBody: + {TslClassBody} '{' members+=TslClassMember* '}' ; -interface SdsClassMember extends SdsDeclaration {} +interface TslClassMember extends TslDeclaration { + isStatic?: boolean +} -SdsClassMember returns SdsClassMember: - SdsAnnotatedClassMember - | SdsUnannotatedClassMember +TslClassMember returns TslClassMember: + TslAnnotatedClassMember + | TslUnannotatedClassMember ; -SdsAnnotatedClassMember returns SdsClassMember: - {SdsAnnotationCallList} - annotationCalls+=SdsAnnotationCall+ +TslAnnotatedClassMember returns TslClassMember: + {TslAnnotationCallList} + annotationCalls+=TslAnnotationCall+ ( - {SdsAttribute.annotationCallList=current} - SdsAttributeFragment + {TslAttribute.annotationCallList=current} + TslAttributeFragment - | {SdsClass.annotationCallList=current} - SdsClassFragment + | {TslClass.annotationCallList=current} + TslClassFragment - | {SdsEnum.annotationCallList=current} - SdsEnumFragment + | {TslEnum.annotationCallList=current} + TslEnumFragment - | {SdsFunction.annotationCallList=current} + | {TslFunction.annotationCallList=current} isStatic?='static'? - SdsFunctionFragment + TslFunctionFragment ) ; -SdsUnannotatedClassMember returns SdsClassMember: - {SdsAttribute} - SdsAttributeFragment +TslUnannotatedClassMember returns TslClassMember: + {TslAttribute} + TslAttributeFragment - | {SdsClass} - SdsClassFragment + | {TslClass} + TslClassFragment - | {SdsEnum} - SdsEnumFragment + | {TslEnum} + TslEnumFragment - | {SdsFunction} + | {TslFunction} isStatic?='static'? - SdsFunctionFragment + TslFunctionFragment ; -interface SdsAttribute extends SdsClassMember { - isStatic: boolean - ^type?: SdsType +interface TslAttribute extends TslClassMember { + ^type?: TslType } -fragment SdsAttributeFragment: +fragment TslAttributeFragment: isStatic?='static'? 'attr' name=ID - (':' ^type=SdsType)? + (':' ^type=TslType)? ; -interface SdsEnum extends SdsNamedTypeDeclaration, SdsClassMember, SdsModuleMember { - body?: SdsEnumBody + +interface TslEnum extends TslNamedTypeDeclaration, TslClassMember, TslModuleMember { + body?: TslEnumBody } -fragment SdsEnumFragment: +fragment TslEnumFragment: 'enum' name=ID - body=SdsEnumBody? + body=TslEnumBody? +; + +interface TslEnumBody extends TslObject { + variants: TslEnumVariant[] +} + +TslEnumBody returns TslEnumBody: + {TslEnumBody} '{' variants+=TslEnumVariant * '}' +; + +interface TslEnumVariant extends TslCallable, TslNamedTypeDeclaration { + constraintList?: TslConstraintList +} + +TslEnumVariant returns TslEnumVariant: + annotationCalls+=TslAnnotationCall* + name=ID + parameterList=TslParameterList? + constraintList=TslConstraintList? +; + +interface TslFunction extends TslCallable, TslClassMember, TslModuleMember { + isID: boolean + typeParameterList?: TslTypeParameterList + resultList?: TslResultList + timeunit?: TslTimeunit + groupedBy?: TslGroupedBy + constraintList?: TslConstraintList + body: TslFunctionBlock +} + +fragment TslFunctionFragment: + (visibility=TslVisibility)? + isID?='id'? + 'function' + (timeunit=TslTimeunit)? + name=ID + typeParameterList=TslTypeParameterList? + parameterList=TslParameterList + resultList=TslResultList? + (groupedBy=TslGroupedBy)? + constraintList=TslConstraintList? + body=TslFunctionBlock ; -interface SdsEnumBody extends SdsObject { - variants: SdsEnumVariant[] +interface TslFunctionBlock extends TslBlock{ + timespans: TslTimespan[] } -SdsEnumBody returns SdsEnumBody: - {SdsEnumBody} '{' variants+=SdsEnumVariant * '}' +TslFunctionBlock returns TslFunctionBlock: + {TslFunctionBlock} + '{' ( statements+=TslStatement* + | timespans+=TslTimespan + '{' ( timespans+=TslTimespan statements+=TslStatement + | statements+=TslStatement)* + '}')* '}' ; -interface SdsEnumVariant extends SdsCallable, SdsNamedTypeDeclaration { - constraintList?: SdsConstraintList +interface TslConstant extends TslModuleMember { + timespan: TslTimespan + ^type: TslType + value: TslExpression } -SdsEnumVariant returns SdsEnumVariant: - annotationCalls+=SdsAnnotationCall* +fragment TslConstantFragment: + (visibility=TslVisibility)? + 'constant' name=ID - parameterList=SdsParameterList? - constraintList=SdsConstraintList? + ':' ^type=TslType + ('{' (timespan=TslTimespan '=' value=TslExpression)*'}' | + '=' value=TslExpression) ';'? ; -interface SdsFunction extends SdsCallable, SdsClassMember, SdsModuleMember { - isStatic: boolean - typeParameterList?: SdsTypeParameterList - resultList?: SdsResultList - constraintList?: SdsConstraintList +interface TslData extends TslModuleMember { + isID: boolean + ^type: TslType + timeunit?: TslTimeunit + groupedBy?: TslGroupedBy } -fragment SdsFunctionFragment: - 'fun' +fragment TslDataFragment: + (visibility=TslVisibility)? + isID?='id'? + 'data' + (timeunit=TslTimeunit)? name=ID - typeParameterList=SdsTypeParameterList? - parameterList=SdsParameterList - resultList=SdsResultList? - constraintList=SdsConstraintList? + ':' ^type=TslType + (groupedBy=TslGroupedBy)? ';'? ; -interface SdsPipeline extends SdsModuleMember { - body: SdsBlock +interface TslPipeline extends TslModuleMember { + body: TslBlock } -fragment SdsPipelineFragment: +fragment TslPipelineFragment: 'pipeline' name=ID - body=SdsBlock + body=TslBlock ; -interface SdsSegment extends SdsCallable, SdsModuleMember { - visibility?: string - resultList?: SdsResultList - constraintList?: SdsConstraintList - body: SdsBlock +interface TslSegment extends TslCallable, TslModuleMember { + resultList?: TslResultList + constraintList?: TslConstraintList + body: TslBlock } -fragment SdsSegmentFragment: - visibility=('internal' | 'private')? +fragment TslSegmentFragment: 'segment' name=ID - parameterList=SdsParameterList - resultList=SdsResultList? - constraintList=SdsConstraintList? - body=SdsBlock + parameterList=TslParameterList + resultList=TslResultList? + constraintList=TslConstraintList? + body=TslBlock ; @@ -339,22 +403,22 @@ fragment SdsSegmentFragment: // Annotation calls // ----------------------------------------------------------------------------- -interface SdsAnnotationCallList extends SdsAnnotatedObject {} +interface TslAnnotationCallList extends TslAnnotatedObject {} -interface SdsAnnotationCall extends SdsAbstractCall { - annotation?: @SdsAnnotation +interface TslAnnotationCall extends TslAbstractCall { + annotation?: @TslAnnotation } -SdsAnnotationCall returns SdsAnnotationCall: - '@' annotation=[SdsAnnotation:ID] argumentList=SdsAnnotationCallArgumentList? +TslAnnotationCall returns TslAnnotationCall: + '@' annotation=[TslAnnotation:ID] argumentList=TslAnnotationCallArgumentList? ; -SdsAnnotationCallArgumentList returns SdsArgumentList: - {SdsArgumentList} '(' (arguments+=SdsAnnotationCallArgument (',' arguments+=SdsAnnotationCallArgument)* ','? )? ')' +TslAnnotationCallArgumentList returns TslArgumentList: + {TslArgumentList} '(' (arguments+=TslAnnotationCallArgument (',' arguments+=TslAnnotationCallArgument)* ','? )? ')' ; -SdsAnnotationCallArgument returns SdsArgument: - (parameter=[SdsParameter:ID ] '=')? value=SdsExpression +TslAnnotationCallArgument returns TslArgument: + (parameter=[TslParameter:ID ] '=')? value=TslExpression ; @@ -362,37 +426,37 @@ SdsAnnotationCallArgument returns SdsArgument: // Constraints // ----------------------------------------------------------------------------- -interface SdsConstraintList extends SdsObject { - constraints: SdsConstraint[] +interface TslConstraintList extends TslObject { + constraints: TslConstraint[] } -SdsConstraintList returns SdsConstraintList: +TslConstraintList returns TslConstraintList: 'where' '{' ( - constraints+=SdsConstraint - (',' constraints+=SdsConstraint)* + constraints+=TslConstraint + (',' constraints+=TslConstraint)* ','? )? '}' ; -interface SdsConstraint extends SdsObject {} +interface TslConstraint extends TslObject {} -SdsConstraint returns SdsConstraint: - SdsParameterBound +TslConstraint returns TslConstraint: + TslParameterBound ; -interface SdsParameterBound extends SdsConstraint { - leftOperand?: @SdsParameter +interface TslParameterBound extends TslConstraint { + leftOperand?: @TslParameter operator: string - rightOperand: SdsExpression + rightOperand: TslExpression } -SdsParameterBound returns SdsParameterBound: - leftOperand=[SdsParameter:ID] - operator=SdsComparisonOperator - rightOperand=SdsExpression +TslParameterBound returns TslParameterBound: + leftOperand=[TslParameter:ID] + operator=TslComparisonOperator + rightOperand=TslExpression ; @@ -400,58 +464,57 @@ SdsParameterBound returns SdsParameterBound: // Callables, parameters, and results // ----------------------------------------------------------------------------- -interface SdsCallable extends SdsObject { - parameterList?: SdsParameterList +interface TslCallable extends TslObject { + parameterList?: TslParameterList } -interface SdsParameterList extends SdsObject { - parameters: SdsParameter[] +interface TslParameterList extends TslObject { + parameters: TslParameter[] } -SdsParameterList returns SdsParameterList: - {SdsParameterList} +TslParameterList returns TslParameterList: + {TslParameterList} '(' ( - parameters+=SdsParameter - (',' parameters+=SdsParameter)* + parameters+=TslParameter + (',' parameters+=TslParameter)* ','? )? ')' ; -interface SdsParameter extends SdsLocalVariable { +interface TslParameter extends TslLocalVariable { isConstant: boolean - ^type?: SdsType - defaultValue?: SdsExpression + defaultValue?: TslExpression } -SdsParameter returns SdsParameter: - annotationCalls+=SdsAnnotationCall* - isConstant?='const'? +TslParameter returns TslParameter: + annotationCalls+=TslAnnotationCall* + isConstant?='constant'? name=ID - (':' ^type=SdsType)? - ('=' defaultValue=SdsExpression)? + (':' ^type=TslType)? + ('=' defaultValue=TslExpression)? ; -interface SdsResultList extends SdsObject { - results: SdsResult[] +interface TslResultList extends TslObject { + results: TslResult[] } -SdsResultList returns SdsResultList: - {SdsResultList} '->' results+=SdsResult - | {SdsResultList} '->' '(' (results+=SdsResult (',' results+=SdsResult)* ','? )? ')' +TslResultList returns TslResultList: + {TslResultList} ':' results+=TslResult + | {TslResultList} ':' '(' (results+=TslResult (',' results+=TslResult)* ','? )? ')' ; -interface SdsAbstractResult extends SdsDeclaration {} +interface TslAbstractResult extends TslDeclaration {} -interface SdsResult extends SdsAbstractResult { - ^type?: SdsType +interface TslResult extends TslAbstractResult { + ^type?: TslType } -SdsResult returns SdsResult: - annotationCalls+=SdsAnnotationCall* +TslResult returns TslResult: + annotationCalls+=TslAnnotationCall* name=ID - (':' ^type=SdsType)? + (':' ^type=TslType)? ; @@ -459,571 +522,688 @@ SdsResult returns SdsResult: // Statements // ----------------------------------------------------------------------------- -interface SdsStatement extends SdsObject {} +interface TslStatement extends TslObject {} -interface SdsBlock extends SdsObject { - statements: SdsStatement[] +interface TslBlock extends TslObject { + statements: TslStatement[] } -SdsBlock returns SdsBlock: - {SdsBlock} '{' statements+=SdsStatement* '}' +TslBlock returns TslBlock: + {TslBlock} '{' statements+=TslStatement* '}' ; -SdsStatement returns SdsStatement: - SdsAssignment - | SdsExpressionStatement +TslStatement returns TslStatement: + TslAssignment + | TslExpressionStatement + | TslConditionalStatement + | TslLoop ; -interface SdsAssignment extends SdsStatement { - assigneeList?: SdsAssigneeList - expression?: SdsExpression +interface TslAssignment extends TslStatement { + assigneeList?: TslAssigneeList + expression?: TslExpression } -SdsAssignment returns SdsAssignment: - assigneeList=SdsAssigneeList '=' expression=SdsExpression ';' +TslAssignment returns TslAssignment: + assigneeList=TslAssigneeList '=' expression=TslExpression ';' ; -interface SdsAssigneeList extends SdsObject { - assignees: SdsAssignee[] +interface TslAssigneeList extends TslObject { + assignees: TslAssignee[] +} + +TslAssigneeList returns TslAssigneeList: + assignees+=TslAssignee (',' assignees+=TslAssignee)* ','? +; + +interface TslAssignee extends TslObject {} + +interface TslPlaceholder extends TslAssignee, TslLocalVariable {} + +interface TslWildcard extends TslAssignee {} + +interface TslYield extends TslAssignee { + result?: @TslResult } -SdsAssigneeList returns SdsAssigneeList: - assignees+=SdsAssignee (',' assignees+=SdsAssignee)* ','? +TslAssignee returns TslAssignee: + {TslPlaceholder} 'var' name=ID ':' type=TslType (groupedBy=TslGroupedBy)? + | {TslWildcard} '_' + | {TslYield} 'yield' result=[TslResult:ID] ; -interface SdsAssignee extends SdsObject {} +interface TslExpressionStatement extends TslStatement { + expression: TslExpression +} -interface SdsPlaceholder extends SdsAssignee, SdsLocalVariable {} +TslExpressionStatement returns TslExpressionStatement: + expression=TslExpression ';' +; -interface SdsWildcard extends SdsAssignee {} +interface TslConditionalStatement extends TslStatement{ + expression: TslExpression + ifBlock: TslBlock + elseBlock?: TslBlock +} -interface SdsYield extends SdsAssignee { - result?: @SdsResult +TslConditionalStatement returns TslConditionalStatement: + 'if''(' expression=TslExpression ')' ifBlock=TslBlock + ('else' elseBlock=TslBlock)? +; + +interface TslLoop extends TslStatement{ + block: TslBlock } -SdsAssignee returns SdsAssignee: - {SdsPlaceholder} 'val' name=ID - | {SdsWildcard} '_' - | {SdsYield} 'yield' result=[SdsResult:ID] +TslLoop returns TslLoop: + TslWhileLoop + | TslForLoop + | TslForeachLoop ; -interface SdsExpressionStatement extends SdsStatement { - expression: SdsExpression +interface TslWhileLoop extends TslLoop{ + condition: TslExpression } -SdsExpressionStatement returns SdsExpressionStatement: - expression=SdsExpression ';' +TslWhileLoop returns TslWhileLoop: + 'while''(' condition=TslExpression ')' block=TslBlock ; +interface TslForLoop extends TslLoop{ + definitionStatement?: TslStatement + condition: TslExpression + iteration?: TslStatement +} + +TslForLoop returns TslForLoop: + 'for''(' (definitionStatement=TslStatement)? + ';' condition=TslExpression + ';' (iteration=TslStatement)? + ')' block=TslBlock +; + +interface TslForeachLoop extends TslLoop{ + element: string + list: TslExpression +} + +TslForeachLoop returns TslForeachLoop: + 'foreach''(' element=STRING 'in' list=TslExpression ')' + block=TslBlock +; // ----------------------------------------------------------------------------- // Expressions // ----------------------------------------------------------------------------- -interface SdsExpression extends SdsObject {} +interface TslExpression extends TslObject {} -SdsExpression returns SdsExpression: - SdsLambda | SdsOrExpression +TslExpression returns TslExpression: + TslLambda | TslOrExpression | TslAggregation ; -interface SdsLambda extends SdsCallable, SdsExpression {} +interface TslAggregation extends TslExpression{ + function: @TslFunction + data: @TslData[] + groupedBy: TslGroupedBy +} -interface SdsBlockLambda extends SdsLambda { - body: SdsBlock +TslAggregation returns TslAggregation: + 'aggregate' function=[TslFunction:ID] 'of' data+=[TslData:ID] (',' data+=[TslData:ID])* groupedBy=TslGroupedBy +; + +interface TslLambda extends TslCallable, TslExpression {} + +interface TslBlockLambda extends TslLambda { + body: TslBlock } -interface SdsExpressionLambda extends SdsLambda { - result: SdsExpression +interface TslExpressionLambda extends TslLambda { + result: TslExpression } -SdsLambda returns SdsExpression: - SdsParameterList +TslLambda returns TslExpression: + TslParameterList ( - {SdsBlockLambda.parameterList=current} body=SdsBlockLambdaBlock - | {SdsExpressionLambda.parameterList=current} '->' result=SdsExpression + {TslBlockLambda.parameterList=current} body=TslBlockLambdaBlock + | {TslExpressionLambda.parameterList=current} '->' result=TslExpression ) ; -SdsBlockLambdaBlock returns SdsBlock: - {SdsBlock} '{' statements+=SdsBlockLambdaStatement* '}' +TslBlockLambdaBlock returns TslBlock: + {TslBlock} '{' statements+=TslBlockLambdaStatement* '}' ; -SdsBlockLambdaStatement returns SdsStatement: - SdsBlockLambdaAssignment | SdsExpressionStatement +TslBlockLambdaStatement returns TslStatement: + TslBlockLambdaAssignment | TslExpressionStatement ; -SdsBlockLambdaAssignment returns SdsAssignment: - assigneeList=SdsBlockLambdaAssigneeList '=' expression=SdsExpression ';' +TslBlockLambdaAssignment returns TslAssignment: + assigneeList=TslBlockLambdaAssigneeList '=' expression=TslExpression ';' ; -SdsBlockLambdaAssigneeList returns SdsAssigneeList: - assignees+=SdsBlockLambdaAssignee (',' assignees+=SdsBlockLambdaAssignee)* ','? +TslBlockLambdaAssigneeList returns TslAssigneeList: + assignees+=TslBlockLambdaAssignee (',' assignees+=TslBlockLambdaAssignee)* ','? ; -interface SdsBlockLambdaResult extends SdsAssignee, SdsAbstractResult {} +interface TslBlockLambdaResult extends TslAssignee, TslAbstractResult {} -SdsBlockLambdaAssignee returns SdsAssignee: - {SdsWildcard} '_' - | {SdsPlaceholder} 'val' name=ID - | {SdsBlockLambdaResult} 'yield' name=ID +TslBlockLambdaAssignee returns TslAssignee: + {TslWildcard} '_' + | {TslPlaceholder} 'var' name=ID ':' type=TslType (groupedBy=TslGroupedBy)? + | {TslBlockLambdaResult} 'yield' name=ID ; -interface SdsInfixOperation extends SdsExpression { - leftOperand: SdsExpression +interface TslInfixOperation extends TslExpression { + leftOperand: TslExpression operator: string - rightOperand: SdsExpression + rightOperand: TslExpression } -interface SdsPrefixOperation extends SdsExpression { - operand: SdsExpression +interface TslPrefixOperation extends TslExpression { + operand: TslExpression operator: string } -SdsOrExpression returns SdsExpression: - SdsAndExpression +TslOrExpression returns TslExpression: + TslAndExpression ( - {SdsInfixOperation.leftOperand=current} + {TslInfixOperation.leftOperand=current} operator='or' - rightOperand=SdsAndExpression + rightOperand=TslAndExpression )* ; -SdsAndExpression returns SdsExpression: - SdsNotExpression +TslAndExpression returns TslExpression: + TslNotExpression ( - {SdsInfixOperation.leftOperand=current} + {TslInfixOperation.leftOperand=current} operator='and' - rightOperand=SdsNotExpression + rightOperand=TslNotExpression )* ; -SdsNotExpression returns SdsExpression: - {SdsPrefixOperation} operator='not' operand=SdsNotExpression - | SdsEqualityExpression +TslNotExpression returns TslExpression: + {TslPrefixOperation} operator='not' operand=TslNotExpression + | TslEqualityExpression ; -SdsEqualityExpression returns SdsExpression: - SdsComparisonExpression +TslEqualityExpression returns TslExpression: + TslComparisonExpression ( - {SdsInfixOperation.leftOperand=current} - operator=SdsEqualityOperator - rightOperand=SdsComparisonExpression + {TslInfixOperation.leftOperand=current} + operator=TslEqualityOperator + rightOperand=TslComparisonExpression )? ; -SdsEqualityOperator returns string: +TslEqualityOperator returns string: '==' | '!=' | '===' | '!==' ; -SdsComparisonExpression returns SdsExpression: - SdsAdditiveExpression +TslComparisonExpression returns TslExpression: + TslAdditiveExpression ( - {SdsInfixOperation.leftOperand=current} - operator=SdsComparisonOperator - rightOperand=SdsAdditiveExpression + {TslInfixOperation.leftOperand=current} + operator=TslComparisonOperator + rightOperand=TslAdditiveExpression )? ; -SdsComparisonOperator returns string: +TslComparisonOperator returns string: '<' | '<=' | '>=' | '>' ; -SdsAdditiveExpression returns SdsExpression: - SdsMultiplicativeExpression +TslAdditiveExpression returns TslExpression: + TslMultiplicativeExpression ( - {SdsInfixOperation.leftOperand=current} - operator=SdsAdditiveOperator - rightOperand=SdsMultiplicativeExpression + {TslInfixOperation.leftOperand=current} + operator=TslAdditiveOperator + rightOperand=TslMultiplicativeExpression )* ; -SdsAdditiveOperator returns string: +TslAdditiveOperator returns string: '+' | '-' ; -SdsMultiplicativeExpression returns SdsExpression: - SdsElvisExpression +TslMultiplicativeExpression returns TslExpression: + TslElvisExpression ( - {SdsInfixOperation.leftOperand=current} - operator=SdsMultiplicativeOperator - rightOperand=SdsElvisExpression + {TslInfixOperation.leftOperand=current} + operator=TslMultiplicativeOperator + rightOperand=TslElvisExpression )* ; -SdsMultiplicativeOperator returns string: +TslMultiplicativeOperator returns string: '*' | '/' ; -SdsElvisExpression returns SdsExpression: - SdsTypeCast +TslElvisExpression returns TslExpression: + TslTypeCast ( - {SdsInfixOperation.leftOperand=current} + {TslInfixOperation.leftOperand=current} operator='?:' - rightOperand=SdsTypeCast + rightOperand=TslTypeCast )* ; -interface SdsTypeCast extends SdsExpression { - expression: SdsExpression - ^type: SdsType +interface TslTypeCast extends TslExpression { + expression: TslExpression + ^type: TslType } -SdsTypeCast returns SdsExpression: - SdsUnaryOperation +TslTypeCast returns TslExpression: + TslUnaryOperation ( - {SdsTypeCast.expression=current} + {TslTypeCast.expression=current} 'as' - ^type=SdsType + ^type=TslType )* ; -SdsUnaryOperation returns SdsExpression: - {SdsPrefixOperation} operator='-' operand=SdsUnaryOperation - | SdsChainedExpression +TslUnaryOperation returns TslExpression: + {TslPrefixOperation} operator='-' operand=TslUnaryOperation + | TslChainedExpression ; -interface SdsChainedExpression extends SdsExpression { - receiver: SdsExpression +interface TslChainedExpression extends TslExpression { + receiver: TslExpression isNullSafe: boolean } -interface SdsCall extends SdsAbstractCall, SdsChainedExpression {} +interface TslCall extends TslAbstractCall, TslChainedExpression {} -interface SdsIndexedAccess extends SdsChainedExpression { - index: SdsExpression +interface TslIndexedAccess extends TslChainedExpression { + index: TslExpression } -interface SdsMemberAccess extends SdsChainedExpression { - member?: SdsReference +interface TslMemberAccess extends TslChainedExpression { + member?: TslReference } -SdsChainedExpression returns SdsExpression: - SdsPrimaryExpression +TslChainedExpression returns TslExpression: + TslPrimaryExpression ( - {SdsCall.receiver=current} + {TslCall.receiver=current} (isNullSafe?='?')? - argumentList=SdsCallArgumentList + argumentList=TslCallArgumentList - | {SdsIndexedAccess.receiver=current} + | {TslIndexedAccess.receiver=current} (isNullSafe?='?')? - '[' index=SdsExpression ']' + '[' index=TslExpression ']' - | {SdsMemberAccess.receiver=current} + | {TslMemberAccess.receiver=current} (isNullSafe?='?')? '.' - member=SdsReference + member=TslReference )* ; -interface SdsArgumentList extends SdsObject { - arguments: SdsArgument[] +interface TslArgumentList extends TslObject { + arguments: TslArgument[] } -SdsCallArgumentList returns SdsArgumentList: - {SdsArgumentList} +TslCallArgumentList returns TslArgumentList: + {TslArgumentList} '(' ( - arguments+=SdsCallArgument - (',' arguments+=SdsCallArgument)* + arguments+=TslCallArgument + (',' arguments+=TslCallArgument)* ','? )? ')' ; -interface SdsArgument extends SdsExpression { - parameter?: @SdsParameter - value: SdsExpression +interface TslArgument extends TslExpression { + parameter?: @TslParameter + value: TslExpression } -SdsCallArgument returns SdsArgument: - (parameter=[SdsParameter:ID] '=')? value=SdsExpression +TslCallArgument returns TslArgument: + (parameter=[TslParameter:ID] '=')? value=TslExpression ; -SdsPrimaryExpression returns SdsExpression: - SdsLiteral - | SdsParenthesizedExpression - | SdsReference - | SdsTemplateString +TslPrimaryExpression returns TslExpression: + TslLiteral + | TslParenthesizedExpression + | TslReference + | TslTemplateString ; -interface SdsLiteral extends SdsExpression {} +interface TslLiteral extends TslExpression {} -SdsLiteral returns SdsLiteral: - SdsBoolean - | SdsFloat - | SdsInt - | SdsList - | SdsMap - | SdsNull - | SdsString +TslLiteral returns TslLiteral: + TslBoolean + | TslFloat + | TslInt + | TslList + | TslDictionary + | TslNull + | TslString + | TslDate ; -interface SdsBoolean extends SdsLiteral { +interface TslBoolean extends TslLiteral { value: boolean } -SdsBoolean returns SdsBoolean: +TslBoolean returns TslBoolean: value?='true' - | {SdsBoolean} 'false' + | {TslBoolean} 'false' ; -interface SdsNumber extends SdsLiteral {} +interface TslNumber extends TslLiteral {} -interface SdsFloat extends SdsNumber { +interface TslFloat extends TslNumber { value: number } -SdsFloat returns SdsFloat: +TslFloat returns TslFloat: value=FLOAT ; -interface SdsInt extends SdsNumber { +interface TslInt extends TslNumber { value: bigint } -SdsInt returns SdsInt: +TslInt returns TslInt: value=INT ; -interface SdsList extends SdsLiteral { - elements: SdsExpression[] +interface TslList extends TslLiteral { + elements: TslExpression[] } -SdsList returns SdsList: - {SdsList} '[' (elements+=SdsExpression (',' elements+=SdsExpression)* ','? )? ']' +TslList returns TslList: + {TslList} '[' (elements+=TslExpression (',' elements+=TslExpression)* ','? )? ']' ; -interface SdsMap extends SdsLiteral { - entries: SdsMapEntry[] +interface TslDictionary extends TslLiteral { + entries: TslDictionaryEntry[] } -SdsMap returns SdsMap: - {SdsMap} '{' (entries+=SdsMapEntry (',' entries+=SdsMapEntry)* ','? )? '}' +TslDictionary returns TslDictionary: + {TslDictionary} '{' (entries+=TslDictionaryEntry (',' entries+=TslDictionaryEntry)* ','? )? '}' ; -interface SdsMapEntry extends SdsObject { - key: SdsExpression - value: SdsExpression +interface TslDictionaryEntry extends TslObject { + key: TslExpression + value: TslExpression } -SdsMapEntry returns SdsMapEntry: - key=SdsExpression ':' value=SdsExpression +TslDictionaryEntry returns TslDictionaryEntry: + key=TslExpression ':' value=TslExpression ; -interface SdsNull extends SdsLiteral {} +interface TslNull extends TslLiteral {} -SdsNull returns SdsNull: - {SdsNull} 'null' +TslNull returns TslNull: + {TslNull} 'null' ; -interface SdsString extends SdsLiteral { +interface TslString extends TslLiteral { value: string } -SdsString returns SdsString: +TslString returns TslString: value=STRING ; -interface SdsParenthesizedExpression extends SdsExpression { - expression: SdsExpression +interface TslDate extends TslLiteral{ + date: Date +} + +TslDate returns TslDate: + date=DATE +; + + +interface TslParenthesizedExpression extends TslExpression { + expression: TslExpression } -SdsParenthesizedExpression returns SdsParenthesizedExpression: - '(' expression=SdsExpression ')' +TslParenthesizedExpression returns TslParenthesizedExpression: + '(' expression=TslExpression ')' ; -interface SdsReference extends SdsExpression { - target: @SdsDeclaration +interface TslReference extends TslExpression { + target: @TslDeclaration } -SdsReference returns SdsReference: - target=[SdsDeclaration:ID] +TslReference returns TslReference: + target=[TslDeclaration:ID] ; -interface SdsTemplateString extends SdsExpression { - expressions: SdsExpression[] +interface TslTemplateString extends TslExpression { + expressions: TslExpression[] } -SdsTemplateString returns SdsTemplateString: - expressions+=SdsTemplateStringStart - expressions+=SdsExpression? - (expressions+=SdsTemplateStringInner expressions+=SdsExpression?)* - expressions+=SdsTemplateStringEnd +TslTemplateString returns TslTemplateString: + expressions+=TslTemplateStringStart + expressions+=TslExpression? + (expressions+=TslTemplateStringInner expressions+=TslExpression?)* + expressions+=TslTemplateStringEnd ; -interface SdsTemplateStringPart extends SdsLiteral { +interface TslTemplateStringPart extends TslLiteral { value: string } -interface SdsTemplateStringStart extends SdsTemplateStringPart {} +interface TslTemplateStringStart extends TslTemplateStringPart {} -SdsTemplateStringStart returns SdsExpression: - {SdsTemplateStringStart} +TslTemplateStringStart returns TslExpression: + {TslTemplateStringStart} value=TEMPLATE_STRING_START ; -interface SdsTemplateStringInner extends SdsTemplateStringPart {} +interface TslTemplateStringInner extends TslTemplateStringPart {} -SdsTemplateStringInner returns SdsExpression: - {SdsTemplateStringInner} +TslTemplateStringInner returns TslExpression: + {TslTemplateStringInner} value=TEMPLATE_STRING_INNER ; -interface SdsTemplateStringEnd extends SdsTemplateStringPart {} +interface TslTemplateStringEnd extends TslTemplateStringPart {} -SdsTemplateStringEnd returns SdsExpression: - {SdsTemplateStringEnd} +TslTemplateStringEnd returns TslExpression: + {TslTemplateStringEnd} value=TEMPLATE_STRING_END ; +// ----------------------------------------------------------------------------- +// Modifier +// ----------------------------------------------------------------------------- + +interface TslModifier extends TslObject{} + +interface TslVisibility extends TslModifier{ + isPublic?: boolean + isPackageprivate?: boolean + isPrivate?: boolean +} + +TslVisibility returns TslVisibility: + isPublic?='public'? | isPackageprivate?='packageprivate'? | isPrivate?='private'? +; + +interface TslTimeunit extends TslModifier{ + timeunit: string +} + +TslTimeunit returns TslTimeunit: + 'per' timeunit=('day'|'week'|'month'|'year') +; + +interface TslGroupedBy extends TslModifier{ + id: TslExpression +} + +TslGroupedBy returns TslGroupedBy: + 'groupedBy' id=TslExpression +; + +// ----------------------------------------------------------------------------- +// Timespan +// ----------------------------------------------------------------------------- + +interface TslTimespan extends TslObject{ + start?: TslDate + end?: TslDate +} + +TslTimespan returns TslTimespan: + ('from' start=TslDate)? ('to' end=TslDate)? +; // ----------------------------------------------------------------------------- // Types // ----------------------------------------------------------------------------- -interface SdsType extends SdsObject {} +interface TslType extends TslObject {} -interface SdsNamedTypeDeclaration extends SdsDeclaration {} +interface TslNamedTypeDeclaration extends TslDeclaration {} -interface SdsMemberType extends SdsType { - receiver: SdsType - member?: SdsNamedType +interface TslMemberType extends TslType { + receiver: TslType + member?: TslNamedType } -SdsType returns SdsType: - SdsPrimaryType ({SdsMemberType.receiver=current} '.' member=SdsNamedType)* +TslType returns TslType: + TslPrimaryType ({TslMemberType.receiver=current} '.' member=TslNamedType)* ; -SdsPrimaryType returns SdsType: - SdsCallableType - | SdsLiteralType - | SdsNamedType - | SdsUnionType +TslPrimaryType returns TslType: + TslCallableType + | TslLiteralType + | TslNamedType + | TslUnionType ; -interface SdsCallableType extends SdsCallable, SdsType { - resultList: SdsResultList +interface TslCallableType extends TslCallable, TslType { + resultList: TslResultList } -SdsCallableType returns SdsCallableType: - parameterList=SdsParameterList - resultList=SdsResultList +TslCallableType returns TslCallableType: + parameterList=TslParameterList + resultList=TslResultList ; -interface SdsLiteralType extends SdsType { - literalList: SdsLiteralList +interface TslLiteralType extends TslType { + literalList: TslLiteralList } -SdsLiteralType returns SdsLiteralType: - 'literal' literalList=SdsLiteralList +TslLiteralType returns TslLiteralType: + 'literal' literalList=TslLiteralList ; -interface SdsLiteralList extends SdsObject { - literals: SdsLiteral[] +interface TslLiteralList extends TslObject { + literals: TslLiteral[] } -SdsLiteralList returns SdsLiteralList: - {SdsLiteralList} +TslLiteralList returns TslLiteralList: + {TslLiteralList} '<' ( - literals+=SdsLiteral - (',' literals+=SdsLiteral)* + literals+=TslLiteral + (',' literals+=TslLiteral)* ','? )? '>' ; -interface SdsNamedType extends SdsType { - declaration?: @SdsNamedTypeDeclaration - typeArgumentList?: SdsTypeArgumentList +interface TslNamedType extends TslType { + declaration?: @TslNamedTypeDeclaration + typeArgumentList?: TslTypeArgumentList isNullable: boolean } -SdsNamedType returns SdsNamedType: - declaration=[SdsNamedTypeDeclaration:ID] - typeArgumentList=SdsTypeArgumentList? +TslNamedType returns TslNamedType: + declaration=[TslNamedTypeDeclaration:ID] + typeArgumentList=TslTypeArgumentList? (isNullable?='?' )? ; -interface SdsUnionType extends SdsType { - typeArgumentList: SdsTypeArgumentList +interface TslUnionType extends TslType { + typeArgumentList: TslTypeArgumentList } -SdsUnionType returns SdsUnionType: - 'union' typeArgumentList=SdsUnionTypeArgumentList +TslUnionType returns TslUnionType: + 'union' typeArgumentList=TslUnionTypeArgumentList ; -SdsUnionTypeArgumentList returns SdsTypeArgumentList: - {SdsTypeArgumentList} +TslUnionTypeArgumentList returns TslTypeArgumentList: + {TslTypeArgumentList} '<' ( - typeArguments+=SdsUnionTypeArgument - (',' typeArguments+=SdsUnionTypeArgument)* + typeArguments+=TslUnionTypeArgument + (',' typeArguments+=TslUnionTypeArgument)* ','? )? '>' ; -SdsUnionTypeArgument returns SdsTypeArgument: - value=SdsType +TslUnionTypeArgument returns TslTypeArgument: + value=TslType ; -SdsParentType returns SdsType: - SdsNamedType ({SdsMemberType.receiver=current} '.' member=SdsNamedType)* +TslParentType returns TslType: + TslNamedType ({TslMemberType.receiver=current} '.' member=TslNamedType)* ; -interface SdsTypeParameterList extends SdsObject { - typeParameters: SdsTypeParameter[] +interface TslTypeParameterList extends TslObject { + typeParameters: TslTypeParameter[] } -SdsTypeParameterList returns SdsTypeParameterList: - {SdsTypeParameterList} +TslTypeParameterList returns TslTypeParameterList: + {TslTypeParameterList} '<' ( - typeParameters+=SdsTypeParameter - (',' typeParameters+=SdsTypeParameter)* + typeParameters+=TslTypeParameter + (',' typeParameters+=TslTypeParameter)* ','? )? '>' ; -interface SdsTypeParameter extends SdsNamedTypeDeclaration { +interface TslTypeParameter extends TslNamedTypeDeclaration { variance?: string - upperBound?: SdsType - defaultValue?: SdsType + upperBound?: TslType + defaultValue?: TslType } -SdsTypeParameter returns SdsTypeParameter: - annotationCalls+=SdsAnnotationCall* - variance=SdsTypeParameterVariance? +TslTypeParameter returns TslTypeParameter: + annotationCalls+=TslAnnotationCall* + variance=TslTypeParameterVariance? name=ID - ('sub' upperBound=SdsType)? - ('=' defaultValue=SdsType)? + ('sub' upperBound=TslType)? + ('=' defaultValue=TslType)? ; -SdsTypeParameterVariance returns string: +TslTypeParameterVariance returns string: 'in' | 'out' ; -interface SdsTypeArgumentList extends SdsObject { - typeArguments: SdsTypeArgument[] +interface TslTypeArgumentList extends TslObject { + typeArguments: TslTypeArgument[] } -SdsTypeArgumentList returns SdsTypeArgumentList: - {SdsTypeArgumentList} +TslTypeArgumentList returns TslTypeArgumentList: + {TslTypeArgumentList} '<' - (typeArguments+=SdsTypeArgument (',' typeArguments+=SdsTypeArgument)* ','? )? + (typeArguments+=TslTypeArgument (',' typeArguments+=TslTypeArgument)* ','? )? '>' ; -interface SdsTypeArgument extends SdsObject { - typeParameter?: @SdsTypeParameter - value: SdsType +interface TslTypeArgument extends TslObject { + typeParameter?: @TslTypeParameter + value: TslType } -SdsTypeArgument returns SdsTypeArgument: - (typeParameter=[SdsTypeParameter:ID] '=' )? - value=SdsType +TslTypeArgument returns TslTypeArgument: + (typeParameter=[TslTypeParameter:ID] '=' )? + value=TslType ; @@ -1031,31 +1211,31 @@ SdsTypeArgument returns SdsTypeArgument: // Schemas // ----------------------------------------------------------------------------- -interface SdsSchema extends SdsModuleMember { - columnList: SdsColumnList +interface TslSchema extends TslModuleMember { + columnList: TslColumnList } -fragment SdsSchemaFragment: +fragment TslSchemaFragment: 'schema' name=ID - columnList=SdsColumnList + columnList=TslColumnList ; -interface SdsColumnList extends SdsObject { - columns: SdsColumn[] +interface TslColumnList extends TslObject { + columns: TslColumn[] } -SdsColumnList returns SdsColumnList: - {SdsColumnList} '{' (columns+=SdsColumn (',' columns+=SdsColumn)* ','? )? '}' +TslColumnList returns TslColumnList: + {TslColumnList} '{' (columns+=TslColumn (',' columns+=TslColumn)* ','? )? '}' ; -interface SdsColumn extends SdsObject { - columnName: SdsString - columnType: SdsType +interface TslColumn extends TslObject { + columnName: TslString + columnType: TslType } -SdsColumn returns SdsColumn: - columnName=SdsString ":" columnType=SdsType +TslColumn returns TslColumn: + columnName=TslString ":" columnType=TslType ; @@ -1070,6 +1250,7 @@ terminal FLOAT returns number : DECIMAL_DIGIT+ '.' DECIMAL_DIGIT+ FLOAT_EXPONENT? | DECIMAL_DIGIT+ FLOAT_EXPONENT; terminal fragment DECIMAL_DIGIT: /[0-9]/; +terminal DATE returns Date: /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}/; terminal fragment FLOAT_EXPONENT: ('e' | 'E' )('+' | '-' )? DECIMAL_DIGIT+; terminal INT returns bigint: DECIMAL_DIGIT+; terminal STRING returns string: STRING_START STRING_TEXT* STRING_END; @@ -1088,6 +1269,6 @@ terminal TEMPLATE_STRING_INNER returns string: TEMPLATE_EXPRESSION_END STRING_TE terminal TEMPLATE_STRING_END returns string: TEMPLATE_EXPRESSION_END STRING_TEXT* STRING_END; hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//; -hidden terminal SL_COMMENT: /\/\/[^\n\r]*/; +hidden terminal SL_COMMENT: /\#[^\n\r]*/; hidden terminal TEST_MARKER: /[»«]/; hidden terminal WS: /\s+/; diff --git a/packages/ttsl-lang/src/language/helpers/fileExtensions.ts b/packages/ttsl-lang/src/language/helpers/fileExtensions.ts index d485bc6f..53aee54b 100644 --- a/packages/ttsl-lang/src/language/helpers/fileExtensions.ts +++ b/packages/ttsl-lang/src/language/helpers/fileExtensions.ts @@ -6,7 +6,7 @@ import { AstNode, AstUtils, LangiumDocument } from 'langium'; * @see isInPipelineFile * @see isPipelineFile */ -export const PIPELINE_FILE_EXTENSION = 'sdspipe'; +export const PIPELINE_FILE_EXTENSION = 'Tslpipe'; /** * Marks the file as a stub file, which describes an external API. @@ -14,7 +14,7 @@ export const PIPELINE_FILE_EXTENSION = 'sdspipe'; * @see isInStubFile * @see isStubFile */ -export const STUB_FILE_EXTENSION = 'sdsstub'; +export const STUB_FILE_EXTENSION = 'Tslstub'; /** * Marks the file as a test file, which disables some checks to simplify its use as input of test cases. This file @@ -23,7 +23,7 @@ export const STUB_FILE_EXTENSION = 'sdsstub'; * @see isInTestFile * @see isTestFile */ -export const TEST_FILE_EXTENSION = 'sdstest'; +export const TEST_FILE_EXTENSION = 'Tsltest'; /** * All file extensions that are supported by the Safe-DS language. @@ -33,7 +33,7 @@ export const SAFE_DS_FILE_EXTENSIONS = [PIPELINE_FILE_EXTENSION, STUB_FILE_EXTEN /** * All file extensions that are supported by the Safe-DS language. */ -export type SdSFileExtension = typeof PIPELINE_FILE_EXTENSION | typeof STUB_FILE_EXTENSION | typeof TEST_FILE_EXTENSION; +export type TslFileExtension = typeof PIPELINE_FILE_EXTENSION | typeof STUB_FILE_EXTENSION | typeof TEST_FILE_EXTENSION; /** * Returns whether the object is contained in a pipeline file. @@ -68,5 +68,5 @@ export const isTestFile = (document: LangiumDocument) => hasExtension(document, /** * Returns whether the resource represents a file with the given extension. */ -const hasExtension = (document: LangiumDocument, extension: SdSFileExtension) => +const hasExtension = (document: LangiumDocument, extension: TslFileExtension) => document.uri.path.endsWith(`.${extension}`); diff --git a/packages/ttsl-lang/src/language/helpers/nodeProperties.ts b/packages/ttsl-lang/src/language/helpers/nodeProperties.ts index f1be4492..8c48bbc5 100644 --- a/packages/ttsl-lang/src/language/helpers/nodeProperties.ts +++ b/packages/ttsl-lang/src/language/helpers/nodeProperties.ts @@ -1,72 +1,72 @@ import { AstNode, AstUtils, Stream, stream } from 'langium'; import { - isSdsAnnotation, - isSdsArgument, - isSdsArgumentList, - isSdsAssignment, - isSdsAttribute, - isSdsBlockLambda, - isSdsBlockLambdaResult, - isSdsCallable, - isSdsCallableType, - isSdsClass, - isSdsDeclaration, - isSdsEnum, - isSdsEnumVariant, - isSdsFunction, - isSdsLambda, - isSdsModule, - isSdsModuleMember, - isSdsNamedType, - isSdsParameter, - isSdsParameterBound, - isSdsPlaceholder, - isSdsQualifiedImport, - isSdsSegment, - isSdsTypeArgumentList, - isSdsTypeParameter, - isSdsTypeParameterList, - SdsAbstractCall, - SdsAbstractResult, - SdsAnnotatedObject, - SdsAnnotation, - SdsAnnotationCall, - SdsArgument, - SdsArgumentList, - SdsAssignee, - SdsAssignment, - SdsBlock, - SdsBlockLambda, - SdsBlockLambdaResult, - SdsCallable, - SdsClass, - SdsClassMember, - SdsColumn, - SdsConstraint, - SdsDeclaration, - SdsEnum, - SdsEnumVariant, - SdsImport, - SdsImportedDeclaration, - SdsLiteral, - SdsLiteralType, - SdsModule, - SdsModuleMember, - SdsNamedType, - SdsNamedTypeDeclaration, - SdsParameter, - SdsParameterBound, - SdsPlaceholder, - SdsQualifiedImport, - SdsResult, - SdsResultList, - SdsSchema, - SdsStatement, - SdsType, - SdsTypeArgument, - SdsTypeArgumentList, - SdsTypeParameter, - SdsTypeParameterList, + isTslAnnotation, + isTslArgument, + isTslArgumentList, + isTslAssignment, + isTslAttribute, + isTslBlockLambda, + isTslBlockLambdaResult, + isTslCallable, + isTslCallableType, + isTslClass, + isTslDeclaration, + isTslEnum, + isTslEnumVariant, + isTslFunction, + isTslLambda, + isTslModule, + isTslModuleMember, + isTslNamedType, + isTslParameter, + isTslParameterBound, + isTslPlaceholder, + isTslQualifiedImport, + isTslSegment, + isTslTypeArgumentList, + isTslTypeParameter, + isTslTypeParameterList, + TslAbstractCall, + TslAbstractResult, + TslAnnotatedObject, + TslAnnotation, + TslAnnotationCall, + TslArgument, + TslArgumentList, + TslAssignee, + TslAssignment, + TslBlock, + TslBlockLambda, + TslBlockLambdaResult, + TslCallable, + TslClass, + TslClassMember, + TslColumn, + TslConstraint, + TslDeclaration, + TslEnum, + TslEnumVariant, + TslImport, + TslImportedDeclaration, + TslLiteral, + TslLiteralType, + TslModule, + TslModuleMember, + TslNamedType, + TslNamedTypeDeclaration, + TslParameter, + TslParameterBound, + TslPlaceholder, + TslQualifiedImport, + TslResult, + TslResultList, + TslSchema, + TslStatement, + TslType, + TslTypeArgument, + TslTypeArgumentList, + TslTypeParameter, + TslTypeParameterList, } from '../generated/ast.js'; // ------------------------------------------------------------------------------------------------- @@ -74,8 +74,8 @@ import { // ------------------------------------------------------------------------------------------------- export const hasAnnotationCallOf = ( - node: SdsAnnotatedObject | undefined, - expected: SdsAnnotation | undefined, + node: TslAnnotatedObject | undefined, + expected: TslAnnotation | undefined, ): boolean => { return getAnnotationCalls(node).some((it) => { const actual = it.annotation?.ref; @@ -83,69 +83,69 @@ export const hasAnnotationCallOf = ( }); }; -export const isInternal = (node: SdsDeclaration | undefined): boolean => { - return isSdsSegment(node) && node.visibility === 'internal'; +export const isInternal = (node: TslDeclaration | undefined): boolean => { + return isTslSegment(node) && node.visibility === 'internal'; }; export namespace Argument { - export const isNamed = (node: SdsArgument | undefined): boolean => { + export const isNamed = (node: TslArgument | undefined): boolean => { return Boolean(node?.parameter); }; - export const isPositional = (node: SdsArgument | undefined): boolean => { - return isSdsArgument(node) && !node.parameter; + export const isPositional = (node: TslArgument | undefined): boolean => { + return isTslArgument(node) && !node.parameter; }; } export namespace Enum { - export const isConstant = (node: SdsEnum | undefined): boolean => { + export const isConstant = (node: TslEnum | undefined): boolean => { return Boolean(node) && getEnumVariants(node).every((it) => EnumVariant.isConstant(it)); }; } export namespace EnumVariant { - export const isConstant = (node: SdsEnumVariant | undefined): boolean => { + export const isConstant = (node: TslEnumVariant | undefined): boolean => { return Boolean(node) && getParameters(node).every((it) => Parameter.isConstant(it)); }; } export namespace Parameter { - export const isConstant = (node: SdsParameter | undefined): boolean => { + export const isConstant = (node: TslParameter | undefined): boolean => { if (!node) { return false; } - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); // In those cases, the const modifier is not applicable - if (isSdsCallableType(containingCallable) || isSdsLambda(containingCallable)) { + if (isTslCallableType(containingCallable) || isTslLambda(containingCallable)) { return false; } - return node.isConstant || isSdsAnnotation(containingCallable); + return node.isConstant || isTslAnnotation(containingCallable); }; - export const isOptional = (node: SdsParameter | undefined): boolean => { + export const isOptional = (node: TslParameter | undefined): boolean => { return Boolean(node?.defaultValue); }; - export const isRequired = (node: SdsParameter | undefined): boolean => { - return isSdsParameter(node) && !node.defaultValue; + export const isRequired = (node: TslParameter | undefined): boolean => { + return isTslParameter(node) && !node.defaultValue; }; - export const getBounds = (node: SdsParameter | undefined): SdsParameterBound[] => { - const callable = AstUtils.getContainerOfType(node, isSdsCallable); - const result = getConstraints(callable).filter((it) => isSdsParameterBound(it) && it.leftOperand?.ref === node); - return result as SdsParameterBound[]; + export const getBounds = (node: TslParameter | undefined): TslParameterBound[] => { + const callable = AstUtils.getContainerOfType(node, isTslCallable); + const result = getConstraints(callable).filter((it) => isTslParameterBound(it) && it.leftOperand?.ref === node); + return result as TslParameterBound[]; }; } -export const isStatic = (node: SdsClassMember | undefined): boolean => { - if (isSdsClass(node) || isSdsEnum(node)) { +export const isStatic = (node: TslClassMember | undefined): boolean => { + if (isTslClass(node) || isTslEnum(node)) { return true; - } else if (isSdsAttribute(node)) { + } else if (isTslAttribute(node)) { return node.isStatic; - } else if (isSdsFunction(node)) { + } else if (isTslFunction(node)) { return node.isStatic; } else { /* c8 ignore next 2 */ @@ -154,30 +154,30 @@ export const isStatic = (node: SdsClassMember | undefined): boolean => { }; export namespace TypeArgument { - export const isNamed = (node: SdsTypeArgument | undefined): boolean => { + export const isNamed = (node: TslTypeArgument | undefined): boolean => { return Boolean(node?.typeParameter); }; } export namespace TypeParameter { - export const isOptional = (node: SdsTypeParameter | undefined): boolean => { + export const isOptional = (node: TslTypeParameter | undefined): boolean => { return Boolean(node?.defaultValue); }; - export const isRequired = (node: SdsTypeParameter | undefined): boolean => { - return isSdsTypeParameter(node) && !node.defaultValue; + export const isRequired = (node: TslTypeParameter | undefined): boolean => { + return isTslTypeParameter(node) && !node.defaultValue; }; - export const isContravariant = (node: SdsTypeParameter | undefined): boolean => { - return isSdsTypeParameter(node) && node.variance === 'in'; + export const isContravariant = (node: TslTypeParameter | undefined): boolean => { + return isTslTypeParameter(node) && node.variance === 'in'; }; - export const isCovariant = (node: SdsTypeParameter | undefined): boolean => { - return isSdsTypeParameter(node) && node.variance === 'out'; + export const isCovariant = (node: TslTypeParameter | undefined): boolean => { + return isTslTypeParameter(node) && node.variance === 'out'; }; - export const isInvariant = (node: SdsTypeParameter | undefined): boolean => { - return isSdsTypeParameter(node) && !node.variance; + export const isInvariant = (node: TslTypeParameter | undefined): boolean => { + return isTslTypeParameter(node) && !node.variance; }; } @@ -185,31 +185,31 @@ export namespace TypeParameter { // Accessors for list elements // ------------------------------------------------------------------------------------------------- -export const getAbstractResults = (node: SdsCallable | undefined): SdsAbstractResult[] => { +export const getAbstractResults = (node: TslCallable | undefined): TslAbstractResult[] => { if (!node) { return []; } - if (isSdsBlockLambda(node)) { + if (isTslBlockLambda(node)) { return streamBlockLambdaResults(node).toArray(); - } else if (isSdsCallableType(node)) { + } else if (isTslCallableType(node)) { return getResults(node.resultList); - } else if (isSdsFunction(node)) { + } else if (isTslFunction(node)) { return getResults(node.resultList); - } else if (isSdsSegment(node)) { + } else if (isTslSegment(node)) { return getResults(node.resultList); } /* c8 ignore start */ else { return []; } /* c8 ignore stop */ }; -export const getAnnotationCalls = (node: SdsAnnotatedObject | undefined): SdsAnnotationCall[] => { +export const getAnnotationCalls = (node: TslAnnotatedObject | undefined): TslAnnotationCall[] => { if (!node) { /* c8 ignore next 2 */ return []; } - if (isSdsDeclaration(node)) { + if (isTslDeclaration(node)) { return node?.annotationCallList?.annotationCalls ?? node?.annotationCalls ?? []; } else { /* c8 ignore next 2 */ @@ -217,14 +217,14 @@ export const getAnnotationCalls = (node: SdsAnnotatedObject | undefined): SdsAnn } }; -export const getAnnotationCallTarget = (node: SdsAnnotationCall | undefined): SdsDeclaration | undefined => { - return AstUtils.getContainerOfType(node, isSdsDeclaration); +export const getAnnotationCallTarget = (node: TslAnnotationCall | undefined): TslDeclaration | undefined => { + return AstUtils.getContainerOfType(node, isTslDeclaration); }; export const findFirstAnnotationCallOf = ( - node: SdsAnnotatedObject | undefined, - expected: SdsAnnotation | undefined, -): SdsAnnotationCall | undefined => { + node: TslAnnotatedObject | undefined, + expected: TslAnnotation | undefined, +): TslAnnotationCall | undefined => { if (!node || !expected) { return undefined; } @@ -235,61 +235,61 @@ export const findFirstAnnotationCallOf = ( }); }; -export const getArguments = (node: SdsArgumentList | SdsAbstractCall | undefined): SdsArgument[] => { - if (isSdsArgumentList(node)) { +export const getArguments = (node: TslArgumentList | TslAbstractCall | undefined): TslArgument[] => { + if (isTslArgumentList(node)) { return node.arguments; } else { return node?.argumentList?.arguments ?? []; } }; -export const getAssignees = (node: SdsAssignment | undefined): SdsAssignee[] => { +export const getAssignees = (node: TslAssignment | undefined): TslAssignee[] => { return node?.assigneeList?.assignees ?? []; }; -export const streamBlockLambdaResults = (node: SdsBlockLambda | undefined): Stream => { +export const streamBlockLambdaResults = (node: TslBlockLambda | undefined): Stream => { return stream(getStatements(node?.body)) - .filter(isSdsAssignment) + .filter(isTslAssignment) .flatMap(getAssignees) - .filter(isSdsBlockLambdaResult); + .filter(isTslBlockLambdaResult); }; -export const getClassMembers = (node: SdsClass | undefined): SdsClassMember[] => { +export const getClassMembers = (node: TslClass | undefined): TslClassMember[] => { return node?.body?.members ?? []; }; -export const getConstraints = (node: SdsCallable | undefined): SdsConstraint[] => { - if (isSdsAnnotation(node)) { +export const getConstraints = (node: TslCallable | undefined): TslConstraint[] => { + if (isTslAnnotation(node)) { return node.constraintList?.constraints ?? []; - } else if (isSdsClass(node)) { + } else if (isTslClass(node)) { return node.constraintList?.constraints ?? []; - } else if (isSdsEnumVariant(node)) { + } else if (isTslEnumVariant(node)) { return node.constraintList?.constraints ?? []; - } else if (isSdsFunction(node)) { + } else if (isTslFunction(node)) { return node.constraintList?.constraints ?? []; - } else if (isSdsSegment(node)) { + } else if (isTslSegment(node)) { return node.constraintList?.constraints ?? []; } else { return []; } }; -export const getColumns = (node: SdsSchema | undefined): SdsColumn[] => { +export const getColumns = (node: TslSchema | undefined): TslColumn[] => { return node?.columnList?.columns ?? []; }; -export const getEnumVariants = (node: SdsEnum | undefined): SdsEnumVariant[] => { +export const getEnumVariants = (node: TslEnum | undefined): TslEnumVariant[] => { return node?.body?.variants ?? []; }; -export const getImports = (node: SdsModule | undefined): SdsImport[] => { +export const getImports = (node: TslModule | undefined): TslImport[] => { return node?.imports ?? []; }; -export const getImportedDeclarations = (node: SdsModule | SdsQualifiedImport | undefined): SdsImportedDeclaration[] => { - if (isSdsModule(node)) { +export const getImportedDeclarations = (node: TslModule | TslQualifiedImport | undefined): TslImportedDeclaration[] => { + if (isTslModule(node)) { return getImports(node).flatMap((imp) => { - if (isSdsQualifiedImport(imp)) { + if (isTslQualifiedImport(imp)) { return getImportedDeclarations(imp); } else { return []; @@ -300,64 +300,64 @@ export const getImportedDeclarations = (node: SdsModule | SdsQualifiedImport | u } }; -export const getLiterals = (node: SdsLiteralType | undefined): SdsLiteral[] => { +export const getLiterals = (node: TslLiteralType | undefined): TslLiteral[] => { return node?.literalList?.literals ?? []; }; -export const getModuleMembers = (node: SdsModule | undefined): SdsModuleMember[] => { - return node?.members?.filter(isSdsModuleMember) ?? []; +export const getModuleMembers = (node: TslModule | undefined): TslModuleMember[] => { + return node?.members?.filter(isTslModuleMember) ?? []; }; export const getPackageName = (node: AstNode | undefined): string | undefined => { - return AstUtils.getContainerOfType(node, isSdsModule)?.name; + return AstUtils.getContainerOfType(node, isTslModule)?.name; }; -export const getParameters = (node: SdsCallable | undefined): SdsParameter[] => { +export const getParameters = (node: TslCallable | undefined): TslParameter[] => { return node?.parameterList?.parameters ?? []; }; -export const getParentTypes = (node: SdsClass | undefined): SdsType[] => { +export const getParentTypes = (node: TslClass | undefined): TslType[] => { return node?.parentTypeList?.parentTypes ?? []; }; -export const getQualifiedName = (node: SdsDeclaration | undefined): string | undefined => { +export const getQualifiedName = (node: TslDeclaration | undefined): string | undefined => { const segments = []; - let current: SdsDeclaration | undefined = node; + let current: TslDeclaration | undefined = node; while (current) { if (current.name) { segments.unshift(current.name); } - current = AstUtils.getContainerOfType(current.$container, isSdsDeclaration); + current = AstUtils.getContainerOfType(current.$container, isTslDeclaration); } return segments.join('.'); }; -export const streamPlaceholders = (node: SdsBlock | undefined): Stream => { - return stream(getStatements(node)).filter(isSdsAssignment).flatMap(getAssignees).filter(isSdsPlaceholder); +export const streamPlaceholders = (node: TslBlock | undefined): Stream => { + return stream(getStatements(node)).filter(isTslAssignment).flatMap(getAssignees).filter(isTslPlaceholder); }; -export const getPlaceholderByName = (block: SdsBlock, name: string | undefined): SdsPlaceholder | undefined => { +export const getPlaceholderByName = (block: TslBlock, name: string | undefined): TslPlaceholder | undefined => { return name ? streamPlaceholders(block).find((placeholder) => placeholder.name === name) : undefined; }; -export const getResults = (node: SdsResultList | undefined): SdsResult[] => { +export const getResults = (node: TslResultList | undefined): TslResult[] => { return node?.results ?? []; }; -export const getStatements = (node: SdsBlock | undefined): SdsStatement[] => { +export const getStatements = (node: TslBlock | undefined): TslStatement[] => { return node?.statements ?? []; }; -export const getTypeArguments = (node: SdsTypeArgumentList | SdsNamedType | undefined): SdsTypeArgument[] => { +export const getTypeArguments = (node: TslTypeArgumentList | TslNamedType | undefined): TslTypeArgument[] => { if (!node) { return []; } - if (isSdsTypeArgumentList(node)) { + if (isTslTypeArgumentList(node)) { return node.typeArguments; - } else if (isSdsNamedType(node)) { + } else if (isTslNamedType(node)) { return getTypeArguments(node.typeArgumentList); } /* c8 ignore start */ else { return []; @@ -365,17 +365,17 @@ export const getTypeArguments = (node: SdsTypeArgumentList | SdsNamedType | unde }; export const getTypeParameters = ( - node: SdsTypeParameterList | SdsCallable | SdsNamedTypeDeclaration | undefined, -): SdsTypeParameter[] => { + node: TslTypeParameterList | TslCallable | TslNamedTypeDeclaration | undefined, +): TslTypeParameter[] => { if (!node) { return []; } - if (isSdsTypeParameterList(node)) { + if (isTslTypeParameterList(node)) { return node.typeParameters; - } else if (isSdsClass(node)) { + } else if (isTslClass(node)) { return getTypeParameters(node.typeParameterList); - } else if (isSdsFunction(node)) { + } else if (isTslFunction(node)) { return getTypeParameters(node.typeParameterList); } /* c8 ignore start */ else { return []; diff --git a/packages/ttsl-lang/src/language/helpers/safe-ds-node-mapper.ts b/packages/ttsl-lang/src/language/helpers/safe-ds-node-mapper.ts index 97a1184b..80fbd0ae 100644 --- a/packages/ttsl-lang/src/language/helpers/safe-ds-node-mapper.ts +++ b/packages/ttsl-lang/src/language/helpers/safe-ds-node-mapper.ts @@ -1,33 +1,33 @@ import { AstUtils, EMPTY_STREAM, Stream } from 'langium'; import { - isSdsAbstractCall, - isSdsAnnotationCall, - isSdsAssignment, - isSdsBlock, - isSdsCall, - isSdsCallable, - isSdsClass, - isSdsEnumVariant, - isSdsExpressionLambda, - isSdsNamedType, - isSdsParameter, - isSdsReference, - isSdsSegment, - isSdsType, - isSdsYield, - SdsAbstractCall, - SdsAbstractResult, - SdsArgument, - SdsAssignee, - SdsCallable, - SdsExpression, - SdsParameter, - SdsPlaceholder, - SdsReference, - SdsResult, - SdsTypeArgument, - SdsTypeParameter, - SdsYield, + isTslAbstractCall, + isTslAnnotationCall, + isTslAssignment, + isTslBlock, + isTslCall, + isTslCallable, + isTslClass, + isTslEnumVariant, + isTslExpressionLambda, + isTslNamedType, + isTslParameter, + isTslReference, + isTslSegment, + isTslType, + isTslYield, + TslAbstractCall, + TslAbstractResult, + TslArgument, + TslAssignee, + TslCallable, + TslExpression, + TslParameter, + TslPlaceholder, + TslReference, + TslResult, + TslTypeArgument, + TslTypeParameter, + TslYield, } from '../generated/ast.js'; import { SafeDsServices } from '../safe-ds-module.js'; import { CallableType, StaticType } from '../typing/model.js'; @@ -52,7 +52,7 @@ export class SafeDsNodeMapper { /** * Returns the parameter that the argument is assigned to. If there is no matching parameter, returns `undefined`. */ - argumentToParameter(node: SdsArgument | undefined): SdsParameter | undefined { + argumentToParameter(node: TslArgument | undefined): TslParameter | undefined { if (!node) { return undefined; } @@ -63,7 +63,7 @@ export class SafeDsNodeMapper { } // Positional argument - const containingAbstractCall = AstUtils.getContainerOfType(node, isSdsAbstractCall)!; + const containingAbstractCall = AstUtils.getContainerOfType(node, isTslAbstractCall)!; const args = getArguments(containingAbstractCall); const argumentPosition = node.$containerIndex ?? -1; @@ -88,12 +88,12 @@ export class SafeDsNodeMapper { * Returns the result, block lambda result, or expression that is assigned to the given assignee. If nothing is * assigned, `undefined` is returned. */ - assigneeToAssignedObject(node: SdsAssignee | undefined): SdsAbstractResult | SdsExpression | undefined { + assigneeToAssignedObject(node: TslAssignee | undefined): TslAbstractResult | TslExpression | undefined { if (!node) { return undefined; } - const containingAssignment = AstUtils.getContainerOfType(node, isSdsAssignment); + const containingAssignment = AstUtils.getContainerOfType(node, isTslAssignment); /* c8 ignore start */ if (!containingAssignment) { return undefined; @@ -104,7 +104,7 @@ export class SafeDsNodeMapper { const expression = containingAssignment.expression; // If the RHS is not a call, the first assignee gets the entire RHS - if (!isSdsCall(expression)) { + if (!isTslCall(expression)) { if (assigneePosition === 0) { return expression; } else { @@ -114,7 +114,7 @@ export class SafeDsNodeMapper { // If the RHS instantiates a class or enum variant, the first assignee gets the entire RHS const callable = this.callToCallable(expression); - if (isSdsClass(callable) || isSdsEnumVariant(callable)) { + if (isTslClass(callable) || isTslEnumVariant(callable)) { if (assigneePosition === 0) { return expression; } else { @@ -123,7 +123,7 @@ export class SafeDsNodeMapper { } // If the RHS calls an expression lambda, the first assignee gets its result - if (isSdsExpressionLambda(callable)) { + if (isTslExpressionLambda(callable)) { if (assigneePosition === 0) { return callable.result; } else { @@ -139,14 +139,14 @@ export class SafeDsNodeMapper { /** * Returns the callable that is called by the given call. If no callable can be found, returns `undefined`. */ - callToCallable(node: SdsAbstractCall | undefined): SdsCallable | undefined { + callToCallable(node: TslAbstractCall | undefined): TslCallable | undefined { if (!node) { return undefined; } - if (isSdsAnnotationCall(node)) { + if (isTslAnnotationCall(node)) { return node.annotation?.ref; - } else if (isSdsCall(node)) { + } else if (isTslCall(node)) { // We ignore nullability, since calls can be made null-safe. For scoping, for instance, we still want to // link the arguments of the call properly, even if the user forgot to make the call null-safe. In this // case, an error is being shown anyway. @@ -157,7 +157,7 @@ export class SafeDsNodeMapper { return nonNullableReceiverType.callable; } else if (nonNullableReceiverType instanceof StaticType) { const declaration = nonNullableReceiverType.instanceType.declaration; - if (isSdsCallable(declaration)) { + if (isTslCallable(declaration)) { return declaration; } } @@ -175,16 +175,16 @@ export class SafeDsNodeMapper { * @param parameter The parameter whose value to return. Can be either a parameter itself or its name. */ callToParameterValue( - call: SdsAbstractCall | undefined, - parameter: SdsParameter | string | undefined, - ): SdsExpression | undefined { + call: TslAbstractCall | undefined, + parameter: TslParameter | string | undefined, + ): TslExpression | undefined { if (!call || !parameter) { return undefined; } // Parameter is set explicitly const argument = getArguments(call).find((it) => { - if (isSdsParameter(parameter)) { + if (isTslParameter(parameter)) { return this.argumentToParameter(it) === parameter; } else { return this.argumentToParameter(it)?.name === parameter; @@ -198,7 +198,7 @@ export class SafeDsNodeMapper { // We must ensure the parameter belongs to the called callable, so we cannot directly get the defaultValue const callable = this.callToCallable(call); return getParameters(callable).find((it) => { - if (isSdsParameter(parameter)) { + if (isTslParameter(parameter)) { return it === parameter; } else { return it.name === parameter; @@ -214,8 +214,8 @@ export class SafeDsNodeMapper { * @param parameters The parameters to map to arguments. * @param args The arguments. */ - parametersToArguments(parameters: SdsParameter[], args: SdsArgument[]): Map { - const result = new Map(); + parametersToArguments(parameters: TslParameter[], args: TslArgument[]): Map { + const result = new Map(); for (const argument of args) { const parameterIndex = this.argumentToParameter(argument)?.$containerIndex ?? -1; @@ -244,12 +244,12 @@ export class SafeDsNodeMapper { /** * Returns all references that target the given parameter. */ - parameterToReferences(node: SdsParameter | undefined): Stream { + parameterToReferences(node: TslParameter | undefined): Stream { if (!node) { return EMPTY_STREAM; } - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); /* c8 ignore start */ if (!containingCallable) { return EMPTY_STREAM; @@ -258,18 +258,18 @@ export class SafeDsNodeMapper { return AstUtils.findLocalReferences(node, containingCallable) .map((it) => it.$refNode?.astNode) - .filter(isSdsReference); + .filter(isTslReference); } /** * Returns all references that target the given placeholder. */ - placeholderToReferences(node: SdsPlaceholder | undefined): Stream { + placeholderToReferences(node: TslPlaceholder | undefined): Stream { if (!node) { return EMPTY_STREAM; } - const containingBlock = AstUtils.getContainerOfType(node, isSdsBlock); + const containingBlock = AstUtils.getContainerOfType(node, isTslBlock); /* c8 ignore start */ if (!containingBlock) { return EMPTY_STREAM; @@ -278,32 +278,32 @@ export class SafeDsNodeMapper { return AstUtils.findLocalReferences(node, containingBlock) .map((it) => it.$refNode?.astNode) - .filter(isSdsReference); + .filter(isTslReference); } /** * Returns all yields that assign to the given result. */ - resultToYields(node: SdsResult | undefined): Stream { + resultToYields(node: TslResult | undefined): Stream { if (!node) { return EMPTY_STREAM; } - const containingSegment = AstUtils.getContainerOfType(node, isSdsSegment); + const containingSegment = AstUtils.getContainerOfType(node, isTslSegment); if (!containingSegment) { return EMPTY_STREAM; } return AstUtils.findLocalReferences(node, containingSegment) .map((it) => it.$refNode?.astNode) - .filter(isSdsYield); + .filter(isTslYield); } /** * Returns the type parameter that the type argument is assigned to. If there is no matching type parameter, returns * `undefined`. */ - typeArgumentToTypeParameter(node: SdsTypeArgument | undefined): SdsTypeParameter | undefined { + typeArgumentToTypeParameter(node: TslTypeArgument | undefined): TslTypeParameter | undefined { if (!node) { return undefined; } @@ -314,8 +314,8 @@ export class SafeDsNodeMapper { } // Positional type argument - const containingType = AstUtils.getContainerOfType(node, isSdsType); - if (!isSdsNamedType(containingType)) { + const containingType = AstUtils.getContainerOfType(node, isTslType); + if (!isTslNamedType(containingType)) { return undefined; } diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-call-hierarchy-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-call-hierarchy-provider.ts index 9d100799..2d6ee832 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-call-hierarchy-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-call-hierarchy-provider.ts @@ -8,11 +8,11 @@ import type { } from 'vscode-languageserver'; import type { SafeDsCallGraphComputer } from '../flow/safe-ds-call-graph-computer.js'; import { - isSdsDeclaration, - isSdsParameter, - type SdsCall, - type SdsCallable, - type SdsDeclaration, + isTslDeclaration, + isTslParameter, + type TslCall, + type TslCallable, + type TslDeclaration, } from '../generated/ast.js'; import type { SafeDsNodeMapper } from '../helpers/safe-ds-node-mapper.js'; import type { SafeDsServices } from '../safe-ds-module.js'; @@ -95,7 +95,7 @@ export class SafeDsCallHierarchyProvider extends AbstractCallHierarchyProvider { * Returns all declarations that contain at least one of the given references. Some of them might not be actual * callers, since the references might not occur in a call. This has to be checked later. */ - private getUniquePotentialCallers(references: Stream): Stream { + private getUniquePotentialCallers(references: Stream): Stream { return references .map((it) => { const document = this.documents.getDocument(it.sourceUri); @@ -116,19 +116,19 @@ export class SafeDsCallHierarchyProvider extends AbstractCallHierarchyProvider { return undefined; } - const containingDeclaration = AstUtils.getContainerOfType(targetCstNode.astNode, isSdsDeclaration); - if (isSdsParameter(containingDeclaration)) { + const containingDeclaration = AstUtils.getContainerOfType(targetCstNode.astNode, isTslDeclaration); + if (isTslParameter(containingDeclaration)) { // For parameters, we return their containing callable instead - return AstUtils.getContainerOfType(containingDeclaration.$container, isSdsDeclaration); + return AstUtils.getContainerOfType(containingDeclaration.$container, isTslDeclaration); } else { return containingDeclaration; } }) .distinct() - .filter(isSdsDeclaration); + .filter(isTslDeclaration); } - private getCallsOf(caller: AstNode, callee: AstNode): SdsCall[] { + private getCallsOf(caller: AstNode, callee: AstNode): TslCall[] { return this.callGraphComputer .getAllContainedCalls(caller) .filter((call) => this.nodeMapper.callToCallable(call) === callee); @@ -138,7 +138,7 @@ export class SafeDsCallHierarchyProvider extends AbstractCallHierarchyProvider { const calls = this.callGraphComputer.getAllContainedCalls(node); const callsGroupedByCallable = new Map< string, - { callable: SdsCallable; callableNameCstNode: CstNode; callableDocumentUri: string; fromRanges: Range[] } + { callable: TslCallable; callableNameCstNode: CstNode; callableDocumentUri: string; fromRanges: Range[] } >(); // Group calls by the callable they refer to diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-document-symbol-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-document-symbol-provider.ts index 021591ee..02308c39 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-document-symbol-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-document-symbol-provider.ts @@ -1,13 +1,13 @@ import { type AstNode, type LangiumDocument } from 'langium'; import type { DocumentSymbol } from 'vscode-languageserver'; import { - isSdsAnnotation, - isSdsAttribute, - isSdsClass, - isSdsEnumVariant, - isSdsFunction, - isSdsPipeline, - isSdsSegment, + isTslAnnotation, + isTslAttribute, + isTslClass, + isTslEnumVariant, + isTslFunction, + isTslPipeline, + isTslSegment, } from '../generated/ast.js'; import type { SafeDsServices } from '../safe-ds-module.js'; import type { SafeDsNodeInfoProvider } from './safe-ds-node-info-provider.js'; @@ -46,7 +46,7 @@ export class SafeDsDocumentSymbolProvider extends DefaultDocumentSymbolProvider protected override getChildSymbols(document: LangiumDocument, node: AstNode): DocumentSymbol[] | undefined { if (this.isLeaf(node)) { return undefined; - } else if (isSdsClass(node)) { + } else if (isTslClass(node)) { if (node.body) { return super.getChildSymbols(document, node.body); } else { @@ -59,12 +59,12 @@ export class SafeDsDocumentSymbolProvider extends DefaultDocumentSymbolProvider private isLeaf(node: AstNode): boolean { return ( - isSdsAnnotation(node) || - isSdsAttribute(node) || - isSdsEnumVariant(node) || - isSdsFunction(node) || - isSdsPipeline(node) || - isSdsSegment(node) + isTslAnnotation(node) || + isTslAttribute(node) || + isTslEnumVariant(node) || + isTslFunction(node) || + isTslPipeline(node) || + isTslSegment(node) ); } } diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-formatter.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-formatter.ts index fc94c98c..17b48e57 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-formatter.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-formatter.ts @@ -26,168 +26,168 @@ export class SafeDsFormatter extends AbstractFormatter { // ----------------------------------------------------------------------------- // Module // ----------------------------------------------------------------------------- - if (ast.isSdsModule(node)) { - this.formatSdsModule(node); - } else if (ast.isSdsImport(node)) { - this.formatSdsImport(node); - } else if (ast.isSdsImportedDeclarationList(node)) { - this.formatSdsImportedDeclarationList(node); - } else if (ast.isSdsImportedDeclaration(node)) { - this.formatSdsImportedDeclaration(node); - } else if (ast.isSdsImportedDeclarationAlias(node)) { - this.formatSdsImportedDeclarationAlias(node); + if (ast.isTslModule(node)) { + this.formatTslModule(node); + } else if (ast.isTslImport(node)) { + this.formatTslImport(node); + } else if (ast.isTslImportedDeclarationList(node)) { + this.formatTslImportedDeclarationList(node); + } else if (ast.isTslImportedDeclaration(node)) { + this.formatTslImportedDeclaration(node); + } else if (ast.isTslImportedDeclarationAlias(node)) { + this.formatTslImportedDeclarationAlias(node); } // ----------------------------------------------------------------------------- // Declarations // ----------------------------------------------------------------------------- - else if (ast.isSdsAnnotation(node)) { - this.formatSdsAnnotation(node); - } else if (ast.isSdsAttribute(node)) { - this.formatSdsAttribute(node); - } else if (ast.isSdsClass(node)) { - this.formatSdsClass(node); - } else if (ast.isSdsParentTypeList(node)) { - this.formatSdsParentTypeList(node); - } else if (ast.isSdsClassBody(node)) { - this.formatSdsClassBody(node); - } else if (ast.isSdsEnum(node)) { - this.formatSdsEnum(node); - } else if (ast.isSdsEnumBody(node)) { - this.formatSdsEnumBody(node); - } else if (ast.isSdsEnumVariant(node)) { - this.formatSdsEnumVariant(node); - } else if (ast.isSdsFunction(node)) { - this.formatSdsFunction(node); - } else if (ast.isSdsPipeline(node)) { - this.formatSdsPipeline(node); - } else if (ast.isSdsSegment(node)) { - this.formatSdsSegment(node); + else if (ast.isTslAnnotation(node)) { + this.formatTslAnnotation(node); + } else if (ast.isTslAttribute(node)) { + this.formatTslAttribute(node); + } else if (ast.isTslClass(node)) { + this.formatTslClass(node); + } else if (ast.isTslParentTypeList(node)) { + this.formatTslParentTypeList(node); + } else if (ast.isTslClassBody(node)) { + this.formatTslClassBody(node); + } else if (ast.isTslEnum(node)) { + this.formatTslEnum(node); + } else if (ast.isTslEnumBody(node)) { + this.formatTslEnumBody(node); + } else if (ast.isTslEnumVariant(node)) { + this.formatTslEnumVariant(node); + } else if (ast.isTslFunction(node)) { + this.formatTslFunction(node); + } else if (ast.isTslPipeline(node)) { + this.formatTslPipeline(node); + } else if (ast.isTslSegment(node)) { + this.formatTslSegment(node); } // ----------------------------------------------------------------------------- // Annotation calls // ----------------------------------------------------------------------------- - else if (ast.isSdsAnnotationCallList(node)) { - this.formatSdsAnnotationCallList(node); - } else if (ast.isSdsAnnotationCall(node)) { - this.formatSdsAnnotationCall(node); + else if (ast.isTslAnnotationCallList(node)) { + this.formatTslAnnotationCallList(node); + } else if (ast.isTslAnnotationCall(node)) { + this.formatTslAnnotationCall(node); } // ----------------------------------------------------------------------------- // Constraints // ----------------------------------------------------------------------------- - else if (ast.isSdsConstraintList(node)) { - this.formatSdsConstraintList(node); - } else if (ast.isSdsParameterBound(node)) { - this.formatSdsParameterBound(node); + else if (ast.isTslConstraintList(node)) { + this.formatTslConstraintList(node); + } else if (ast.isTslParameterBound(node)) { + this.formatTslParameterBound(node); } // ----------------------------------------------------------------------------- // Callables, parameters, and results // ----------------------------------------------------------------------------- - else if (ast.isSdsParameterList(node)) { - this.formatSdsParameterList(node); - } else if (ast.isSdsParameter(node)) { - this.formatSdsParameter(node); - } else if (ast.isSdsResultList(node)) { - this.formatSdsResultList(node); - } else if (ast.isSdsResult(node)) { - this.formatSdsResult(node); + else if (ast.isTslParameterList(node)) { + this.formatTslParameterList(node); + } else if (ast.isTslParameter(node)) { + this.formatTslParameter(node); + } else if (ast.isTslResultList(node)) { + this.formatTslResultList(node); + } else if (ast.isTslResult(node)) { + this.formatTslResult(node); } // ----------------------------------------------------------------------------- // Statements // ----------------------------------------------------------------------------- - else if (ast.isSdsBlock(node)) { - this.formatSdsBlock(node); - } else if (ast.isSdsAssignment(node)) { - this.formatSdsAssignment(node); - } else if (ast.isSdsAssigneeList(node)) { - this.formatSdsAssigneeList(node); - } else if (ast.isSdsPlaceholder(node)) { - this.formatSdsPlaceholder(node); - } else if (ast.isSdsYield(node)) { - this.formatSdsYield(node); - } else if (ast.isSdsExpressionStatement(node)) { - this.formatSdsExpressionStatement(node); + else if (ast.isTslBlock(node)) { + this.formatTslBlock(node); + } else if (ast.isTslAssignment(node)) { + this.formatTslAssignment(node); + } else if (ast.isTslAssigneeList(node)) { + this.formatTslAssigneeList(node); + } else if (ast.isTslPlaceholder(node)) { + this.formatTslPlaceholder(node); + } else if (ast.isTslYield(node)) { + this.formatTslYield(node); + } else if (ast.isTslExpressionStatement(node)) { + this.formatTslExpressionStatement(node); } // ----------------------------------------------------------------------------- // Expressions // ----------------------------------------------------------------------------- - else if (ast.isSdsBlockLambda(node)) { - this.formatSdsBlockLambda(node); - } else if (ast.isSdsBlockLambdaResult(node)) { - this.formatSdsBlockLambdaResult(node); - } else if (ast.isSdsExpressionLambda(node)) { - this.formatSdsExpressionLambda(node); - } else if (ast.isSdsInfixOperation(node)) { - this.formatSdsInfixOperation(node); - } else if (ast.isSdsPrefixOperation(node)) { - this.formatSdsPrefixOperation(node); - } else if (ast.isSdsCall(node)) { - this.formatSdsCall(node); - } else if (ast.isSdsArgumentList(node)) { - this.formatSdsArgumentList(node); - } else if (ast.isSdsArgument(node)) { - this.formatSdsArgument(node); - } else if (ast.isSdsIndexedAccess(node)) { - this.formatSdsIndexedAccess(node); - } else if (ast.isSdsMemberAccess(node)) { - this.formatSdsMemberAccess(node); - } else if (ast.isSdsList(node)) { - this.formatSdsList(node); - } else if (ast.isSdsMap(node)) { - this.formatSdsMap(node); - } else if (ast.isSdsMapEntry(node)) { - this.formatSdsMapEntry(node); - } else if (ast.isSdsParenthesizedExpression(node)) { - this.formatSdsParenthesizedExpression(node); - } else if (ast.isSdsTemplateStringStart(node)) { - this.formatSdsTemplateStringStart(node); - } else if (ast.isSdsTemplateStringInner(node)) { - this.formatSdsTemplateStringInner(node); - } else if (ast.isSdsTemplateStringEnd(node)) { - this.formatSdsTemplateStringEnd(node); - } else if (ast.isSdsTypeCast(node)) { - this.formatSdsTypeCast(node); + else if (ast.isTslBlockLambda(node)) { + this.formatTslBlockLambda(node); + } else if (ast.isTslBlockLambdaResult(node)) { + this.formatTslBlockLambdaResult(node); + } else if (ast.isTslExpressionLambda(node)) { + this.formatTslExpressionLambda(node); + } else if (ast.isTslInfixOperation(node)) { + this.formatTslInfixOperation(node); + } else if (ast.isTslPrefixOperation(node)) { + this.formatTslPrefixOperation(node); + } else if (ast.isTslCall(node)) { + this.formatTslCall(node); + } else if (ast.isTslArgumentList(node)) { + this.formatTslArgumentList(node); + } else if (ast.isTslArgument(node)) { + this.formatTslArgument(node); + } else if (ast.isTslIndexedAccess(node)) { + this.formatTslIndexedAccess(node); + } else if (ast.isTslMemberAccess(node)) { + this.formatTslMemberAccess(node); + } else if (ast.isTslList(node)) { + this.formatTslList(node); + } else if (ast.isTslDictionary(node)) { + this.formatTslDictionary(node); + } else if (ast.isTslDictionaryEntry(node)) { + this.formatTslDictionaryEntry(node); + } else if (ast.isTslParenthesizedExpression(node)) { + this.formatTslParenthesizedExpression(node); + } else if (ast.isTslTemplateStringStart(node)) { + this.formatTslTemplateStringStart(node); + } else if (ast.isTslTemplateStringInner(node)) { + this.formatTslTemplateStringInner(node); + } else if (ast.isTslTemplateStringEnd(node)) { + this.formatTslTemplateStringEnd(node); + } else if (ast.isTslTypeCast(node)) { + this.formatTslTypeCast(node); } // ----------------------------------------------------------------------------- // Types // ----------------------------------------------------------------------------- - else if (ast.isSdsMemberType(node)) { - this.formatSdsMemberType(node); - } else if (ast.isSdsCallableType(node)) { - this.formatSdsCallableType(node); - } else if (ast.isSdsLiteralType(node)) { - this.formatSdsLiteralType(node); - } else if (ast.isSdsLiteralList(node)) { - this.formatSdsLiteralList(node); - } else if (ast.isSdsNamedType(node)) { - this.formatSdsNamedType(node); - } else if (ast.isSdsUnionType(node)) { - this.formatSdsUnionType(node); - } else if (ast.isSdsTypeParameterList(node)) { - this.formatSdsTypeParameterList(node); - } else if (ast.isSdsTypeParameter(node)) { - this.formatSdsTypeParameter(node); - } else if (ast.isSdsTypeArgumentList(node)) { - this.formatSdsTypeArgumentList(node); - } else if (ast.isSdsTypeArgument(node)) { - this.formatSdsTypeArgument(node); + else if (ast.isTslMemberType(node)) { + this.formatTslMemberType(node); + } else if (ast.isTslCallableType(node)) { + this.formatTslCallableType(node); + } else if (ast.isTslLiteralType(node)) { + this.formatTslLiteralType(node); + } else if (ast.isTslLiteralList(node)) { + this.formatTslLiteralList(node); + } else if (ast.isTslNamedType(node)) { + this.formatTslNamedType(node); + } else if (ast.isTslUnionType(node)) { + this.formatTslUnionType(node); + } else if (ast.isTslTypeParameterList(node)) { + this.formatTslTypeParameterList(node); + } else if (ast.isTslTypeParameter(node)) { + this.formatTslTypeParameter(node); + } else if (ast.isTslTypeArgumentList(node)) { + this.formatTslTypeArgumentList(node); + } else if (ast.isTslTypeArgument(node)) { + this.formatTslTypeArgument(node); } // ----------------------------------------------------------------------------- // Schemas // ----------------------------------------------------------------------------- - else if (ast.isSdsSchema(node)) { - this.formatSdsSchema(node); - } else if (ast.isSdsColumnList(node)) { - this.formatSdsColumnList(node); - } else if (ast.isSdsColumn(node)) { - this.formatSdsColumn(node); + else if (ast.isTslSchema(node)) { + this.formatTslSchema(node); + } else if (ast.isTslColumnList(node)) { + this.formatTslColumnList(node); + } else if (ast.isTslColumn(node)) { + this.formatTslColumn(node); } } @@ -195,7 +195,7 @@ export class SafeDsFormatter extends AbstractFormatter { // Module // ----------------------------------------------------------------------------- - private formatSdsModule(node: ast.SdsModule): void { + private formatTslModule(node: ast.TslModule): void { const formatter = this.getNodeFormatter(node); const annotations = getAnnotationCalls(node); const name = node.name; @@ -276,7 +276,7 @@ export class SafeDsFormatter extends AbstractFormatter { }); } - private formatSdsImport(node: ast.SdsImport): void { + private formatTslImport(node: ast.TslImport): void { const formatter = this.getNodeFormatter(node); formatter.keyword('from').append(oneSpace()); @@ -284,19 +284,19 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword('import').surround(oneSpace()); } - private formatSdsImportedDeclarationList(node: ast.SdsImportedDeclarationList): void { + private formatTslImportedDeclarationList(node: ast.TslImportedDeclarationList): void { const formatter = this.getNodeFormatter(node); formatter.keywords(',').prepend(noSpace()).append(oneSpace()); } - private formatSdsImportedDeclaration(node: ast.SdsImportedDeclaration): void { + private formatTslImportedDeclaration(node: ast.TslImportedDeclaration): void { const formatter = this.getNodeFormatter(node); formatter.property('alias').prepend(oneSpace()); } - private formatSdsImportedDeclarationAlias(node: ast.SdsImportedDeclarationAlias): void { + private formatTslImportedDeclarationAlias(node: ast.TslImportedDeclarationAlias): void { const formatter = this.getNodeFormatter(node); formatter.keyword('as').append(oneSpace()); @@ -306,7 +306,7 @@ export class SafeDsFormatter extends AbstractFormatter { // Declarations // ----------------------------------------------------------------------------- - private formatSdsAnnotation(node: ast.SdsAnnotation): void { + private formatTslAnnotation(node: ast.TslAnnotation): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -318,7 +318,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.property('constraintList').prepend(oneSpace()); } - private formatSdsAttribute(node: ast.SdsAttribute): void { + private formatTslAttribute(node: ast.TslAttribute): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -334,7 +334,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword(':').prepend(noSpace()).append(oneSpace()); } - private formatSdsClass(node: ast.SdsClass): void { + private formatTslClass(node: ast.TslClass): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -354,14 +354,14 @@ export class SafeDsFormatter extends AbstractFormatter { } } - formatSdsParentTypeList(node: ast.SdsParentTypeList): void { + formatTslParentTypeList(node: ast.TslParentTypeList): void { const formatter = this.getNodeFormatter(node); formatter.keyword('sub').append(oneSpace()); formatter.keywords(',').prepend(noSpace()).append(oneSpace()); } - private formatSdsClassBody(node: ast.SdsClassBody): void { + private formatTslClassBody(node: ast.TslClassBody): void { const formatter = this.getNodeFormatter(node); const members = node.members ?? []; @@ -380,7 +380,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsEnum(node: ast.SdsEnum): void { + private formatTslEnum(node: ast.TslEnum): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -391,7 +391,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.property('body').prepend(oneSpace()); } - private formatSdsEnumBody(node: ast.SdsEnumBody): void { + private formatTslEnumBody(node: ast.TslEnumBody): void { const formatter = this.getNodeFormatter(node); const variants = node.variants ?? []; @@ -410,7 +410,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsEnumVariant(node: ast.SdsEnumVariant): void { + private formatTslEnumVariant(node: ast.TslEnumVariant): void { const formatter = this.getNodeFormatter(node); const annotationCalls = getAnnotationCalls(node); @@ -425,7 +425,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.property('constraintList').prepend(oneSpace()); } - formatSdsFunction(node: ast.SdsFunction): void { + formatTslFunction(node: ast.TslFunction): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -444,7 +444,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.property('constraintList').prepend(oneSpace()); } - private formatSdsPipeline(node: ast.SdsPipeline): void { + private formatTslPipeline(node: ast.TslPipeline): void { const formatter = this.getNodeFormatter(node); formatter.property('annotationCallList').prepend(noSpace()); @@ -457,7 +457,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.node(node.body).prepend(oneSpace()); } - private formatSdsSegment(node: ast.SdsSegment): void { + private formatTslSegment(node: ast.TslSegment): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length === 0) { @@ -484,14 +484,14 @@ export class SafeDsFormatter extends AbstractFormatter { // Annotation calls // ----------------------------------------------------------------------------- - private formatSdsAnnotationCallList(node: ast.SdsAnnotationCallList): void { + private formatTslAnnotationCallList(node: ast.TslAnnotationCallList): void { const formatter = this.getNodeFormatter(node); const annotationCalls = node.annotationCalls ?? []; formatter.nodes(...annotationCalls.slice(1)).prepend(newLine()); } - private formatSdsAnnotationCall(node: ast.SdsAnnotationCall): void { + private formatTslAnnotationCall(node: ast.TslAnnotationCall): void { const formatter = this.getNodeFormatter(node); formatter.keyword('@').append(noSpace()); @@ -502,7 +502,7 @@ export class SafeDsFormatter extends AbstractFormatter { // Constraints // ----------------------------------------------------------------------------- - private formatSdsConstraintList(node: ast.SdsConstraintList) { + private formatTslConstraintList(node: ast.TslConstraintList) { const formatter = this.getNodeFormatter(node); formatter.keyword('where').append(oneSpace()); @@ -522,7 +522,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsParameterBound(node: ast.SdsParameterBound) { + private formatTslParameterBound(node: ast.TslParameterBound) { const formatter = this.getNodeFormatter(node); formatter.property('operator').surround(oneSpace()); @@ -532,7 +532,7 @@ export class SafeDsFormatter extends AbstractFormatter { // Callables, parameters, and results // ----------------------------------------------------------------------------- - private formatSdsParameterList(node: ast.SdsParameterList): void { + private formatTslParameterList(node: ast.TslParameterList): void { const formatter = this.getNodeFormatter(node); const openingParenthesis = formatter.keyword('('); @@ -555,7 +555,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsParameter(node: ast.SdsParameter): void { + private formatTslParameter(node: ast.TslParameter): void { const formatter = this.getNodeFormatter(node); const lastAnnotationCall = last(getAnnotationCalls(node)); @@ -569,7 +569,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword('=').surround(oneSpace()); } - private formatSdsResultList(node: ast.SdsResultList): void { + private formatTslResultList(node: ast.TslResultList): void { const formatter = this.getNodeFormatter(node); formatter.keyword('->').surround(oneSpace()); @@ -594,7 +594,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsResult(node: ast.SdsResult): void { + private formatTslResult(node: ast.TslResult): void { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -608,7 +608,7 @@ export class SafeDsFormatter extends AbstractFormatter { // Statements // ----------------------------------------------------------------------------- - private formatSdsBlock(node: ast.SdsBlock): void { + private formatTslBlock(node: ast.TslBlock): void { const formatter = this.getNodeFormatter(node); const openingBrace = formatter.keyword('{'); const closingBrace = formatter.keyword('}'); @@ -622,33 +622,33 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsAssignment(node: ast.SdsAssignment) { + private formatTslAssignment(node: ast.TslAssignment) { const formatter = this.getNodeFormatter(node); formatter.keyword('=').surround(oneSpace()); formatter.keyword(';').prepend(noSpace()); } - private formatSdsAssigneeList(node: ast.SdsAssigneeList) { + private formatTslAssigneeList(node: ast.TslAssigneeList) { const formatter = this.getNodeFormatter(node); formatter.keywords(',').prepend(noSpace()).append(oneSpace()); } - private formatSdsPlaceholder(node: ast.SdsPlaceholder) { + private formatTslPlaceholder(node: ast.TslPlaceholder) { const formatter = this.getNodeFormatter(node); formatter.keyword('val').append(oneSpace()); } - private formatSdsYield(node: ast.SdsYield) { + private formatTslYield(node: ast.TslYield) { const formatter = this.getNodeFormatter(node); formatter.keyword('yield').append(oneSpace()); formatter.property('result').prepend(oneSpace()); } - private formatSdsExpressionStatement(node: ast.SdsExpressionStatement) { + private formatTslExpressionStatement(node: ast.TslExpressionStatement) { const formatter = this.getNodeFormatter(node); formatter.keyword(';').prepend(noSpace()); @@ -658,45 +658,45 @@ export class SafeDsFormatter extends AbstractFormatter { // Expressions // ----------------------------------------------------------------------------- - private formatSdsBlockLambda(node: ast.SdsBlockLambda): void { + private formatTslBlockLambda(node: ast.TslBlockLambda): void { const formatter = this.getNodeFormatter(node); formatter.property('body').prepend(oneSpace()); } - private formatSdsBlockLambdaResult(node: ast.SdsBlockLambdaResult) { + private formatTslBlockLambdaResult(node: ast.TslBlockLambdaResult) { const formatter = this.getNodeFormatter(node); formatter.keyword('yield').append(oneSpace()); } - private formatSdsExpressionLambda(node: ast.SdsExpressionLambda) { + private formatTslExpressionLambda(node: ast.TslExpressionLambda) { const formatter = this.getNodeFormatter(node); formatter.keyword('->').surround(oneSpace()); } - private formatSdsInfixOperation(node: ast.SdsInfixOperation) { + private formatTslInfixOperation(node: ast.TslInfixOperation) { const formatter = this.getNodeFormatter(node); formatter.property('operator').surround(oneSpace()); } - private formatSdsPrefixOperation(node: ast.SdsPrefixOperation) { + private formatTslPrefixOperation(node: ast.TslPrefixOperation) { const formatter = this.getNodeFormatter(node); formatter.keyword('not').append(oneSpace()); formatter.keyword('-').append(noSpace()); } - private formatSdsCall(node: ast.SdsCall) { + private formatTslCall(node: ast.TslCall) { const formatter = this.getNodeFormatter(node); formatter.keyword('?').surround(noSpace()); formatter.property('argumentList').prepend(noSpace()); } - private formatSdsArgumentList(node: ast.SdsArgumentList): void { + private formatTslArgumentList(node: ast.TslArgumentList): void { const formatter = this.getNodeFormatter(node); const openingParenthesis = formatter.keyword('('); @@ -716,13 +716,13 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsArgument(node: ast.SdsArgument): void { + private formatTslArgument(node: ast.TslArgument): void { const formatter = this.getNodeFormatter(node); formatter.keyword('=').surround(oneSpace()); } - private formatSdsIndexedAccess(node: ast.SdsIndexedAccess) { + private formatTslIndexedAccess(node: ast.TslIndexedAccess) { const formatter = this.getNodeFormatter(node); formatter.keyword('?').surround(noSpace()); @@ -730,14 +730,14 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword(']').prepend(noSpace()); } - private formatSdsMemberAccess(node: ast.SdsMemberAccess) { + private formatTslMemberAccess(node: ast.TslMemberAccess) { const formatter = this.getNodeFormatter(node); formatter.keyword('?').surround(noSpace()); formatter.keyword('.').surround(noSpace()); } - private formatSdsList(node: ast.SdsList) { + private formatTslList(node: ast.TslList) { const formatter = this.getNodeFormatter(node); const openingSquareBracket = formatter.keyword('['); @@ -757,7 +757,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsMap(node: ast.SdsMap) { + private formatTslDictionary(node: ast.TslDictionary) { const formatter = this.getNodeFormatter(node); const openingCurlyBrace = formatter.keyword('{'); @@ -780,38 +780,38 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsMapEntry(node: ast.SdsMapEntry) { + private formatTslDictionaryEntry(node: ast.TslDictionaryEntry) { const formatter = this.getNodeFormatter(node); formatter.keyword(':').prepend(noSpace()).append(oneSpace()); } - private formatSdsParenthesizedExpression(node: ast.SdsParenthesizedExpression): void { + private formatTslParenthesizedExpression(node: ast.TslParenthesizedExpression): void { const formatter = this.getNodeFormatter(node); formatter.keyword('(').append(noSpace()); formatter.keyword(')').prepend(noSpace()); } - private formatSdsTemplateStringStart(node: ast.SdsTemplateStringStart) { + private formatTslTemplateStringStart(node: ast.TslTemplateStringStart) { const formatter = this.getNodeFormatter(node); formatter.node(node).append(oneSpace()); } - private formatSdsTemplateStringInner(node: ast.SdsTemplateStringInner) { + private formatTslTemplateStringInner(node: ast.TslTemplateStringInner) { const formatter = this.getNodeFormatter(node); formatter.node(node).surround(oneSpace()); } - private formatSdsTemplateStringEnd(node: ast.SdsTemplateStringEnd) { + private formatTslTemplateStringEnd(node: ast.TslTemplateStringEnd) { const formatter = this.getNodeFormatter(node); formatter.node(node).prepend(oneSpace()); } - private formatSdsTypeCast(node: ast.SdsTypeCast) { + private formatTslTypeCast(node: ast.TslTypeCast) { const formatter = this.getNodeFormatter(node); formatter.keyword('as').surround(oneSpace()); @@ -823,33 +823,33 @@ export class SafeDsFormatter extends AbstractFormatter { * * @param node The expression to check. */ - private isComplexExpression(node: ast.SdsExpression | undefined): boolean { - return ast.isSdsChainedExpression(node) || ast.isSdsList(node) || ast.isSdsMap(node); + private isComplexExpression(node: ast.TslExpression | undefined): boolean { + return ast.isTslChainedExpression(node) || ast.isTslList(node) || ast.isTslDictionary(node); } // ----------------------------------------------------------------------------- // Types // ----------------------------------------------------------------------------- - private formatSdsMemberType(node: ast.SdsMemberType) { + private formatTslMemberType(node: ast.TslMemberType) { const formatter = this.getNodeFormatter(node); formatter.keyword('.').surround(noSpace()); } - private formatSdsCallableType(node: ast.SdsCallableType) { + private formatTslCallableType(node: ast.TslCallableType) { const formatter = this.getNodeFormatter(node); formatter.keyword('->').surround(oneSpace()); } - private formatSdsLiteralType(node: ast.SdsLiteralType): void { + private formatTslLiteralType(node: ast.TslLiteralType): void { const formatter = this.getNodeFormatter(node); formatter.keyword('literal').append(noSpace()); } - private formatSdsLiteralList(node: ast.SdsLiteralList): void { + private formatTslLiteralList(node: ast.TslLiteralList): void { const formatter = this.getNodeFormatter(node); const literals = node.literals ?? []; @@ -862,20 +862,20 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword('>').prepend(noSpace()); } - private formatSdsNamedType(node: ast.SdsNamedType) { + private formatTslNamedType(node: ast.TslNamedType) { const formatter = this.getNodeFormatter(node); formatter.keyword('?').prepend(noSpace()); formatter.property('typeArgumentList').prepend(noSpace()); } - private formatSdsUnionType(node: ast.SdsUnionType): void { + private formatTslUnionType(node: ast.TslUnionType): void { const formatter = this.getNodeFormatter(node); formatter.keyword('union').append(noSpace()); } - private formatSdsTypeParameterList(node: ast.SdsTypeParameterList): void { + private formatTslTypeParameterList(node: ast.TslTypeParameterList): void { const formatter = this.getNodeFormatter(node); const closingBracket = formatter.keyword('>'); @@ -896,7 +896,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsTypeParameter(node: ast.SdsTypeParameter) { + private formatTslTypeParameter(node: ast.TslTypeParameter) { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -912,7 +912,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword('=').surround(oneSpace()); } - private formatSdsTypeArgumentList(node: ast.SdsTypeArgumentList): void { + private formatTslTypeArgumentList(node: ast.TslTypeArgumentList): void { const formatter = this.getNodeFormatter(node); const typeArguments = node.typeArguments ?? []; @@ -925,7 +925,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.keyword('>').prepend(noSpace()); } - private formatSdsTypeArgument(node: ast.SdsTypeArgument) { + private formatTslTypeArgument(node: ast.TslTypeArgument) { const formatter = this.getNodeFormatter(node); formatter.keyword('=').surround(oneSpace()); @@ -937,18 +937,18 @@ export class SafeDsFormatter extends AbstractFormatter { * * @param node The type to check. */ - private isComplexType(node: ast.SdsType | undefined): boolean { + private isComplexType(node: ast.TslType | undefined): boolean { if (!node) { return false; } - if (ast.isSdsCallableType(node) || ast.isSdsMemberType(node)) { + if (ast.isTslCallableType(node) || ast.isTslMemberType(node)) { return true; - } else if (ast.isSdsLiteralType(node)) { + } else if (ast.isTslLiteralType(node)) { return getLiterals(node).length > 0; - } else if (ast.isSdsNamedType(node)) { + } else if (ast.isTslNamedType(node)) { return getTypeArguments(node.typeArgumentList).length > 0; - } else if (ast.isSdsUnionType(node)) { + } else if (ast.isTslUnionType(node)) { return getTypeArguments(node.typeArgumentList).length > 0; } else { /* c8 ignore next 2 */ @@ -960,7 +960,7 @@ export class SafeDsFormatter extends AbstractFormatter { // Schemas // ----------------------------------------------------------------------------- - private formatSdsSchema(node: ast.SdsSchema) { + private formatTslSchema(node: ast.TslSchema) { const formatter = this.getNodeFormatter(node); if (getAnnotationCalls(node).length > 0) { @@ -971,7 +971,7 @@ export class SafeDsFormatter extends AbstractFormatter { formatter.property('columnList').prepend(oneSpace()); } - private formatSdsColumnList(node: ast.SdsColumnList) { + private formatTslColumnList(node: ast.TslColumnList) { const formatter = this.getNodeFormatter(node); const columns = node.columns ?? []; @@ -985,7 +985,7 @@ export class SafeDsFormatter extends AbstractFormatter { } } - private formatSdsColumn(node: ast.SdsColumn) { + private formatTslColumn(node: ast.TslColumn) { const formatter = this.getNodeFormatter(node); formatter.keyword(':').prepend(noSpace()).append(oneSpace()); diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts index 68ab4a7d..0a005dfd 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-inlay-hint-provider.ts @@ -1,7 +1,7 @@ import { AstNode, DocumentationProvider } from 'langium'; import { InlayHintKind, MarkupContent } from 'vscode-languageserver'; import { createMarkupContent } from '../documentation/safe-ds-comment-provider.js'; -import { isSdsArgument, isSdsBlockLambdaResult, isSdsPlaceholder, isSdsYield } from '../generated/ast.js'; +import { isTslArgument, isTslBlockLambdaResult, isTslPlaceholder, isTslYield } from '../generated/ast.js'; import { Argument } from '../helpers/nodeProperties.js'; import { SafeDsNodeMapper } from '../helpers/safe-ds-node-mapper.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -30,7 +30,7 @@ export class SafeDsInlayHintProvider extends AbstractInlayHintProvider { } /* c8 ignore stop */ - if (isSdsArgument(node) && Argument.isPositional(node)) { + if (isTslArgument(node) && Argument.isPositional(node)) { const parameter = this.nodeMapper.argumentToParameter(node); if (parameter) { acceptor({ @@ -40,7 +40,7 @@ export class SafeDsInlayHintProvider extends AbstractInlayHintProvider { tooltip: createMarkupContent(this.documentationProvider.getDocumentation(parameter)), }); } - } else if (isSdsBlockLambdaResult(node) || isSdsPlaceholder(node) || isSdsYield(node)) { + } else if (isTslBlockLambdaResult(node) || isTslPlaceholder(node) || isTslYield(node)) { const type = this.typeComputer.computeType(node); let tooltip: MarkupContent | undefined = undefined; if (type instanceof NamedType) { diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-node-info-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-node-info-provider.ts index 8d6ca2ce..b6e7415f 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-node-info-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-node-info-provider.ts @@ -1,7 +1,7 @@ import { AstNode } from 'langium'; import { SymbolTag } from 'vscode-languageserver'; import type { SafeDsAnnotations } from '../builtins/safe-ds-annotations.js'; -import { isSdsAnnotatedObject, isSdsAttribute, isSdsFunction, isSdsSegment } from '../generated/ast.js'; +import { isTslAnnotatedObject, isTslAttribute, isTslFunction, isTslSegment } from '../generated/ast.js'; import type { SafeDsServices } from '../safe-ds-module.js'; import { SafeDsTypeComputer } from '../typing/safe-ds-type-computer.js'; @@ -19,9 +19,9 @@ export class SafeDsNodeInfoProvider { * hierarchies. */ getDetails(node: AstNode): string | undefined { - if (isSdsAttribute(node)) { + if (isTslAttribute(node)) { return `: ${this.typeComputer.computeType(node)}`; - } else if (isSdsFunction(node) || isSdsSegment(node)) { + } else if (isTslFunction(node) || isTslSegment(node)) { return this.typeComputer.computeType(node)?.toString(); } else { return undefined; @@ -33,7 +33,7 @@ export class SafeDsNodeInfoProvider { * hierarchies. */ getTags(node: AstNode): SymbolTag[] | undefined { - if (isSdsAnnotatedObject(node) && this.builtinAnnotations.callsDeprecated(node)) { + if (isTslAnnotatedObject(node) && this.builtinAnnotations.callsDeprecated(node)) { return [SymbolTag.Deprecated]; } else { return undefined; diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-node-kind-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-node-kind-provider.ts index 70e7a02e..b41ed191 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-node-kind-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-node-kind-provider.ts @@ -1,23 +1,23 @@ import { AstNode, AstNodeDescription, AstUtils, isAstNode } from 'langium'; import { CompletionItemKind, SymbolKind } from 'vscode-languageserver'; import { - isSdsClass, - isSdsFunction, - SdsAnnotation, - SdsAttribute, - SdsBlockLambdaResult, - SdsClass, - SdsEnum, - SdsEnumVariant, - SdsFunction, - SdsModule, - SdsParameter, - SdsPipeline, - SdsPlaceholder, - SdsResult, - SdsSchema, - SdsSegment, - SdsTypeParameter, + isTslClass, + isTslFunction, + TslAnnotation, + TslAttribute, + TslBlockLambdaResult, + TslClass, + TslEnum, + TslEnumVariant, + TslFunction, + TslModule, + TslParameter, + TslPipeline, + TslPlaceholder, + TslResult, + TslSchema, + TslSegment, + TslTypeParameter, } from '../generated/ast.js'; import { NodeKindProvider } from 'langium/lsp'; @@ -25,46 +25,46 @@ export class SafeDsNodeKindProvider implements NodeKindProvider { getSymbolKind(nodeOrDescription: AstNode | AstNodeDescription): SymbolKind { // The WorkspaceSymbolProvider only passes descriptions, where the node might be undefined const node = this.getNode(nodeOrDescription); - if (isSdsFunction(node) && AstUtils.hasContainerOfType(node, isSdsClass)) { + if (isTslFunction(node) && AstUtils.hasContainerOfType(node, isTslClass)) { return SymbolKind.Method; } const type = this.getNodeType(nodeOrDescription); switch (type) { - case SdsAnnotation: + case TslAnnotation: return SymbolKind.Interface; - case SdsAttribute: + case TslAttribute: return SymbolKind.Property; /* c8 ignore next 2 */ - case SdsBlockLambdaResult: + case TslBlockLambdaResult: return SymbolKind.Variable; - case SdsClass: + case TslClass: return SymbolKind.Class; - case SdsEnum: + case TslEnum: return SymbolKind.Enum; - case SdsEnumVariant: + case TslEnumVariant: return SymbolKind.EnumMember; - case SdsFunction: + case TslFunction: return SymbolKind.Function; - case SdsModule: + case TslModule: return SymbolKind.Package; /* c8 ignore next 2 */ - case SdsParameter: + case TslParameter: return SymbolKind.Variable; - case SdsPipeline: + case TslPipeline: return SymbolKind.Function; /* c8 ignore next 2 */ - case SdsPlaceholder: + case TslPlaceholder: return SymbolKind.Variable; /* c8 ignore next 2 */ - case SdsResult: + case TslResult: return SymbolKind.Variable; - case SdsSchema: + case TslSchema: return SymbolKind.Struct; - case SdsSegment: + case TslSegment: return SymbolKind.Function; /* c8 ignore next 2 */ - case SdsTypeParameter: + case TslTypeParameter: return SymbolKind.TypeParameter; /* c8 ignore next 2 */ default: diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-rename-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-rename-provider.ts index 27447afe..3b75cc52 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-rename-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-rename-provider.ts @@ -11,7 +11,7 @@ import { } from 'langium'; import { Position, RenameParams, TextEdit, WorkspaceEdit } from 'vscode-languageserver'; import { SafeDsServices } from '../safe-ds-module.js'; -import { isSdsImportedDeclaration, isSdsModule } from '../generated/ast.js'; +import { isTslImportedDeclaration, isTslModule } from '../generated/ast.js'; import { getImportedDeclarations } from '../helpers/nodeProperties.js'; import { DefaultRenameProvider } from 'langium/lsp'; @@ -66,12 +66,12 @@ export class SafeDsRenameProvider extends DefaultRenameProvider { // References in imported declaration nodes must always be renamed const sourceNode = this.getAstNode(ref.sourceUri, ref.sourcePath); - if (isSdsImportedDeclaration(sourceNode)) { + if (isTslImportedDeclaration(sourceNode)) { return true; } // Other references must be renamed unless they are imported under an alias - const sourceModule = AstUtils.getContainerOfType(sourceNode, isSdsModule); + const sourceModule = AstUtils.getContainerOfType(sourceNode, isTslModule); if (!sourceModule) { /* c8 ignore next 2 */ return false; diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-semantic-token-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-semantic-token-provider.ts index a35a6bd1..29f98b7e 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-semantic-token-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-semantic-token-provider.ts @@ -3,30 +3,30 @@ import { AstNode, AstUtils } from 'langium'; import { SemanticTokenModifiers, SemanticTokenTypes } from 'vscode-languageserver'; import { SafeDsClasses } from '../builtins/safe-ds-classes.js'; import { - isSdsAnnotation, - isSdsAnnotationCall, - isSdsArgument, - isSdsAttribute, - isSdsClass, - isSdsDeclaration, - isSdsEnum, - isSdsEnumVariant, - isSdsFunction, - isSdsImport, - isSdsImportedDeclaration, - isSdsModule, - isSdsNamedType, - isSdsParameter, - isSdsParameterBound, - isSdsPipeline, - isSdsPlaceholder, - isSdsReference, - isSdsResult, - isSdsSchema, - isSdsSegment, - isSdsTypeArgument, - isSdsTypeParameter, - isSdsYield, + isTslAnnotation, + isTslAnnotationCall, + isTslArgument, + isTslAttribute, + isTslClass, + isTslDeclaration, + isTslEnum, + isTslEnumVariant, + isTslFunction, + isTslImport, + isTslImportedDeclaration, + isTslModule, + isTslNamedType, + isTslParameter, + isTslParameterBound, + isTslPipeline, + isTslPlaceholder, + isTslReference, + isTslResult, + isTslSchema, + isTslSegment, + isTslTypeArgument, + isTslTypeParameter, + isTslYield, } from '../generated/ast.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -40,7 +40,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { } protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void { - if (isSdsAnnotationCall(node)) { + if (isTslAnnotationCall(node)) { acceptor({ node, keyword: '@', @@ -51,7 +51,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { property: 'annotation', type: SemanticTokenTypes.decorator, }); - } else if (isSdsArgument(node)) { + } else if (isTslArgument(node)) { if (node.parameter) { acceptor({ node, @@ -59,7 +59,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { type: SemanticTokenTypes.parameter, }); } - } else if (isSdsDeclaration(node)) { + } else if (isTslDeclaration(node)) { const info = this.computeSemanticTokenInfoForDeclaration(node, [SemanticTokenModifiers.declaration]); if (info) { acceptor({ @@ -68,13 +68,13 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { ...info, }); } - } else if (isSdsImport(node)) { + } else if (isTslImport(node)) { acceptor({ node, property: 'package', type: SemanticTokenTypes.namespace, }); - } else if (isSdsImportedDeclaration(node)) { + } else if (isTslImportedDeclaration(node)) { const info = this.computeSemanticTokenInfoForDeclaration(node.declaration?.ref); if (info) { acceptor({ @@ -83,7 +83,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { ...info, }); } - } else if (isSdsNamedType(node)) { + } else if (isTslNamedType(node)) { const info = this.computeSemanticTokenInfoForDeclaration(node.declaration?.ref); if (info) { acceptor({ @@ -92,13 +92,13 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { ...info, }); } - } else if (isSdsParameterBound(node)) { + } else if (isTslParameterBound(node)) { acceptor({ node, property: 'leftOperand', type: SemanticTokenTypes.parameter, }); - } else if (isSdsReference(node)) { + } else if (isTslReference(node)) { const info = this.computeSemanticTokenInfoForDeclaration(node.target.ref); if (info) { acceptor({ @@ -107,7 +107,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { ...info, }); } - } else if (isSdsTypeArgument(node)) { + } else if (isTslTypeArgument(node)) { if (node.typeParameter) { acceptor({ node, @@ -115,7 +115,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { type: SemanticTokenTypes.typeParameter, }); } - } else if (isSdsYield(node)) { + } else if (isTslYield(node)) { // For lack of a better option, we use the token type for parameters here acceptor({ node, @@ -135,12 +135,12 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { } /* c8 ignore stop */ - if (isSdsAnnotation(node)) { + if (isTslAnnotation(node)) { return { type: SemanticTokenTypes.decorator, modifier: additionalModifiers, }; - } else if (isSdsAttribute(node)) { + } else if (isTslAttribute(node)) { const modifier = [SemanticTokenModifiers.readonly, ...additionalModifiers]; if (node.isStatic) { modifier.push(SemanticTokenModifiers.static); @@ -150,7 +150,7 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { type: SemanticTokenTypes.property, modifier, }; - } else if (isSdsClass(node)) { + } else if (isTslClass(node)) { const isBuiltinClass = this.builtinClasses.isBuiltinClass(node); return { type: SemanticTokenTypes.class, @@ -158,18 +158,18 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { ? [SemanticTokenModifiers.defaultLibrary, ...additionalModifiers] : additionalModifiers, }; - } else if (isSdsEnum(node)) { + } else if (isTslEnum(node)) { return { type: SemanticTokenTypes.enum, modifier: additionalModifiers, }; - } else if (isSdsEnumVariant(node)) { + } else if (isTslEnumVariant(node)) { return { type: SemanticTokenTypes.enumMember, modifier: additionalModifiers, }; - } else if (isSdsFunction(node)) { - if (AstUtils.hasContainerOfType(node, isSdsClass)) { + } else if (isTslFunction(node)) { + if (AstUtils.hasContainerOfType(node, isTslClass)) { return { type: SemanticTokenTypes.method, modifier: node.isStatic @@ -182,43 +182,43 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider { modifier: additionalModifiers, }; } - } else if (isSdsModule(node)) { + } else if (isTslModule(node)) { return { type: SemanticTokenTypes.namespace, modifier: additionalModifiers, }; - } else if (isSdsParameter(node)) { + } else if (isTslParameter(node)) { return { type: SemanticTokenTypes.parameter, modifier: additionalModifiers, }; - } else if (isSdsPipeline(node)) { + } else if (isTslPipeline(node)) { return { type: SemanticTokenTypes.function, modifier: additionalModifiers, }; - } else if (isSdsPlaceholder(node)) { + } else if (isTslPlaceholder(node)) { return { type: SemanticTokenTypes.variable, modifier: [SemanticTokenModifiers.readonly, ...additionalModifiers], }; - } else if (isSdsResult(node)) { + } else if (isTslResult(node)) { return { // For lack of a better option, we use the token type for parameters here type: SemanticTokenTypes.parameter, modifier: additionalModifiers, }; - } else if (isSdsSchema(node)) { + } else if (isTslSchema(node)) { return { type: SemanticTokenTypes.type, modifier: additionalModifiers, }; - } else if (isSdsSegment(node)) { + } else if (isTslSegment(node)) { return { type: SemanticTokenTypes.function, modifier: additionalModifiers, }; - } else if (isSdsTypeParameter(node)) { + } else if (isTslTypeParameter(node)) { return { type: SemanticTokenTypes.typeParameter, modifier: additionalModifiers, diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-signature-help-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-signature-help-provider.ts index cc0505c5..7421fe92 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-signature-help-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-signature-help-provider.ts @@ -15,7 +15,7 @@ import type { SignatureHelpParams, } from 'vscode-languageserver'; import { createMarkupContent } from '../documentation/safe-ds-comment-provider.js'; -import { isSdsAbstractCall, SdsCallable, SdsParameter } from '../generated/ast.js'; +import { isTslAbstractCall, TslCallable, TslParameter } from '../generated/ast.js'; import { getParameters, Parameter } from '../helpers/nodeProperties.js'; import { type SafeDsNodeMapper } from '../helpers/safe-ds-node-mapper.js'; import type { SafeDsServices } from '../safe-ds-module.js'; @@ -61,7 +61,7 @@ export class SafeDsSignatureHelpProvider implements SignatureHelpProvider { * Returns the signature help for the given node at the given offset. */ private getSignature(node: AstNode, offset: number): MaybePromise { - const containingAbstractCall = AstUtils.getContainerOfType(node, isSdsAbstractCall); + const containingAbstractCall = AstUtils.getContainerOfType(node, isTslAbstractCall); if (!containingAbstractCall) { return undefined; } @@ -87,7 +87,7 @@ export class SafeDsSignatureHelpProvider implements SignatureHelpProvider { }; } - private getLabel(callable: SdsCallable): string { + private getLabel(callable: TslCallable): string { const type = this.typeComputer.computeType(callable); if (type instanceof NamedType) { @@ -101,13 +101,13 @@ export class SafeDsSignatureHelpProvider implements SignatureHelpProvider { } } - private getParameterInformation = (parameter: SdsParameter) => { + private getParameterInformation = (parameter: TslParameter) => { return { label: this.getParameterLabel(parameter), }; }; - private getParameterLabel = (parameter: SdsParameter) => { + private getParameterLabel = (parameter: TslParameter) => { const optionality = Parameter.isOptional(parameter) ? '?' : ''; const type = this.typeComputer.computeType(parameter); return `${parameter.name}${optionality}: ${type}`; diff --git a/packages/ttsl-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts b/packages/ttsl-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts index 3b8bf8f3..ef53bd44 100644 --- a/packages/ttsl-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts +++ b/packages/ttsl-lang/src/language/lsp/safe-ds-type-hierarchy-provider.ts @@ -1,13 +1,13 @@ import { type AstNode, AstUtils, CstUtils, type ReferenceDescription, stream, type Stream } from 'langium'; import { type TypeHierarchyItem } from 'vscode-languageserver'; import { - isSdsClass, - isSdsEnum, - isSdsEnumVariant, - isSdsParentTypeList, - SdsClass, - SdsEnum, - SdsEnumVariant, + isTslClass, + isTslEnum, + isTslEnumVariant, + isTslParentTypeList, + TslClass, + TslEnum, + TslEnumVariant, } from '../generated/ast.js'; import type { SafeDsServices } from '../safe-ds-module.js'; import { SafeDsClassHierarchy } from '../typing/safe-ds-class-hierarchy.js'; @@ -38,16 +38,16 @@ export class SafeDsTypeHierarchyProvider extends AbstractTypeHierarchyProvider { } protected override getSupertypes(node: AstNode): TypeHierarchyItem[] | undefined { - if (isSdsClass(node)) { + if (isTslClass(node)) { return this.getSupertypesOfClass(node); - } else if (isSdsEnumVariant(node)) { + } else if (isTslEnumVariant(node)) { return this.getSupertypesOfEnumVariant(node); } else { return undefined; } } - private getSupertypesOfClass(node: SdsClass): TypeHierarchyItem[] | undefined { + private getSupertypesOfClass(node: TslClass): TypeHierarchyItem[] | undefined { const parentClass = this.classHierarchy.streamProperSuperclasses(node).head(); if (!parentClass) { /* c8 ignore next 2 */ @@ -57,8 +57,8 @@ export class SafeDsTypeHierarchyProvider extends AbstractTypeHierarchyProvider { return this.getTypeHierarchyItems(parentClass, AstUtils.getDocument(parentClass)); } - private getSupertypesOfEnumVariant(node: SdsEnumVariant): TypeHierarchyItem[] | undefined { - const containingEnum = AstUtils.getContainerOfType(node, isSdsEnum); + private getSupertypesOfEnumVariant(node: TslEnumVariant): TypeHierarchyItem[] | undefined { + const containingEnum = AstUtils.getContainerOfType(node, isTslEnum); if (!containingEnum) { /* c8 ignore next 2 */ return undefined; @@ -74,9 +74,9 @@ export class SafeDsTypeHierarchyProvider extends AbstractTypeHierarchyProvider { let items: TypeHierarchyItem[]; - if (isSdsClass(node)) { + if (isTslClass(node)) { items = this.getSubtypesOfClass(references); - } else if (isSdsEnum(node)) { + } else if (isTslEnum(node)) { items = this.getSubtypesOfEnum(node); } else { return undefined; @@ -108,11 +108,11 @@ export class SafeDsTypeHierarchyProvider extends AbstractTypeHierarchyProvider { // Only consider the first parent type const targetNode = targetCstNode.astNode; - if (!isSdsParentTypeList(targetNode.$container) || targetNode.$containerIndex !== 0) { + if (!isTslParentTypeList(targetNode.$container) || targetNode.$containerIndex !== 0) { return []; } - const containingClass = AstUtils.getContainerOfType(targetNode, isSdsClass); + const containingClass = AstUtils.getContainerOfType(targetNode, isTslClass); if (!containingClass) { /* c8 ignore next 2 */ return []; @@ -123,7 +123,7 @@ export class SafeDsTypeHierarchyProvider extends AbstractTypeHierarchyProvider { .toArray(); } - private getSubtypesOfEnum(node: SdsEnum): TypeHierarchyItem[] { + private getSubtypesOfEnum(node: TslEnum): TypeHierarchyItem[] { const variants = getEnumVariants(node); const document = AstUtils.getDocument(node); diff --git a/packages/ttsl-lang/src/language/partialEvaluation/model.ts b/packages/ttsl-lang/src/language/partialEvaluation/model.ts index f01bd85b..78964daa 100644 --- a/packages/ttsl-lang/src/language/partialEvaluation/model.ts +++ b/packages/ttsl-lang/src/language/partialEvaluation/model.ts @@ -1,20 +1,20 @@ import { stream } from 'langium'; import { - type SdsAbstractResult, - type SdsBlockLambda, - type SdsBlockLambdaResult, - type SdsCallable, - type SdsDeclaration, - type SdsEnumVariant, - type SdsExpression, - type SdsExpressionLambda, - type SdsParameter, + type TslAbstractResult, + type TslBlockLambda, + type TslBlockLambdaResult, + type TslCallable, + type TslDeclaration, + type TslEnumVariant, + type TslExpression, + type TslExpressionLambda, + type TslParameter, } from '../generated/ast.js'; import { getParameters, streamBlockLambdaResults } from '../helpers/nodeProperties.js'; import { escapeString } from '../grammar/safe-ds-value-converter.js'; -export type ParameterSubstitutions = Map; -export type ResultSubstitutions = Map; +export type ParameterSubstitutions = Map; +export type ResultSubstitutions = Map; /** * A node that has been partially evaluated. @@ -149,16 +149,16 @@ export const isConstant = (node: EvaluatedNode): node is Constant => { // ------------------------------------------------------------------------------------------------- export abstract class EvaluatedCallable extends EvaluatedNode { - abstract readonly callable: SdsCallable | SdsParameter; + abstract readonly callable: TslCallable | TslParameter; abstract readonly substitutionsOnCreation: ParameterSubstitutions; override readonly isFullyEvaluated: boolean = false; } export class BlockLambdaClosure extends EvaluatedCallable { - readonly results: SdsBlockLambdaResult[]; + readonly results: TslBlockLambdaResult[]; constructor( - override readonly callable: SdsBlockLambda, + override readonly callable: TslBlockLambda, override readonly substitutionsOnCreation: ParameterSubstitutions, ) { super(); @@ -184,10 +184,10 @@ export class BlockLambdaClosure extends EvaluatedCallable { } export class ExpressionLambdaClosure extends EvaluatedCallable { - readonly result: SdsExpression; + readonly result: TslExpression; constructor( - override readonly callable: SdsExpressionLambda, + override readonly callable: TslExpressionLambda, override readonly substitutionsOnCreation: ParameterSubstitutions, ) { super(); @@ -212,7 +212,7 @@ export class ExpressionLambdaClosure extends EvaluatedCallable { } } -export class NamedCallable extends EvaluatedCallable { +export class NamedCallable extends EvaluatedCallable { override readonly isFullyEvaluated: boolean = false; override readonly substitutionsOnCreation: ParameterSubstitutions = new Map(); @@ -235,7 +235,7 @@ export class NamedCallable { }; export const substitutionsAreEqual = ( - a: Map | undefined, - b: Map | undefined, + a: Map | undefined, + b: Map | undefined, ): boolean => { if (a?.size !== b?.size) { return false; diff --git a/packages/ttsl-lang/src/language/partialEvaluation/safe-ds-partial-evaluator.ts b/packages/ttsl-lang/src/language/partialEvaluation/safe-ds-partial-evaluator.ts index 0e5963a7..bcacace3 100644 --- a/packages/ttsl-lang/src/language/partialEvaluation/safe-ds-partial-evaluator.ts +++ b/packages/ttsl-lang/src/language/partialEvaluation/safe-ds-partial-evaluator.ts @@ -1,53 +1,53 @@ import { AstNode, AstNodeLocator, AstUtils, WorkspaceCache } from 'langium'; import { isEmpty } from '../../helpers/collections.js'; import { - isSdsArgument, - isSdsAssignee, - isSdsAssignment, - isSdsBlockLambda, - isSdsBoolean, - isSdsCall, - isSdsCallable, - isSdsClass, - isSdsDeclaration, - isSdsEnumVariant, - isSdsExpression, - isSdsExpressionLambda, - isSdsFloat, - isSdsFunction, - isSdsIndexedAccess, - isSdsInfixOperation, - isSdsInt, - isSdsList, - isSdsMap, - isSdsMemberAccess, - isSdsNull, - isSdsParameter, - isSdsParenthesizedExpression, - isSdsPrefixOperation, - isSdsReference, - isSdsResult, - isSdsSegment, - isSdsString, - isSdsTemplateString, - isSdsTemplateStringEnd, - isSdsTemplateStringInner, - isSdsTemplateStringStart, - isSdsTypeCast, - type SdsArgument, - type SdsAssignee, - type SdsCall, - type SdsCallable, - type SdsDeclaration, - type SdsExpression, - type SdsIndexedAccess, - type SdsInfixOperation, - type SdsList, - type SdsMap, - type SdsMemberAccess, - type SdsParameter, - type SdsPrefixOperation, - type SdsTemplateString, + isTslArgument, + isTslAssignee, + isTslAssignment, + isTslBlockLambda, + isTslBoolean, + isTslCall, + isTslCallable, + isTslClass, + isTslDeclaration, + isTslEnumVariant, + isTslExpression, + isTslExpressionLambda, + isTslFloat, + isTslFunction, + isTslIndexedAccess, + isTslInfixOperation, + isTslInt, + isTslList, + isTslDictionary, + isTslMemberAccess, + isTslNull, + isTslParameter, + isTslParenthesizedExpression, + isTslPrefixOperation, + isTslReference, + isTslResult, + isTslSegment, + isTslString, + isTslTemplateString, + isTslTemplateStringEnd, + isTslTemplateStringInner, + isTslTemplateStringStart, + isTslTypeCast, + type TslArgument, + type TslAssignee, + type TslCall, + type TslCallable, + type TslDeclaration, + type TslExpression, + type TslIndexedAccess, + type TslInfixOperation, + type TslList, + type TslDictionary, + type TslMemberAccess, + type TslParameter, + type TslPrefixOperation, + type TslTemplateString, } from '../generated/ast.js'; import { getAbstractResults, getArguments, getParameters } from '../helpers/nodeProperties.js'; import { SafeDsNodeMapper } from '../helpers/safe-ds-node-mapper.js'; @@ -132,11 +132,11 @@ export class SafeDsPartialEvaluator { substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { - if (isSdsAssignee(node)) { + if (isTslAssignee(node)) { return this.evaluateAssignee(node, substitutions, visited); - } else if (isSdsDeclaration(node)) { + } else if (isTslDeclaration(node)) { return this.evaluateDeclaration(node, substitutions, visited); - } else if (isSdsExpression(node)) { + } else if (isTslExpression(node)) { return this.evaluateExpression(node, substitutions, visited); } /* c8 ignore start */ else { return UnknownEvaluatedNode; @@ -144,11 +144,11 @@ export class SafeDsPartialEvaluator { } private evaluateAssignee( - node: SdsAssignee, + node: TslAssignee, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { - const containingAssignment = AstUtils.getContainerOfType(node, isSdsAssignment); + const containingAssignment = AstUtils.getContainerOfType(node, isTslAssignment); if (!containingAssignment) { /* c8 ignore next 2 */ return UnknownEvaluatedNode; @@ -170,78 +170,78 @@ export class SafeDsPartialEvaluator { } private evaluateDeclaration( - node: SdsDeclaration, + node: TslDeclaration, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { - if (isSdsClass(node)) { + if (isTslClass(node)) { return new NamedCallable(node); - } else if (isSdsEnumVariant(node)) { + } else if (isTslEnumVariant(node)) { return new EvaluatedEnumVariant(node, undefined); - } else if (isSdsFunction(node)) { + } else if (isTslFunction(node)) { return new NamedCallable(node); - } else if (isSdsParameter(node)) { + } else if (isTslParameter(node)) { return substitutions.get(node) ?? UnknownEvaluatedNode; - } else if (isSdsResult(node)) { + } else if (isTslResult(node)) { return this.evaluateWithRecursionCheck(this.nodeMapper.resultToYields(node).head(), substitutions, visited); - } else if (isSdsSegment(node)) { + } else if (isTslSegment(node)) { return new NamedCallable(node); } else { return UnknownEvaluatedNode; } } private evaluateExpression( - node: SdsExpression, + node: TslExpression, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { // Base cases - if (isSdsBoolean(node)) { + if (isTslBoolean(node)) { return new BooleanConstant(node.value); - } else if (isSdsFloat(node)) { + } else if (isTslFloat(node)) { return new FloatConstant(node.value); - } else if (isSdsInt(node)) { + } else if (isTslInt(node)) { return new IntConstant(node.value); - } else if (isSdsNull(node)) { + } else if (isTslNull(node)) { return NullConstant; - } else if (isSdsString(node)) { + } else if (isTslString(node)) { return new StringConstant(node.value); - } else if (isSdsTemplateStringStart(node)) { + } else if (isTslTemplateStringStart(node)) { return new StringConstant(node.value); - } else if (isSdsTemplateStringInner(node)) { + } else if (isTslTemplateStringInner(node)) { return new StringConstant(node.value); - } else if (isSdsTemplateStringEnd(node)) { + } else if (isTslTemplateStringEnd(node)) { return new StringConstant(node.value); - } else if (isSdsBlockLambda(node)) { + } else if (isTslBlockLambda(node)) { return new BlockLambdaClosure(node, substitutions); - } else if (isSdsExpressionLambda(node)) { + } else if (isTslExpressionLambda(node)) { return new ExpressionLambdaClosure(node, substitutions); } // Recursive cases - else if (isSdsArgument(node)) { + else if (isTslArgument(node)) { return this.evaluateWithRecursionCheck(node.value, substitutions, visited); - } else if (isSdsCall(node)) { + } else if (isTslCall(node)) { return this.evaluateCall(node, substitutions, visited); - } else if (isSdsIndexedAccess(node)) { + } else if (isTslIndexedAccess(node)) { return this.evaluateIndexedAccess(node, substitutions, visited); - } else if (isSdsInfixOperation(node)) { + } else if (isTslInfixOperation(node)) { return this.evaluateInfixOperation(node, substitutions, visited); - } else if (isSdsList(node)) { + } else if (isTslList(node)) { return this.evaluateList(node, substitutions, visited); - } else if (isSdsMap(node)) { + } else if (isTslDictionary(node)) { return this.evaluateMap(node, substitutions, visited); - } else if (isSdsMemberAccess(node)) { + } else if (isTslMemberAccess(node)) { return this.evaluateMemberAccess(node, substitutions, visited); - } else if (isSdsParenthesizedExpression(node)) { + } else if (isTslParenthesizedExpression(node)) { return this.evaluateWithRecursionCheck(node.expression, substitutions, visited); - } else if (isSdsPrefixOperation(node)) { + } else if (isTslPrefixOperation(node)) { return this.evaluatePrefixOperation(node, substitutions, visited); - } else if (isSdsReference(node)) { + } else if (isTslReference(node)) { return this.evaluateWithRecursionCheck(node.target.ref, substitutions, visited); - } else if (isSdsTemplateString(node)) { + } else if (isTslTemplateString(node)) { return this.evaluateTemplateString(node, substitutions, visited); - } else if (isSdsTypeCast(node)) { + } else if (isTslTypeCast(node)) { return this.evaluateWithRecursionCheck(node.expression, substitutions, visited); } /* c8 ignore start */ else { throw new Error(`Unexpected expression type: ${node.$type}`); @@ -249,7 +249,7 @@ export class SafeDsPartialEvaluator { } private evaluateInfixOperation( - node: SdsInfixOperation, + node: TslInfixOperation, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -347,7 +347,7 @@ export class SafeDsPartialEvaluator { private evaluateOr( evaluatedLeft: EvaluatedNode, - rightOperand: SdsExpression, + rightOperand: TslExpression, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -367,7 +367,7 @@ export class SafeDsPartialEvaluator { private evaluateAnd( evaluatedLeft: EvaluatedNode, - rightOperand: SdsExpression, + rightOperand: TslExpression, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -387,7 +387,7 @@ export class SafeDsPartialEvaluator { private evaluateElvisOperator( evaluatedLeft: EvaluatedNode, - rightOperand: SdsExpression, + rightOperand: TslExpression, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -434,13 +434,13 @@ export class SafeDsPartialEvaluator { return UnknownEvaluatedNode; } - private evaluateList(node: SdsList, substitutions: ParameterSubstitutions, visited: VisitedState[]): EvaluatedNode { + private evaluateList(node: TslList, substitutions: ParameterSubstitutions, visited: VisitedState[]): EvaluatedNode { return new EvaluatedList( node.elements.map((it) => this.evaluateWithRecursionCheck(it, substitutions, visited)), ); } - private evaluateMap(node: SdsMap, substitutions: ParameterSubstitutions, visited: VisitedState[]): EvaluatedNode { + private evaluateMap(node: TslDictionary, substitutions: ParameterSubstitutions, visited: VisitedState[]): EvaluatedNode { return new EvaluatedMap( node.entries.map((it) => { const key = this.evaluateWithRecursionCheck(it.key, substitutions, visited); @@ -451,7 +451,7 @@ export class SafeDsPartialEvaluator { } private evaluatePrefixOperation( - node: SdsPrefixOperation, + node: TslPrefixOperation, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -476,7 +476,7 @@ export class SafeDsPartialEvaluator { } private evaluateTemplateString( - node: SdsTemplateString, + node: TslTemplateString, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -488,7 +488,7 @@ export class SafeDsPartialEvaluator { return UnknownEvaluatedNode; } - private evaluateCall(node: SdsCall, substitutions: ParameterSubstitutions, visited: VisitedState[]): EvaluatedNode { + private evaluateCall(node: TslCall, substitutions: ParameterSubstitutions, visited: VisitedState[]): EvaluatedNode { const receiver = this.evaluateWithRecursionCheck(node.receiver, substitutions, visited).unwrap(); const args = getArguments(node); @@ -511,8 +511,8 @@ export class SafeDsPartialEvaluator { private evaluateEnumVariantCall( receiver: EvaluatedEnumVariant, - args: SdsArgument[], - substitutions: Map, + args: TslArgument[], + substitutions: Map, visited: VisitedState[], ) { // The enum variant has already been instantiated @@ -532,13 +532,13 @@ export class SafeDsPartialEvaluator { } private evaluateCallableCall( - callable: SdsCallable | SdsParameter, - args: SdsArgument[], + callable: TslCallable | TslParameter, + args: TslArgument[], substitutionsOnCreation: ParameterSubstitutions, substitutionsOnCall: ParameterSubstitutions, visited: VisitedState[], ) { - if (!isSdsCallable(callable)) { + if (!isTslCallable(callable)) { /* c8 ignore next 2 */ return UnknownEvaluatedNode; } @@ -551,9 +551,9 @@ export class SafeDsPartialEvaluator { visited, ); - if (isSdsExpressionLambda(callable)) { + if (isTslExpressionLambda(callable)) { return this.evaluateWithRecursionCheck(callable.result, parameterSubstitutionsAfterCall, visited); - } else if (isSdsBlockLambda(callable) || isSdsSegment(callable)) { + } else if (isTslBlockLambda(callable) || isTslSegment(callable)) { return new EvaluatedNamedTuple( new Map( getAbstractResults(callable).map((it) => [ @@ -568,13 +568,13 @@ export class SafeDsPartialEvaluator { } private getParameterSubstitutionsAfterCall( - callable: SdsCallable | SdsParameter | undefined, - args: SdsArgument[], + callable: TslCallable | TslParameter | undefined, + args: TslArgument[], substitutionsOnCreation: ParameterSubstitutions, substitutionsOnCall: ParameterSubstitutions, visited: VisitedState[], ): ParameterSubstitutions { - if (!callable || isSdsParameter(callable)) { + if (!callable || isTslParameter(callable)) { /* c8 ignore next 2 */ return NO_SUBSTITUTIONS; } @@ -609,7 +609,7 @@ export class SafeDsPartialEvaluator { } private evaluateIndexedAccess( - node: SdsIndexedAccess, + node: TslIndexedAccess, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { @@ -631,14 +631,14 @@ export class SafeDsPartialEvaluator { } private evaluateMemberAccess( - node: SdsMemberAccess, + node: TslMemberAccess, substitutions: ParameterSubstitutions, visited: VisitedState[], ): EvaluatedNode { const member = node.member?.target?.ref; if (!member) { return UnknownEvaluatedNode; - } else if (isSdsEnumVariant(member)) { + } else if (isTslEnumVariant(member)) { return this.evaluateWithRecursionCheck(member, substitutions, visited); } @@ -662,7 +662,7 @@ export class SafeDsPartialEvaluator { * Returns the parameter substitutions for the given call. */ computeParameterSubstitutionsForCall( - call: SdsCall | undefined, + call: TslCall | undefined, substitutions: ParameterSubstitutions = NO_SUBSTITUTIONS, ): ParameterSubstitutions { const callable = this.nodeMapper.callToCallable(call); @@ -677,32 +677,32 @@ export class SafeDsPartialEvaluator { /** * Returns whether the given expression can be the value of a constant parameter. */ - canBeValueOfConstantParameter = (node: SdsExpression): boolean => { - if (isSdsBoolean(node) || isSdsFloat(node) || isSdsInt(node) || isSdsNull(node) || isSdsString(node)) { + canBeValueOfConstantParameter = (node: TslExpression): boolean => { + if (isTslBoolean(node) || isTslFloat(node) || isTslInt(node) || isTslNull(node) || isTslString(node)) { return true; - } else if (isSdsCall(node)) { + } else if (isTslCall(node)) { // If some arguments are not provided, we already show an error. return ( this.canBeValueOfConstantParameter(node.receiver) && getArguments(node).every((it) => this.canBeValueOfConstantParameter(it.value)) ); - } else if (isSdsList(node)) { + } else if (isTslList(node)) { return node.elements.every(this.canBeValueOfConstantParameter); - } else if (isSdsMap(node)) { + } else if (isTslDictionary(node)) { return node.entries.every( (it) => this.canBeValueOfConstantParameter(it.key) && this.canBeValueOfConstantParameter(it.value), ); - } else if (isSdsMemberAccess(node)) { + } else if (isTslMemberAccess(node)) { // 1. We cannot allow all member accesses, since we might also access an attribute that has type 'Int', for // example. Thus, type checking does not always show an error, even though we already restrict the // possible types of constant parameters. // 2. If the member cannot be resolved, we already show an error. // 3. If the enum variant has parameters that are not provided, we already show an error. const member = node.member?.target?.ref; - return !member || isSdsEnumVariant(member); - } else if (isSdsPrefixOperation(node)) { + return !member || isTslEnumVariant(member); + } else if (isTslPrefixOperation(node)) { return node.operator === '-' && this.canBeValueOfConstantParameter(node.operand); - } else if (isSdsReference(node)) { + } else if (isTslReference(node)) { // If the reference cannot be resolved, we already show an error. return !node.target.ref; } else { diff --git a/packages/ttsl-lang/src/language/purity/model.ts b/packages/ttsl-lang/src/language/purity/model.ts index af02f49c..4f63298f 100644 --- a/packages/ttsl-lang/src/language/purity/model.ts +++ b/packages/ttsl-lang/src/language/purity/model.ts @@ -1,4 +1,4 @@ -import { isSdsParameter, type SdsParameter } from '../generated/ast.js'; +import { isTslParameter, type TslParameter } from '../generated/ast.js'; import { getQualifiedName } from '../helpers/nodeProperties.js'; /** @@ -35,7 +35,7 @@ export abstract class ImpurityReason { export class FileRead extends ImpurityReason { override isSideEffect = false; - constructor(readonly path: SdsParameter | string | undefined) { + constructor(readonly path: TslParameter | string | undefined) { super(); } @@ -44,7 +44,7 @@ export class FileRead extends ImpurityReason { } override toString(): string { - if (isSdsParameter(this.path)) { + if (isTslParameter(this.path)) { return `File read from ${getQualifiedName(this.path)}`; } else if (typeof this.path === 'string') { return `File read from "${this.path}"`; @@ -67,7 +67,7 @@ export class FileRead extends ImpurityReason { export class FileWrite extends ImpurityReason { override isSideEffect = true; - constructor(readonly path: SdsParameter | string | undefined) { + constructor(readonly path: TslParameter | string | undefined) { super(); } @@ -76,7 +76,7 @@ export class FileWrite extends ImpurityReason { } override toString(): string { - if (isSdsParameter(this.path)) { + if (isTslParameter(this.path)) { return `File write to ${getQualifiedName(this.path)}`; } else if (typeof this.path === 'string') { return `File write to "${this.path}"`; @@ -104,7 +104,7 @@ export class FileWrite extends ImpurityReason { export class PotentiallyImpureParameterCall extends ImpurityReason { override isSideEffect = true; - constructor(readonly parameter: SdsParameter | undefined) { + constructor(readonly parameter: TslParameter | undefined) { super(); } @@ -113,7 +113,7 @@ export class PotentiallyImpureParameterCall extends ImpurityReason { } override toString(): string { - if (isSdsParameter(this.parameter)) { + if (isTslParameter(this.parameter)) { return `Potentially impure call of ${getQualifiedName(this.parameter)}`; } else { return 'Potentially impure call of ?'; diff --git a/packages/ttsl-lang/src/language/purity/safe-ds-purity-computer.ts b/packages/ttsl-lang/src/language/purity/safe-ds-purity-computer.ts index 3fb6b168..3d19733c 100644 --- a/packages/ttsl-lang/src/language/purity/safe-ds-purity-computer.ts +++ b/packages/ttsl-lang/src/language/purity/safe-ds-purity-computer.ts @@ -12,22 +12,22 @@ import { UnknownCallableCall, } from './model.js'; import { - isSdsAnnotation, - isSdsAssignment, - isSdsCallable, - isSdsClass, - isSdsEnumVariant, - isSdsExpressionStatement, - isSdsFunction, - isSdsLambda, - isSdsParameter, - isSdsWildcard, - SdsCall, - SdsCallable, - SdsExpression, - SdsFunction, - SdsParameter, - SdsStatement, + isTslAnnotation, + isTslAssignment, + isTslCallable, + isTslClass, + isTslEnumVariant, + isTslExpressionStatement, + isTslFunction, + isTslLambda, + isTslParameter, + isTslWildcard, + TslCall, + TslCallable, + TslExpression, + TslFunction, + TslParameter, + TslStatement, } from '../generated/ast.js'; import { EvaluatedEnumVariant, ParameterSubstitutions, StringConstant } from '../partialEvaluation/model.js'; import { SafeDsAnnotations } from '../builtins/safe-ds-annotations.js'; @@ -66,7 +66,7 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - isPureCallable(node: SdsCallable | undefined, substitutions = NO_SUBSTITUTIONS): boolean { + isPureCallable(node: TslCallable | undefined, substitutions = NO_SUBSTITUTIONS): boolean { return isEmpty(this.getImpurityReasonsForCallable(node, substitutions)); } @@ -80,7 +80,7 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - isPureExpression(node: SdsExpression | undefined, substitutions = NO_SUBSTITUTIONS): boolean { + isPureExpression(node: TslExpression | undefined, substitutions = NO_SUBSTITUTIONS): boolean { return isEmpty(this.getImpurityReasonsForExpression(node, substitutions)); } @@ -90,16 +90,16 @@ export class SafeDsPurityComputer { * @param node * The parameter to check. */ - isPureParameter(node: SdsParameter | undefined): boolean { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); + isPureParameter(node: TslParameter | undefined): boolean { + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); if ( !containingCallable || - isSdsAnnotation(containingCallable) || - isSdsClass(containingCallable) || - isSdsEnumVariant(containingCallable) + isTslAnnotation(containingCallable) || + isTslClass(containingCallable) || + isTslEnumVariant(containingCallable) ) { return true; - } else if (isSdsFunction(containingCallable)) { + } else if (isTslFunction(containingCallable)) { const expectedImpurityReason = new PotentiallyImpureParameterCall(node); return !this.getImpurityReasons(containingCallable).some((it) => it.equals(expectedImpurityReason)); } else { @@ -117,7 +117,7 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - callableHasSideEffects(node: SdsCallable | undefined, substitutions = NO_SUBSTITUTIONS): boolean { + callableHasSideEffects(node: TslCallable | undefined, substitutions = NO_SUBSTITUTIONS): boolean { return this.getImpurityReasonsForCallable(node, substitutions).some((it) => it.isSideEffect); } @@ -131,7 +131,7 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - expressionHasSideEffects(node: SdsExpression | undefined, substitutions = NO_SUBSTITUTIONS): boolean { + expressionHasSideEffects(node: TslExpression | undefined, substitutions = NO_SUBSTITUTIONS): boolean { return this.getImpurityReasonsForExpression(node, substitutions).some((it) => it.isSideEffect); } @@ -148,13 +148,13 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - statementDoesSomething(node: SdsStatement, substitutions = NO_SUBSTITUTIONS): boolean { - if (isSdsAssignment(node)) { + statementDoesSomething(node: TslStatement, substitutions = NO_SUBSTITUTIONS): boolean { + if (isTslAssignment(node)) { return ( - !getAssignees(node).every(isSdsWildcard) || + !getAssignees(node).every(isTslWildcard) || this.expressionHasSideEffects(node.expression, substitutions) ); - } else if (isSdsExpressionStatement(node)) { + } else if (isTslExpressionStatement(node)) { return this.expressionHasSideEffects(node.expression, substitutions); } else { /* c8 ignore next 2 */ @@ -172,7 +172,7 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - getImpurityReasonsForCallable(node: SdsCallable | undefined, substitutions = NO_SUBSTITUTIONS): ImpurityReason[] { + getImpurityReasonsForCallable(node: TslCallable | undefined, substitutions = NO_SUBSTITUTIONS): ImpurityReason[] { return this.getImpurityReasons(node, substitutions); } @@ -186,10 +186,10 @@ export class SafeDsPurityComputer { * The parameter substitutions to use. These are **not** the argument of a call, but the values of the parameters * of any containing callables, i.e. the context of the node. */ - getImpurityReasonsForStatement(node: SdsStatement | undefined, substitutions = NO_SUBSTITUTIONS): ImpurityReason[] { - if (isSdsAssignment(node)) { + getImpurityReasonsForStatement(node: TslStatement | undefined, substitutions = NO_SUBSTITUTIONS): ImpurityReason[] { + if (isTslAssignment(node)) { return this.getImpurityReasonsForExpression(node.expression, substitutions); - } else if (isSdsExpressionStatement(node)) { + } else if (isTslExpressionStatement(node)) { return this.getImpurityReasonsForExpression(node.expression, substitutions); } else { /* c8 ignore next 2 */ @@ -208,14 +208,14 @@ export class SafeDsPurityComputer { * of any containing callables, i.e. the context of the node. */ getImpurityReasonsForExpression( - node: SdsExpression | undefined, + node: TslExpression | undefined, substitutions = NO_SUBSTITUTIONS, ): ImpurityReason[] { return this.getExecutedCallsInExpression(node).flatMap((it) => this.getImpurityReasons(it, substitutions)); } private getImpurityReasons( - node: SdsCall | SdsCallable | undefined, + node: TslCall | TslCallable | undefined, substitutions = NO_SUBSTITUTIONS, ): ImpurityReason[] { if (!node) { @@ -233,7 +233,7 @@ export class SafeDsPurityComputer { } } - private doGetImpurityReasons(node: SdsCall | SdsCallable, substitutions = NO_SUBSTITUTIONS): ImpurityReason[] { + private doGetImpurityReasons(node: TslCall | TslCallable, substitutions = NO_SUBSTITUTIONS): ImpurityReason[] { const callGraph = this.callGraphComputer.getCallGraph(node, substitutions); const recursionImpurityReason: ImpurityReason[] = []; @@ -244,13 +244,13 @@ export class SafeDsPurityComputer { const otherImpurityReasons = callGraph.streamCalledCallables().flatMap((it) => { if (!it) { return [UnknownCallableCall]; - } else if (isSdsFunction(it)) { + } else if (isTslFunction(it)) { return this.getImpurityReasonsForFunction(it); } else if ( - isSdsParameter(it) && + isTslParameter(it) && // Leads to endless recursion if we don't check this // (see test case "should return the impurity reasons of a parameter call in a function") - !isSdsFunction(AstUtils.getContainerOfType(it, isSdsCallable)) && + !isTslFunction(AstUtils.getContainerOfType(it, isTslCallable)) && !this.isPureParameter(it) ) { return [new PotentiallyImpureParameterCall(it)]; @@ -262,15 +262,15 @@ export class SafeDsPurityComputer { return [...recursionImpurityReason, ...otherImpurityReasons]; } - private getExecutedCallsInExpression(expression: SdsExpression | undefined): SdsCall[] { + private getExecutedCallsInExpression(expression: TslExpression | undefined): TslCall[] { return this.callGraphComputer.getAllContainedCalls(expression).filter((it) => { // Keep only calls that are not contained in a lambda inside the expression - const containingLambda = AstUtils.getContainerOfType(it, isSdsLambda); + const containingLambda = AstUtils.getContainerOfType(it, isTslLambda); return !containingLambda || !isContainedInOrEqual(containingLambda, expression); }); } - private getImpurityReasonsForFunction(node: SdsFunction): Stream { + private getImpurityReasonsForFunction(node: TslFunction): Stream { return this.builtinAnnotations.streamImpurityReasons(node).flatMap((it) => { switch (it.variant) { case this.builtinImpurityReasons.FileReadFromConstantPath: @@ -301,7 +301,7 @@ export class SafeDsPurityComputer { } } - private getParameter(node: SdsFunction, variant: EvaluatedEnumVariant): SdsParameter | undefined { + private getParameter(node: TslFunction, variant: EvaluatedEnumVariant): TslParameter | undefined { const parameterName = variant.getParameterValueByName('parameterName'); if (!(parameterName instanceof StringConstant)) { return undefined; diff --git a/packages/ttsl-lang/src/language/runner/safe-ds-runner.ts b/packages/ttsl-lang/src/language/runner/safe-ds-runner.ts index a1bbab72..c7415333 100644 --- a/packages/ttsl-lang/src/language/runner/safe-ds-runner.ts +++ b/packages/ttsl-lang/src/language/runner/safe-ds-runner.ts @@ -15,7 +15,7 @@ import { BasicSourceMapConsumer, SourceMapConsumer } from 'source-map'; import treeKill from 'tree-kill'; import { SafeDsAnnotations } from '../builtins/safe-ds-annotations.js'; import { SafeDsPythonGenerator } from '../generation/safe-ds-python-generator.js'; -import { isSdsModule } from '../generated/ast.js'; +import { isTslModule } from '../generated/ast.js'; import semver from 'semver'; // Most of the functionality cannot be tested automatically as a functioning runner setup would always be required @@ -300,7 +300,7 @@ export class SafeDsRunner { } } const node = pipelineDocument.parseResult.value; - if (!isSdsModule(node)) { + if (!isTslModule(node)) { return; } // Pipeline / Module name handling @@ -347,15 +347,15 @@ export class SafeDsRunner { for (const generatedDocument of generatedDocuments) { const fsPath = URI.parse(generatedDocument.uri).fsPath; const workspaceRelativeFilePath = path.relative(rootGenerationDir, path.dirname(fsPath)); - const sdsFileName = path.basename(fsPath); - const sdsNoExtFilename = - path.extname(sdsFileName).length > 0 - ? sdsFileName.substring(0, sdsFileName.length - path.extname(sdsFileName).length) + const TslFileName = path.basename(fsPath); + const TslNoExtFilename = + path.extname(TslFileName).length > 0 + ? TslFileName.substring(0, TslFileName.length - path.extname(TslFileName).length) : /* c8 ignore next */ - sdsFileName; + TslFileName; // Put code in map for further use in the extension (e.g. to remap errors) lastGeneratedSources.set( - path.join(workspaceRelativeFilePath, sdsFileName).replaceAll('\\', '/'), + path.join(workspaceRelativeFilePath, TslFileName).replaceAll('\\', '/'), generatedDocument.getText(), ); // Check for sourcemaps after they are already added to the pipeline context @@ -369,16 +369,16 @@ export class SafeDsRunner { codeMap[modulePath] = {}; } // Put code in object for runner - codeMap[modulePath]![sdsNoExtFilename] = generatedDocument.getText(); + codeMap[modulePath]![TslNoExtFilename] = generatedDocument.getText(); } return [codeMap, lastGeneratedSources]; } public getMainModuleName(pipelineDocument: LangiumDocument): string { - if (pipelineDocument.uri.fsPath.endsWith('.sdspipe')) { - return this.generator.sanitizeModuleNameForPython(path.basename(pipelineDocument.uri.fsPath, '.sdspipe')); - } else if (pipelineDocument.uri.fsPath.endsWith('.sdstest')) { - return this.generator.sanitizeModuleNameForPython(path.basename(pipelineDocument.uri.fsPath, '.sdstest')); + if (pipelineDocument.uri.fsPath.endsWith('.Tslpipe')) { + return this.generator.sanitizeModuleNameForPython(path.basename(pipelineDocument.uri.fsPath, '.Tslpipe')); + } else if (pipelineDocument.uri.fsPath.endsWith('.Tsltest')) { + return this.generator.sanitizeModuleNameForPython(path.basename(pipelineDocument.uri.fsPath, '.Tsltest')); } else { return this.generator.sanitizeModuleNameForPython(path.basename(pipelineDocument.uri.fsPath)); } diff --git a/packages/ttsl-lang/src/language/scoping/safe-ds-scope-computation.ts b/packages/ttsl-lang/src/language/scoping/safe-ds-scope-computation.ts index c461c22f..57c60a52 100644 --- a/packages/ttsl-lang/src/language/scoping/safe-ds-scope-computation.ts +++ b/packages/ttsl-lang/src/language/scoping/safe-ds-scope-computation.ts @@ -7,35 +7,35 @@ import { PrecomputedScopes, } from 'langium'; import { - isSdsAnnotation, - isSdsClass, - isSdsDeclaration, - isSdsEnum, - isSdsEnumVariant, - isSdsFunction, - isSdsModule, - isSdsParameter, - isSdsParameterList, - isSdsPipeline, - isSdsSegment, - isSdsTypeParameter, - isSdsTypeParameterList, - SdsClass, - SdsEnum, - SdsEnumVariant, - SdsParameter, - SdsTypeParameter, + isTslAnnotation, + isTslClass, + isTslDeclaration, + isTslEnum, + isTslEnumVariant, + isTslFunction, + isTslModule, + isTslParameter, + isTslParameterList, + isTslPipeline, + isTslSegment, + isTslTypeParameter, + isTslTypeParameterList, + TslClass, + TslEnum, + TslEnumVariant, + TslParameter, + TslTypeParameter, } from '../generated/ast.js'; export class SafeDsScopeComputation extends DefaultScopeComputation { protected override exportNode(node: AstNode, exports: AstNodeDescription[], document: LangiumDocument): void { // Modules, pipelines, and private segments cannot be referenced from other documents - if (isSdsModule(node) || isSdsPipeline(node) || (isSdsSegment(node) && node.visibility === 'private')) { + if (isTslModule(node) || isTslPipeline(node) || (isTslSegment(node) && node.visibility === 'private')) { return; } // Modules that don't state their package don't export anything - const containingModule = AstUtils.getContainerOfType(node, isSdsModule); + const containingModule = AstUtils.getContainerOfType(node, isTslModule); if (!containingModule || !containingModule.name) { return; } @@ -44,22 +44,22 @@ export class SafeDsScopeComputation extends DefaultScopeComputation { } protected override processNode(node: AstNode, document: LangiumDocument, scopes: PrecomputedScopes): void { - if (isSdsClass(node)) { - this.processSdsClass(node, document, scopes); - } else if (isSdsEnum(node)) { - this.processSdsEnum(node, document, scopes); - } else if (isSdsEnumVariant(node)) { - this.processSdsEnumVariant(node, document, scopes); - } else if (isSdsParameter(node)) { - this.processSdsParameter(node, document, scopes); - } else if (isSdsTypeParameter(node)) { - this.processSdsTypeParameter(node, document, scopes); + if (isTslClass(node)) { + this.processTslClass(node, document, scopes); + } else if (isTslEnum(node)) { + this.processTslEnum(node, document, scopes); + } else if (isTslEnumVariant(node)) { + this.processTslEnumVariant(node, document, scopes); + } else if (isTslParameter(node)) { + this.processTslParameter(node, document, scopes); + } else if (isTslTypeParameter(node)) { + this.processTslTypeParameter(node, document, scopes); } else { super.processNode(node, document, scopes); } } - private processSdsClass(node: SdsClass, document: LangiumDocument, scopes: PrecomputedScopes): void { + private processTslClass(node: TslClass, document: LangiumDocument, scopes: PrecomputedScopes): void { const name = this.nameProvider.getName(node); if (!name) { return; @@ -72,13 +72,13 @@ export class SafeDsScopeComputation extends DefaultScopeComputation { this.addToScopesIfKeyIsDefined(scopes, node.constraintList, description); this.addToScopesIfKeyIsDefined(scopes, node.body, description); - const containingDeclaration = AstUtils.getContainerOfType(node.$container, isSdsDeclaration); - if (isSdsModule(containingDeclaration)) { + const containingDeclaration = AstUtils.getContainerOfType(node.$container, isTslDeclaration); + if (isTslModule(containingDeclaration)) { this.addToScopesIfKeyIsDefined(scopes, containingDeclaration, description); } } - private processSdsEnum(node: SdsEnum, document: LangiumDocument, scopes: PrecomputedScopes): void { + private processTslEnum(node: TslEnum, document: LangiumDocument, scopes: PrecomputedScopes): void { const name = this.nameProvider.getName(node); if (!name) { return; @@ -88,13 +88,13 @@ export class SafeDsScopeComputation extends DefaultScopeComputation { this.addToScopesIfKeyIsDefined(scopes, node.body, description); - const containingDeclaration = AstUtils.getContainerOfType(node.$container, isSdsDeclaration); - if (isSdsModule(containingDeclaration)) { + const containingDeclaration = AstUtils.getContainerOfType(node.$container, isTslDeclaration); + if (isTslModule(containingDeclaration)) { this.addToScopesIfKeyIsDefined(scopes, containingDeclaration, description); } } - private processSdsEnumVariant(node: SdsEnumVariant, document: LangiumDocument, scopes: PrecomputedScopes): void { + private processTslEnumVariant(node: TslEnumVariant, document: LangiumDocument, scopes: PrecomputedScopes): void { const name = this.nameProvider.getName(node); if (!name) { /* c8 ignore next 2 */ @@ -107,8 +107,8 @@ export class SafeDsScopeComputation extends DefaultScopeComputation { this.addToScopesIfKeyIsDefined(scopes, node.constraintList, description); } - private processSdsParameter(node: SdsParameter, document: LangiumDocument, scopes: PrecomputedScopes): void { - const containingCallable = AstUtils.getContainerOfType(node, isSdsParameterList)?.$container; + private processTslParameter(node: TslParameter, document: LangiumDocument, scopes: PrecomputedScopes): void { + const containingCallable = AstUtils.getContainerOfType(node, isTslParameterList)?.$container; if (!containingCallable) { /* c8 ignore next 2 */ return; @@ -122,25 +122,25 @@ export class SafeDsScopeComputation extends DefaultScopeComputation { const description = this.descriptions.createDescription(node, name, document); - if (isSdsAnnotation(containingCallable)) { + if (isTslAnnotation(containingCallable)) { this.addToScopesIfKeyIsDefined(scopes, containingCallable.constraintList, description); - } else if (isSdsClass(containingCallable)) { + } else if (isTslClass(containingCallable)) { this.addToScopesIfKeyIsDefined(scopes, containingCallable.constraintList, description); - } else if (isSdsEnumVariant(containingCallable)) { + } else if (isTslEnumVariant(containingCallable)) { this.addToScopesIfKeyIsDefined(scopes, containingCallable.constraintList, description); - } else if (isSdsFunction(containingCallable)) { + } else if (isTslFunction(containingCallable)) { this.addToScopesIfKeyIsDefined(scopes, containingCallable.constraintList, description); - } else if (isSdsSegment(containingCallable)) { + } else if (isTslSegment(containingCallable)) { this.addToScopesIfKeyIsDefined(scopes, containingCallable.constraintList, description); } } - private processSdsTypeParameter( - node: SdsTypeParameter, + private processTslTypeParameter( + node: TslTypeParameter, document: LangiumDocument, scopes: PrecomputedScopes, ): void { - const containingDeclaration = AstUtils.getContainerOfType(node, isSdsTypeParameterList)?.$container; + const containingDeclaration = AstUtils.getContainerOfType(node, isTslTypeParameterList)?.$container; if (!containingDeclaration) { /* c8 ignore next 2 */ return; @@ -154,11 +154,11 @@ export class SafeDsScopeComputation extends DefaultScopeComputation { const description = this.descriptions.createDescription(node, name, document); - if (isSdsClass(containingDeclaration)) { + if (isTslClass(containingDeclaration)) { this.addToScopesIfKeyIsDefined(scopes, containingDeclaration.parameterList, description); this.addToScopesIfKeyIsDefined(scopes, containingDeclaration.parentTypeList, description); this.addToScopesIfKeyIsDefined(scopes, containingDeclaration.body, description); - } else if (isSdsFunction(containingDeclaration)) { + } else if (isTslFunction(containingDeclaration)) { this.addToScopesIfKeyIsDefined(scopes, containingDeclaration.parameterList, description); this.addToScopesIfKeyIsDefined(scopes, containingDeclaration.resultList, description); } diff --git a/packages/ttsl-lang/src/language/scoping/safe-ds-scope-provider.ts b/packages/ttsl-lang/src/language/scoping/safe-ds-scope-provider.ts index 893402d3..ff1cffe9 100644 --- a/packages/ttsl-lang/src/language/scoping/safe-ds-scope-provider.ts +++ b/packages/ttsl-lang/src/language/scoping/safe-ds-scope-provider.ts @@ -10,49 +10,49 @@ import { WorkspaceCache, } from 'langium'; import { - isSdsAbstractCall, - isSdsAnnotationCall, - isSdsArgument, - isSdsAssignment, - isSdsBlock, - isSdsCall, - isSdsCallable, - isSdsClass, - isSdsEnum, - isSdsImportedDeclaration, - isSdsLambda, - isSdsMemberAccess, - isSdsMemberType, - isSdsModule, - isSdsNamedType, - isSdsNamedTypeDeclaration, - isSdsParameter, - isSdsPlaceholder, - isSdsQualifiedImport, - isSdsReference, - isSdsSegment, - isSdsStatement, - isSdsTypeArgument, - isSdsTypeParameter, - isSdsWildcardImport, - isSdsYield, - SdsAnnotation, - SdsArgument, - type SdsCallable, - SdsDeclaration, - SdsExpression, - SdsImportedDeclaration, - SdsMemberAccess, - SdsMemberType, - SdsNamedType, - SdsNamedTypeDeclaration, - type SdsParameter, - SdsPlaceholder, - SdsReference, - SdsStatement, - SdsType, - SdsTypeArgument, - SdsYield, + isTslAbstractCall, + isTslAnnotationCall, + isTslArgument, + isTslAssignment, + isTslBlock, + isTslCall, + isTslCallable, + isTslClass, + isTslEnum, + isTslImportedDeclaration, + isTslLambda, + isTslMemberAccess, + isTslMemberType, + isTslModule, + isTslNamedType, + isTslNamedTypeDeclaration, + isTslParameter, + isTslPlaceholder, + isTslQualifiedImport, + isTslReference, + isTslSegment, + isTslStatement, + isTslTypeArgument, + isTslTypeParameter, + isTslWildcardImport, + isTslYield, + TslAnnotation, + TslArgument, + type TslCallable, + TslDeclaration, + TslExpression, + TslImportedDeclaration, + TslMemberAccess, + TslMemberType, + TslNamedType, + TslNamedTypeDeclaration, + type TslParameter, + TslPlaceholder, + TslReference, + TslStatement, + TslType, + TslTypeArgument, + TslYield, } from '../generated/ast.js'; import { isContainedInOrEqual } from '../helpers/astUtils.js'; import { @@ -101,27 +101,27 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { override getScope(context: ReferenceInfo): Scope { const node = context.container; - if (isSdsAnnotationCall(node) && context.property === 'annotation') { + if (isTslAnnotationCall(node) && context.property === 'annotation') { return this.getScopeForAnnotationCallAnnotation(context); - } else if (isSdsArgument(node) && context.property === 'parameter') { + } else if (isTslArgument(node) && context.property === 'parameter') { return this.getScopeForArgumentParameter(node); - } else if (isSdsImportedDeclaration(node) && context.property === 'declaration') { + } else if (isTslImportedDeclaration(node) && context.property === 'declaration') { return this.getScopeForImportedDeclarationDeclaration(node); - } else if (isSdsNamedType(node) && context.property === 'declaration') { - if (isSdsMemberType(node.$container) && node.$containerProperty === 'member') { + } else if (isTslNamedType(node) && context.property === 'declaration') { + if (isTslMemberType(node.$container) && node.$containerProperty === 'member') { return this.getScopeForMemberTypeMember(node.$container); } else { return this.getScopeForNamedTypeDeclaration(node, context); } - } else if (isSdsReference(node) && context.property === 'target') { - if (isSdsMemberAccess(node.$container) && node.$containerProperty === 'member') { + } else if (isTslReference(node) && context.property === 'target') { + if (isTslMemberAccess(node.$container) && node.$containerProperty === 'member') { return this.getScopeForMemberAccessMember(node.$container); } else { return this.getScopeForReferenceTarget(node, context); } - } else if (isSdsTypeArgument(node) && context.property === 'typeParameter') { + } else if (isTslTypeArgument(node) && context.property === 'typeParameter') { return this.getScopeForTypeArgumentTypeParameter(node); - } else if (isSdsYield(node) && context.property === 'result') { + } else if (isTslYield(node) && context.property === 'result') { return this.getScopeForYieldResult(node); } else { return super.getScope(context); @@ -129,11 +129,11 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } private getScopeForAnnotationCallAnnotation(context: ReferenceInfo) { - return this.coreDeclarations(SdsAnnotation, super.getScope(context)); + return this.coreDeclarations(TslAnnotation, super.getScope(context)); } - private getScopeForArgumentParameter(node: SdsArgument): Scope { - const containingAbstractCall = AstUtils.getContainerOfType(node, isSdsAbstractCall); + private getScopeForArgumentParameter(node: TslArgument): Scope { + const containingAbstractCall = AstUtils.getContainerOfType(node, isTslAbstractCall); const callable = this.nodeMapper.callToCallable(containingAbstractCall); if (!callable) { return EMPTY_SCOPE; @@ -143,32 +143,32 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { return this.createScopeForNodes(parameters); } - private getScopeForImportedDeclarationDeclaration(node: SdsImportedDeclaration): Scope { + private getScopeForImportedDeclarationDeclaration(node: TslImportedDeclaration): Scope { const ownPackageName = getPackageName(node); - const containingQualifiedImport = AstUtils.getContainerOfType(node, isSdsQualifiedImport); + const containingQualifiedImport = AstUtils.getContainerOfType(node, isTslQualifiedImport); if (!containingQualifiedImport) { /* c8 ignore next 2 */ return EMPTY_SCOPE; } const declarationsInPackage = this.packageManager.getDeclarationsInPackage(containingQualifiedImport.package, { - nodeType: SdsDeclaration, + nodeType: TslDeclaration, hideInternal: containingQualifiedImport.package !== ownPackageName, }); return this.createScope(declarationsInPackage); } - private getScopeForMemberTypeMember(node: SdsMemberType): Scope { + private getScopeForMemberTypeMember(node: TslMemberType): Scope { const declaration = this.getUniqueReferencedDeclarationForType(node.receiver); if (!declaration) { return EMPTY_SCOPE; } - if (isSdsClass(declaration)) { + if (isTslClass(declaration)) { const members = declaration.body?.members ?? []; - return this.createScopeForNodes(members.filter(isSdsNamedTypeDeclaration)); - } else if (isSdsEnum(declaration)) { + return this.createScopeForNodes(members.filter(isTslNamedTypeDeclaration)); + } else if (isTslEnum(declaration)) { const variants = declaration.body?.variants ?? []; return this.createScopeForNodes(variants); } else { @@ -183,22 +183,22 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { * @param node The type to get the referenced declaration for. * @returns The referenced declaration or undefined. */ - private getUniqueReferencedDeclarationForType(node: SdsType): SdsNamedTypeDeclaration | undefined { - if (isSdsNamedType(node)) { + private getUniqueReferencedDeclarationForType(node: TslType): TslNamedTypeDeclaration | undefined { + if (isTslNamedType(node)) { return node.declaration?.ref; - } else if (isSdsMemberType(node)) { + } else if (isTslMemberType(node)) { return node.member?.declaration?.ref; } else { return undefined; } } - private getScopeForNamedTypeDeclaration(node: SdsNamedType, context: ReferenceInfo): Scope { + private getScopeForNamedTypeDeclaration(node: TslNamedType, context: ReferenceInfo): Scope { // Default scope - let currentScope = this.coreDeclarations(SdsNamedTypeDeclaration, super.getScope(context)); + let currentScope = this.coreDeclarations(TslNamedTypeDeclaration, super.getScope(context)); // Type parameters (up to the containing type parameter) - const containingTypeParameter = AstUtils.getContainerOfType(node, isSdsTypeParameter); + const containingTypeParameter = AstUtils.getContainerOfType(node, isTslTypeParameter); if (containingTypeParameter) { const allTypeParameters = getTypeParameters(containingTypeParameter?.$container); const priorTypeParameters = allTypeParameters.slice(0, containingTypeParameter.$containerIndex); @@ -208,21 +208,21 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { return currentScope; } - private getScopeForMemberAccessMember(node: SdsMemberAccess): Scope { + private getScopeForMemberAccessMember(node: TslMemberAccess): Scope { // Static access const declaration = this.getUniqueReferencedDeclarationForExpression(node.receiver); - if (isSdsClass(declaration)) { + if (isTslClass(declaration)) { const ownStaticMembers = getClassMembers(declaration).filter(isStatic); const superclassStaticMembers = this.classHierarchy.streamSuperclassMembers(declaration).filter(isStatic); return this.createScopeForNodes(ownStaticMembers, this.createScopeForNodes(superclassStaticMembers)); - } else if (isSdsEnum(declaration)) { + } else if (isTslEnum(declaration)) { return this.createScopeForNodes(getEnumVariants(declaration)); } // Call results let resultScope = EMPTY_SCOPE; - if (isSdsCall(node.receiver)) { + if (isTslCall(node.receiver)) { const callable = this.nodeMapper.callToCallable(node.receiver); const results = getAbstractResults(callable); @@ -268,19 +268,19 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { * @param node The expression to get the referenced declaration for. * @returns The referenced declaration or undefined. */ - private getUniqueReferencedDeclarationForExpression(node: SdsExpression): SdsDeclaration | undefined { - if (isSdsReference(node)) { + private getUniqueReferencedDeclarationForExpression(node: TslExpression): TslDeclaration | undefined { + if (isTslReference(node)) { return node.target.ref; - } else if (isSdsMemberAccess(node)) { + } else if (isTslMemberAccess(node)) { return node.member?.target?.ref; } else { return undefined; } } - private getScopeForReferenceTarget(node: SdsReference, context: ReferenceInfo): Scope { + private getScopeForReferenceTarget(node: TslReference, context: ReferenceInfo): Scope { // Declarations in other files - let currentScope = this.getGlobalScope(SdsDeclaration, context); + let currentScope = this.getGlobalScope(TslDeclaration, context); // Declarations in this file currentScope = this.globalDeclarationsInSameFile(node, currentScope); @@ -292,7 +292,7 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { currentScope = this.localDeclarations(node, currentScope); // Core declarations - return this.coreDeclarations(SdsDeclaration, currentScope); + return this.coreDeclarations(TslDeclaration, currentScope); } private containingDeclarations(node: AstNode, outerScope: Scope): Scope { @@ -300,7 +300,7 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { // Cannot reference the target of an annotation call from inside the annotation call let start: AstNode | undefined; - const containingAnnotationCall = AstUtils.getContainerOfType(node, isSdsAnnotationCall); + const containingAnnotationCall = AstUtils.getContainerOfType(node, isTslAnnotationCall); if (containingAnnotationCall) { start = getAnnotationCallTarget(containingAnnotationCall)?.$container; } else { @@ -308,17 +308,17 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } // Only containing classes, enums, and enum variants can be referenced - let current = AstUtils.getContainerOfType(start, isSdsNamedTypeDeclaration); + let current = AstUtils.getContainerOfType(start, isTslNamedTypeDeclaration); while (current) { result.push(current); - current = AstUtils.getContainerOfType(current.$container, isSdsNamedTypeDeclaration); + current = AstUtils.getContainerOfType(current.$container, isTslNamedTypeDeclaration); } return this.createScopeForNodes(result, outerScope); } private globalDeclarationsInSameFile(node: AstNode, outerScope: Scope): Scope { - const module = AstUtils.getContainerOfType(node, isSdsModule); + const module = AstUtils.getContainerOfType(node, isTslModule); if (!module) { /* c8 ignore next 2 */ return outerScope; @@ -334,12 +334,12 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } private localDeclarations(node: AstNode, outerScope: Scope): Scope { - const containingCallable = AstUtils.getContainerOfType(node.$container, isSdsCallable); + const containingCallable = AstUtils.getContainerOfType(node.$container, isTslCallable); // Parameters (up to the containing parameter) - const containingParameter = AstUtils.getContainerOfType(node, isSdsParameter); + const containingParameter = AstUtils.getContainerOfType(node, isTslParameter); - let parameters: Iterable; + let parameters: Iterable; if (containingCallable && containingParameter) { parameters = this.parametersUpToParameter(containingCallable, containingParameter); } else { @@ -347,9 +347,9 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } // Placeholders up to the containing statement - const containingStatement = AstUtils.getContainerOfType(node.$container, isSdsStatement); + const containingStatement = AstUtils.getContainerOfType(node.$container, isTslStatement); - let placeholders: Iterable; + let placeholders: Iterable; if (!containingCallable || isContainedInOrEqual(containingStatement, containingCallable)) { placeholders = this.placeholdersUpToStatement(containingStatement); } else { @@ -361,7 +361,7 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { const localDeclarations = [...parameters, ...placeholders]; // Lambdas can be nested - if (isSdsLambda(containingCallable)) { + if (isTslLambda(containingCallable)) { return this.createScopeForNodes(localDeclarations, this.localDeclarations(containingCallable, outerScope)); } else { return this.createScopeForNodes(localDeclarations, outerScope); @@ -369,9 +369,9 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } private *parametersUpToParameter( - callable: SdsCallable, - parameter: SdsParameter, - ): Generator { + callable: TslCallable, + parameter: TslParameter, + ): Generator { for (const current of getParameters(callable)) { if (current === parameter) { return; @@ -382,33 +382,33 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } private *placeholdersUpToStatement( - statement: SdsStatement | undefined, - ): Generator { + statement: TslStatement | undefined, + ): Generator { if (!statement) { return; } - const containingBlock = AstUtils.getContainerOfType(statement, isSdsBlock); + const containingBlock = AstUtils.getContainerOfType(statement, isTslBlock); for (const current of getStatements(containingBlock)) { if (current === statement) { return; } - if (isSdsAssignment(current)) { - yield* getAssignees(current).filter(isSdsPlaceholder); + if (isTslAssignment(current)) { + yield* getAssignees(current).filter(isTslPlaceholder); } } } - private getScopeForTypeArgumentTypeParameter(node: SdsTypeArgument): Scope { - const containingNamedType = AstUtils.getContainerOfType(node, isSdsNamedType); + private getScopeForTypeArgumentTypeParameter(node: TslTypeArgument): Scope { + const containingNamedType = AstUtils.getContainerOfType(node, isTslNamedType); if (!containingNamedType) { /* c8 ignore next 2 */ return EMPTY_SCOPE; } const namedTypeDeclaration = containingNamedType.declaration?.ref; - if (isSdsClass(namedTypeDeclaration)) { + if (isTslClass(namedTypeDeclaration)) { const typeParameters = getTypeParameters(namedTypeDeclaration.typeParameterList); return this.createScopeForNodes(typeParameters); } else { @@ -416,8 +416,8 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } } - private getScopeForYieldResult(node: SdsYield): Scope { - const containingSegment = AstUtils.getContainerOfType(node, isSdsSegment); + private getScopeForYieldResult(node: TslYield): Scope { + const containingSegment = AstUtils.getContainerOfType(node, isTslSegment); if (!containingSegment) { return EMPTY_SCOPE; } @@ -465,12 +465,12 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { } private explicitlyImportedDeclarations(referenceType: string, node: AstNode): AstNodeDescription[] { - const containingModule = AstUtils.getContainerOfType(node, isSdsModule); + const containingModule = AstUtils.getContainerOfType(node, isTslModule); const imports = getImports(containingModule); const result: AstNodeDescription[] = []; for (const imp of imports) { - if (isSdsQualifiedImport(imp)) { + if (isTslQualifiedImport(imp)) { for (const importedDeclaration of getImportedDeclarations(imp)) { const description = importedDeclaration.declaration?.$nodeDescription; if (!description || !this.astReflection.isSubtype(description.type, referenceType)) { @@ -483,7 +483,7 @@ export class SafeDsScopeProvider extends DefaultScopeProvider { result.push(description); } } - } else if (isSdsWildcardImport(imp)) { + } else if (isTslWildcardImport(imp)) { const declarationsInPackage = this.packageManager.getDeclarationsInPackage(imp.package, { nodeType: referenceType, hideInternal: true, diff --git a/packages/ttsl-lang/src/language/typing/model.ts b/packages/ttsl-lang/src/language/typing/model.ts index 7bd4f3f8..bf135e6f 100644 --- a/packages/ttsl-lang/src/language/typing/model.ts +++ b/packages/ttsl-lang/src/language/typing/model.ts @@ -1,14 +1,14 @@ import { isEmpty } from '../../helpers/collections.js'; import { - isSdsEnum, - SdsAbstractResult, - SdsCallable, - SdsClass, - SdsDeclaration, - SdsEnum, - SdsEnumVariant, - SdsParameter, - SdsTypeParameter, + isTslEnum, + TslAbstractResult, + TslCallable, + TslClass, + TslDeclaration, + TslEnum, + TslEnumVariant, + TslParameter, + TslTypeParameter, } from '../generated/ast.js'; import { getTypeParameters, Parameter } from '../helpers/nodeProperties.js'; import { Constant, NullConstant } from '../partialEvaluation/model.js'; @@ -18,7 +18,7 @@ import { SafeDsServices } from '../safe-ds-module.js'; import { SafeDsTypeFactory } from './safe-ds-type-factory.js'; import { SafeDsTypeChecker } from './safe-ds-type-checker.js'; -export type TypeParameterSubstitutions = Map; +export type TypeParameterSubstitutions = Map; /** * The type of an AST node. @@ -71,10 +71,10 @@ export class CallableType extends Type { constructor( services: SafeDsServices, - readonly callable: SdsCallable, - readonly parameter: SdsParameter | undefined, - readonly inputType: NamedTupleType, - readonly outputType: NamedTupleType, + readonly callable: TslCallable, + readonly parameter: TslParameter | undefined, + readonly inputType: NamedTupleType, + readonly outputType: NamedTupleType, ) { super(); @@ -232,7 +232,7 @@ export class LiteralType extends Type { } } -export class NamedTupleType extends Type { +export class NamedTupleType extends Type { private readonly factory: SafeDsTypeFactory; readonly entries: NamedTupleEntry[]; @@ -315,7 +315,7 @@ export class NamedTupleType extends Type { } } -export class NamedTupleEntry { +export class NamedTupleEntry { constructor( readonly declaration: T | undefined, readonly name: string, @@ -352,7 +352,7 @@ export class NamedTupleEntry { } } -export abstract class NamedType extends Type { +export abstract class NamedType extends Type { protected constructor(readonly declaration: T) { super(); } @@ -372,11 +372,11 @@ export abstract class NamedType extends Type { abstract override withExplicitNullability(isExplicitlyNullable: boolean): NamedType; } -export class ClassType extends NamedType { +export class ClassType extends NamedType { private _isFullySubstituted: boolean | undefined; constructor( - declaration: SdsClass, + declaration: TslClass, readonly substitutions: TypeParameterSubstitutions, override readonly isExplicitlyNullable: boolean, ) { @@ -456,11 +456,11 @@ export class ClassType extends NamedType { } } -export class EnumType extends NamedType { +export class EnumType extends NamedType { override readonly isFullySubstituted = true; constructor( - declaration: SdsEnum, + declaration: TslEnum, override readonly isExplicitlyNullable: boolean, ) { super(declaration); @@ -489,11 +489,11 @@ export class EnumType extends NamedType { } } -export class EnumVariantType extends NamedType { +export class EnumVariantType extends NamedType { override readonly isFullySubstituted = true; constructor( - declaration: SdsEnumVariant, + declaration: TslEnumVariant, override readonly isExplicitlyNullable: boolean, ) { super(declaration); @@ -514,7 +514,7 @@ export class EnumVariantType extends NamedType { } override toString(): string { - const containingEnum = AstUtils.getContainerOfType(this.declaration, isSdsEnum); + const containingEnum = AstUtils.getContainerOfType(this.declaration, isTslEnum); if (containingEnum) { return `${containingEnum.name}.${super.toString()}`; } else { @@ -532,11 +532,11 @@ export class EnumVariantType extends NamedType { } } -export class TypeParameterType extends NamedType { +export class TypeParameterType extends NamedType { override readonly isFullySubstituted = false; constructor( - declaration: SdsTypeParameter, + declaration: TslTypeParameter, override readonly isExplicitlyNullable: boolean, ) { super(declaration); @@ -584,7 +584,7 @@ export class StaticType extends Type { constructor( services: SafeDsServices, - readonly instanceType: NamedType, + readonly instanceType: NamedType, ) { super(); @@ -809,8 +809,8 @@ export const UnknownType = new UnknownTypeClass(); // ------------------------------------------------------------------------------------------------- const substitutionsAreEqual = ( - a: Map | undefined, - b: Map | undefined, + a: Map | undefined, + b: Map | undefined, ): boolean => { if (a?.size !== b?.size) { return false; diff --git a/packages/ttsl-lang/src/language/typing/safe-ds-class-hierarchy.ts b/packages/ttsl-lang/src/language/typing/safe-ds-class-hierarchy.ts index 1dca6992..925944b0 100644 --- a/packages/ttsl-lang/src/language/typing/safe-ds-class-hierarchy.ts +++ b/packages/ttsl-lang/src/language/typing/safe-ds-class-hierarchy.ts @@ -1,6 +1,6 @@ import { AstUtils, EMPTY_STREAM, stream, Stream } from 'langium'; import { SafeDsClasses } from '../builtins/safe-ds-classes.js'; -import { isSdsClass, isSdsNamedType, SdsClass, type SdsClassMember } from '../generated/ast.js'; +import { isTslClass, isTslNamedType, TslClass, type TslClassMember } from '../generated/ast.js'; import { getClassMembers, getParentTypes, isStatic } from '../helpers/nodeProperties.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -15,7 +15,7 @@ export class SafeDsClassHierarchy { * Returns `true` if the given node is equal to or a subclass of the given other node. If one of the nodes is * `undefined`, `false` is returned. */ - isEqualToOrSubclassOf(node: SdsClass | undefined, other: SdsClass | undefined): boolean { + isEqualToOrSubclassOf(node: TslClass | undefined, other: TslClass | undefined): boolean { if (!node || !other) { return false; } @@ -33,7 +33,7 @@ export class SafeDsClassHierarchy { * ancestors and so on. The class itself is not included in the stream unless there is a cycle in the inheritance * hierarchy. */ - streamProperSuperclasses(node: SdsClass | undefined): Stream { + streamProperSuperclasses(node: TslClass | undefined): Stream { if (!node) { return EMPTY_STREAM; } @@ -41,8 +41,8 @@ export class SafeDsClassHierarchy { return stream(this.properSuperclassesGenerator(node)); } - private *properSuperclassesGenerator(node: SdsClass): Generator { - const visited = new Set(); + private *properSuperclassesGenerator(node: TslClass): Generator { + const visited = new Set(); let current = this.parentClass(node); while (current && !visited.has(current)) { yield current; @@ -56,7 +56,7 @@ export class SafeDsClassHierarchy { } } - streamSuperclassMembers(node: SdsClass | undefined): Stream { + streamSuperclassMembers(node: TslClass | undefined): Stream { if (!node) { return EMPTY_STREAM; } @@ -68,11 +68,11 @@ export class SafeDsClassHierarchy { * Returns the parent class of the given class, or undefined if there is no parent class. Only the first parent * type is considered, i.e. multiple inheritance is not supported. */ - private parentClass(node: SdsClass | undefined): SdsClass | undefined { + private parentClass(node: TslClass | undefined): TslClass | undefined { const [firstParentType] = getParentTypes(node); - if (isSdsNamedType(firstParentType)) { + if (isTslNamedType(firstParentType)) { const declaration = firstParentType.declaration?.ref; - if (isSdsClass(declaration)) { + if (isTslClass(declaration)) { return declaration; } } @@ -84,14 +84,14 @@ export class SafeDsClassHierarchy { * Returns the member that is overridden by the given member, or `undefined` if the member does not override * anything. */ - getOverriddenMember(node: SdsClassMember | undefined): SdsClassMember | undefined { + getOverriddenMember(node: TslClassMember | undefined): TslClassMember | undefined { // Static members cannot override anything if (!node || isStatic(node)) { return undefined; } // Don't consider members with the same name as a previous member - const containingClass = AstUtils.getContainerOfType(node, isSdsClass); + const containingClass = AstUtils.getContainerOfType(node, isTslClass); if (!containingClass) { return undefined; } diff --git a/packages/ttsl-lang/src/language/typing/safe-ds-core-types.ts b/packages/ttsl-lang/src/language/typing/safe-ds-core-types.ts index 0ae219bd..5cb5d597 100644 --- a/packages/ttsl-lang/src/language/typing/safe-ds-core-types.ts +++ b/packages/ttsl-lang/src/language/typing/safe-ds-core-types.ts @@ -1,6 +1,6 @@ import { WorkspaceCache } from 'langium'; import { SafeDsClasses } from '../builtins/safe-ds-classes.js'; -import { SdsClass } from '../generated/ast.js'; +import { TslClass } from '../generated/ast.js'; import { SafeDsServices } from '../safe-ds-module.js'; import { ClassType, Type, TypeParameterSubstitutions, UnknownType } from './model.js'; import { getTypeParameters } from '../helpers/nodeProperties.js'; @@ -80,7 +80,7 @@ export class SafeDsCoreTypes { return this.createCoreType(this.builtinClasses.String); } - private createCoreType(coreClass: SdsClass | undefined, isNullable: boolean = false): Type { + private createCoreType(coreClass: TslClass | undefined, isNullable: boolean = false): Type { if (!coreClass) { /* c8 ignore next 2 */ return UnknownType; diff --git a/packages/ttsl-lang/src/language/typing/safe-ds-type-checker.ts b/packages/ttsl-lang/src/language/typing/safe-ds-type-checker.ts index ab910b34..762a2728 100644 --- a/packages/ttsl-lang/src/language/typing/safe-ds-type-checker.ts +++ b/packages/ttsl-lang/src/language/typing/safe-ds-type-checker.ts @@ -1,5 +1,5 @@ import type { SafeDsClasses } from '../builtins/safe-ds-classes.js'; -import { isSdsCallable, isSdsClass, isSdsEnum, SdsDeclaration } from '../generated/ast.js'; +import { isTslCallable, isTslClass, isTslEnum, TslDeclaration } from '../generated/ast.js'; import { Enum, EnumVariant, getTypeParameters, Parameter, TypeParameter } from '../helpers/nodeProperties.js'; import { Constant, NullConstant } from '../partialEvaluation/model.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -233,7 +233,7 @@ export class SafeDsTypeChecker { if (other instanceof ClassType) { return other.declaration === this.builtinClasses.Any; } else if (other instanceof EnumType) { - const containingEnum = AstUtils.getContainerOfType(type.declaration, isSdsEnum); + const containingEnum = AstUtils.getContainerOfType(type.declaration, isTslEnum); return containingEnum === other.declaration; } else if (other instanceof EnumVariantType) { return type.declaration === other.declaration; @@ -274,7 +274,7 @@ export class SafeDsTypeChecker { } private namedTupleTypeIsSubtypeOf( - type: NamedTupleType, + type: NamedTupleType, other: Type, options: TypeCheckOptions, ): boolean { @@ -338,11 +338,11 @@ export class SafeDsTypeChecker { return true; } else if (nonNullableReceiverType instanceof StaticType) { const declaration = nonNullableReceiverType.instanceType.declaration; - if (isSdsClass(declaration)) { + if (isTslClass(declaration)) { // Must have a constructor return declaration.parameterList !== undefined; } else { - return isSdsCallable(declaration); + return isTslCallable(declaration); } } else { return false; diff --git a/packages/ttsl-lang/src/language/typing/safe-ds-type-computer.ts b/packages/ttsl-lang/src/language/typing/safe-ds-type-computer.ts index 5caa1330..974028eb 100644 --- a/packages/ttsl-lang/src/language/typing/safe-ds-type-computer.ts +++ b/packages/ttsl-lang/src/language/typing/safe-ds-type-computer.ts @@ -1,69 +1,69 @@ import { AstNode, AstNodeLocator, AstUtils, EMPTY_STREAM, Stream, stream, WorkspaceCache } from 'langium'; import { isEmpty } from '../../helpers/collections.js'; import { - isSdsAnnotation, - isSdsArgument, - isSdsAssignee, - isSdsAssignment, - isSdsAttribute, - isSdsBlockLambda, - isSdsCall, - isSdsCallable, - isSdsCallableType, - isSdsClass, - isSdsDeclaration, - isSdsEnum, - isSdsEnumVariant, - isSdsExpression, - isSdsExpressionLambda, - isSdsFunction, - isSdsIndexedAccess, - isSdsInfixOperation, - isSdsLambda, - isSdsList, - isSdsLiteralType, - isSdsMap, - isSdsMemberAccess, - isSdsMemberType, - isSdsNamedType, - isSdsNamedTypeDeclaration, - isSdsParameter, - isSdsParenthesizedExpression, - isSdsPipeline, - isSdsPrefixOperation, - isSdsReference, - isSdsResult, - isSdsSchema, - isSdsSegment, - isSdsTemplateString, - isSdsType, - isSdsTypeArgument, - isSdsTypeCast, - isSdsTypeParameter, - isSdsUnionType, - isSdsYield, - SdsAbstractResult, - SdsAssignee, - type SdsBlockLambda, - SdsCall, - SdsCallableType, - SdsClass, - SdsDeclaration, - SdsExpression, - type SdsExpressionLambda, - SdsFunction, - SdsIndexedAccess, - SdsInfixOperation, - SdsLiteralType, - SdsMemberAccess, - SdsNamedType, - SdsParameter, - SdsPrefixOperation, - SdsReference, - SdsSegment, - SdsType, - SdsTypeArgument, - SdsTypeParameter, + isTslAnnotation, + isTslArgument, + isTslAssignee, + isTslAssignment, + isTslAttribute, + isTslBlockLambda, + isTslCall, + isTslCallable, + isTslCallableType, + isTslClass, + isTslDeclaration, + isTslEnum, + isTslEnumVariant, + isTslExpression, + isTslExpressionLambda, + isTslFunction, + isTslIndexedAccess, + isTslInfixOperation, + isTslLambda, + isTslList, + isTslLiteralType, + isTslDictionary, + isTslMemberAccess, + isTslMemberType, + isTslNamedType, + isTslNamedTypeDeclaration, + isTslParameter, + isTslParenthesizedExpression, + isTslPipeline, + isTslPrefixOperation, + isTslReference, + isTslResult, + isTslSchema, + isTslSegment, + isTslTemplateString, + isTslType, + isTslTypeArgument, + isTslTypeCast, + isTslTypeParameter, + isTslUnionType, + isTslYield, + TslAbstractResult, + TslAssignee, + type TslBlockLambda, + TslCall, + TslCallableType, + TslClass, + TslDeclaration, + TslExpression, + type TslExpressionLambda, + TslFunction, + TslIndexedAccess, + TslInfixOperation, + TslLiteralType, + TslMemberAccess, + TslNamedType, + TslParameter, + TslPrefixOperation, + TslReference, + TslSegment, + TslType, + TslTypeArgument, + TslTypeParameter, } from '../generated/ast.js'; import { getArguments, @@ -168,23 +168,23 @@ export class SafeDsTypeComputer { } private doComputeType(node: AstNode): Type { - if (isSdsAssignee(node)) { + if (isTslAssignee(node)) { return this.computeTypeOfAssignee(node); - } else if (isSdsDeclaration(node)) { + } else if (isTslDeclaration(node)) { return this.computeTypeOfDeclaration(node); - } else if (isSdsExpression(node)) { + } else if (isTslExpression(node)) { return this.computeTypeOfExpression(node); - } else if (isSdsType(node)) { + } else if (isTslType(node)) { return this.computeTypeOfType(node); - } else if (isSdsTypeArgument(node)) { + } else if (isTslTypeArgument(node)) { return this.computeTypeOfType(node.value); } /* c8 ignore start */ else { return UnknownType; } /* c8 ignore stop */ } - private computeTypeOfAssignee(node: SdsAssignee): Type { - const containingAssignment = AstUtils.getContainerOfType(node, isSdsAssignment); + private computeTypeOfAssignee(node: TslAssignee): Type { + const containingAssignment = AstUtils.getContainerOfType(node, isTslAssignment); if (!containingAssignment) { /* c8 ignore next 2 */ return UnknownType; @@ -201,8 +201,8 @@ export class SafeDsTypeComputer { return UnknownType; } - private computeTypeOfDeclaration(node: SdsDeclaration): Type { - if (isSdsAnnotation(node)) { + private computeTypeOfDeclaration(node: TslDeclaration): Type { + if (isTslAnnotation(node)) { const parameterEntries = getParameters(node).map( (it) => new NamedTupleEntry(it, it.name, this.computeType(it.type)), ); @@ -213,34 +213,34 @@ export class SafeDsTypeComputer { this.factory.createNamedTupleType(...parameterEntries), this.factory.createNamedTupleType(), ); - } else if (isSdsAttribute(node)) { + } else if (isTslAttribute(node)) { return this.computeType(node.type); - } else if (isSdsClass(node)) { + } else if (isTslClass(node)) { return this.factory.createClassType(node, NO_SUBSTITUTIONS, false); - } else if (isSdsEnum(node)) { + } else if (isTslEnum(node)) { return this.factory.createEnumType(node, false); - } else if (isSdsEnumVariant(node)) { + } else if (isTslEnumVariant(node)) { return this.factory.createEnumVariantType(node, false); - } else if (isSdsFunction(node)) { + } else if (isTslFunction(node)) { return this.computeTypeOfCallableWithManifestTypes(node); - } else if (isSdsParameter(node)) { + } else if (isTslParameter(node)) { return this.computeTypeOfParameter(node); - } else if (isSdsPipeline(node)) { + } else if (isTslPipeline(node)) { return UnknownType; - } else if (isSdsResult(node)) { + } else if (isTslResult(node)) { return this.computeType(node.type); - } else if (isSdsSchema(node)) { + } else if (isTslSchema(node)) { return UnknownType; - } else if (isSdsSegment(node)) { + } else if (isTslSegment(node)) { return this.computeTypeOfCallableWithManifestTypes(node); - } else if (isSdsTypeParameter(node)) { + } else if (isTslTypeParameter(node)) { return this.factory.createTypeParameterType(node, false); } /* c8 ignore start */ else { return UnknownType; } /* c8 ignore stop */ } - private computeTypeOfCallableWithManifestTypes(node: SdsFunction | SdsSegment | SdsCallableType): Type { + private computeTypeOfCallableWithManifestTypes(node: TslFunction | TslSegment | TslCallableType): Type { const parameterEntries = getParameters(node).map( (it) => new NamedTupleEntry(it, it.name, this.computeType(it.type)), ); @@ -256,7 +256,7 @@ export class SafeDsTypeComputer { ); } - private computeTypeOfParameter(node: SdsParameter): Type { + private computeTypeOfParameter(node: TslParameter): Type { // Manifest type if (node.type) { const type = this.computeType(node.type); @@ -274,16 +274,16 @@ export class SafeDsTypeComputer { return this.rememberParameterInCallableType(node, type); } - private computeTypeOfParameterContext(node: SdsParameter): Type { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); - if (!isSdsLambda(containingCallable)) { + private computeTypeOfParameterContext(node: TslParameter): Type { + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); + if (!isTslLambda(containingCallable)) { return UnknownType; } const containerOfLambda = containingCallable.$container; // Lambda passed as argument - if (isSdsArgument(containerOfLambda)) { + if (isTslArgument(containerOfLambda)) { const parameter = this.nodeMapper.argumentToParameter(containerOfLambda); if (!parameter) { return UnknownType; @@ -292,14 +292,14 @@ export class SafeDsTypeComputer { } // Lambda passed as default value - if (isSdsParameter(containerOfLambda)) { + if (isTslParameter(containerOfLambda)) { return this.computeType(containerOfLambda); } // Yielded lambda - else if (isSdsAssignment(containerOfLambda)) { + else if (isTslAssignment(containerOfLambda)) { const firstAssignee = getAssignees(containerOfLambda)[0]; - if (!isSdsYield(firstAssignee)) { + if (!isTslYield(firstAssignee)) { return UnknownType; } return this.computeType(firstAssignee.result?.ref); @@ -308,7 +308,7 @@ export class SafeDsTypeComputer { return UnknownType; } - private rememberParameterInCallableType(node: SdsParameter, type: Type) { + private rememberParameterInCallableType(node: TslParameter, type: Type) { if (type instanceof CallableType) { return this.factory.createCallableType(type.callable, node, type.inputType, type.outputType); } else { @@ -316,23 +316,23 @@ export class SafeDsTypeComputer { } } - private computeTypeOfExpression(node: SdsExpression): Type { + private computeTypeOfExpression(node: TslExpression): Type { // Type cast - if (isSdsTypeCast(node)) { + if (isTslTypeCast(node)) { return this.computeType(node.type); } - // Partial evaluation (definitely handles SdsBoolean, SdsFloat, SdsInt, SdsNull, and SdsString) + // Partial evaluation (definitely handles TslBoolean, TslFloat, TslInt, TslNull, and TslString) const evaluatedNode = this.partialEvaluator.evaluate(node); if (evaluatedNode instanceof Constant) { return this.factory.createLiteralType(evaluatedNode); } // Terminal cases - if (isSdsList(node)) { + if (isTslList(node)) { const elementType = this.lowestCommonSupertype(node.elements.map((it) => this.computeType(it))); return this.coreTypes.List(elementType); - } else if (isSdsMap(node)) { + } else if (isTslDictionary(node)) { let keyType = this.lowestCommonSupertype(node.entries.map((it) => this.computeType(it.key))); // Keeping literal types for keys is too strict: We would otherwise infer the key type of `{"a": 1, "b": 2}` @@ -343,22 +343,22 @@ export class SafeDsTypeComputer { const valueType = this.lowestCommonSupertype(node.entries.map((it) => this.computeType(it.value))); return this.coreTypes.Map(keyType, valueType); - } else if (isSdsTemplateString(node)) { + } else if (isTslTemplateString(node)) { return this.coreTypes.String; } // Recursive cases - else if (isSdsArgument(node)) { + else if (isTslArgument(node)) { return this.computeType(node.value); - } else if (isSdsBlockLambda(node)) { + } else if (isTslBlockLambda(node)) { return this.computeTypeOfBlockLambda(node); - } else if (isSdsCall(node)) { + } else if (isTslCall(node)) { return this.computeTypeOfCall(node); - } else if (isSdsExpressionLambda(node)) { + } else if (isTslExpressionLambda(node)) { return this.computeTypeOfExpressionLambda(node); - } else if (isSdsIndexedAccess(node)) { + } else if (isTslIndexedAccess(node)) { return this.computeTypeOfIndexedAccess(node); - } else if (isSdsInfixOperation(node)) { + } else if (isTslInfixOperation(node)) { switch (node.operator) { // Boolean operators case 'or': @@ -395,11 +395,11 @@ export class SafeDsTypeComputer { default: return UnknownType; } - } else if (isSdsMemberAccess(node)) { + } else if (isTslMemberAccess(node)) { return this.computeTypeOfMemberAccess(node); - } else if (isSdsParenthesizedExpression(node)) { + } else if (isTslParenthesizedExpression(node)) { return this.computeType(node.expression); - } else if (isSdsPrefixOperation(node)) { + } else if (isTslPrefixOperation(node)) { switch (node.operator) { case 'not': return this.coreTypes.Boolean; @@ -411,14 +411,14 @@ export class SafeDsTypeComputer { default: return UnknownType; } - } else if (isSdsReference(node)) { + } else if (isTslReference(node)) { return this.computeTypeOfReference(node); } /* c8 ignore start */ else { return UnknownType; } /* c8 ignore stop */ } - private computeTypeOfBlockLambda(node: SdsBlockLambda): Type { + private computeTypeOfBlockLambda(node: TslBlockLambda): Type { const parameterEntries = getParameters(node).map( (it) => new NamedTupleEntry(it, it.name, this.computeType(it)), ); @@ -434,24 +434,24 @@ export class SafeDsTypeComputer { ); } - private computeTypeOfCall(node: SdsCall): Type { + private computeTypeOfCall(node: TslCall): Type { const receiverType = this.computeType(node.receiver); const nonNullableReceiverType = this.computeNonNullableType(receiverType); let result: Type = UnknownType; if (nonNullableReceiverType instanceof CallableType) { - if (!isSdsAnnotation(nonNullableReceiverType.callable)) { + if (!isTslAnnotation(nonNullableReceiverType.callable)) { result = nonNullableReceiverType.outputType; } // Substitute type parameters - if (isSdsFunction(nonNullableReceiverType.callable)) { + if (isTslFunction(nonNullableReceiverType.callable)) { const substitutions = this.computeSubstitutionsForCall(node); result = result.substituteTypeParameters(substitutions); } } else if (nonNullableReceiverType instanceof StaticType) { const instanceType = nonNullableReceiverType.instanceType; - if (isSdsCallable(instanceType.declaration)) { + if (isTslCallable(instanceType.declaration)) { result = instanceType; } @@ -471,12 +471,12 @@ export class SafeDsTypeComputer { return result.withExplicitNullability(receiverType.isExplicitlyNullable && node.isNullSafe); } - private computeTypeOfExpressionLambda(node: SdsExpressionLambda): Type { + private computeTypeOfExpressionLambda(node: TslExpressionLambda): Type { const parameterEntries = getParameters(node).map( (it) => new NamedTupleEntry(it, it.name, this.computeType(it)), ); const resultEntries = [ - new NamedTupleEntry(undefined, 'result', this.computeType(node.result)), + new NamedTupleEntry(undefined, 'result', this.computeType(node.result)), ]; return this.factory.createCallableType( @@ -487,7 +487,7 @@ export class SafeDsTypeComputer { ); } - private computeTypeOfIndexedAccess(node: SdsIndexedAccess): Type { + private computeTypeOfIndexedAccess(node: TslIndexedAccess): Type { const receiverType = this.computeType(node.receiver); if (!(receiverType instanceof ClassType) && !(receiverType instanceof TypeParameterType)) { return UnknownType; @@ -512,7 +512,7 @@ export class SafeDsTypeComputer { return UnknownType; } - private computeTypeOfArithmeticInfixOperation(node: SdsInfixOperation): Type { + private computeTypeOfArithmeticInfixOperation(node: TslInfixOperation): Type { const leftOperandType = this.computeType(node.leftOperand); const rightOperandType = this.computeType(node.rightOperand); @@ -526,7 +526,7 @@ export class SafeDsTypeComputer { } } - private computeTypeOfElvisOperation(node: SdsInfixOperation): Type { + private computeTypeOfElvisOperation(node: TslInfixOperation): Type { const leftOperandType = this.computeType(node.leftOperand); if (leftOperandType.isExplicitlyNullable) { const rightOperandType = this.computeType(node.rightOperand); @@ -536,11 +536,11 @@ export class SafeDsTypeComputer { } } - private computeTypeOfMemberAccess(node: SdsMemberAccess) { + private computeTypeOfMemberAccess(node: TslMemberAccess) { const memberType = this.computeType(node.member); // A member access of an enum variant without parameters always yields an instance, even if it is not in a call - if (memberType instanceof StaticType && !isSdsCall(node.$container)) { + if (memberType instanceof StaticType && !isTslCall(node.$container)) { const instanceType = memberType.instanceType; if (instanceType instanceof EnumVariantType && isEmpty(getParameters(instanceType.declaration))) { @@ -553,7 +553,7 @@ export class SafeDsTypeComputer { // Substitute type parameters (must also work for inherited members) if (receiverType instanceof ClassType) { - const classContainingMember = AstUtils.getContainerOfType(node.member?.target.ref, isSdsClass); + const classContainingMember = AstUtils.getContainerOfType(node.member?.target.ref, isTslClass); const typeContainingMember = this.computeMatchingSupertype(receiverType, classContainingMember); if (typeContainingMember) { @@ -567,7 +567,7 @@ export class SafeDsTypeComputer { ); } - private computeTypeOfArithmeticPrefixOperation(node: SdsPrefixOperation): Type { + private computeTypeOfArithmeticPrefixOperation(node: TslPrefixOperation): Type { const operandType = this.computeType(node.operand); if (this.typeChecker.isSubtypeOf(operandType, this.coreTypes.Int)) { @@ -577,27 +577,27 @@ export class SafeDsTypeComputer { } } - private computeTypeOfReference(node: SdsReference): Type { + private computeTypeOfReference(node: TslReference): Type { const target = node.target.ref; const instanceType = this.computeType(target); - if (isSdsNamedTypeDeclaration(target) && instanceType instanceof NamedType) { + if (isTslNamedTypeDeclaration(target) && instanceType instanceof NamedType) { return this.factory.createStaticType(instanceType.withExplicitNullability(false)); } else { return instanceType; } } - private computeTypeOfType(node: SdsType): Type { - if (isSdsCallableType(node)) { + private computeTypeOfType(node: TslType): Type { + if (isTslCallableType(node)) { return this.computeTypeOfCallableWithManifestTypes(node); - } else if (isSdsLiteralType(node)) { + } else if (isTslLiteralType(node)) { return this.computeTypeOfLiteralType(node); - } else if (isSdsMemberType(node)) { + } else if (isTslMemberType(node)) { return this.computeType(node.member); - } else if (isSdsNamedType(node)) { + } else if (isTslNamedType(node)) { return this.computeTypeOfNamedType(node); - } else if (isSdsUnionType(node)) { + } else if (isTslUnionType(node)) { const typeArguments = getTypeArguments(node.typeArgumentList); return this.factory.createUnionType( ...typeArguments.map((typeArgument) => this.computeType(typeArgument.value)), @@ -607,7 +607,7 @@ export class SafeDsTypeComputer { } /* c8 ignore stop */ } - private computeTypeOfLiteralType(node: SdsLiteralType): Type { + private computeTypeOfLiteralType(node: TslLiteralType): Type { const constants = getLiterals(node).map((it) => this.partialEvaluator.evaluate(it)); if (constants.every(isConstant)) { return this.factory.createLiteralType(...constants); @@ -616,7 +616,7 @@ export class SafeDsTypeComputer { } /* c8 ignore stop */ } - private computeTypeOfNamedType(node: SdsNamedType) { + private computeTypeOfNamedType(node: TslNamedType) { const unparameterizedType = this.computeType(node.declaration?.ref).withExplicitNullability(node.isNullable); if (!(unparameterizedType instanceof ClassType)) { return unparameterizedType; @@ -627,8 +627,8 @@ export class SafeDsTypeComputer { } private computeTypeParameterSubstitutionsForNamedType( - node: SdsNamedType, - clazz: SdsClass, + node: TslNamedType, + clazz: TslClass, ): TypeParameterSubstitutions { const typeParameters = getTypeParameters(clazz); if (isEmpty(typeParameters)) { @@ -636,7 +636,7 @@ export class SafeDsTypeComputer { } // Map type parameters to the first type argument that sets it - const typeArgumentsByTypeParameters = new Map(); + const typeArgumentsByTypeParameters = new Map(); for (const typeArgument of getTypeArguments(node)) { const typeParameter = this.nodeMapper.typeArgumentToTypeParameter(typeArgument); if (typeParameter && !typeArgumentsByTypeParameters.has(typeParameter)) { @@ -645,7 +645,7 @@ export class SafeDsTypeComputer { } // Compute substitutions (ordered by the position of the type parameters) - const result = new Map(); + const result = new Map(); for (const typeParameter of typeParameters) { const typeArgument = typeArgumentsByTypeParameters.get(typeParameter); @@ -710,7 +710,7 @@ export class SafeDsTypeComputer { ...getParameters(declaration).map((it) => new NamedTupleEntry(it, it.name, this.computeType(it))), ); const resultEntries = this.factory.createNamedTupleType( - new NamedTupleEntry(undefined, 'instance', instanceType), + new NamedTupleEntry(undefined, 'instance', instanceType), ); return this.factory.createCallableType(declaration, undefined, parameterEntries, resultEntries); @@ -721,7 +721,7 @@ export class SafeDsTypeComputer { ...getParameters(declaration).map((it) => new NamedTupleEntry(it, it.name, this.computeType(it))), ); const resultEntries = this.factory.createNamedTupleType( - new NamedTupleEntry(undefined, 'instance', instanceType), + new NamedTupleEntry(undefined, 'instance', instanceType), ); return this.factory.createCallableType(declaration, undefined, parameterEntries, resultEntries); @@ -739,7 +739,7 @@ export class SafeDsTypeComputer { * invalid upper bounds are specified, but are invalid (e.g. because of an unresolved reference or a cycle), * `$unknown` is returned. The result is simplified as much as possible. */ - computeUpperBound(nodeOrType: SdsTypeParameter | TypeParameterType, options: ComputeUpperBoundOptions = {}): Type { + computeUpperBound(nodeOrType: TslTypeParameter | TypeParameterType, options: ComputeUpperBoundOptions = {}): Type { let type: TypeParameterType; if (nodeOrType instanceof TypeParameterType) { type = nodeOrType; @@ -777,7 +777,7 @@ export class SafeDsTypeComputer { * @param call The call to compute substitutions for. * @returns The computed substitutions for the type parameters of the callable. */ - computeSubstitutionsForCall(call: SdsCall): TypeParameterSubstitutions { + computeSubstitutionsForCall(call: TslCall): TypeParameterSubstitutions { const callable = this.nodeMapper.callToCallable(call); const typeParameters = getTypeParameters(callable); if (isEmpty(typeParameters)) { @@ -834,7 +834,7 @@ export class SafeDsTypeComputer { * @returns The computed substitutions for the type parameters in the parameter types. */ private computeTypeParameterSubstitutionsForArguments( - typeParameters: SdsTypeParameter[], + typeParameters: TslTypeParameter[], parameterTypesToArgumentTypes: [Type, Type][], ): TypeParameterSubstitutions { // Build initial state @@ -1160,7 +1160,7 @@ export class SafeDsTypeComputer { } private substitutionsForInvariantTypeParametersAreEqual( - allTypeParameters: SdsTypeParameter[], + allTypeParameters: TslTypeParameter[], candidate: ClassType, others: ClassType[], ): boolean { @@ -1177,7 +1177,7 @@ export class SafeDsTypeComputer { } private newTypeParameterSubstitutionsLCS( - typeParameters: SdsTypeParameter[], + typeParameters: TslTypeParameter[], candidate: ClassType, others: ClassType[], ): TypeParameterSubstitutions { @@ -1212,7 +1212,7 @@ export class SafeDsTypeComputer { } else if (!isEmpty(enumVariantTypes)) { candidates.push(enumVariantTypes[0]!.withExplicitNullability(isNullable)); - const containingEnum = AstUtils.getContainerOfType(enumVariantTypes[0]!.declaration, isSdsEnum); + const containingEnum = AstUtils.getContainerOfType(enumVariantTypes[0]!.declaration, isTslEnum); if (containingEnum) { candidates.push(this.factory.createEnumType(containingEnum, isNullable)); } @@ -1410,7 +1410,7 @@ export class SafeDsTypeComputer { } // See where the type parameters ended up in the computed super type - const invertedTypeParameterMap = new Map(); + const invertedTypeParameterMap = new Map(); for (const [key, value] of superType.substitutions) { if (value instanceof TypeParameterType) { invertedTypeParameterMap.set(value.declaration, key); @@ -1439,7 +1439,7 @@ export class SafeDsTypeComputer { } private newTypeParameterSubstitutionsHCS( - typeParameters: SdsTypeParameter[], + typeParameters: TslTypeParameter[], candidate: ClassType, others: ClassType[], ): TypeParameterSubstitutions { @@ -1496,7 +1496,7 @@ export class SafeDsTypeComputer { */ computeMatchingSupertype( type: ClassType | TypeParameterType | undefined, - target: SdsClass | undefined, + target: TslClass | undefined, ): ClassType | undefined { // Handle undefined if (!type || !target) { @@ -1536,7 +1536,7 @@ export class SafeDsTypeComputer { private *properSupertypesGenerator(type: ClassType): Generator { // Compared to `ClassHierarchy.properSuperclassesGenerator`, we already include the given type in the list of // visited elements, since this method here is not used to detect cycles. - const visited = new Set([type.declaration]); + const visited = new Set([type.declaration]); let current = this.parentClassType(type); while (current && !visited.has(current.declaration)) { @@ -1579,7 +1579,7 @@ export class SafeDsTypeComputer { } private newTypeParameterSubstitutions( - typeParameters: SdsTypeParameter[], + typeParameters: TslTypeParameter[], candidate: ClassType, others: ClassType[], covariantUnifier: (types: Type[]) => Type, @@ -1618,7 +1618,7 @@ interface ComputeUpperBoundOptions { interface ComputeTypeParameterSubstitutionsForParametersState { substitutions: TypeParameterSubstitutions; - remainingVariances: Map; + remainingVariances: Map; } type Variance = 'bivariant' | 'covariant' | 'contravariant' | 'invariant'; diff --git a/packages/ttsl-lang/src/language/typing/safe-ds-type-factory.ts b/packages/ttsl-lang/src/language/typing/safe-ds-type-factory.ts index eec41eeb..1d94496c 100644 --- a/packages/ttsl-lang/src/language/typing/safe-ds-type-factory.ts +++ b/packages/ttsl-lang/src/language/typing/safe-ds-type-factory.ts @@ -16,41 +16,41 @@ import { } from './model.js'; import { Constant } from '../partialEvaluation/model.js'; import { - SdsAbstractResult, - SdsCallable, - SdsClass, - SdsDeclaration, - SdsEnum, - SdsEnumVariant, - SdsParameter, - SdsTypeParameter, + TslAbstractResult, + TslCallable, + TslClass, + TslDeclaration, + TslEnum, + TslEnumVariant, + TslParameter, + TslTypeParameter, } from '../generated/ast.js'; export class SafeDsTypeFactory { constructor(private readonly services: SafeDsServices) {} createCallableType( - callable: SdsCallable, - parameter: SdsParameter | undefined, - inputType: NamedTupleType, - outputType: NamedTupleType, + callable: TslCallable, + parameter: TslParameter | undefined, + inputType: NamedTupleType, + outputType: NamedTupleType, ): CallableType { return new CallableType(this.services, callable, parameter, inputType, outputType); } createClassType( - declaration: SdsClass, + declaration: TslClass, substitutions: TypeParameterSubstitutions, isExplicitlyNullable: boolean, ): ClassType { return new ClassType(declaration, substitutions, isExplicitlyNullable); } - createEnumType(declaration: SdsEnum, isExplicitlyNullable: boolean): EnumType { + createEnumType(declaration: TslEnum, isExplicitlyNullable: boolean): EnumType { return new EnumType(declaration, isExplicitlyNullable); } - createEnumVariantType(declaration: SdsEnumVariant, isExplicitlyNullable: boolean): EnumVariantType { + createEnumVariantType(declaration: TslEnumVariant, isExplicitlyNullable: boolean): EnumVariantType { return new EnumVariantType(declaration, isExplicitlyNullable); } @@ -58,15 +58,15 @@ export class SafeDsTypeFactory { return new LiteralType(this.services, constants); } - createNamedTupleType(...entries: NamedTupleEntry[]): NamedTupleType { + createNamedTupleType(...entries: NamedTupleEntry[]): NamedTupleType { return new NamedTupleType(this.services, entries); } - createStaticType(instanceType: NamedType): StaticType { + createStaticType(instanceType: NamedType): StaticType { return new StaticType(this.services, instanceType); } - createTypeParameterType(declaration: SdsTypeParameter, isExplicitlyNullable: boolean): TypeParameterType { + createTypeParameterType(declaration: TslTypeParameter, isExplicitlyNullable: boolean): TypeParameterType { return new TypeParameterType(declaration, isExplicitlyNullable); } diff --git a/packages/ttsl-lang/src/language/validation/builtins/deprecated.ts b/packages/ttsl-lang/src/language/validation/builtins/deprecated.ts index 8303edda..4c17fc3d 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/deprecated.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/deprecated.ts @@ -1,15 +1,15 @@ import { ValidationAcceptor } from 'langium'; import { DiagnosticTag } from 'vscode-languageserver'; import { - isSdsParameter, - isSdsResult, - isSdsWildcard, - SdsAnnotationCall, - SdsArgument, - SdsAssignee, - SdsNamedType, - SdsParameter, - SdsReference, + isTslParameter, + isTslResult, + isTslWildcard, + TslAnnotationCall, + TslArgument, + TslAssignee, + TslNamedType, + TslParameter, + TslReference, } from '../../generated/ast.js'; import { Parameter } from '../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../safe-ds-module.js'; @@ -19,13 +19,13 @@ export const CODE_DEPRECATED_LIBRARY_ELEMENT = 'deprecated/library-element'; export const CODE_DEPRECATED_REQUIRED_PARAMETER = 'deprecated/required-parameter'; export const assigneeAssignedResultShouldNotBeDeprecated = - (services: SafeDsServices) => (node: SdsAssignee, accept: ValidationAcceptor) => { - if (isSdsWildcard(node)) { + (services: SafeDsServices) => (node: TslAssignee, accept: ValidationAcceptor) => { + if (isTslWildcard(node)) { return; } const assignedObject = services.helpers.NodeMapper.assigneeToAssignedObject(node); - if (!isSdsResult(assignedObject)) { + if (!isTslResult(assignedObject)) { return; } @@ -39,7 +39,7 @@ export const assigneeAssignedResultShouldNotBeDeprecated = }; export const annotationCallAnnotationShouldNotBeDeprecated = - (services: SafeDsServices) => (node: SdsAnnotationCall, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslAnnotationCall, accept: ValidationAcceptor) => { const annotation = node.annotation?.ref; if (!annotation) { return; @@ -56,7 +56,7 @@ export const annotationCallAnnotationShouldNotBeDeprecated = }; export const argumentCorrespondingParameterShouldNotBeDeprecated = - (services: SafeDsServices) => (node: SdsArgument, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslArgument, accept: ValidationAcceptor) => { const parameter = services.helpers.NodeMapper.argumentToParameter(node); if (!parameter) { return; @@ -72,7 +72,7 @@ export const argumentCorrespondingParameterShouldNotBeDeprecated = }; export const namedTypeDeclarationShouldNotBeDeprecated = - (services: SafeDsServices) => (node: SdsNamedType, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslNamedType, accept: ValidationAcceptor) => { const declaration = node.declaration?.ref; if (!declaration) { return; @@ -88,9 +88,9 @@ export const namedTypeDeclarationShouldNotBeDeprecated = }; export const referenceTargetShouldNotBeDeprecated = - (services: SafeDsServices) => (node: SdsReference, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslReference, accept: ValidationAcceptor) => { const target = node.target.ref; - if (!target || isSdsParameter(target)) { + if (!target || isTslParameter(target)) { return; } @@ -104,7 +104,7 @@ export const referenceTargetShouldNotBeDeprecated = }; export const requiredParameterMustNotBeDeprecated = - (services: SafeDsServices) => (node: SdsParameter, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslParameter, accept: ValidationAcceptor) => { if (Parameter.isRequired(node) && parameterCanBeAnnotated(node)) { if (services.builtins.Annotations.callsDeprecated(node)) { accept('error', 'A deprecated parameter must be optional.', { diff --git a/packages/ttsl-lang/src/language/validation/builtins/experimental.ts b/packages/ttsl-lang/src/language/validation/builtins/experimental.ts index 42182c8b..d2bde550 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/experimental.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/experimental.ts @@ -1,13 +1,13 @@ import { ValidationAcceptor } from 'langium'; import { - isSdsParameter, - isSdsResult, - isSdsWildcard, - SdsAnnotationCall, - SdsArgument, - SdsAssignee, - SdsNamedType, - SdsReference, + isTslParameter, + isTslResult, + isTslWildcard, + TslAnnotationCall, + TslArgument, + TslAssignee, + TslNamedType, + TslReference, } from '../../generated/ast.js'; import { SafeDsServices } from '../../safe-ds-module.js'; @@ -16,18 +16,18 @@ export const CODE_EXPERIMENTAL_LIBRARY_ELEMENT = 'experimental/library-element'; export const assigneeAssignedResultShouldNotBeExperimental = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsAssignee, accept: ValidationAcceptor) => { + return async (node: TslAssignee, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLibraryElement())) { /* c8 ignore next 2 */ return; } - if (isSdsWildcard(node)) { + if (isTslWildcard(node)) { return; } const assignedObject = services.helpers.NodeMapper.assigneeToAssignedObject(node); - if (!isSdsResult(assignedObject)) { + if (!isTslResult(assignedObject)) { return; } @@ -43,7 +43,7 @@ export const assigneeAssignedResultShouldNotBeExperimental = (services: SafeDsSe export const annotationCallAnnotationShouldNotBeExperimental = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsAnnotationCall, accept: ValidationAcceptor) => { + return async (node: TslAnnotationCall, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLibraryElement())) { /* c8 ignore next 2 */ return; @@ -67,7 +67,7 @@ export const annotationCallAnnotationShouldNotBeExperimental = (services: SafeDs export const argumentCorrespondingParameterShouldNotBeExperimental = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsArgument, accept: ValidationAcceptor) => { + return async (node: TslArgument, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLibraryElement())) { /* c8 ignore next 2 */ return; @@ -90,7 +90,7 @@ export const argumentCorrespondingParameterShouldNotBeExperimental = (services: export const namedTypeDeclarationShouldNotBeExperimental = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsNamedType, accept: ValidationAcceptor) => { + return async (node: TslNamedType, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLibraryElement())) { /* c8 ignore next 2 */ return; @@ -113,14 +113,14 @@ export const namedTypeDeclarationShouldNotBeExperimental = (services: SafeDsServ export const referenceTargetShouldNotExperimental = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsReference, accept: ValidationAcceptor) => { + return async (node: TslReference, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLibraryElement())) { /* c8 ignore next 2 */ return; } const target = node.target.ref; - if (!target || isSdsParameter(target)) { + if (!target || isTslParameter(target)) { return; } diff --git a/packages/ttsl-lang/src/language/validation/builtins/expert.ts b/packages/ttsl-lang/src/language/validation/builtins/expert.ts index 6521428e..58a2c595 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/expert.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/expert.ts @@ -1,5 +1,5 @@ import { ValidationAcceptor } from 'langium'; -import { SdsParameter } from '../../generated/ast.js'; +import { TslParameter } from '../../generated/ast.js'; import { Parameter } from '../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../safe-ds-module.js'; import { parameterCanBeAnnotated } from '../other/declarations/annotationCalls.js'; @@ -7,7 +7,7 @@ import { parameterCanBeAnnotated } from '../other/declarations/annotationCalls.j export const CODE_EXPERT_TARGET_PARAMETER = 'expert/target-parameter'; export const requiredParameterMustNotBeExpert = - (services: SafeDsServices) => (node: SdsParameter, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslParameter, accept: ValidationAcceptor) => { if (Parameter.isRequired(node) && parameterCanBeAnnotated(node)) { if (services.builtins.Annotations.callsExpert(node)) { accept('error', 'An expert parameter must be optional.', { diff --git a/packages/ttsl-lang/src/language/validation/builtins/pythonCall.ts b/packages/ttsl-lang/src/language/validation/builtins/pythonCall.ts index 29d8e4b0..551655a8 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/pythonCall.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/pythonCall.ts @@ -1,5 +1,5 @@ import { AstUtils, ValidationAcceptor } from 'langium'; -import { isSdsClass, SdsFunction } from '../../generated/ast.js'; +import { isTslClass, TslFunction } from '../../generated/ast.js'; import { SafeDsServices } from '../../safe-ds-module.js'; import { findFirstAnnotationCallOf, getParameters } from '../../helpers/nodeProperties.js'; import { pluralize } from '../../../helpers/strings.js'; @@ -9,7 +9,7 @@ export const CODE_PYTHON_CALL_INVALID_TEMPLATE_EXPRESSION = 'python-call/invalid export const pythonCallMustOnlyContainValidTemplateExpressions = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - return (node: SdsFunction, accept: ValidationAcceptor) => { + return (node: TslFunction, accept: ValidationAcceptor) => { const pythonCall = builtinAnnotations.getPythonCall(node); if (!pythonCall) { return; @@ -21,7 +21,7 @@ export const pythonCallMustOnlyContainValidTemplateExpressions = (services: Safe // Compute valid template expressions const validTemplateExpressions = new Set(getParameters(node).map((it) => `\$${it.name}`)); - if (AstUtils.hasContainerOfType(node, isSdsClass)) { + if (AstUtils.hasContainerOfType(node, isTslClass)) { validTemplateExpressions.add('$this'); } diff --git a/packages/ttsl-lang/src/language/validation/builtins/pythonModule.ts b/packages/ttsl-lang/src/language/validation/builtins/pythonModule.ts index 4061934d..11167755 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/pythonModule.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/pythonModule.ts @@ -1,5 +1,5 @@ import { ValidationAcceptor } from 'langium'; -import { SdsModule } from '../../generated/ast.js'; +import { TslModule } from '../../generated/ast.js'; import { SafeDsServices } from '../../safe-ds-module.js'; import { findFirstAnnotationCallOf } from '../../helpers/nodeProperties.js'; @@ -8,7 +8,7 @@ export const CODE_PYTHON_MODULE_SAME_AS_SAFE_DS_PACKAGE = 'python-module/same-as export const pythonModuleShouldDifferFromSafeDsPackage = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - return (node: SdsModule, accept: ValidationAcceptor) => { + return (node: TslModule, accept: ValidationAcceptor) => { const pythonModule = builtinAnnotations.getPythonModule(node); if (!pythonModule || pythonModule !== node.name) { return; diff --git a/packages/ttsl-lang/src/language/validation/builtins/pythonName.ts b/packages/ttsl-lang/src/language/validation/builtins/pythonName.ts index 7d285348..d782ffe2 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/pythonName.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/pythonName.ts @@ -1,5 +1,5 @@ import { ValidationAcceptor } from 'langium'; -import { SdsDeclaration, SdsFunction } from '../../generated/ast.js'; +import { TslDeclaration, TslFunction } from '../../generated/ast.js'; import { SafeDsServices } from '../../safe-ds-module.js'; import { findFirstAnnotationCallOf, hasAnnotationCallOf } from '../../helpers/nodeProperties.js'; @@ -9,7 +9,7 @@ export const CODE_PYTHON_NAME_SAME_AS_SAFE_DS_NAME = 'python-name/same-as-safe-d export const pythonNameMustNotBeSetIfPythonCallIsSet = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - return (node: SdsFunction, accept: ValidationAcceptor) => { + return (node: TslFunction, accept: ValidationAcceptor) => { if (!hasAnnotationCallOf(node, builtinAnnotations.PythonCall)) { return; } @@ -30,7 +30,7 @@ export const pythonNameMustNotBeSetIfPythonCallIsSet = (services: SafeDsServices export const pythonNameShouldDifferFromSafeDsName = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - return (node: SdsDeclaration, accept: ValidationAcceptor) => { + return (node: TslDeclaration, accept: ValidationAcceptor) => { const pythonName = builtinAnnotations.getPythonName(node); if (!pythonName || pythonName !== node.name) { return; diff --git a/packages/ttsl-lang/src/language/validation/builtins/repeatable.ts b/packages/ttsl-lang/src/language/validation/builtins/repeatable.ts index 5e8ba5ee..5a9aa97b 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/repeatable.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/repeatable.ts @@ -1,13 +1,13 @@ import { ValidationAcceptor } from 'langium'; import { duplicatesBy } from '../../../helpers/collections.js'; -import { SdsDeclaration } from '../../generated/ast.js'; +import { TslDeclaration } from '../../generated/ast.js'; import { getAnnotationCalls } from '../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../safe-ds-module.js'; export const CODE_ANNOTATION_NOT_REPEATABLE = 'annotation/not-repeatable'; export const singleUseAnnotationsMustNotBeRepeated = - (services: SafeDsServices) => (node: SdsDeclaration, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslDeclaration, accept: ValidationAcceptor) => { const callsOfSingleUseAnnotations = getAnnotationCalls(node).filter((it) => { const annotation = it.annotation?.ref; return annotation && !services.builtins.Annotations.callsRepeatable(annotation); diff --git a/packages/ttsl-lang/src/language/validation/builtins/target.ts b/packages/ttsl-lang/src/language/validation/builtins/target.ts index d38f914a..7fe4bc4e 100644 --- a/packages/ttsl-lang/src/language/validation/builtins/target.ts +++ b/packages/ttsl-lang/src/language/validation/builtins/target.ts @@ -1,21 +1,21 @@ import { ValidationAcceptor } from 'langium'; import { - isSdsAnnotation, - isSdsAttribute, - isSdsClass, - isSdsEnum, - isSdsEnumVariant, - isSdsFunction, - isSdsList, - isSdsModule, - isSdsParameter, - isSdsPipeline, - isSdsResult, - isSdsSegment, - isSdsTypeParameter, - SdsAnnotation, - SdsAnnotationCall, - SdsEnumVariant, + isTslAnnotation, + isTslAttribute, + isTslClass, + isTslEnum, + isTslEnumVariant, + isTslFunction, + isTslList, + isTslModule, + isTslParameter, + isTslPipeline, + isTslResult, + isTslSegment, + isTslTypeParameter, + TslAnnotation, + TslAnnotationCall, + TslEnumVariant, } from '../../generated/ast.js'; import { findFirstAnnotationCallOf, getAnnotationCallTarget } from '../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../safe-ds-module.js'; @@ -29,18 +29,18 @@ export const targetShouldNotHaveDuplicateEntries = (services: SafeDsServices) => const partialEvaluator = services.evaluation.PartialEvaluator; const nodeMapper = services.helpers.NodeMapper; - return (node: SdsAnnotation, accept: ValidationAcceptor) => { + return (node: TslAnnotation, accept: ValidationAcceptor) => { const annotationCall = findFirstAnnotationCallOf(node, builtinAnnotations.Target); if (!annotationCall) { return; } const targets = nodeMapper.callToParameterValue(annotationCall, 'targets'); - if (!isSdsList(targets)) { + if (!isTslList(targets)) { return; } - const knownTargets = new Set(); + const knownTargets = new Set(); for (const target of targets.elements) { const evaluatedTarget = partialEvaluator.evaluate(target); if (!builtinEnums.isEvaluatedAnnotationTarget(evaluatedTarget)) { @@ -62,7 +62,7 @@ export const targetShouldNotHaveDuplicateEntries = (services: SafeDsServices) => export const annotationCallMustHaveCorrectTarget = (services: SafeDsServices) => { const builtinAnnotations = services.builtins.Annotations; - return (node: SdsAnnotationCall, accept: ValidationAcceptor) => { + return (node: TslAnnotationCall, accept: ValidationAcceptor) => { const annotation = node.annotation?.ref; if (!annotation) { return; @@ -90,65 +90,65 @@ export const annotationCallMustHaveCorrectTarget = (services: SafeDsServices) => }; }; -const getActualTarget = (node: SdsAnnotationCall): GetActualTargetResult | void => { +const getActualTarget = (node: TslAnnotationCall): GetActualTargetResult | void => { const annotatedObject = getAnnotationCallTarget(node); - if (isSdsAnnotation(annotatedObject)) { + if (isTslAnnotation(annotatedObject)) { return { enumVariantName: 'Annotation', prettyName: 'an annotation', }; - } else if (isSdsAttribute(annotatedObject)) { + } else if (isTslAttribute(annotatedObject)) { return { enumVariantName: 'Attribute', prettyName: 'an attribute', }; - } else if (isSdsClass(annotatedObject)) { + } else if (isTslClass(annotatedObject)) { return { enumVariantName: 'Class', prettyName: 'a class', }; - } else if (isSdsEnum(annotatedObject)) { + } else if (isTslEnum(annotatedObject)) { return { enumVariantName: 'Enum', prettyName: 'an enum', }; - } else if (isSdsEnumVariant(annotatedObject)) { + } else if (isTslEnumVariant(annotatedObject)) { return { enumVariantName: 'EnumVariant', prettyName: 'an enum variant', }; - } else if (isSdsFunction(annotatedObject)) { + } else if (isTslFunction(annotatedObject)) { return { enumVariantName: 'Function', prettyName: 'a function', }; - } else if (isSdsModule(annotatedObject)) { + } else if (isTslModule(annotatedObject)) { return { enumVariantName: 'Module', prettyName: 'a module', }; - } else if (isSdsParameter(annotatedObject)) { + } else if (isTslParameter(annotatedObject)) { return { enumVariantName: 'Parameter', prettyName: 'a parameter', }; - } else if (isSdsPipeline(annotatedObject)) { + } else if (isTslPipeline(annotatedObject)) { return { enumVariantName: 'Pipeline', prettyName: 'a pipeline', }; - } else if (isSdsResult(annotatedObject)) { + } else if (isTslResult(annotatedObject)) { return { enumVariantName: 'Result', prettyName: 'a result', }; - } else if (isSdsSegment(annotatedObject)) { + } else if (isTslSegment(annotatedObject)) { return { enumVariantName: 'Segment', prettyName: 'a segment', }; - } else if (isSdsTypeParameter(annotatedObject)) { + } else if (isTslTypeParameter(annotatedObject)) { return { enumVariantName: 'TypeParameter', prettyName: 'a type parameter', diff --git a/packages/ttsl-lang/src/language/validation/experimentalLanguageFeatures.ts b/packages/ttsl-lang/src/language/validation/experimentalLanguageFeatures.ts index 773df37e..bc8d5935 100644 --- a/packages/ttsl-lang/src/language/validation/experimentalLanguageFeatures.ts +++ b/packages/ttsl-lang/src/language/validation/experimentalLanguageFeatures.ts @@ -1,11 +1,11 @@ import { AstUtils, ValidationAcceptor } from 'langium'; import { - isSdsMap, - isSdsUnionType, - type SdsConstraintList, - type SdsLiteralType, - type SdsMap, - type SdsUnionType, + isTslDictionary, + isTslUnionType, + type TslConstraintList, + type TslLiteralType, + type TslDictionary, + type TslUnionType, } from '../generated/ast.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -14,7 +14,7 @@ export const CODE_EXPERIMENTAL_LANGUAGE_FEATURE = 'experimental/language-feature export const constraintListsShouldBeUsedWithCaution = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsConstraintList, accept: ValidationAcceptor) => { + return async (node: TslConstraintList, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLanguageFeature())) { /* c8 ignore next 2 */ return; @@ -31,7 +31,7 @@ export const constraintListsShouldBeUsedWithCaution = (services: SafeDsServices) export const literalTypesShouldBeUsedWithCaution = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsLiteralType, accept: ValidationAcceptor) => { + return async (node: TslLiteralType, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLanguageFeature())) { /* c8 ignore next 2 */ return; @@ -48,14 +48,14 @@ export const literalTypesShouldBeUsedWithCaution = (services: SafeDsServices) => export const mapsShouldBeUsedWithCaution = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsMap, accept: ValidationAcceptor) => { + return async (node: TslDictionary, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLanguageFeature())) { /* c8 ignore next 2 */ return; } // There's already a warning on the container - if (AstUtils.hasContainerOfType(node.$container, isSdsMap)) { + if (AstUtils.hasContainerOfType(node.$container, isTslDictionary)) { return; } @@ -69,14 +69,14 @@ export const mapsShouldBeUsedWithCaution = (services: SafeDsServices) => { export const unionTypesShouldBeUsedWithCaution = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsUnionType, accept: ValidationAcceptor) => { + return async (node: TslUnionType, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateExperimentalLanguageFeature())) { /* c8 ignore next 2 */ return; } // There's already a warning on the container - if (AstUtils.hasContainerOfType(node.$container, isSdsUnionType)) { + if (AstUtils.hasContainerOfType(node.$container, isTslUnionType)) { return; } diff --git a/packages/ttsl-lang/src/language/validation/inheritance.ts b/packages/ttsl-lang/src/language/validation/inheritance.ts index dbe60708..599c410f 100644 --- a/packages/ttsl-lang/src/language/validation/inheritance.ts +++ b/packages/ttsl-lang/src/language/validation/inheritance.ts @@ -1,6 +1,6 @@ import { AstUtils, ValidationAcceptor } from 'langium'; import { isEmpty, isEqualSet } from '../../helpers/collections.js'; -import { isSdsClass, isSdsFunction, SdsClass, type SdsClassMember } from '../generated/ast.js'; +import { isTslClass, isTslFunction, TslClass, type TslClassMember } from '../generated/ast.js'; import { getParentTypes, getQualifiedName } from '../helpers/nodeProperties.js'; import { SafeDsServices } from '../safe-ds-module.js'; import { ClassType, Type, UnknownType } from '../typing/model.js'; @@ -20,7 +20,7 @@ export const classMemberMustMatchOverriddenMemberAndShouldBeNeeded = (services: const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsClassMember, accept: ValidationAcceptor): void => { + return (node: TslClassMember, accept: ValidationAcceptor): void => { // Check whether the member overrides something const overriddenMember = classHierarchy.getOverriddenMember(node); if (!overriddenMember) { @@ -54,8 +54,8 @@ export const classMemberMustMatchOverriddenMemberAndShouldBeNeeded = (services: // Reasons for impurity must differ if ( - isSdsFunction(node) && - isSdsFunction(overriddenMember) && + isTslFunction(node) && + isTslFunction(overriddenMember) && !isEqualSet( builtinAnnotations .streamImpurityReasons(node) @@ -80,8 +80,8 @@ export const classMemberMustMatchOverriddenMemberAndShouldBeNeeded = (services: }; const computeMemberTypes = ( - ownMember: SdsClassMember, - overriddenMember: SdsClassMember, + ownMember: TslClassMember, + overriddenMember: TslClassMember, typeComputer: SafeDsTypeComputer, ): ComputeMemberTypesResult => { // Compute basic types (might contain type parameters) @@ -89,11 +89,11 @@ const computeMemberTypes = ( let overriddenMemberType = typeComputer.computeType(overriddenMember); // Substitute type parameters of class containing the overridden member - const classContainingOwnMember = AstUtils.getContainerOfType(ownMember, isSdsClass); + const classContainingOwnMember = AstUtils.getContainerOfType(ownMember, isTslClass); const typeContainingOwnMember = typeComputer.computeType(classContainingOwnMember); if (typeContainingOwnMember instanceof ClassType) { - const classContainingOverriddenMember = AstUtils.getContainerOfType(overriddenMember, isSdsClass); + const classContainingOverriddenMember = AstUtils.getContainerOfType(overriddenMember, isTslClass); const typeContainingOverriddenMember = typeComputer.computeMatchingSupertype( typeContainingOwnMember, classContainingOverriddenMember, @@ -142,10 +142,10 @@ interface ComputeMemberTypesResult { substitutedOverriddenMemberType: Type; } -const isInSafedsLangAnyClass = (services: SafeDsServices, node: SdsClassMember): boolean => { - const containingClass = AstUtils.getContainerOfType(node, isSdsClass); +const isInSafedsLangAnyClass = (services: SafeDsServices, node: TslClassMember): boolean => { + const containingClass = AstUtils.getContainerOfType(node, isTslClass); return ( - isSdsClass(containingClass) && + isTslClass(containingClass) && getQualifiedName(containingClass) === getQualifiedName(services.builtins.Classes.Any) ); }; @@ -154,7 +154,7 @@ export const classMustOnlyInheritASingleClass = (services: SafeDsServices) => { const typeComputer = services.types.TypeComputer; const computeType = typeComputer.computeType.bind(typeComputer); - return (node: SdsClass, accept: ValidationAcceptor): void => { + return (node: TslClass, accept: ValidationAcceptor): void => { const parentTypes = getParentTypes(node); if (isEmpty(parentTypes)) { return; @@ -191,7 +191,7 @@ export const classMustOnlyInheritASingleClass = (services: SafeDsServices) => { export const classMustNotInheritItself = (services: SafeDsServices) => { const classHierarchy = services.types.ClassHierarchy; - return (node: SdsClass, accept: ValidationAcceptor): void => { + return (node: TslClass, accept: ValidationAcceptor): void => { const superClasses = classHierarchy.streamProperSuperclasses(node); if (superClasses.includes(node)) { accept('error', 'A class must not directly or indirectly be a subtype of itself.', { diff --git a/packages/ttsl-lang/src/language/validation/names.ts b/packages/ttsl-lang/src/language/validation/names.ts index 6dbe7471..97adac9f 100644 --- a/packages/ttsl-lang/src/language/validation/names.ts +++ b/packages/ttsl-lang/src/language/validation/names.ts @@ -3,27 +3,27 @@ import { duplicatesBy } from '../../helpers/collections.js'; import { listBuiltinFiles } from '../builtins/fileFinder.js'; import { BUILTINS_LANG_PACKAGE, BUILTINS_ROOT_PACKAGE } from '../builtins/packageNames.js'; import { - isSdsQualifiedImport, - SdsAnnotation, - SdsAttribute, - SdsBlockLambda, - SdsBlockLambdaResult, - SdsCallableType, - SdsClass, - SdsDeclaration, - SdsEnum, - SdsEnumVariant, - SdsExpressionLambda, - SdsFunction, - SdsImportedDeclaration, - SdsModule, - SdsParameter, - SdsPipeline, - SdsPlaceholder, - SdsResult, - SdsSchema, - SdsSegment, - SdsTypeParameter, + isTslQualifiedImport, + TslAnnotation, + TslAttribute, + TslBlockLambda, + TslBlockLambdaResult, + TslCallableType, + TslClass, + TslDeclaration, + TslEnum, + TslEnumVariant, + TslExpressionLambda, + TslFunction, + TslImportedDeclaration, + TslModule, + TslParameter, + TslPipeline, + TslPlaceholder, + TslResult, + TslSchema, + TslSegment, + TslTypeParameter, } from '../generated/ast.js'; import { CODEGEN_PREFIX } from '../generation/safe-ds-python-generator.js'; import { isInPipelineFile, isInStubFile, isInTestFile } from '../helpers/fileExtensions.js'; @@ -54,7 +54,7 @@ export const CODE_NAME_DUPLICATE = 'name/duplicate'; // Codegen prefix // ----------------------------------------------------------------------------- -export const nameMustNotStartWithCodegenPrefix = (node: SdsDeclaration, accept: ValidationAcceptor) => { +export const nameMustNotStartWithCodegenPrefix = (node: TslDeclaration, accept: ValidationAcceptor) => { const name = node.name ?? ''; if (name.startsWith(CODEGEN_PREFIX)) { accept( @@ -76,7 +76,7 @@ export const nameMustNotStartWithCodegenPrefix = (node: SdsDeclaration, accept: export const nameMustNotOccurOnCoreDeclaration = (services: SafeDsServices) => { const packageManager = services.workspace.PackageManager; - return (node: SdsDeclaration, accept: ValidationAcceptor) => { + return (node: TslDeclaration, accept: ValidationAcceptor) => { if (!node.name) { /* c8 ignore next 2 */ return; @@ -106,28 +106,28 @@ export const nameMustNotOccurOnCoreDeclaration = (services: SafeDsServices) => { export const nameShouldHaveCorrectCasing = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsDeclaration, accept: ValidationAcceptor) => { + return async (node: TslDeclaration, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateNameConvention())) { /* c8 ignore next 2 */ return; } switch (node.$type) { - case SdsAnnotation: + case TslAnnotation: return nameShouldBeUpperCamelCase(node, 'annotations', accept); - case SdsAttribute: + case TslAttribute: return nameShouldBeLowerCamelCase(node, 'attributes', accept); - case SdsBlockLambdaResult: + case TslBlockLambdaResult: return nameShouldBeLowerCamelCase(node, 'block lambda results', accept); - case SdsClass: + case TslClass: return nameShouldBeUpperCamelCase(node, 'classes', accept); - case SdsEnum: + case TslEnum: return nameShouldBeUpperCamelCase(node, 'enums', accept); - case SdsEnumVariant: + case TslEnumVariant: return nameShouldBeUpperCamelCase(node, 'enum variants', accept); - case SdsFunction: + case TslFunction: return nameShouldBeLowerCamelCase(node, 'functions', accept); - case SdsModule: + case TslModule: const name = node.name ?? ''; const segments = name.split('.'); if (name !== '' && segments.every((it) => it !== '') && !segments.every(isLowerCamelCase)) { @@ -138,26 +138,26 @@ export const nameShouldHaveCorrectCasing = (services: SafeDsServices) => { }); } return; - case SdsParameter: + case TslParameter: return nameShouldBeLowerCamelCase(node, 'parameters', accept); - case SdsPipeline: + case TslPipeline: return nameShouldBeLowerCamelCase(node, 'pipelines', accept); - case SdsPlaceholder: + case TslPlaceholder: return nameShouldBeLowerCamelCase(node, 'placeholders', accept); - case SdsResult: + case TslResult: return nameShouldBeLowerCamelCase(node, 'results', accept); - case SdsSchema: + case TslSchema: return nameShouldBeUpperCamelCase(node, 'schemas', accept); - case SdsSegment: + case TslSegment: return nameShouldBeLowerCamelCase(node, 'segments', accept); - case SdsTypeParameter: + case TslTypeParameter: return nameShouldBeUpperCamelCase(node, 'type parameters', accept); } /* c8 ignore next */ }; }; -const nameShouldBeLowerCamelCase = (node: SdsDeclaration, nodeName: string, accept: ValidationAcceptor): void => { +const nameShouldBeLowerCamelCase = (node: TslDeclaration, nodeName: string, accept: ValidationAcceptor): void => { const name = node.name ?? ''; if (!isLowerCamelCase(name)) { acceptCasingWarning(node, nodeName, 'lowerCamelCase', accept); @@ -168,7 +168,7 @@ const isLowerCamelCase = (name: string): boolean => { return /^[a-z][a-zA-Z0-9]*$/gu.test(name); }; -const nameShouldBeUpperCamelCase = (node: SdsDeclaration, nodeName: string, accept: ValidationAcceptor): void => { +const nameShouldBeUpperCamelCase = (node: TslDeclaration, nodeName: string, accept: ValidationAcceptor): void => { const name = node.name ?? ''; if (!isUpperCamelCase(name)) { acceptCasingWarning(node, nodeName, 'UpperCamelCase', accept); @@ -180,7 +180,7 @@ const isUpperCamelCase = (name: string): boolean => { }; const acceptCasingWarning = ( - node: SdsDeclaration, + node: TslDeclaration, nodeName: string, expectedCasing: string, accept: ValidationAcceptor, @@ -196,11 +196,11 @@ const acceptCasingWarning = ( // Uniqueness // ----------------------------------------------------------------------------- -export const annotationMustContainUniqueNames = (node: SdsAnnotation, accept: ValidationAcceptor): void => { +export const annotationMustContainUniqueNames = (node: TslAnnotation, accept: ValidationAcceptor): void => { namesMustBeUnique(getParameters(node), (name) => `A parameter with name '${name}' exists already.`, accept); }; -export const blockLambdaMustContainUniqueNames = (node: SdsBlockLambda, accept: ValidationAcceptor): void => { +export const blockLambdaMustContainUniqueNames = (node: TslBlockLambda, accept: ValidationAcceptor): void => { const parametersAndPlaceholders = [...getParameters(node), ...streamPlaceholders(node.body)]; namesMustBeUnique( parametersAndPlaceholders, @@ -211,12 +211,12 @@ export const blockLambdaMustContainUniqueNames = (node: SdsBlockLambda, accept: namesMustBeUnique(streamBlockLambdaResults(node), (name) => `A result with name '${name}' exists already.`, accept); }; -export const callableTypeMustContainUniqueNames = (node: SdsCallableType, accept: ValidationAcceptor): void => { +export const callableTypeMustContainUniqueNames = (node: TslCallableType, accept: ValidationAcceptor): void => { namesMustBeUnique(getParameters(node), (name) => `A parameter with name '${name}' exists already.`, accept); namesMustBeUnique(getResults(node.resultList), (name) => `A result with name '${name}' exists already.`, accept); }; -export const classMustContainUniqueNames = (node: SdsClass, accept: ValidationAcceptor): void => { +export const classMustContainUniqueNames = (node: TslClass, accept: ValidationAcceptor): void => { const typeParametersAndParameters = [...getTypeParameters(node.typeParameterList), ...getParameters(node)]; namesMustBeUnique( typeParametersAndParameters, @@ -231,20 +231,20 @@ export const classMustContainUniqueNames = (node: SdsClass, accept: ValidationAc namesMustBeUnique(staticMembers, (name) => `A static member with name '${name}' exists already.`, accept); }; -export const enumMustContainUniqueNames = (node: SdsEnum, accept: ValidationAcceptor): void => { +export const enumMustContainUniqueNames = (node: TslEnum, accept: ValidationAcceptor): void => { namesMustBeUnique(getEnumVariants(node), (name) => `A variant with name '${name}' exists already.`, accept); }; -export const enumVariantMustContainUniqueNames = (node: SdsEnumVariant, accept: ValidationAcceptor): void => { +export const enumVariantMustContainUniqueNames = (node: TslEnumVariant, accept: ValidationAcceptor): void => { const parameters = [...getParameters(node)]; namesMustBeUnique(parameters, (name) => `A parameter with name '${name}' exists already.`, accept); }; -export const expressionLambdaMustContainUniqueNames = (node: SdsExpressionLambda, accept: ValidationAcceptor): void => { +export const expressionLambdaMustContainUniqueNames = (node: TslExpressionLambda, accept: ValidationAcceptor): void => { namesMustBeUnique(getParameters(node), (name) => `A parameter with name '${name}' exists already.`, accept); }; -export const functionMustContainUniqueNames = (node: SdsFunction, accept: ValidationAcceptor): void => { +export const functionMustContainUniqueNames = (node: TslFunction, accept: ValidationAcceptor): void => { const typeParametersAndParameters = [...getTypeParameters(node.typeParameterList), ...getParameters(node)]; namesMustBeUnique( typeParametersAndParameters, @@ -259,7 +259,7 @@ export const moduleMemberMustHaveNameThatIsUniqueInPackage = (services: SafeDsSe const packageManager = services.workspace.PackageManager; const builtinUris = new Set(listBuiltinFiles().map((it) => it.toString())); - return (node: SdsModule, accept: ValidationAcceptor): void => { + return (node: TslModule, accept: ValidationAcceptor): void => { const moduleUri = AstUtils.getDocument(node).uri?.toString(); if (builtinUris.has(moduleUri)) { return; @@ -297,9 +297,9 @@ export const moduleMemberMustHaveNameThatIsUniqueInPackage = (services: SafeDsSe }; }; -export const moduleMustContainUniqueNames = (node: SdsModule, accept: ValidationAcceptor): void => { +export const moduleMustContainUniqueNames = (node: TslModule, accept: ValidationAcceptor): void => { // Names of imported declarations must be unique - const importedDeclarations = getImports(node).filter(isSdsQualifiedImport).flatMap(getImportedDeclarations); + const importedDeclarations = getImports(node).filter(isTslQualifiedImport).flatMap(getImportedDeclarations); for (const duplicate of duplicatesBy(importedDeclarations, importedDeclarationName)) { if (duplicate.alias) { accept('error', `A declaration with name '${importedDeclarationName(duplicate)}' was imported already.`, { @@ -340,11 +340,11 @@ export const moduleMustContainUniqueNames = (node: SdsModule, accept: Validation } }; -const importedDeclarationName = (node: SdsImportedDeclaration | undefined): string | undefined => { +const importedDeclarationName = (node: TslImportedDeclaration | undefined): string | undefined => { return node?.alias?.alias ?? node?.declaration?.ref?.name; }; -export const pipelineMustContainUniqueNames = (node: SdsPipeline, accept: ValidationAcceptor): void => { +export const pipelineMustContainUniqueNames = (node: TslPipeline, accept: ValidationAcceptor): void => { namesMustBeUnique( streamPlaceholders(node.body), (name) => `A placeholder with name '${name}' exists already.`, @@ -352,7 +352,7 @@ export const pipelineMustContainUniqueNames = (node: SdsPipeline, accept: Valida ); }; -export const schemaMustContainUniqueNames = (node: SdsSchema, accept: ValidationAcceptor): void => { +export const schemaMustContainUniqueNames = (node: TslSchema, accept: ValidationAcceptor): void => { const duplicates = duplicatesBy(getColumns(node), (it) => it.columnName.value); for (const duplicate of duplicates) { accept('error', `A column with name '${duplicate.columnName.value}' exists already.`, { @@ -363,7 +363,7 @@ export const schemaMustContainUniqueNames = (node: SdsSchema, accept: Validation } }; -export const segmentMustContainUniqueNames = (node: SdsSegment, accept: ValidationAcceptor): void => { +export const segmentMustContainUniqueNames = (node: TslSegment, accept: ValidationAcceptor): void => { const parametersAndPlaceholder = [...getParameters(node), ...streamPlaceholders(node.body)]; namesMustBeUnique( parametersAndPlaceholder, @@ -375,10 +375,10 @@ export const segmentMustContainUniqueNames = (node: SdsSegment, accept: Validati }; const namesMustBeUnique = ( - nodes: Iterable, + nodes: Iterable, createMessage: (name: string) => string, accept: ValidationAcceptor, - shouldReportErrorOn: (node: SdsDeclaration) => boolean = () => true, + shouldReportErrorOn: (node: TslDeclaration) => boolean = () => true, ): void => { for (const node of duplicatesBy(nodes, (it) => it.name)) { if (shouldReportErrorOn(node)) { diff --git a/packages/ttsl-lang/src/language/validation/other/argumentLists.ts b/packages/ttsl-lang/src/language/validation/other/argumentLists.ts index b3cd6884..2c902ac9 100644 --- a/packages/ttsl-lang/src/language/validation/other/argumentLists.ts +++ b/packages/ttsl-lang/src/language/validation/other/argumentLists.ts @@ -1,7 +1,7 @@ import { AstUtils, ValidationAcceptor } from 'langium'; import { duplicatesBy, isEmpty } from '../../../helpers/collections.js'; import { pluralize } from '../../../helpers/strings.js'; -import { isSdsAnnotation, isSdsCall, SdsAbstractCall, SdsArgumentList } from '../../generated/ast.js'; +import { isTslAnnotation, isTslCall, TslAbstractCall, TslArgumentList } from '../../generated/ast.js'; import { getArguments, getParameters, Parameter } from '../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../safe-ds-module.js'; @@ -11,7 +11,7 @@ export const CODE_ARGUMENT_LIST_POSITIONAL_AFTER_NAMED = 'argument-list/position export const CODE_ARGUMENT_LIST_TOO_MANY_ARGUMENTS = 'argument-list/too-many-arguments'; export const argumentListMustNotHavePositionalArgumentsAfterNamedArguments = ( - node: SdsArgumentList, + node: TslArgumentList, accept: ValidationAcceptor, ): void => { let foundNamed = false; @@ -30,7 +30,7 @@ export const argumentListMustNotHavePositionalArgumentsAfterNamedArguments = ( export const argumentListMustNotHaveTooManyArguments = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsAbstractCall, accept: ValidationAcceptor): void => { + return (node: TslAbstractCall, accept: ValidationAcceptor): void => { const actualArgumentCount = getArguments(node).length; // We can never have too many arguments in this case @@ -40,7 +40,7 @@ export const argumentListMustNotHaveTooManyArguments = (services: SafeDsServices // We already report other errors in those cases const callable = nodeMapper.callToCallable(node); - if (!callable || (isSdsCall(node) && isSdsAnnotation(callable))) { + if (!callable || (isTslCall(node) && isTslAnnotation(callable))) { return; } @@ -78,11 +78,11 @@ export const argumentListMustNotSetParameterMultipleTimes = (services: SafeDsSer const nodeMapper = services.helpers.NodeMapper; const argumentToParameterOrUndefined = nodeMapper.argumentToParameter.bind(nodeMapper); - return (node: SdsArgumentList, accept: ValidationAcceptor): void => { + return (node: TslArgumentList, accept: ValidationAcceptor): void => { // We already report other errors in this case - const containingCall = AstUtils.getContainerOfType(node, isSdsCall); + const containingCall = AstUtils.getContainerOfType(node, isTslCall); const callable = nodeMapper.callToCallable(containingCall); - if (isSdsAnnotation(callable)) { + if (isTslAnnotation(callable)) { return; } @@ -102,7 +102,7 @@ export const argumentListMustNotSetParameterMultipleTimes = (services: SafeDsSer export const argumentListMustSetAllRequiredParameters = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsAbstractCall, accept: ValidationAcceptor): void => { + return (node: TslAbstractCall, accept: ValidationAcceptor): void => { // We already report other errors in this case if (!node.argumentList) { return; @@ -110,7 +110,7 @@ export const argumentListMustSetAllRequiredParameters = (services: SafeDsService // We already report other errors in those cases const callable = nodeMapper.callToCallable(node); - if (!callable || (isSdsCall(node) && isSdsAnnotation(callable))) { + if (!callable || (isTslCall(node) && isTslAnnotation(callable))) { return; } diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/annotationCalls.ts b/packages/ttsl-lang/src/language/validation/other/declarations/annotationCalls.ts index af36262f..cfbb9589 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/annotationCalls.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/annotationCalls.ts @@ -1,13 +1,13 @@ import { AstUtils, ValidationAcceptor } from 'langium'; import { isEmpty } from '../../../../helpers/collections.js'; import { - isSdsCallable, - isSdsCallableType, - isSdsLambda, - SdsAnnotationCall, - SdsCallableType, - SdsLambda, - SdsParameter, + isTslCallable, + isTslCallableType, + isTslLambda, + TslAnnotationCall, + TslCallableType, + TslLambda, + TslParameter, } from '../../../generated/ast.js'; import { getAnnotationCalls, @@ -26,7 +26,7 @@ export const CODE_ANNOTATION_CALL_TARGET_RESULT = 'annotation-call/target-result export const annotationCallArgumentsMustBeConstant = (services: SafeDsServices) => { const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsAnnotationCall, accept: ValidationAcceptor) => { + return (node: TslAnnotationCall, accept: ValidationAcceptor) => { for (const argument of getArguments(node)) { if (!partialEvaluator.canBeValueOfConstantParameter(argument.value)) { accept('error', 'Values assigned to annotation parameters must be constant.', { @@ -39,7 +39,7 @@ export const annotationCallArgumentsMustBeConstant = (services: SafeDsServices) }; }; -export const annotationCallMustNotLackArgumentList = (node: SdsAnnotationCall, accept: ValidationAcceptor) => { +export const annotationCallMustNotLackArgumentList = (node: TslAnnotationCall, accept: ValidationAcceptor) => { if (node.argumentList) { return; } @@ -58,7 +58,7 @@ export const annotationCallMustNotLackArgumentList = (node: SdsAnnotationCall, a } }; -export const callableTypeParametersMustNotBeAnnotated = (node: SdsCallableType, accept: ValidationAcceptor) => { +export const callableTypeParametersMustNotBeAnnotated = (node: TslCallableType, accept: ValidationAcceptor) => { for (const parameter of getParameters(node)) { for (const annotationCall of getAnnotationCalls(parameter)) { accept('error', 'Parameters of callable types must not be annotated.', { @@ -69,7 +69,7 @@ export const callableTypeParametersMustNotBeAnnotated = (node: SdsCallableType, } }; -export const callableTypeResultsMustNotBeAnnotated = (node: SdsCallableType, accept: ValidationAcceptor) => { +export const callableTypeResultsMustNotBeAnnotated = (node: TslCallableType, accept: ValidationAcceptor) => { for (const result of getResults(node.resultList)) { for (const annotationCall of getAnnotationCalls(result)) { accept('error', 'Results of callable types must not be annotated.', { @@ -80,7 +80,7 @@ export const callableTypeResultsMustNotBeAnnotated = (node: SdsCallableType, acc } }; -export const lambdaParametersMustNotBeAnnotated = (node: SdsLambda, accept: ValidationAcceptor) => { +export const lambdaParametersMustNotBeAnnotated = (node: TslLambda, accept: ValidationAcceptor) => { for (const parameter of getParameters(node)) { for (const annotationCall of getAnnotationCalls(parameter)) { accept('error', 'Lambda parameters must not be annotated.', { @@ -91,7 +91,7 @@ export const lambdaParametersMustNotBeAnnotated = (node: SdsLambda, accept: Vali } }; -export const parameterCanBeAnnotated = (node: SdsParameter) => { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); - return !isSdsCallableType(containingCallable) && !isSdsLambda(containingCallable); +export const parameterCanBeAnnotated = (node: TslParameter) => { + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); + return !isTslCallableType(containingCallable) && !isTslLambda(containingCallable); }; diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/parameterBounds.ts b/packages/ttsl-lang/src/language/validation/other/declarations/parameterBounds.ts index 6e2360aa..043898d9 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/parameterBounds.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/parameterBounds.ts @@ -1,10 +1,10 @@ import { SafeDsServices } from '../../../safe-ds-module.js'; import { - isSdsCallable, - isSdsComparisonOperator, - type SdsCall, - SdsParameter, - SdsParameterBound, + isTslCallable, + isTslComparisonOperator, + type TslCall, + TslParameter, + TslParameterBound, } from '../../../generated/ast.js'; import { AstUtils, ValidationAcceptor } from 'langium'; import { getArguments, getParameters, Parameter } from '../../../helpers/nodeProperties.js'; @@ -18,7 +18,7 @@ export const callArgumentMustRespectParameterBounds = (services: SafeDsServices) const nodeMapper = services.helpers.NodeMapper; const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsCall, accept: ValidationAcceptor) => { + return (node: TslCall, accept: ValidationAcceptor) => { const substitutions = partialEvaluator.computeParameterSubstitutionsForCall(node); for (const argument of getArguments(node)) { @@ -51,7 +51,7 @@ export const callArgumentMustRespectParameterBounds = (services: SafeDsServices) export const parameterDefaultValueMustRespectParameterBounds = (services: SafeDsServices) => { const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsParameter, accept: ValidationAcceptor) => { + return (node: TslParameter, accept: ValidationAcceptor) => { if (!node.defaultValue) { return; } @@ -98,7 +98,7 @@ const checkBound = ( // Arguments must be valid if ( (!(leftOperand instanceof FloatConstant) && !(leftOperand instanceof IntConstant)) || - !isSdsComparisonOperator(operator) || + !isTslComparisonOperator(operator) || (!(rightOperand instanceof FloatConstant) && !(rightOperand instanceof IntConstant)) ) { return; @@ -134,7 +134,7 @@ export const parameterBoundParameterMustBeConstFloatOrInt = (services: SafeDsSer const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsParameterBound, accept: ValidationAcceptor) => { + return (node: TslParameterBound, accept: ValidationAcceptor) => { const parameter = node.leftOperand?.ref; if (!parameter) { return; @@ -167,7 +167,7 @@ export const parameterBoundRightOperandMustEvaluateToFloatConstantOrIntConstant const partialEvaluator = services.evaluation.PartialEvaluator; const one = new IntConstant(1n); - return (node: SdsParameterBound, accept: ValidationAcceptor) => { + return (node: TslParameterBound, accept: ValidationAcceptor) => { const rightOperandType = typeComputer.computeType(node.rightOperand); // Must have correct type @@ -177,7 +177,7 @@ export const parameterBoundRightOperandMustEvaluateToFloatConstantOrIntConstant // Must evaluate to a constant after substituting constant parameters if (rightOperandIsValid) { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); const constantParameters = getParameters(containingCallable).filter(Parameter.isConstant); const substitutions = new Map(constantParameters.map((it) => [it, one])); const value = partialEvaluator.evaluate(node.rightOperand, substitutions); diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/parameterLists.ts b/packages/ttsl-lang/src/language/validation/other/declarations/parameterLists.ts index 0dfdfc58..7691eb27 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/parameterLists.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/parameterLists.ts @@ -1,11 +1,11 @@ import { ValidationAcceptor } from 'langium'; -import { SdsParameterList } from '../../../generated/ast.js'; +import { TslParameterList } from '../../../generated/ast.js'; import { Parameter } from '../../../helpers/nodeProperties.js'; export const CODE_PARAMETER_LIST_REQUIRED_AFTER_OPTIONAL = 'parameter-list/required-after-optional'; export const parameterListMustNotHaveRequiredParametersAfterOptionalParameters = ( - node: SdsParameterList, + node: TslParameterList, accept: ValidationAcceptor, ) => { let foundOptional = false; diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/parameters.ts b/packages/ttsl-lang/src/language/validation/other/declarations/parameters.ts index b33d3bd4..746e5c2c 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/parameters.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/parameters.ts @@ -1,5 +1,5 @@ import { AstUtils, ValidationAcceptor } from 'langium'; -import { isSdsAnnotation, isSdsCallable, SdsParameter } from '../../../generated/ast.js'; +import { isTslAnnotation, isTslCallable, TslParameter } from '../../../generated/ast.js'; import { Parameter } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -9,14 +9,14 @@ export const CODE_PARAMETER_CONSTANT_TYPE = 'parameter/constant-type'; export const constantParameterMustHaveConstantDefaultValue = (services: SafeDsServices) => { const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsParameter, accept: ValidationAcceptor) => { + return (node: TslParameter, accept: ValidationAcceptor) => { if (!Parameter.isConstant(node) || !node.defaultValue) { return; } if (!partialEvaluator.canBeValueOfConstantParameter(node.defaultValue)) { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); - const kind = isSdsAnnotation(containingCallable) ? 'annotation' : 'constant'; + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); + const kind = isTslAnnotation(containingCallable) ? 'annotation' : 'constant'; accept('error', `Default values of ${kind} parameters must be constant.`, { node, @@ -31,15 +31,15 @@ export const constantParameterMustHaveTypeThatCanBeEvaluatedToConstant = (servic const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsParameter, accept: ValidationAcceptor) => { + return (node: TslParameter, accept: ValidationAcceptor) => { if (!Parameter.isConstant(node) || !node.type) { return; } const type = typeComputer.computeType(node); if (!typeChecker.canBeTypeOfConstantParameter(type)) { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); - const kind = isSdsAnnotation(containingCallable) ? 'An annotation' : 'A constant'; + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); + const kind = isTslAnnotation(containingCallable) ? 'An annotation' : 'A constant'; accept('error', `${kind} parameter cannot have type '${type.toString()}'.`, { node, diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/placeholders.ts b/packages/ttsl-lang/src/language/validation/other/declarations/placeholders.ts index 10f16f36..ff55d0b2 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/placeholders.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/placeholders.ts @@ -1,11 +1,11 @@ import { - isSdsAssignment, - isSdsBlock, - isSdsParameter, - isSdsPlaceholder, - isSdsReference, - isSdsStatement, - SdsPlaceholder, + isTslAssignment, + isTslBlock, + isTslParameter, + isTslPlaceholder, + isTslReference, + isTslStatement, + TslPlaceholder, } from '../../../generated/ast.js'; import { AstUtils, ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -16,19 +16,19 @@ import { last } from '../../../../helpers/collections.js'; export const CODE_PLACEHOLDER_ALIAS = 'placeholder/alias'; export const CODE_PLACEHOLDER_UNUSED = 'placeholder/unused'; -export const placeholdersMustNotBeAnAlias = (node: SdsPlaceholder, accept: ValidationAcceptor): void => { +export const placeholdersMustNotBeAnAlias = (node: TslPlaceholder, accept: ValidationAcceptor): void => { if (node.$containerIndex ?? 0 > 0) { return; } - const containingAssignment = AstUtils.getContainerOfType(node, isSdsAssignment); + const containingAssignment = AstUtils.getContainerOfType(node, isTslAssignment); const rhs = containingAssignment?.expression; - if (!isSdsReference(rhs)) { + if (!isTslReference(rhs)) { return; } const referenceTarget = rhs.target.ref; - if (isSdsParameter(referenceTarget) || isSdsPlaceholder(referenceTarget)) { + if (isTslParameter(referenceTarget) || isTslPlaceholder(referenceTarget)) { accept('error', 'Aliases are not allowed to provide a cleaner graphical view.', { node, property: 'name', @@ -38,15 +38,15 @@ export const placeholdersMustNotBeAnAlias = (node: SdsPlaceholder, accept: Valid }; export const placeholderShouldBeUsed = - (services: SafeDsServices) => (node: SdsPlaceholder, accept: ValidationAcceptor) => { + (services: SafeDsServices) => (node: TslPlaceholder, accept: ValidationAcceptor) => { const usages = services.helpers.NodeMapper.placeholderToReferences(node); if (!usages.isEmpty()) { return; } // Don't show a warning if the placeholder is declared in the last statement in the block - const containingStatement = AstUtils.getContainerOfType(node, isSdsStatement); - const containingBlock = AstUtils.getContainerOfType(containingStatement, isSdsBlock); + const containingStatement = AstUtils.getContainerOfType(node, isTslStatement); + const containingBlock = AstUtils.getContainerOfType(containingStatement, isTslBlock); const allStatementsInBlock = getStatements(containingBlock); if (last(allStatementsInBlock) === containingStatement) { return; diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/segments.ts b/packages/ttsl-lang/src/language/validation/other/declarations/segments.ts index 6a7280f4..74a14a90 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/segments.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/segments.ts @@ -1,4 +1,4 @@ -import { SdsSegment } from '../../../generated/ast.js'; +import { TslSegment } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { getParameters, getResults } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -12,7 +12,7 @@ export const CODE_SEGMENT_UNUSED_PARAMETER = 'segment/unused-parameter'; export const segmentResultMustBeAssignedExactlyOnce = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsSegment, accept: ValidationAcceptor) => { + return (node: TslSegment, accept: ValidationAcceptor) => { const results = getResults(node.resultList); for (const result of results) { const yields = nodeMapper.resultToYields(result); @@ -40,7 +40,7 @@ export const segmentResultMustBeAssignedExactlyOnce = (services: SafeDsServices) export const segmentShouldBeUsed = (services: SafeDsServices) => { const referenceProvider = services.references.References; - return (node: SdsSegment, accept: ValidationAcceptor) => { + return (node: TslSegment, accept: ValidationAcceptor) => { // Don't show this warning for public segments if (node.visibility === undefined) { return; @@ -61,7 +61,7 @@ export const segmentShouldBeUsed = (services: SafeDsServices) => { export const segmentParameterShouldBeUsed = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsSegment, accept: ValidationAcceptor) => { + return (node: TslSegment, accept: ValidationAcceptor) => { for (const parameter of getParameters(node)) { const usages = nodeMapper.parameterToReferences(parameter); diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/typeParameterLists.ts b/packages/ttsl-lang/src/language/validation/other/declarations/typeParameterLists.ts index beeeeeae..10a2682f 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/typeParameterLists.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/typeParameterLists.ts @@ -1,11 +1,11 @@ import { ValidationAcceptor } from 'langium'; -import { SdsTypeParameterList } from '../../../generated/ast.js'; +import { TslTypeParameterList } from '../../../generated/ast.js'; import { TypeParameter } from '../../../helpers/nodeProperties.js'; export const CODE_TYPE_PARAMETER_LIST_REQUIRED_AFTER_OPTIONAL = 'type-parameter-list/required-after-optional'; export const typeParameterListMustNotHaveRequiredTypeParametersAfterOptionalTypeParameters = ( - node: SdsTypeParameterList, + node: TslTypeParameterList, accept: ValidationAcceptor, ) => { let foundOptional = false; diff --git a/packages/ttsl-lang/src/language/validation/other/declarations/typeParameters.ts b/packages/ttsl-lang/src/language/validation/other/declarations/typeParameters.ts index a9f0b58a..66829f22 100644 --- a/packages/ttsl-lang/src/language/validation/other/declarations/typeParameters.ts +++ b/packages/ttsl-lang/src/language/validation/other/declarations/typeParameters.ts @@ -1,17 +1,17 @@ import { AstNode, AstUtils, ValidationAcceptor } from 'langium'; import { - isSdsCallable, - isSdsClass, - isSdsClassMember, - isSdsDeclaration, - isSdsNamedTypeDeclaration, - isSdsParameter, - isSdsParameterList, - isSdsTypeArgument, - isSdsUnionType, - SdsClass, - SdsDeclaration, - SdsTypeParameter, + isTslCallable, + isTslClass, + isTslClassMember, + isTslDeclaration, + isTslNamedTypeDeclaration, + isTslParameter, + isTslParameterList, + isTslTypeArgument, + isTslUnionType, + TslClass, + TslDeclaration, + TslTypeParameter, } from '../../../generated/ast.js'; import { isStatic, TypeParameter } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -23,8 +23,8 @@ export const CODE_TYPE_PARAMETER_UPPER_BOUND = 'type-parameter/upper-bound'; export const CODE_TYPE_PARAMETER_USAGE = 'type-parameter/usage'; export const CODE_TYPE_PARAMETER_VARIANCE = 'type-parameter/variance'; -export const typeParameterMustHaveSufficientContext = (node: SdsTypeParameter, accept: ValidationAcceptor) => { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); +export const typeParameterMustHaveSufficientContext = (node: TslTypeParameter, accept: ValidationAcceptor) => { + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); /* c8 ignore start */ if (!containingCallable) { return; @@ -32,7 +32,7 @@ export const typeParameterMustHaveSufficientContext = (node: SdsTypeParameter, a /* c8 ignore stop */ // Classes without constructor can only be used as named types, where type arguments are manifest - if (isSdsClass(containingCallable) && !containingCallable.parameterList) { + if (isTslClass(containingCallable) && !containingCallable.parameterList) { return; } @@ -43,10 +43,10 @@ export const typeParameterMustHaveSufficientContext = (node: SdsTypeParameter, a // ...but references in a union type or in the parameter list of a callable type don't count .filter((reference) => { const referenceNode = reference.$refNode?.astNode; - const containingParameterList = AstUtils.getContainerOfType(referenceNode, isSdsParameterList); + const containingParameterList = AstUtils.getContainerOfType(referenceNode, isTslParameterList); return ( - !AstUtils.hasContainerOfType(referenceNode, isSdsUnionType) && + !AstUtils.hasContainerOfType(referenceNode, isTslUnionType) && containingParameterList === containingCallable.parameterList ); }) @@ -64,7 +64,7 @@ export const typeParameterMustHaveSufficientContext = (node: SdsTypeParameter, a export const typeParameterUpperBoundMustBeNamedType = (services: SafeDsServices) => { const typeComputer = services.types.TypeComputer; - return (node: SdsTypeParameter, accept: ValidationAcceptor) => { + return (node: TslTypeParameter, accept: ValidationAcceptor) => { const boundType = typeComputer.computeType(node.upperBound); if (boundType !== UnknownType && !(boundType instanceof NamedType)) { @@ -80,13 +80,13 @@ export const typeParameterUpperBoundMustBeNamedType = (services: SafeDsServices) export const typeParameterMustBeUsedInCorrectPosition = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsTypeParameter, accept: ValidationAcceptor) => { - const declarationWithTypeParameter = AstUtils.getContainerOfType(node.$container, isSdsDeclaration); + return (node: TslTypeParameter, accept: ValidationAcceptor) => { + const declarationWithTypeParameter = AstUtils.getContainerOfType(node.$container, isTslDeclaration); // Early exit if ( !declarationWithTypeParameter || - (!isSdsClass(declarationWithTypeParameter) && TypeParameter.isInvariant(node)) + (!isTslClass(declarationWithTypeParameter) && TypeParameter.isInvariant(node)) ) { return; } @@ -100,7 +100,7 @@ export const typeParameterMustBeUsedInCorrectPosition = (services: SafeDsService // Check usage of class type parameters if ( - isSdsClass(declarationWithTypeParameter) && + isTslClass(declarationWithTypeParameter) && !classTypeParameterIsUsedInCorrectPosition(declarationWithTypeParameter, reference) ) { accept('error', 'This type parameter of a containing class cannot be used here.', { @@ -141,12 +141,12 @@ export const typeParameterMustBeUsedInCorrectPosition = (services: SafeDsService }; const isInConstructor = (node: AstNode) => { - const parameterList = AstUtils.getContainerOfType(node, isSdsParameterList); - return isSdsClass(parameterList?.$container); + const parameterList = AstUtils.getContainerOfType(node, isTslParameterList); + return isTslClass(parameterList?.$container); }; -const classTypeParameterIsUsedInCorrectPosition = (classWithTypeParameter: SdsClass, reference: AstNode) => { - const containingClassMember = AstUtils.getContainerOfType(reference, isSdsClassMember); +const classTypeParameterIsUsedInCorrectPosition = (classWithTypeParameter: TslClass, reference: AstNode) => { + const containingClassMember = AstUtils.getContainerOfType(reference, isTslClassMember); // Handle usage in constructor if (!containingClassMember || containingClassMember === classWithTypeParameter) { @@ -159,7 +159,7 @@ const classTypeParameterIsUsedInCorrectPosition = (classWithTypeParameter: SdsCl } // Handle usage inside nested enums and classes (could be an instance attribute/function) - const containingNamedTypeDeclaration = AstUtils.getContainerOfType(reference, isSdsNamedTypeDeclaration); + const containingNamedTypeDeclaration = AstUtils.getContainerOfType(reference, isTslNamedTypeDeclaration); return !containingNamedTypeDeclaration || containingNamedTypeDeclaration === classWithTypeParameter; }; @@ -167,7 +167,7 @@ type TypePosition = 'contravariant' | 'covariant' | 'invariant'; const getTypePosition = ( nodeMapper: SafeDsNodeMapper, - declarationWithTypeParameter: SdsDeclaration, + declarationWithTypeParameter: TslDeclaration, reference: AstNode, ): TypePosition => { let current: AstNode | undefined = reference; @@ -176,9 +176,9 @@ const getTypePosition = ( while (current && current !== declarationWithTypeParameter && result !== 'invariant') { let step: TypePosition; - if (isSdsParameter(current)) { + if (isTslParameter(current)) { step = 'contravariant'; - } else if (isSdsTypeArgument(current)) { + } else if (isTslTypeArgument(current)) { const typeParameter = nodeMapper.typeArgumentToTypeParameter(current); if (TypeParameter.isContravariant(typeParameter)) { @@ -217,13 +217,13 @@ const nextTypePosition = (aggregator: TypePosition, step: TypePosition): TypePos } }; -export const typeParameterMustOnlyBeVariantOnClass = (node: SdsTypeParameter, accept: ValidationAcceptor) => { +export const typeParameterMustOnlyBeVariantOnClass = (node: TslTypeParameter, accept: ValidationAcceptor) => { if (TypeParameter.isInvariant(node)) { return; } - const declarationWithTypeParameter = AstUtils.getContainerOfType(node.$container, isSdsDeclaration); - if (declarationWithTypeParameter && !isSdsClass(declarationWithTypeParameter)) { + const declarationWithTypeParameter = AstUtils.getContainerOfType(node.$container, isTslDeclaration); + if (declarationWithTypeParameter && !isTslClass(declarationWithTypeParameter)) { accept('error', 'Only type parameters of classes can be variant.', { node, property: 'variance', diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/calls.ts b/packages/ttsl-lang/src/language/validation/other/expressions/calls.ts index 8aae2d4f..43a998f9 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/calls.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/calls.ts @@ -1,5 +1,5 @@ import { ValidationAcceptor } from 'langium'; -import { type SdsCall } from '../../../generated/ast.js'; +import { type TslCall } from '../../../generated/ast.js'; import { getArguments, Parameter } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -10,7 +10,7 @@ export const callArgumentMustBeConstantIfParameterIsConstant = (services: SafeDs const nodeMapper = services.helpers.NodeMapper; const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsCall, accept: ValidationAcceptor) => { + return (node: TslCall, accept: ValidationAcceptor) => { for (const argument of getArguments(node)) { if (!argument.value) { /* c8 ignore next 2 */ @@ -36,7 +36,7 @@ export const callArgumentMustBeConstantIfParameterIsConstant = (services: SafeDs export const callMustNotBeRecursive = (services: SafeDsServices) => { const callGraphComputer = services.flow.CallGraphComputer; - return (node: SdsCall, accept: ValidationAcceptor) => { + return (node: TslCall, accept: ValidationAcceptor) => { if (callGraphComputer.isRecursive(node)) { accept('error', 'Call leads to infinite recursion.', { node, diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/chainedExpressions.ts b/packages/ttsl-lang/src/language/validation/other/expressions/chainedExpressions.ts index e8880338..befba295 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/chainedExpressions.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/chainedExpressions.ts @@ -1,5 +1,5 @@ import { SafeDsServices } from '../../../safe-ds-module.js'; -import { isSdsCall, isSdsIndexedAccess, isSdsMemberAccess, SdsChainedExpression } from '../../../generated/ast.js'; +import { isTslCall, isTslIndexedAccess, isTslMemberAccess, TslChainedExpression } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { UnknownType } from '../../../typing/model.js'; @@ -9,7 +9,7 @@ export const chainedExpressionsMustBeNullSafeIfReceiverIsNullable = (services: S const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsChainedExpression, accept: ValidationAcceptor): void => { + return (node: TslChainedExpression, accept: ValidationAcceptor): void => { if (node.isNullSafe) { return; } @@ -19,17 +19,17 @@ export const chainedExpressionsMustBeNullSafeIfReceiverIsNullable = (services: S return; } - if (isSdsCall(node) && typeChecker.canBeCalled(receiverType)) { + if (isTslCall(node) && typeChecker.canBeCalled(receiverType)) { accept('error', 'The receiver can be null so a null-safe call must be used.', { node, code: CODE_CHAINED_EXPRESSION_MISSING_NULL_SAFETY, }); - } else if (isSdsIndexedAccess(node) && typeChecker.canBeAccessedByIndex(receiverType)) { + } else if (isTslIndexedAccess(node) && typeChecker.canBeAccessedByIndex(receiverType)) { accept('error', 'The receiver can be null so a null-safe indexed access must be used.', { node, code: CODE_CHAINED_EXPRESSION_MISSING_NULL_SAFETY, }); - } else if (isSdsMemberAccess(node)) { + } else if (isTslMemberAccess(node)) { accept('error', 'The receiver can be null so a null-safe member access must be used.', { node, code: CODE_CHAINED_EXPRESSION_MISSING_NULL_SAFETY, diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/indexedAccess.ts b/packages/ttsl-lang/src/language/validation/other/expressions/indexedAccess.ts index 678d9958..792e0abf 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/indexedAccess.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/indexedAccess.ts @@ -1,4 +1,4 @@ -import { SdsIndexedAccess } from '../../../generated/ast.js'; +import { TslIndexedAccess } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; import { EvaluatedList, EvaluatedMap, IntConstant } from '../../../partialEvaluation/model.js'; @@ -10,7 +10,7 @@ export const indexedAccessIndexMustBeValid = (services: SafeDsServices) => { const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { + return (node: TslIndexedAccess, accept: ValidationAcceptor): void => { const indexValue = partialEvaluator.evaluate(node.index); if (!indexValue.isFullyEvaluated) { return; diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/infixOperations.ts b/packages/ttsl-lang/src/language/validation/other/expressions/infixOperations.ts index 6457f0c3..abbe25b4 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/infixOperations.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/infixOperations.ts @@ -1,4 +1,4 @@ -import { SdsInfixOperation } from '../../../generated/ast.js'; +import { TslInfixOperation } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; import { FloatConstant, IntConstant, NumberConstant } from '../../../partialEvaluation/model.js'; @@ -16,7 +16,7 @@ export const divisionDivisorMustNotBeZero = (services: SafeDsServices) => { const zeroFloat = new FloatConstant(0.0); const minusZeroFloat = new FloatConstant(-0.0); - return (node: SdsInfixOperation, accept: ValidationAcceptor): void => { + return (node: TslInfixOperation, accept: ValidationAcceptor): void => { if (node.operator !== '/') { return; } diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/lambdas.ts b/packages/ttsl-lang/src/language/validation/other/expressions/lambdas.ts index 90d453b2..49c51f1b 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/lambdas.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/lambdas.ts @@ -1,4 +1,4 @@ -import { isSdsArgument, isSdsParameter, isSdsParenthesizedExpression, SdsLambda } from '../../../generated/ast.js'; +import { isTslArgument, isTslParameter, isTslParenthesizedExpression, TslLambda } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { getParameters } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -9,16 +9,16 @@ export const CODE_LAMBDA_CONST_MODIFIER = 'lambda/const-modifier'; export const lambdaMustBeAssignedToTypedParameter = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsLambda, accept: ValidationAcceptor): void => { + return (node: TslLambda, accept: ValidationAcceptor): void => { let context = node.$container; - while (isSdsParenthesizedExpression(context)) { + while (isTslParenthesizedExpression(context)) { context = context.$container; } let contextIsValid = false; - if (isSdsParameter(context)) { + if (isTslParameter(context)) { contextIsValid = context.type !== undefined; - } else if (isSdsArgument(context)) { + } else if (isTslArgument(context)) { const parameter = nodeMapper.argumentToParameter(context); // If the resolution of the parameter failed, we already show another error nearby contextIsValid = parameter === undefined || parameter.type !== undefined; @@ -33,7 +33,7 @@ export const lambdaMustBeAssignedToTypedParameter = (services: SafeDsServices) = }; }; -export const lambdaParameterMustNotHaveConstModifier = (node: SdsLambda, accept: ValidationAcceptor): void => { +export const lambdaParameterMustNotHaveConstModifier = (node: TslLambda, accept: ValidationAcceptor): void => { for (const parameter of getParameters(node)) { if (parameter.isConstant) { accept('error', 'The const modifier is not applicable to parameters of lambdas.', { diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/memberAccesses.ts b/packages/ttsl-lang/src/language/validation/other/expressions/memberAccesses.ts index 9dd5d084..c0ae32ad 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/memberAccesses.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/memberAccesses.ts @@ -1,4 +1,4 @@ -import { isSdsCall, isSdsEnumVariant, SdsMemberAccess } from '../../../generated/ast.js'; +import { isTslCall, isTslEnumVariant, TslMemberAccess } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { getParameters } from '../../../helpers/nodeProperties.js'; import { isEmpty } from '../../../../helpers/collections.js'; @@ -6,15 +6,15 @@ import { isEmpty } from '../../../../helpers/collections.js'; export const CODE_MEMBER_ACCESS_MISSING_ENUM_VARIANT_INSTANTIATION = 'member-access/missing-enum-variant-instantiation'; export const memberAccessOfEnumVariantMustNotLackInstantiation = ( - node: SdsMemberAccess, + node: TslMemberAccess, accept: ValidationAcceptor, ): void => { const declaration = node.member?.target?.ref; - if (!isSdsEnumVariant(declaration)) { + if (!isTslEnumVariant(declaration)) { return; } - if (!isSdsCall(node.$container) && !isEmpty(getParameters(declaration))) { + if (!isTslCall(node.$container) && !isEmpty(getParameters(declaration))) { accept('error', `The enum variant '${declaration.name}' has parameters, so an argument list must be added.`, { node, property: 'member', diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/references.ts b/packages/ttsl-lang/src/language/validation/other/expressions/references.ts index 767a5915..b11e1504 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/references.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/references.ts @@ -1,14 +1,14 @@ import { - isSdsAnnotation, - isSdsCall, - isSdsClass, - isSdsEnum, - isSdsFunction, - isSdsMemberAccess, - isSdsPipeline, - isSdsSchema, - isSdsSegment, - SdsReference, + isTslAnnotation, + isTslCall, + isTslClass, + isTslEnum, + isTslFunction, + isTslMemberAccess, + isTslPipeline, + isTslSchema, + isTslSegment, + TslReference, } from '../../../generated/ast.js'; import { AstNode, ValidationAcceptor } from 'langium'; @@ -17,19 +17,19 @@ export const CODE_REFERENCE_STATIC_CLASS_REFERENCE = 'reference/static-class-ref export const CODE_REFERENCE_STATIC_ENUM_REFERENCE = 'reference/static-enum-reference'; export const CODE_REFERENCE_TARGET = 'reference/target'; -export const referenceMustNotBeFunctionPointer = (node: SdsReference, accept: ValidationAcceptor): void => { +export const referenceMustNotBeFunctionPointer = (node: TslReference, accept: ValidationAcceptor): void => { const target = node.target.ref; - if (!isSdsFunction(target) && !isSdsSegment(target)) { + if (!isTslFunction(target) && !isTslSegment(target)) { return; } // Get the containing member access if the node is on its right side let nodeOrContainer: AstNode | undefined = node; - if (isSdsMemberAccess(node.$container) && node.$containerProperty === 'member') { + if (isTslMemberAccess(node.$container) && node.$containerProperty === 'member') { nodeOrContainer = nodeOrContainer.$container; } - if (!isSdsCall(nodeOrContainer?.$container)) { + if (!isTslCall(nodeOrContainer?.$container)) { accept( 'error', 'Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead.', @@ -41,35 +41,35 @@ export const referenceMustNotBeFunctionPointer = (node: SdsReference, accept: Va } }; -export const referenceMustNotBeStaticClassOrEnumReference = (node: SdsReference, accept: ValidationAcceptor) => { +export const referenceMustNotBeStaticClassOrEnumReference = (node: TslReference, accept: ValidationAcceptor) => { const target = node.target.ref; - if (!isSdsClass(target) && !isSdsEnum(target)) { + if (!isTslClass(target) && !isTslEnum(target)) { return; } // Get the containing member access if the node is on its right side let nodeOrContainer: AstNode | undefined = node; - if (isSdsMemberAccess(node.$container) && node.$containerProperty === 'member') { + if (isTslMemberAccess(node.$container) && node.$containerProperty === 'member') { nodeOrContainer = nodeOrContainer.$container; } // Access to a member of the class or enum - if (isSdsMemberAccess(nodeOrContainer?.$container) && nodeOrContainer?.$containerProperty === 'receiver') { + if (isTslMemberAccess(nodeOrContainer?.$container) && nodeOrContainer?.$containerProperty === 'receiver') { return; } // Call of the class or enum - if (isSdsCall(nodeOrContainer?.$container)) { + if (isTslCall(nodeOrContainer?.$container)) { return; } // Static reference to the class or enum - if (isSdsClass(target)) { + if (isTslClass(target)) { accept('error', 'A class must not be statically referenced.', { node, code: CODE_REFERENCE_STATIC_CLASS_REFERENCE, }); - } else if (isSdsEnum(target)) { + } else if (isTslEnum(target)) { accept('error', 'An enum must not be statically referenced.', { node, code: CODE_REFERENCE_STATIC_ENUM_REFERENCE, @@ -78,22 +78,22 @@ export const referenceMustNotBeStaticClassOrEnumReference = (node: SdsReference, }; export const referenceTargetMustNotBeAnnotationPipelineOrSchema = ( - node: SdsReference, + node: TslReference, accept: ValidationAcceptor, ): void => { const target = node.target.ref; - if (isSdsAnnotation(target)) { + if (isTslAnnotation(target)) { accept('error', 'An annotation must not be the target of a reference.', { node, code: CODE_REFERENCE_TARGET, }); - } else if (isSdsPipeline(target)) { + } else if (isTslPipeline(target)) { accept('error', 'A pipeline must not be the target of a reference.', { node, code: CODE_REFERENCE_TARGET, }); - } else if (isSdsSchema(target)) { + } else if (isTslSchema(target)) { accept('error', 'A schema must not be the target of a reference.', { node, code: CODE_REFERENCE_TARGET, diff --git a/packages/ttsl-lang/src/language/validation/other/expressions/templateStrings.ts b/packages/ttsl-lang/src/language/validation/other/expressions/templateStrings.ts index 8f713b70..ff7f2496 100644 --- a/packages/ttsl-lang/src/language/validation/other/expressions/templateStrings.ts +++ b/packages/ttsl-lang/src/language/validation/other/expressions/templateStrings.ts @@ -1,17 +1,17 @@ -import { isSdsTemplateStringPart, SdsTemplateString } from '../../../generated/ast.js'; +import { isTslTemplateStringPart, TslTemplateString } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; export const CODE_TEMPLATE_STRING_MISSING_TEMPLATE_EXPRESSION = 'template-string/missing-template-expression'; export const templateStringMustHaveExpressionBetweenTwoStringParts = ( - node: SdsTemplateString, + node: TslTemplateString, accept: ValidationAcceptor, ): void => { for (let i = 0; i < node.expressions.length - 1; i++) { const first = node.expressions[i]; const second = node.expressions[i + 1]; - if (isSdsTemplateStringPart(first) && isSdsTemplateStringPart(second)) { + if (isTslTemplateStringPart(first) && isTslTemplateStringPart(second)) { accept('error', 'There must be an expression between two string parts.', { node: second, code: CODE_TEMPLATE_STRING_MISSING_TEMPLATE_EXPRESSION, diff --git a/packages/ttsl-lang/src/language/validation/other/imports.ts b/packages/ttsl-lang/src/language/validation/other/imports.ts index 27fe06a4..92bfdf0a 100644 --- a/packages/ttsl-lang/src/language/validation/other/imports.ts +++ b/packages/ttsl-lang/src/language/validation/other/imports.ts @@ -1,5 +1,5 @@ import { ValidationAcceptor } from 'langium'; -import { SdsImport } from '../../generated/ast.js'; +import { TslImport } from '../../generated/ast.js'; import { SafeDsServices } from '../../safe-ds-module.js'; import { isEmpty } from '../../../helpers/collections.js'; @@ -8,7 +8,7 @@ export const CODE_IMPORT_EMPTY_PACKAGE = 'import/empty-package'; export const importPackageMustExist = (services: SafeDsServices) => - (node: SdsImport, accept: ValidationAcceptor): void => { + (node: TslImport, accept: ValidationAcceptor): void => { if (!services.workspace.PackageManager.hasPackage(node.package)) { accept('error', `The package '${node.package}' does not exist.`, { node, @@ -19,7 +19,7 @@ export const importPackageMustExist = export const importPackageShouldNotBeEmpty = (services: SafeDsServices) => - (node: SdsImport, accept: ValidationAcceptor): void => { + (node: TslImport, accept: ValidationAcceptor): void => { const declarationsInPackage = services.workspace.PackageManager.getDeclarationsInPackage(node.package); if (isEmpty(declarationsInPackage)) { accept('warning', `The package '${node.package}' is empty.`, { diff --git a/packages/ttsl-lang/src/language/validation/other/modules.ts b/packages/ttsl-lang/src/language/validation/other/modules.ts index ad1d5377..21a62b46 100644 --- a/packages/ttsl-lang/src/language/validation/other/modules.ts +++ b/packages/ttsl-lang/src/language/validation/other/modules.ts @@ -1,5 +1,5 @@ import { ValidationAcceptor } from 'langium'; -import { isSdsDeclaration, isSdsPipeline, isSdsSegment, SdsDeclaration, SdsModule } from '../../generated/ast.js'; +import { isTslDeclaration, isTslPipeline, isTslSegment, TslDeclaration, TslModule } from '../../generated/ast.js'; import { isInPipelineFile, isInStubFile } from '../../helpers/fileExtensions.js'; import { getModuleMembers } from '../../helpers/nodeProperties.js'; import { BUILTINS_ROOT_PACKAGE } from '../../builtins/packageNames.js'; @@ -9,8 +9,8 @@ export const CODE_MODULE_FORBIDDEN_IN_STUB_FILE = 'module/forbidden-in-stub-file export const CODE_MODULE_MISSING_PACKAGE = 'module/missing-package'; export const CODE_MODULE_PIPELINE_FILE_IN_BUILTIN_PACKAGE = 'module/pipeline-file-in-builtin-package'; -export const moduleDeclarationsMustMatchFileKind = (node: SdsModule, accept: ValidationAcceptor): void => { - const declarations = node.members.filter(isSdsDeclaration); +export const moduleDeclarationsMustMatchFileKind = (node: TslModule, accept: ValidationAcceptor): void => { + const declarations = node.members.filter(isTslDeclaration); if (isInPipelineFile(node)) { for (const declaration of declarations) { @@ -35,15 +35,15 @@ export const moduleDeclarationsMustMatchFileKind = (node: SdsModule, accept: Val } }; -export const declarationIsAllowedInPipelineFile = (declaration: SdsDeclaration): boolean => { - return isSdsPipeline(declaration) || isSdsSegment(declaration); +export const declarationIsAllowedInPipelineFile = (declaration: TslDeclaration): boolean => { + return isTslPipeline(declaration) || isTslSegment(declaration); }; -export const declarationIsAllowedInStubFile = (declaration: SdsDeclaration): boolean => { - return !isSdsPipeline(declaration) && !isSdsSegment(declaration); +export const declarationIsAllowedInStubFile = (declaration: TslDeclaration): boolean => { + return !isTslPipeline(declaration) && !isTslSegment(declaration); }; -export const moduleWithDeclarationsMustStatePackage = (node: SdsModule, accept: ValidationAcceptor): void => { +export const moduleWithDeclarationsMustStatePackage = (node: TslModule, accept: ValidationAcceptor): void => { if (!node.name) { const members = getModuleMembers(node); if (members.length > 0) { @@ -56,7 +56,7 @@ export const moduleWithDeclarationsMustStatePackage = (node: SdsModule, accept: } }; -export const pipelineFileMustNotBeInBuiltinPackage = (node: SdsModule, accept: ValidationAcceptor): void => { +export const pipelineFileMustNotBeInBuiltinPackage = (node: TslModule, accept: ValidationAcceptor): void => { if (isInPipelineFile(node) && node.name?.startsWith(BUILTINS_ROOT_PACKAGE)) { accept('error', `A pipeline file must not be in a '${BUILTINS_ROOT_PACKAGE}' package.`, { node, diff --git a/packages/ttsl-lang/src/language/validation/other/statements/assignments.ts b/packages/ttsl-lang/src/language/validation/other/statements/assignments.ts index dc266144..37603c2e 100644 --- a/packages/ttsl-lang/src/language/validation/other/statements/assignments.ts +++ b/packages/ttsl-lang/src/language/validation/other/statements/assignments.ts @@ -1,4 +1,4 @@ -import { isSdsCall, isSdsPipeline, SdsAssignment, SdsYield } from '../../../generated/ast.js'; +import { isTslCall, isTslPipeline, TslAssignment, TslYield } from '../../../generated/ast.js'; import { AstUtils, ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; import { getAbstractResults, getAssignees } from '../../../helpers/nodeProperties.js'; @@ -10,7 +10,7 @@ export const CODE_ASSIGMENT_YIELD_FORBIDDEN_IN_PIPELINE = 'assignment/yield-forb export const assignmentAssigneeMustGetValue = (services: SafeDsServices) => - (node: SdsAssignment, accept: ValidationAcceptor): void => { + (node: TslAssignment, accept: ValidationAcceptor): void => { for (const assignee of getAssignees(node)) { if (!services.helpers.NodeMapper.assigneeToAssignedObject(assignee)) { accept('error', 'No value is assigned to this assignee.', { @@ -24,9 +24,9 @@ export const assignmentAssigneeMustGetValue = export const assignmentShouldNotImplicitlyIgnoreResult = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsAssignment, accept: ValidationAcceptor): void => { + return (node: TslAssignment, accept: ValidationAcceptor): void => { const expression = node.expression; - if (!isSdsCall(expression)) { + if (!isTslCall(expression)) { return; } @@ -49,8 +49,8 @@ export const assignmentShouldNotImplicitlyIgnoreResult = (services: SafeDsServic }; }; -export const yieldMustNotBeUsedInPipeline = (node: SdsYield, accept: ValidationAcceptor): void => { - const containingPipeline = AstUtils.getContainerOfType(node, isSdsPipeline); +export const yieldMustNotBeUsedInPipeline = (node: TslYield, accept: ValidationAcceptor): void => { + const containingPipeline = AstUtils.getContainerOfType(node, isTslPipeline); if (containingPipeline) { accept('error', 'Yield must not be used in a pipeline.', { diff --git a/packages/ttsl-lang/src/language/validation/other/statements/statements.ts b/packages/ttsl-lang/src/language/validation/other/statements/statements.ts index 689bb8bf..b34bb3b7 100644 --- a/packages/ttsl-lang/src/language/validation/other/statements/statements.ts +++ b/packages/ttsl-lang/src/language/validation/other/statements/statements.ts @@ -1,4 +1,4 @@ -import { SdsStatement } from '../../../generated/ast.js'; +import { TslStatement } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -7,7 +7,7 @@ export const CODE_STATEMENT_HAS_NO_EFFECT = 'statement/has-no-effect'; export const statementMustDoSomething = (services: SafeDsServices) => { const purityComputer = services.purity.PurityComputer; - return (node: SdsStatement, accept: ValidationAcceptor): void => { + return (node: TslStatement, accept: ValidationAcceptor): void => { if (!purityComputer.statementDoesSomething(node)) { accept('warning', 'This statement does nothing.', { node, diff --git a/packages/ttsl-lang/src/language/validation/other/types/callableTypes.ts b/packages/ttsl-lang/src/language/validation/other/types/callableTypes.ts index 98da98ce..bd0baa31 100644 --- a/packages/ttsl-lang/src/language/validation/other/types/callableTypes.ts +++ b/packages/ttsl-lang/src/language/validation/other/types/callableTypes.ts @@ -1,5 +1,5 @@ import { AstUtils, ValidationAcceptor } from 'langium'; -import { isSdsCallableType, isSdsParameter, SdsCallableType } from '../../../generated/ast.js'; +import { isTslCallableType, isTslParameter, TslCallableType } from '../../../generated/ast.js'; import { getParameters, Parameter } from '../../../helpers/nodeProperties.js'; @@ -8,7 +8,7 @@ export const CODE_CALLABLE_TYPE_CONTEXT = 'callable-type/context'; export const CODE_CALLABLE_TYPE_NO_OPTIONAL_PARAMETERS = 'callable-type/no-optional-parameters'; export const callableTypeParameterMustNotHaveConstModifier = ( - node: SdsCallableType, + node: TslCallableType, accept: ValidationAcceptor, ): void => { for (const parameter of getParameters(node)) { @@ -22,7 +22,7 @@ export const callableTypeParameterMustNotHaveConstModifier = ( } }; -export const callableTypeMustBeUsedInCorrectContext = (node: SdsCallableType, accept: ValidationAcceptor): void => { +export const callableTypeMustBeUsedInCorrectContext = (node: TslCallableType, accept: ValidationAcceptor): void => { if (!contextIsCorrect(node)) { accept('error', 'Callable types must only be used for parameters.', { node, @@ -31,24 +31,24 @@ export const callableTypeMustBeUsedInCorrectContext = (node: SdsCallableType, ac } }; -const contextIsCorrect = (node: SdsCallableType): boolean => { - if (isSdsParameter(node.$container)) { +const contextIsCorrect = (node: TslCallableType): boolean => { + if (isTslParameter(node.$container)) { return true; } // Check whether we already show an error on a containing callable type - let containingCallableType = AstUtils.getContainerOfType(node.$container, isSdsCallableType); + let containingCallableType = AstUtils.getContainerOfType(node.$container, isTslCallableType); while (containingCallableType) { - if (!isSdsParameter(containingCallableType.$container)) { + if (!isTslParameter(containingCallableType.$container)) { return true; // Container already has wrong context } - containingCallableType = AstUtils.getContainerOfType(containingCallableType.$container, isSdsCallableType); + containingCallableType = AstUtils.getContainerOfType(containingCallableType.$container, isTslCallableType); } return false; }; -export const callableTypeMustNotHaveOptionalParameters = (node: SdsCallableType, accept: ValidationAcceptor): void => { +export const callableTypeMustNotHaveOptionalParameters = (node: TslCallableType, accept: ValidationAcceptor): void => { for (const parameter of getParameters(node)) { if (Parameter.isOptional(parameter)) { accept('error', 'A callable type must not have optional parameters.', { diff --git a/packages/ttsl-lang/src/language/validation/other/types/literalTypes.ts b/packages/ttsl-lang/src/language/validation/other/types/literalTypes.ts index a1728b34..28531e84 100644 --- a/packages/ttsl-lang/src/language/validation/other/types/literalTypes.ts +++ b/packages/ttsl-lang/src/language/validation/other/types/literalTypes.ts @@ -1,4 +1,4 @@ -import { isSdsList, isSdsMap, SdsLiteralType } from '../../../generated/ast.js'; +import { isTslList, isTslDictionary, TslLiteralType } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { getLiterals } from '../../../helpers/nodeProperties.js'; import { SafeDsServices } from '../../../safe-ds-module.js'; @@ -10,7 +10,7 @@ export const CODE_LITERAL_TYPE_LIST_LITERAL = 'literal-type/list-literal'; export const CODE_LITERAL_TYPE_MAP_LITERAL = 'literal-type/map-literal'; export const CODE_LITERAL_TYPE_MISSING_LITERALS = 'literal-type/missing-literals'; -export const literalTypeMustHaveLiterals = (node: SdsLiteralType, accept: ValidationAcceptor): void => { +export const literalTypeMustHaveLiterals = (node: TslLiteralType, accept: ValidationAcceptor): void => { if (isEmpty(getLiterals(node))) { accept('error', 'A literal type must have at least one literal.', { node, @@ -20,9 +20,9 @@ export const literalTypeMustHaveLiterals = (node: SdsLiteralType, accept: Valida } }; -export const literalTypeMustNotContainListLiteral = (node: SdsLiteralType, accept: ValidationAcceptor): void => { +export const literalTypeMustNotContainListLiteral = (node: TslLiteralType, accept: ValidationAcceptor): void => { for (const literal of getLiterals(node)) { - if (isSdsList(literal)) { + if (isTslList(literal)) { accept('error', 'Literal types must not contain list literals.', { node: literal, code: CODE_LITERAL_TYPE_LIST_LITERAL, @@ -31,9 +31,9 @@ export const literalTypeMustNotContainListLiteral = (node: SdsLiteralType, accep } }; -export const literalTypeMustNotContainMapLiteral = (node: SdsLiteralType, accept: ValidationAcceptor): void => { +export const literalTypeMustNotContainMapLiteral = (node: TslLiteralType, accept: ValidationAcceptor): void => { for (const literal of getLiterals(node)) { - if (isSdsMap(literal)) { + if (isTslDictionary(literal)) { accept('error', 'Literal types must not contain map literals.', { node: literal, code: CODE_LITERAL_TYPE_MAP_LITERAL, @@ -45,7 +45,7 @@ export const literalTypeMustNotContainMapLiteral = (node: SdsLiteralType, accept export const literalTypeShouldNotHaveDuplicateLiteral = (services: SafeDsServices) => { const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsLiteralType, accept: ValidationAcceptor): void => { + return (node: TslLiteralType, accept: ValidationAcceptor): void => { const literals = getLiterals(node); const constants: EvaluatedNode[] = []; diff --git a/packages/ttsl-lang/src/language/validation/other/types/namedTypes.ts b/packages/ttsl-lang/src/language/validation/other/types/namedTypes.ts index 2871ed61..d4f323fc 100644 --- a/packages/ttsl-lang/src/language/validation/other/types/namedTypes.ts +++ b/packages/ttsl-lang/src/language/validation/other/types/namedTypes.ts @@ -1,4 +1,4 @@ -import { SdsNamedType } from '../../../generated/ast.js'; +import { TslNamedType } from '../../../generated/ast.js'; import { ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; import { getTypeArguments, getTypeParameters, TypeParameter } from '../../../helpers/nodeProperties.js'; @@ -13,7 +13,7 @@ export const namedTypeMustNotSetTypeParameterMultipleTimes = (services: SafeDsSe const nodeMapper = services.helpers.NodeMapper; const typeArgumentToTypeParameter = nodeMapper.typeArgumentToTypeParameter.bind(nodeMapper); - return (node: SdsNamedType, accept: ValidationAcceptor): void => { + return (node: TslNamedType, accept: ValidationAcceptor): void => { const typeArguments = getTypeArguments(node.typeArgumentList); const duplicates = duplicatesBy(typeArguments, typeArgumentToTypeParameter); @@ -28,7 +28,7 @@ export const namedTypeMustNotSetTypeParameterMultipleTimes = (services: SafeDsSe }; export const namedTypeTypeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments = ( - node: SdsNamedType, + node: TslNamedType, accept: ValidationAcceptor, ): void => { const typeArgumentList = node.typeArgumentList; @@ -49,7 +49,7 @@ export const namedTypeTypeArgumentListMustNotHavePositionalArgumentsAfterNamedAr } }; -export const namedTypeMustNotHaveTooManyTypeArguments = (node: SdsNamedType, accept: ValidationAcceptor): void => { +export const namedTypeMustNotHaveTooManyTypeArguments = (node: TslNamedType, accept: ValidationAcceptor): void => { const actualTypeArgumentCount = getTypeArguments(node).length; // We can never have too many arguments in this case diff --git a/packages/ttsl-lang/src/language/validation/other/types/unionTypes.ts b/packages/ttsl-lang/src/language/validation/other/types/unionTypes.ts index fa4b6173..0b81a506 100644 --- a/packages/ttsl-lang/src/language/validation/other/types/unionTypes.ts +++ b/packages/ttsl-lang/src/language/validation/other/types/unionTypes.ts @@ -1,11 +1,11 @@ import { - isSdsAnnotation, - isSdsCallable, - isSdsClass, - isSdsFunction, - isSdsParameter, - isSdsUnionType, - SdsUnionType, + isTslAnnotation, + isTslCallable, + isTslClass, + isTslFunction, + isTslParameter, + isTslUnionType, + TslUnionType, } from '../../../generated/ast.js'; import { AstUtils, ValidationAcceptor } from 'langium'; import { getTypeArguments } from '../../../helpers/nodeProperties.js'; @@ -17,7 +17,7 @@ export const CODE_UNION_TYPE_CONTEXT = 'union-type/context'; export const CODE_UNION_TYPE_DUPLICATE_TYPE = 'union-type/duplicate-type'; export const CODE_UNION_TYPE_MISSING_TYPES = 'union-type/missing-types'; -export const unionTypeMustBeUsedInCorrectContext = (node: SdsUnionType, accept: ValidationAcceptor): void => { +export const unionTypeMustBeUsedInCorrectContext = (node: TslUnionType, accept: ValidationAcceptor): void => { if (!contextIsCorrect(node)) { accept('error', 'Union types must only be used for parameters of annotations, classes, and functions.', { node, @@ -26,26 +26,26 @@ export const unionTypeMustBeUsedInCorrectContext = (node: SdsUnionType, accept: } }; -const contextIsCorrect = (node: SdsUnionType): boolean => { - if (AstUtils.hasContainerOfType(node.$container, isSdsUnionType)) { +const contextIsCorrect = (node: TslUnionType): boolean => { + if (AstUtils.hasContainerOfType(node.$container, isTslUnionType)) { return true; } const container = node.$container; - if (!isSdsParameter(container)) { + if (!isTslParameter(container)) { return false; } - const containingCallable = AstUtils.getContainerOfType(container, isSdsCallable); + const containingCallable = AstUtils.getContainerOfType(container, isTslCallable); return ( !containingCallable || - isSdsAnnotation(containingCallable) || - isSdsClass(containingCallable) || - isSdsFunction(containingCallable) + isTslAnnotation(containingCallable) || + isTslClass(containingCallable) || + isTslFunction(containingCallable) ); }; -export const unionTypeMustHaveTypes = (node: SdsUnionType, accept: ValidationAcceptor): void => { +export const unionTypeMustHaveTypes = (node: TslUnionType, accept: ValidationAcceptor): void => { if (isEmpty(getTypeArguments(node.typeArgumentList))) { accept('error', 'A union type must have at least one type.', { node, @@ -58,7 +58,7 @@ export const unionTypeMustHaveTypes = (node: SdsUnionType, accept: ValidationAcc export const unionTypeShouldNotHaveDuplicateTypes = (services: SafeDsServices) => { const typeComputer = services.types.TypeComputer; - return (node: SdsUnionType, accept: ValidationAcceptor): void => { + return (node: TslUnionType, accept: ValidationAcceptor): void => { const typeArguments = getTypeArguments(node.typeArgumentList); const knownTypes: Type[] = []; diff --git a/packages/ttsl-lang/src/language/validation/purity.ts b/packages/ttsl-lang/src/language/validation/purity.ts index 7ba94e6e..e57d73b9 100644 --- a/packages/ttsl-lang/src/language/validation/purity.ts +++ b/packages/ttsl-lang/src/language/validation/purity.ts @@ -1,6 +1,6 @@ import { stream, type ValidationAcceptor } from 'langium'; import { isSubset } from '../../helpers/collections.js'; -import { isSdsCall, isSdsFunction, isSdsList, SdsCall, type SdsFunction, SdsParameter } from '../generated/ast.js'; +import { isTslCall, isTslFunction, isTslList, TslCall, type TslFunction, TslParameter } from '../generated/ast.js'; import { findFirstAnnotationCallOf, getArguments, getParameters } from '../helpers/nodeProperties.js'; import { StringConstant } from '../partialEvaluation/model.js'; import type { SafeDsServices } from '../safe-ds-module.js'; @@ -17,7 +17,7 @@ export const CODE_PURITY_PURE_PARAMETER_SET_TO_IMPURE_CALLABLE = 'purity/pure-pa export const functionPurityMustBeSpecified = (services: SafeDsServices) => { const annotations = services.builtins.Annotations; - return (node: SdsFunction, accept: ValidationAcceptor) => { + return (node: TslFunction, accept: ValidationAcceptor) => { if (annotations.callsPure(node) && annotations.callsImpure(node)) { return accept('error', "'@Impure' and '@Pure' are mutually exclusive.", { node, @@ -51,9 +51,9 @@ export const impurityReasonsOfOverridingMethodMustBeSubsetOfOverriddenMethod = ( const builtinAnnotations = services.builtins.Annotations; const classHierarchy = services.types.ClassHierarchy; - return (node: SdsFunction, accept: ValidationAcceptor): void => { + return (node: TslFunction, accept: ValidationAcceptor): void => { const overriddenMember = classHierarchy.getOverriddenMember(node); - if (!overriddenMember || !isSdsFunction(overriddenMember)) { + if (!overriddenMember || !isTslFunction(overriddenMember)) { return; } @@ -95,7 +95,7 @@ export const impurityReasonParameterNameMustBelongToParameterOfCorrectType = (se const partialEvaluator = services.evaluation.PartialEvaluator; const typeComputer = services.types.TypeComputer; - return (node: SdsFunction, accept: ValidationAcceptor) => { + return (node: TslFunction, accept: ValidationAcceptor) => { const annotationCall = findFirstAnnotationCallOf(node, builtinAnnotations.Impure); // Don't further validate if the function is marked as impure and as pure @@ -105,7 +105,7 @@ export const impurityReasonParameterNameMustBelongToParameterOfCorrectType = (se // Check whether allReasons is valid const allReasons = nodeMapper.callToParameterValue(annotationCall, 'allReasons'); - if (!isSdsList(allReasons)) { + if (!isTslList(allReasons)) { return; } @@ -115,7 +115,7 @@ export const impurityReasonParameterNameMustBelongToParameterOfCorrectType = (se for (const reason of allReasons.elements) { // If it's not a call, no parameter name could've been provided - if (!isSdsCall(reason)) { + if (!isTslCall(reason)) { continue; } @@ -182,7 +182,7 @@ export const impurityReasonShouldNotBeSetMultipleTimes = (services: SafeDsServic const nodeMapper = services.helpers.NodeMapper; const partialEvaluator = services.evaluation.PartialEvaluator; - return (node: SdsFunction, accept: ValidationAcceptor) => { + return (node: TslFunction, accept: ValidationAcceptor) => { const annotationCall = findFirstAnnotationCallOf(node, builtinAnnotations.Impure); // Don't further validate if the function is marked as impure and as pure @@ -192,7 +192,7 @@ export const impurityReasonShouldNotBeSetMultipleTimes = (services: SafeDsServic // Check whether allReasons is valid const allReasons = nodeMapper.callToParameterValue(annotationCall, 'allReasons'); - if (!isSdsList(allReasons)) { + if (!isTslList(allReasons)) { return; } @@ -221,7 +221,7 @@ export const pureParameterDefaultValueMustBePure = (services: SafeDsServices) => const purityComputer = services.purity.PurityComputer; const typeComputer = services.types.TypeComputer; - return (node: SdsParameter, accept: ValidationAcceptor) => { + return (node: TslParameter, accept: ValidationAcceptor) => { if (!node.defaultValue) { return; } @@ -250,7 +250,7 @@ export const callArgumentAssignedToPureParameterMustBePure = (services: SafeDsSe const purityComputer = services.purity.PurityComputer; const typeComputer = services.types.TypeComputer; - return (node: SdsCall, accept: ValidationAcceptor) => { + return (node: TslCall, accept: ValidationAcceptor) => { for (const argument of getArguments(node)) { const parameter = nodeMapper.argumentToParameter(argument); if (!parameter) { diff --git a/packages/ttsl-lang/src/language/validation/safe-ds-validator.ts b/packages/ttsl-lang/src/language/validation/safe-ds-validator.ts index 8f9e870b..cfa1fea5 100644 --- a/packages/ttsl-lang/src/language/validation/safe-ds-validator.ts +++ b/packages/ttsl-lang/src/language/validation/safe-ds-validator.ts @@ -192,26 +192,26 @@ import { export const registerValidationChecks = function (services: SafeDsServices) { const registry = services.validation.ValidationRegistry; const checks: ValidationChecks = { - SdsAssignee: [ + TslAssignee: [ assigneeAssignedResultShouldNotBeDeprecated(services), assigneeAssignedResultShouldNotBeExperimental(services), ], - SdsAssignment: [ + TslAssignment: [ assignmentAssigneeMustGetValue(services), assignmentShouldNotImplicitlyIgnoreResult(services), assignmentShouldHaveMoreThanWildcardsAsAssignees(services), ], - SdsAbstractCall: [ + TslAbstractCall: [ argumentListMustNotHaveTooManyArguments(services), argumentListMustSetAllRequiredParameters(services), ], - SdsAnnotation: [ + TslAnnotation: [ annotationMustContainUniqueNames, annotationParameterListShouldNotBeEmpty(services), annotationParameterShouldNotHaveConstModifier(services), targetShouldNotHaveDuplicateEntries(services), ], - SdsAnnotationCall: [ + TslAnnotationCall: [ annotationCallAnnotationShouldNotBeDeprecated(services), annotationCallAnnotationShouldNotBeExperimental(services), annotationCallArgumentListShouldBeNeeded(services), @@ -219,17 +219,17 @@ export const registerValidationChecks = function (services: SafeDsServices) { annotationCallMustHaveCorrectTarget(services), annotationCallMustNotLackArgumentList, ], - SdsArgument: [ + TslArgument: [ argumentCorrespondingParameterShouldNotBeDeprecated(services), argumentCorrespondingParameterShouldNotBeExperimental(services), ], - SdsArgumentList: [ + TslArgumentList: [ argumentListMustNotHavePositionalArgumentsAfterNamedArguments, argumentListMustNotSetParameterMultipleTimes(services), ], - SdsAttribute: [attributeMustHaveTypeHint], - SdsBlockLambda: [blockLambdaMustContainUniqueNames], - SdsCall: [ + TslAttribute: [attributeMustHaveTypeHint], + TslBlockLambda: [blockLambdaMustContainUniqueNames], + TslCall: [ callArgumentListShouldBeNeeded(services), callArgumentAssignedToPureParameterMustBePure(services), callArgumentMustBeConstantIfParameterIsConstant(services), @@ -238,7 +238,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { callMustNotBeRecursive(services), callReceiverMustBeCallable(services), ], - SdsCallableType: [ + TslCallableType: [ callableTypeMustBeUsedInCorrectContext, callableTypeMustContainUniqueNames, callableTypeMustNotHaveOptionalParameters, @@ -246,30 +246,30 @@ export const registerValidationChecks = function (services: SafeDsServices) { callableTypeParameterMustNotHaveConstModifier, callableTypeResultsMustNotBeAnnotated, ], - SdsChainedExpression: [ + TslChainedExpression: [ chainedExpressionsMustBeNullSafeIfReceiverIsNullable(services), chainedExpressionNullSafetyShouldBeNeeded(services), ], - SdsClass: [ + TslClass: [ classMustContainUniqueNames, classMustOnlyInheritASingleClass(services), classMustNotInheritItself(services), ], - SdsClassBody: [classBodyShouldNotBeEmpty(services)], - SdsClassMember: [classMemberMustMatchOverriddenMemberAndShouldBeNeeded(services)], - SdsConstraintList: [constraintListsShouldBeUsedWithCaution(services), constraintListShouldNotBeEmpty(services)], - SdsDeclaration: [ + TslClassBody: [classBodyShouldNotBeEmpty(services)], + TslClassMember: [classMemberMustMatchOverriddenMemberAndShouldBeNeeded(services)], + TslConstraintList: [constraintListsShouldBeUsedWithCaution(services), constraintListShouldNotBeEmpty(services)], + TslDeclaration: [ nameMustNotOccurOnCoreDeclaration(services), nameMustNotStartWithCodegenPrefix, nameShouldHaveCorrectCasing(services), pythonNameShouldDifferFromSafeDsName(services), singleUseAnnotationsMustNotBeRepeated(services), ], - SdsEnum: [enumMustContainUniqueNames], - SdsEnumBody: [enumBodyShouldNotBeEmpty(services)], - SdsEnumVariant: [enumVariantMustContainUniqueNames, enumVariantParameterListShouldNotBeEmpty(services)], - SdsExpressionLambda: [expressionLambdaMustContainUniqueNames], - SdsFunction: [ + TslEnum: [enumMustContainUniqueNames], + TslEnumBody: [enumBodyShouldNotBeEmpty(services)], + TslEnumVariant: [enumVariantMustContainUniqueNames, enumVariantParameterListShouldNotBeEmpty(services)], + TslExpressionLambda: [expressionLambdaMustContainUniqueNames], + TslFunction: [ functionMustContainUniqueNames, functionResultListShouldNotBeEmpty(services), functionPurityMustBeSpecified(services), @@ -279,34 +279,34 @@ export const registerValidationChecks = function (services: SafeDsServices) { pythonCallMustOnlyContainValidTemplateExpressions(services), pythonNameMustNotBeSetIfPythonCallIsSet(services), ], - SdsImport: [importPackageMustExist(services), importPackageShouldNotBeEmpty(services)], - SdsImportedDeclaration: [importedDeclarationAliasShouldDifferFromDeclarationName(services)], - SdsIndexedAccess: [ + TslImport: [importPackageMustExist(services), importPackageShouldNotBeEmpty(services)], + TslImportedDeclaration: [importedDeclarationAliasShouldDifferFromDeclarationName(services)], + TslIndexedAccess: [ indexedAccessIndexMustBeValid(services), indexedAccessIndexMustHaveCorrectType(services), indexedAccessReceiverMustBeListOrMap(services), ], - SdsInfixOperation: [ + TslInfixOperation: [ divisionDivisorMustNotBeZero(services), elvisOperatorShouldBeNeeded(services), infixOperationOperandsMustHaveCorrectType(services), ], - SdsLambda: [ + TslLambda: [ lambdaMustBeAssignedToTypedParameter(services), lambdaParametersMustNotBeAnnotated, lambdaParameterMustNotHaveConstModifier, ], - SdsList: [listMustNotContainNamedTuples(services)], - SdsLiteralType: [ + TslList: [listMustNotContainNamedTuples(services)], + TslLiteralType: [ literalTypeMustHaveLiterals, literalTypeMustNotContainListLiteral, literalTypeMustNotContainMapLiteral, literalTypesShouldBeUsedWithCaution(services), literalTypeShouldNotHaveDuplicateLiteral(services), ], - SdsMap: [mapMustNotContainNamedTuples(services), mapsShouldBeUsedWithCaution(services)], - SdsMemberAccess: [memberAccessOfEnumVariantMustNotLackInstantiation], - SdsModule: [ + TslDictionary: [mapMustNotContainNamedTuples(services), mapsShouldBeUsedWithCaution(services)], + TslMemberAccess: [memberAccessOfEnumVariantMustNotLackInstantiation], + TslModule: [ moduleDeclarationsMustMatchFileKind, moduleMemberMustHaveNameThatIsUniqueInPackage(services), moduleMustContainUniqueNames, @@ -314,7 +314,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { pipelineFileMustNotBeInBuiltinPackage, pythonModuleShouldDifferFromSafeDsPackage(services), ], - SdsNamedType: [ + TslNamedType: [ namedTypeDeclarationShouldNotBeDeprecated(services), namedTypeDeclarationShouldNotBeExperimental(services), namedTypeMustNotHaveTooManyTypeArguments, @@ -324,7 +324,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { namedTypeTypeArgumentListMustNotHavePositionalArgumentsAfterNamedArguments, namedTypeTypeArgumentsMustMatchBounds(services), ], - SdsParameter: [ + TslParameter: [ constantParameterMustHaveConstantDefaultValue(services), constantParameterMustHaveTypeThatCanBeEvaluatedToConstant(services), parameterMustHaveTypeHint, @@ -334,52 +334,52 @@ export const registerValidationChecks = function (services: SafeDsServices) { requiredParameterMustNotBeDeprecated(services), requiredParameterMustNotBeExpert(services), ], - SdsParameterBound: [ + TslParameterBound: [ parameterBoundParameterMustBeConstFloatOrInt(services), parameterBoundRightOperandMustEvaluateToFloatConstantOrIntConstant(services), ], - SdsParameterList: [parameterListMustNotHaveRequiredParametersAfterOptionalParameters], - SdsPipeline: [pipelineMustContainUniqueNames], - SdsPlaceholder: [placeholdersMustNotBeAnAlias, placeholderShouldBeUsed(services)], - SdsPrefixOperation: [prefixOperationOperandMustHaveCorrectType(services)], - SdsReference: [ + TslParameterList: [parameterListMustNotHaveRequiredParametersAfterOptionalParameters], + TslPipeline: [pipelineMustContainUniqueNames], + TslPlaceholder: [placeholdersMustNotBeAnAlias, placeholderShouldBeUsed(services)], + TslPrefixOperation: [prefixOperationOperandMustHaveCorrectType(services)], + TslReference: [ referenceMustNotBeFunctionPointer, referenceMustNotBeStaticClassOrEnumReference, referenceTargetMustNotBeAnnotationPipelineOrSchema, referenceTargetShouldNotBeDeprecated(services), referenceTargetShouldNotExperimental(services), ], - SdsResult: [resultMustHaveTypeHint], - SdsSchema: [schemaMustContainUniqueNames], - SdsSegment: [ + TslResult: [resultMustHaveTypeHint], + TslSchema: [schemaMustContainUniqueNames], + TslSegment: [ segmentMustContainUniqueNames, segmentParameterShouldBeUsed(services), segmentResultMustBeAssignedExactlyOnce(services), segmentResultListShouldNotBeEmpty(services), segmentShouldBeUsed(services), ], - SdsStatement: [statementMustDoSomething(services)], - SdsTemplateString: [templateStringMustHaveExpressionBetweenTwoStringParts], - SdsTypeCast: [typeCastExpressionMustHaveUnknownType(services)], - SdsTypeParameter: [ + TslStatement: [statementMustDoSomething(services)], + TslTemplateString: [templateStringMustHaveExpressionBetweenTwoStringParts], + TslTypeCast: [typeCastExpressionMustHaveUnknownType(services)], + TslTypeParameter: [ typeParameterDefaultValueMustMatchUpperBound(services), typeParameterMustBeUsedInCorrectPosition(services), typeParameterMustHaveSufficientContext, typeParameterMustOnlyBeVariantOnClass, typeParameterUpperBoundMustBeNamedType(services), ], - SdsTypeParameterList: [ + TslTypeParameterList: [ typeParameterListMustNotHaveRequiredTypeParametersAfterOptionalTypeParameters, typeParameterListShouldNotBeEmpty(services), ], - SdsUnionType: [ + TslUnionType: [ unionTypeMustBeUsedInCorrectContext, unionTypeMustHaveTypes, unionTypesShouldBeUsedWithCaution(services), unionTypeShouldNotHaveDuplicateTypes(services), unionTypeShouldNotHaveASingularTypeArgument(services), ], - SdsYield: [yieldMustNotBeUsedInPipeline, yieldTypeMustMatchResultType(services)], + TslYield: [yieldMustNotBeUsedInPipeline, yieldTypeMustMatchResultType(services)], }; registry.register(checks); }; diff --git a/packages/ttsl-lang/src/language/validation/style.ts b/packages/ttsl-lang/src/language/validation/style.ts index d0f9eb0f..8ad1ae67 100644 --- a/packages/ttsl-lang/src/language/validation/style.ts +++ b/packages/ttsl-lang/src/language/validation/style.ts @@ -1,27 +1,27 @@ import { ValidationAcceptor } from 'langium'; import { isEmpty } from '../../helpers/collections.js'; import { - isSdsCall, - isSdsEnumVariant, - isSdsIndexedAccess, - isSdsMemberAccess, - isSdsWildcard, - SdsAnnotation, - SdsAnnotationCall, - SdsAssignment, - SdsCall, - SdsChainedExpression, - SdsClassBody, - SdsConstraintList, - SdsEnumBody, - SdsEnumVariant, - SdsFunction, - SdsImportedDeclaration, - SdsInfixOperation, - SdsNamedType, - SdsSegment, - SdsTypeParameterList, - SdsUnionType, + isTslCall, + isTslEnumVariant, + isTslIndexedAccess, + isTslMemberAccess, + isTslWildcard, + TslAnnotation, + TslAnnotationCall, + TslAssignment, + TslCall, + TslChainedExpression, + TslClassBody, + TslConstraintList, + TslEnumBody, + TslEnumVariant, + TslFunction, + TslImportedDeclaration, + TslInfixOperation, + TslNamedType, + TslSegment, + TslTypeParameterList, + TslUnionType, } from '../generated/ast.js'; import { getParameters, getTypeParameters, Parameter } from '../helpers/nodeProperties.js'; import { NullConstant } from '../partialEvaluation/model.js'; @@ -49,7 +49,7 @@ export const CODE_STYLE_UNNECESSARY_UNION_TYPE = 'style/unnecessary-union-type'; export const annotationCallArgumentListShouldBeNeeded = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsAnnotationCall, accept: ValidationAcceptor) => { + return async (node: TslAnnotationCall, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -79,7 +79,7 @@ export const annotationCallArgumentListShouldBeNeeded = (services: SafeDsService export const callArgumentListShouldBeNeeded = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsCall, accept: ValidationAcceptor) => { + return async (node: TslCall, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -92,7 +92,7 @@ export const callArgumentListShouldBeNeeded = (services: SafeDsServices) => { } const callable = services.helpers.NodeMapper.callToCallable(node); - if (!isSdsEnumVariant(callable)) { + if (!isTslEnumVariant(callable)) { return; } @@ -112,14 +112,14 @@ export const callArgumentListShouldBeNeeded = (services: SafeDsServices) => { export const assignmentShouldHaveMoreThanWildcardsAsAssignees = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsAssignment, accept: ValidationAcceptor) => { + return async (node: TslAssignment, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; } const assignees = node.assigneeList?.assignees ?? []; - if (assignees.every(isSdsWildcard)) { + if (assignees.every(isTslWildcard)) { accept('info', 'This assignment can be replaced by an expression statement.', { node, code: CODE_STYLE_UNNECESSARY_ASSIGNMENT, @@ -135,7 +135,7 @@ export const assignmentShouldHaveMoreThanWildcardsAsAssignees = (services: SafeD export const classBodyShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsClassBody, accept: ValidationAcceptor) => { + return async (node: TslClassBody, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -153,7 +153,7 @@ export const classBodyShouldNotBeEmpty = (services: SafeDsServices) => { export const enumBodyShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsEnumBody, accept: ValidationAcceptor) => { + return async (node: TslEnumBody, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -175,7 +175,7 @@ export const enumBodyShouldNotBeEmpty = (services: SafeDsServices) => { export const annotationParameterShouldNotHaveConstModifier = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsAnnotation, accept: ValidationAcceptor) => { + return async (node: TslAnnotation, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -200,7 +200,7 @@ export const annotationParameterShouldNotHaveConstModifier = (services: SafeDsSe export const constraintListShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsConstraintList, accept: ValidationAcceptor) => { + return async (node: TslConstraintList, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -225,7 +225,7 @@ export const elvisOperatorShouldBeNeeded = (services: SafeDsServices) => { const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return async (node: SdsInfixOperation, accept: ValidationAcceptor) => { + return async (node: TslInfixOperation, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -287,7 +287,7 @@ export const elvisOperatorShouldBeNeeded = (services: SafeDsServices) => { export const importedDeclarationAliasShouldDifferFromDeclarationName = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsImportedDeclaration, accept: ValidationAcceptor) => { + return async (node: TslImportedDeclaration, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -312,7 +312,7 @@ export const chainedExpressionNullSafetyShouldBeNeeded = (services: SafeDsServic const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return async (node: SdsChainedExpression, accept: ValidationAcceptor) => { + return async (node: TslChainedExpression, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -328,9 +328,9 @@ export const chainedExpressionNullSafetyShouldBeNeeded = (services: SafeDsServic } if ( - (isSdsCall(node) && typeChecker.canBeCalled(receiverType)) || - (isSdsIndexedAccess(node) && typeChecker.canBeAccessedByIndex(receiverType)) || - isSdsMemberAccess(node) + (isTslCall(node) && typeChecker.canBeCalled(receiverType)) || + (isTslIndexedAccess(node) && typeChecker.canBeAccessedByIndex(receiverType)) || + isTslMemberAccess(node) ) { accept('info', 'The receiver is never null, so null-safety is unnecessary.', { node, @@ -347,7 +347,7 @@ export const chainedExpressionNullSafetyShouldBeNeeded = (services: SafeDsServic export const annotationParameterListShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsAnnotation, accept: ValidationAcceptor) => { + return async (node: TslAnnotation, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -366,7 +366,7 @@ export const annotationParameterListShouldNotBeEmpty = (services: SafeDsServices export const enumVariantParameterListShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsEnumVariant, accept: ValidationAcceptor) => { + return async (node: TslEnumVariant, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -389,7 +389,7 @@ export const enumVariantParameterListShouldNotBeEmpty = (services: SafeDsService export const functionResultListShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsFunction, accept: ValidationAcceptor) => { + return async (node: TslFunction, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -408,7 +408,7 @@ export const functionResultListShouldNotBeEmpty = (services: SafeDsServices) => export const segmentResultListShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsSegment, accept: ValidationAcceptor) => { + return async (node: TslSegment, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -431,7 +431,7 @@ export const segmentResultListShouldNotBeEmpty = (services: SafeDsServices) => { export const namedTypeTypeArgumentListShouldBeNeeded = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsNamedType, accept: ValidationAcceptor) => { + return async (node: TslNamedType, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -464,7 +464,7 @@ export const namedTypeTypeArgumentListShouldBeNeeded = (services: SafeDsServices export const typeParameterListShouldNotBeEmpty = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsTypeParameterList, accept: ValidationAcceptor) => { + return async (node: TslTypeParameterList, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; @@ -486,7 +486,7 @@ export const typeParameterListShouldNotBeEmpty = (services: SafeDsServices) => { export const unionTypeShouldNotHaveASingularTypeArgument = (services: SafeDsServices) => { const settingsProvider = services.workspace.SettingsProvider; - return async (node: SdsUnionType, accept: ValidationAcceptor) => { + return async (node: TslUnionType, accept: ValidationAcceptor) => { if (!(await settingsProvider.shouldValidateCodeStyle())) { /* c8 ignore next 2 */ return; diff --git a/packages/ttsl-lang/src/language/validation/types.ts b/packages/ttsl-lang/src/language/validation/types.ts index c4be233f..f81c46d0 100644 --- a/packages/ttsl-lang/src/language/validation/types.ts +++ b/packages/ttsl-lang/src/language/validation/types.ts @@ -2,27 +2,27 @@ import { AstNode, AstUtils, ValidationAcceptor } from 'langium'; import { isEmpty } from '../../helpers/collections.js'; import { pluralize } from '../../helpers/strings.js'; import { - isSdsAnnotation, - isSdsCallable, - isSdsClass, - isSdsLambda, - isSdsMemberAccess, - isSdsPipeline, - isSdsReference, - isSdsSchema, - SdsAttribute, - SdsCall, - SdsIndexedAccess, - SdsInfixOperation, - SdsList, - SdsMap, - SdsNamedType, - SdsParameter, - SdsPrefixOperation, - SdsResult, - SdsTypeCast, - SdsTypeParameter, - SdsYield, + isTslAnnotation, + isTslCallable, + isTslClass, + isTslLambda, + isTslMemberAccess, + isTslPipeline, + isTslReference, + isTslSchema, + TslAttribute, + TslCall, + TslIndexedAccess, + TslInfixOperation, + TslList, + TslDictionary, + TslNamedType, + TslParameter, + TslPrefixOperation, + TslResult, + TslTypeCast, + TslTypeParameter, + TslYield, } from '../generated/ast.js'; import { getArguments, getTypeArguments, getTypeParameters, TypeParameter } from '../helpers/nodeProperties.js'; import { SafeDsServices } from '../safe-ds-module.js'; @@ -42,7 +42,7 @@ export const callArgumentTypesMustMatchParameterTypes = (services: SafeDsService const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsCall, accept: ValidationAcceptor) => { + return (node: TslCall, accept: ValidationAcceptor) => { const substitutions = typeComputer.computeSubstitutionsForCall(node); for (const argument of getArguments(node)) { @@ -68,28 +68,28 @@ export const callArgumentTypesMustMatchParameterTypes = (services: SafeDsService export const callReceiverMustBeCallable = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; - return (node: SdsCall, accept: ValidationAcceptor): void => { + return (node: TslCall, accept: ValidationAcceptor): void => { let receiver: AstNode | undefined = node.receiver; - if (isSdsMemberAccess(receiver)) { + if (isTslMemberAccess(receiver)) { receiver = receiver.member; } - if (isSdsReference(receiver)) { + if (isTslReference(receiver)) { const target = receiver.target.ref; // We already report other errors at this position in those cases - if (!target || isSdsAnnotation(target) || isSdsPipeline(target) || isSdsSchema(target)) { + if (!target || isTslAnnotation(target) || isTslPipeline(target) || isTslSchema(target)) { return; } } const callable = nodeMapper.callToCallable(node); - if (node.receiver && (!callable || isSdsAnnotation(callable))) { + if (node.receiver && (!callable || isTslAnnotation(callable))) { accept('error', 'This expression is not callable.', { node: node.receiver, code: CODE_TYPE_CALLABLE_RECEIVER, }); - } else if (node.receiver && isSdsClass(callable) && !callable.parameterList) { + } else if (node.receiver && isTslClass(callable) && !callable.parameterList) { accept('error', 'Cannot instantiate a class that has no constructor.', { node: node.receiver, code: CODE_TYPE_CALLABLE_RECEIVER, @@ -102,7 +102,7 @@ export const indexedAccessReceiverMustBeListOrMap = (services: SafeDsServices) = const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { + return (node: TslIndexedAccess, accept: ValidationAcceptor): void => { if (!node.receiver) { /* c8 ignore next 2 */ return; @@ -124,7 +124,7 @@ export const indexedAccessIndexMustHaveCorrectType = (services: SafeDsServices) const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsIndexedAccess, accept: ValidationAcceptor): void => { + return (node: TslIndexedAccess, accept: ValidationAcceptor): void => { const receiverType = typeComputer.computeType(node.receiver); if (typeChecker.isList(receiverType)) { const indexType = typeComputer.computeType(node.index); @@ -157,7 +157,7 @@ export const infixOperationOperandsMustHaveCorrectType = (services: SafeDsServic const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsInfixOperation, accept: ValidationAcceptor): void => { + return (node: TslInfixOperation, accept: ValidationAcceptor): void => { const leftType = typeComputer.computeType(node.leftOperand); const rightType = typeComputer.computeType(node.rightOperand); switch (node.operator) { @@ -216,7 +216,7 @@ export const infixOperationOperandsMustHaveCorrectType = (services: SafeDsServic export const listMustNotContainNamedTuples = (services: SafeDsServices) => { const typeComputer = services.types.TypeComputer; - return (node: SdsList, accept: ValidationAcceptor): void => { + return (node: TslList, accept: ValidationAcceptor): void => { for (const element of node.elements) { const elementType = typeComputer.computeType(element); if (elementType instanceof NamedTupleType) { @@ -232,7 +232,7 @@ export const listMustNotContainNamedTuples = (services: SafeDsServices) => { export const mapMustNotContainNamedTuples = (services: SafeDsServices) => { const typeComputer = services.types.TypeComputer; - return (node: SdsMap, accept: ValidationAcceptor): void => { + return (node: TslDictionary, accept: ValidationAcceptor): void => { for (const entry of node.entries) { const keyType = typeComputer.computeType(entry.key); if (keyType instanceof NamedTupleType) { @@ -260,7 +260,7 @@ export const namedTypeTypeArgumentsMustMatchBounds = (services: SafeDsServices) const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsNamedType, accept: ValidationAcceptor): void => { + return (node: TslNamedType, accept: ValidationAcceptor): void => { const type = typeComputer.computeType(node); if (!(type instanceof ClassType) || isEmpty(type.substitutions)) { return; @@ -297,7 +297,7 @@ export const parameterDefaultValueTypeMustMatchParameterType = (services: SafeDs const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsParameter, accept: ValidationAcceptor) => { + return (node: TslParameter, accept: ValidationAcceptor) => { const defaultValue = node.defaultValue; if (!defaultValue) { return; @@ -321,7 +321,7 @@ export const prefixOperationOperandMustHaveCorrectType = (services: SafeDsServic const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsPrefixOperation, accept: ValidationAcceptor): void => { + return (node: TslPrefixOperation, accept: ValidationAcceptor): void => { const operandType = typeComputer.computeType(node.operand); switch (node.operator) { case 'not': @@ -356,7 +356,7 @@ export const prefixOperationOperandMustHaveCorrectType = (services: SafeDsServic export const typeCastExpressionMustHaveUnknownType = (services: SafeDsServices) => { const typeComputer = services.types.TypeComputer; - return (node: SdsTypeCast, accept: ValidationAcceptor): void => { + return (node: TslTypeCast, accept: ValidationAcceptor): void => { const expressionType = typeComputer.computeType(node.expression); if (node.expression && expressionType !== UnknownType) { accept('error', 'Type casts can only be applied to expressions of unknown type.', { @@ -372,7 +372,7 @@ export const typeParameterDefaultValueMustMatchUpperBound = (services: SafeDsSer const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsTypeParameter, accept: ValidationAcceptor): void => { + return (node: TslTypeParameter, accept: ValidationAcceptor): void => { if (!node.defaultValue || !node.upperBound) { return; } @@ -394,7 +394,7 @@ export const yieldTypeMustMatchResultType = (services: SafeDsServices) => { const typeChecker = services.types.TypeChecker; const typeComputer = services.types.TypeComputer; - return (node: SdsYield, accept: ValidationAcceptor) => { + return (node: TslYield, accept: ValidationAcceptor) => { const result = node.result?.ref; if (!result) { return; @@ -419,7 +419,7 @@ export const yieldTypeMustMatchResultType = (services: SafeDsServices) => { export const namedTypeMustSetAllTypeParameters = (services: SafeDsServices) => - (node: SdsNamedType, accept: ValidationAcceptor): void => { + (node: TslNamedType, accept: ValidationAcceptor): void => { const expectedTypeParameters = getTypeParameters(node.declaration?.ref).filter(TypeParameter.isRequired); if (isEmpty(expectedTypeParameters)) { return; @@ -457,7 +457,7 @@ export const namedTypeMustSetAllTypeParameters = // Missing type hints // ----------------------------------------------------------------------------- -export const attributeMustHaveTypeHint = (node: SdsAttribute, accept: ValidationAcceptor): void => { +export const attributeMustHaveTypeHint = (node: TslAttribute, accept: ValidationAcceptor): void => { if (!node.type) { accept('error', 'An attribute must have a type hint.', { node, @@ -467,11 +467,11 @@ export const attributeMustHaveTypeHint = (node: SdsAttribute, accept: Validation } }; -export const parameterMustHaveTypeHint = (node: SdsParameter, accept: ValidationAcceptor): void => { +export const parameterMustHaveTypeHint = (node: TslParameter, accept: ValidationAcceptor): void => { if (!node.type) { - const containingCallable = AstUtils.getContainerOfType(node, isSdsCallable); + const containingCallable = AstUtils.getContainerOfType(node, isTslCallable); - if (!isSdsLambda(containingCallable)) { + if (!isTslLambda(containingCallable)) { accept('error', 'A parameter must have a type hint.', { node, property: 'name', @@ -481,7 +481,7 @@ export const parameterMustHaveTypeHint = (node: SdsParameter, accept: Validation } }; -export const resultMustHaveTypeHint = (node: SdsResult, accept: ValidationAcceptor): void => { +export const resultMustHaveTypeHint = (node: TslResult, accept: ValidationAcceptor): void => { if (!node.type) { accept('error', 'A result must have a type hint.', { node, diff --git a/packages/ttsl-lang/src/language/workspace/safe-ds-package-manager.ts b/packages/ttsl-lang/src/language/workspace/safe-ds-package-manager.ts index f8ce9237..af30ce2e 100644 --- a/packages/ttsl-lang/src/language/workspace/safe-ds-package-manager.ts +++ b/packages/ttsl-lang/src/language/workspace/safe-ds-package-manager.ts @@ -8,7 +8,7 @@ import { IndexManager, LangiumDocuments, } from 'langium'; -import { isSdsSegment } from '../generated/ast.js'; +import { isTslSegment } from '../generated/ast.js'; import { getPackageName, isInternal } from '../helpers/nodeProperties.js'; export class SafeDsPackageManager { @@ -112,7 +112,7 @@ export class SafeDsPackageManager { } if (hideInternal) { - result = result.filter((it) => !isSdsSegment(it.node) || !isInternal(it.node)); + result = result.filter((it) => !isTslSegment(it.node) || !isInternal(it.node)); } return result; diff --git a/packages/ttsl-lang/tests/helpers/__snapshots__/nodeFinder.test.ts.snap b/packages/ttsl-lang/tests/helpers/__snapshots__/nodeFinder.test.ts.snap index b437dddd..743aaa89 100644 --- a/packages/ttsl-lang/tests/helpers/__snapshots__/nodeFinder.test.ts.snap +++ b/packages/ttsl-lang/tests/helpers/__snapshots__/nodeFinder.test.ts.snap @@ -1,6 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`getNodeByLocation > should throw if no document is found 1`] = `[AssertionError: No document found at file:///test.sdstest]`; +exports[`getNodeByLocation > should throw if no document is found 1`] = `[AssertionError: No document found at file:///test.Tsltest]`; exports[`getNodeOfType > should throw if no node is found 1`] = `[AssertionError: Expected to find a matching node but found none.]`; diff --git a/packages/ttsl-lang/tests/helpers/diagnostics.ts b/packages/ttsl-lang/tests/helpers/diagnostics.ts index 916b4046..9ac70edd 100644 --- a/packages/ttsl-lang/tests/helpers/diagnostics.ts +++ b/packages/ttsl-lang/tests/helpers/diagnostics.ts @@ -64,7 +64,7 @@ export const getErrorsAtURI = (services: LangiumServices, uri: URI): Diagnostic[ const getDiagnostics = async (services: LangiumServices, code: string): Promise => { const parse = parseHelper(services); const document = await parse(code, { - documentUri: `file:///$autogen$${nextId++}.sdstest`, + documentUri: `file:///$autogen$${nextId++}.Tsltest`, validation: true, }); return document.diagnostics ?? []; diff --git a/packages/ttsl-lang/tests/helpers/locations.test.ts b/packages/ttsl-lang/tests/helpers/locations.test.ts index ecb19e4c..29151c9c 100644 --- a/packages/ttsl-lang/tests/helpers/locations.test.ts +++ b/packages/ttsl-lang/tests/helpers/locations.test.ts @@ -35,17 +35,17 @@ describe('locationToString', () => { it.each([ { location: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }, - expected: 'file:///test.sdstest:1:1 -> 1:1', + expected: 'file:///test.Tsltest:1:1 -> 1:1', }, { location: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 1, character: 0 } }, }, - expected: 'file:///test.sdstest:1:1 -> 2:1', + expected: 'file:///test.Tsltest:1:1 -> 2:1', }, ])(`should convert location to string ($expected)`, ({ location, expected }) => { expect(locationToString(location)).toBe(expected); @@ -56,11 +56,11 @@ describe('isLocationEqual', () => { it.each([ { location1: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }, location2: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }, expected: true, @@ -68,11 +68,11 @@ describe('isLocationEqual', () => { }, { location1: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }, location2: { - uri: 'file:///test2.sdstest', + uri: 'file:///test2.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }, expected: false, @@ -80,11 +80,11 @@ describe('isLocationEqual', () => { }, { location1: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }, location2: { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 1, character: 0 } }, }, expected: false, diff --git a/packages/ttsl-lang/tests/helpers/nodeFinder.test.ts b/packages/ttsl-lang/tests/helpers/nodeFinder.test.ts index 6cda0de5..3878cd2a 100644 --- a/packages/ttsl-lang/tests/helpers/nodeFinder.test.ts +++ b/packages/ttsl-lang/tests/helpers/nodeFinder.test.ts @@ -4,7 +4,7 @@ import { createSafeDsServices } from '../../src/language/index.js'; import { EmptyFileSystem } from 'langium'; import { AssertionError } from 'assert'; import { clearDocuments, parseHelper } from 'langium/test'; -import { isSdsClass, isSdsDeclaration, isSdsEnum } from '../../src/language/generated/ast.js'; +import { isTslClass, isTslDeclaration, isTslEnum } from '../../src/language/generated/ast.js'; describe('getNodeByLocation', async () => { const services = (await createSafeDsServices(EmptyFileSystem, { omitBuiltins: true })).SafeDs; @@ -16,7 +16,7 @@ describe('getNodeByLocation', async () => { it('should throw if no document is found', () => { expect(() => { getNodeByLocation(services, { - uri: 'file:///test.sdstest', + uri: 'file:///test.Tsltest', range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }, }); }).toThrowErrorMatchingSnapshot(); @@ -41,7 +41,7 @@ describe('getNodeByLocation', async () => { uri: document.uri.toString(), range: { start: { line: 0, character: 0 }, end: { line: 0, character: 7 } }, }), - ).to.satisfy(isSdsClass); + ).to.satisfy(isTslClass); }); it('should return the node whose name fills the range completely', async () => { @@ -52,7 +52,7 @@ describe('getNodeByLocation', async () => { uri: document.uri.toString(), range: { start: { line: 0, character: 6 }, end: { line: 0, character: 7 } }, }), - ).to.satisfy(isSdsClass); + ).to.satisfy(isTslClass); }); }); @@ -66,21 +66,21 @@ describe('getNodeOfType', async () => { it('should throw if no node is found', async () => { const code = ''; expect(async () => { - await getNodeOfType(services, code, isSdsClass); + await getNodeOfType(services, code, isTslClass); }).rejects.toThrowErrorMatchingSnapshot(); }); it('should throw if not enough nodes are found', async () => { const code = `class C`; expect(async () => { - await getNodeOfType(services, code, isSdsClass, 1); + await getNodeOfType(services, code, isTslClass, 1); }).rejects.toThrowErrorMatchingSnapshot(); }); it('should return the first matching node if no index is set', async () => { const code = 'class C'; - const node = await getNodeOfType(services, code, isSdsClass); - expect(node).to.satisfy(isSdsClass); + const node = await getNodeOfType(services, code, isTslClass); + expect(node).to.satisfy(isTslClass); }); it('should return the nth matching node if an index is set', async () => { @@ -90,7 +90,7 @@ describe('getNodeOfType', async () => { class C enum D `; - const node = await getNodeOfType(services, code, isSdsDeclaration, 2); - expect(node).to.satisfy(isSdsEnum); + const node = await getNodeOfType(services, code, isTslDeclaration, 2); + expect(node).to.satisfy(isTslEnum); }); }); diff --git a/packages/ttsl-lang/tests/helpers/nodeFinder.ts b/packages/ttsl-lang/tests/helpers/nodeFinder.ts index 4804194b..06c908de 100644 --- a/packages/ttsl-lang/tests/helpers/nodeFinder.ts +++ b/packages/ttsl-lang/tests/helpers/nodeFinder.ts @@ -2,7 +2,7 @@ import { Location, Range } from 'vscode-languageserver'; import { isRangeEqual, parseHelper } from 'langium/test'; import { SafeDsServices } from '../../src/language/index.js'; import { AstNode, AstUtils, URI } from 'langium'; -import { SdsModule } from '../../src/language/generated/ast.js'; +import { TslModule } from '../../src/language/generated/ast.js'; import { AssertionError } from 'assert'; import { locationToString } from '../../src/helpers/locations.js'; @@ -25,7 +25,7 @@ export const getNodeByLocation = (services: SafeDsServices, location: Location): }); } - const module = document.parseResult.value as SdsModule; + const module = document.parseResult.value as TslModule; for (const node of AstUtils.streamAllContents(module)) { // Entire node matches the range @@ -66,7 +66,7 @@ export const getNodeOfType = async ( index: number = 0, ): Promise => { const document = await parseHelper(services)(code); - const module = document.parseResult.value as SdsModule; + const module = document.parseResult.value as TslModule; const candidates = AstUtils.streamAst(module).filter(predicate).toArray(); if (candidates.length === 0) { diff --git a/packages/ttsl-lang/tests/helpers/testChecks.test.ts b/packages/ttsl-lang/tests/helpers/testChecks.test.ts index 2ed4ee46..1d789e94 100644 --- a/packages/ttsl-lang/tests/helpers/testChecks.test.ts +++ b/packages/ttsl-lang/tests/helpers/testChecks.test.ts @@ -10,7 +10,7 @@ import { import { Range } from 'vscode-languageserver'; import { URI } from 'langium'; -const uri = 'file:///test.sdstest'; +const uri = 'file:///test.Tsltest'; describe('findTestChecks', () => { it.each([ diff --git a/packages/ttsl-lang/tests/helpers/testResources.test.ts b/packages/ttsl-lang/tests/helpers/testResources.test.ts index 111c3c59..0c1f4f5b 100644 --- a/packages/ttsl-lang/tests/helpers/testResources.test.ts +++ b/packages/ttsl-lang/tests/helpers/testResources.test.ts @@ -29,12 +29,12 @@ describe('listTestSafeDsFiles', () => { const rootResourceName = 'helpers/listSafeDsFiles'; const actual = listTestSafeDsFiles(rootResourceName); const expected = [ - 'pipeline file.sdspipe', - 'stub file.sdsstub', - 'test file.sdstest', - 'nested/pipeline file.sdspipe', - 'nested/stub file.sdsstub', - 'nested/test file.sdstest', + 'pipeline file.Tslpipe', + 'stub file.Tslstub', + 'test file.Tsltest', + 'nested/pipeline file.Tslpipe', + 'nested/stub file.Tslstub', + 'nested/test file.Tsltest', ]; expectFileListsToMatch(rootResourceName, actual, expected); @@ -65,7 +65,7 @@ describe('listTestSafeDsFilesGroupedByParentDirectory', () => { const actualValuesDirectlyInRoot = [...result.entries()].find( ([key]) => uriToShortenedTestResourceName(key, rootResourceName) === '', )!; - const expectedValuesDirectlyInRoot = ['pipeline file.sdspipe', 'stub file.sdsstub', 'test file.sdstest']; + const expectedValuesDirectlyInRoot = ['pipeline file.Tslpipe', 'stub file.Tslstub', 'test file.Tsltest']; expectFileListsToMatch(rootResourceName, actualValuesDirectlyInRoot[1], expectedValuesDirectlyInRoot); // Compare the values, i.e. the files, in the nested directory @@ -73,9 +73,9 @@ describe('listTestSafeDsFilesGroupedByParentDirectory', () => { ([key]) => uriToShortenedTestResourceName(key, rootResourceName) === 'nested', )!; const expectedValuesInNested = [ - 'nested/pipeline file.sdspipe', - 'nested/stub file.sdsstub', - 'nested/test file.sdstest', + 'nested/pipeline file.Tslpipe', + 'nested/stub file.Tslstub', + 'nested/test file.Tsltest', ]; expectFileListsToMatch(rootResourceName, actualValuesInNested[1], expectedValuesInNested); }); diff --git a/packages/ttsl-lang/tests/language/documentation/safe-ds-comment-provider.test.ts b/packages/ttsl-lang/tests/language/documentation/safe-ds-comment-provider.test.ts index ebf7d7f2..7f27ad3e 100644 --- a/packages/ttsl-lang/tests/language/documentation/safe-ds-comment-provider.test.ts +++ b/packages/ttsl-lang/tests/language/documentation/safe-ds-comment-provider.test.ts @@ -2,15 +2,15 @@ import { AssertionError } from 'assert'; import { AstNode, EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; import { - isSdsAnnotation, - isSdsAttribute, - isSdsBlockLambdaResult, - isSdsEnumVariant, - isSdsExpressionStatement, - isSdsParameter, - isSdsPlaceholder, - isSdsResult, - isSdsTypeParameter, + isTslAnnotation, + isTslAttribute, + isTslBlockLambdaResult, + isTslEnumVariant, + isTslExpressionStatement, + isTslParameter, + isTslPlaceholder, + isTslResult, + isTslTypeParameter, } from '../../../src/language/generated/ast.js'; import { createSafeDsServices } from '../../../src/language/index.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; @@ -27,7 +27,7 @@ describe('SafeDsCommentProvider', () => { ${testComment} annotation MyAnnotation `, - predicate: isSdsAnnotation, + predicate: isTslAnnotation, expectedComment: testComment, }, { @@ -37,7 +37,7 @@ describe('SafeDsCommentProvider', () => { @Test annotation MyAnnotation `, - predicate: isSdsAnnotation, + predicate: isTslAnnotation, expectedComment: undefined, }, { @@ -49,7 +49,7 @@ describe('SafeDsCommentProvider', () => { @Test annotation MyAnnotation `, - predicate: isSdsAnnotation, + predicate: isTslAnnotation, expectedComment: testComment, }, { @@ -57,7 +57,7 @@ describe('SafeDsCommentProvider', () => { code: ` annotation MyAnnotation `, - predicate: isSdsAnnotation, + predicate: isTslAnnotation, expectedComment: undefined, }, { @@ -68,7 +68,7 @@ describe('SafeDsCommentProvider', () => { attr a: Int } `, - predicate: isSdsAttribute, + predicate: isTslAttribute, expectedComment: testComment, }, { @@ -80,7 +80,7 @@ describe('SafeDsCommentProvider', () => { attr a: Int } `, - predicate: isSdsAttribute, + predicate: isTslAttribute, expectedComment: testComment, }, { @@ -90,7 +90,7 @@ describe('SafeDsCommentProvider', () => { attr a: Int } `, - predicate: isSdsAttribute, + predicate: isTslAttribute, expectedComment: undefined, }, { @@ -101,7 +101,7 @@ describe('SafeDsCommentProvider', () => { MyEnumVariant } `, - predicate: isSdsEnumVariant, + predicate: isTslEnumVariant, expectedComment: testComment, }, { @@ -113,7 +113,7 @@ describe('SafeDsCommentProvider', () => { MyEnumVariant } `, - predicate: isSdsEnumVariant, + predicate: isTslEnumVariant, expectedComment: testComment, }, { @@ -123,7 +123,7 @@ describe('SafeDsCommentProvider', () => { MyEnumVariant } `, - predicate: isSdsEnumVariant, + predicate: isTslEnumVariant, expectedComment: undefined, }, { @@ -136,7 +136,7 @@ describe('SafeDsCommentProvider', () => { } } `, - predicate: isSdsBlockLambdaResult, + predicate: isTslBlockLambdaResult, expectedComment: undefined, }, { @@ -148,7 +148,7 @@ describe('SafeDsCommentProvider', () => { } } `, - predicate: isSdsBlockLambdaResult, + predicate: isTslBlockLambdaResult, expectedComment: undefined, }, { @@ -156,7 +156,7 @@ describe('SafeDsCommentProvider', () => { code: ` segment mySegment(${testComment} p: Int) {} `, - predicate: isSdsParameter, + predicate: isTslParameter, expectedComment: undefined, }, { @@ -164,7 +164,7 @@ describe('SafeDsCommentProvider', () => { code: ` segment mySegment(p: Int) {} `, - predicate: isSdsParameter, + predicate: isTslParameter, expectedComment: undefined, }, { @@ -175,7 +175,7 @@ describe('SafeDsCommentProvider', () => { val p = 1; } `, - predicate: isSdsPlaceholder, + predicate: isTslPlaceholder, expectedComment: undefined, }, { @@ -185,7 +185,7 @@ describe('SafeDsCommentProvider', () => { val p = 1; } `, - predicate: isSdsPlaceholder, + predicate: isTslPlaceholder, expectedComment: undefined, }, { @@ -193,7 +193,7 @@ describe('SafeDsCommentProvider', () => { code: ` segment mySegment() -> (${testComment} r: Int) {} `, - predicate: isSdsResult, + predicate: isTslResult, expectedComment: undefined, }, { @@ -201,7 +201,7 @@ describe('SafeDsCommentProvider', () => { code: ` segment mySegment() -> (r: Int) {} `, - predicate: isSdsResult, + predicate: isTslResult, expectedComment: undefined, }, { @@ -209,7 +209,7 @@ describe('SafeDsCommentProvider', () => { code: ` class MyClass<${testComment} T> `, - predicate: isSdsTypeParameter, + predicate: isTslTypeParameter, expectedComment: undefined, }, { @@ -217,7 +217,7 @@ describe('SafeDsCommentProvider', () => { code: ` class MyClass `, - predicate: isSdsTypeParameter, + predicate: isTslTypeParameter, expectedComment: undefined, }, { @@ -228,7 +228,7 @@ describe('SafeDsCommentProvider', () => { f(); } `, - predicate: isSdsExpressionStatement, + predicate: isTslExpressionStatement, expectedComment: undefined, }, { @@ -238,7 +238,7 @@ describe('SafeDsCommentProvider', () => { f(); } `, - predicate: isSdsExpressionStatement, + predicate: isTslExpressionStatement, expectedComment: undefined, }, ]; diff --git a/packages/ttsl-lang/tests/language/documentation/safe-ds-documentation-provider.test.ts b/packages/ttsl-lang/tests/language/documentation/safe-ds-documentation-provider.test.ts index bf8343c2..72cf2298 100644 --- a/packages/ttsl-lang/tests/language/documentation/safe-ds-documentation-provider.test.ts +++ b/packages/ttsl-lang/tests/language/documentation/safe-ds-documentation-provider.test.ts @@ -2,11 +2,11 @@ import { AstNode, EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; import { normalizeLineBreaks } from '../../../src/helpers/strings.js'; import { - isSdsAnnotation, - isSdsFunction, - isSdsParameter, - isSdsResult, - isSdsTypeParameter, + isTslAnnotation, + isTslFunction, + isTslParameter, + isTslResult, + isTslTypeParameter, } from '../../../src/language/generated/ast.js'; import { createSafeDsServices } from '../../../src/language/index.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; @@ -26,7 +26,7 @@ describe('SafeDsDocumentationProvider', () => { */ annotation MyAnnotation `, - predicate: isSdsAnnotation, + predicate: isTslAnnotation, expectedDocumentation: testDocumentation, }, { @@ -37,7 +37,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction(param: String) `, - predicate: isSdsParameter, + predicate: isTslParameter, expectedDocumentation: testDocumentation, }, { @@ -49,7 +49,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction(param: String) `, - predicate: isSdsParameter, + predicate: isTslParameter, expectedDocumentation: testDocumentation, }, { @@ -60,7 +60,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction(param2: String) `, - predicate: isSdsParameter, + predicate: isTslParameter, expectedDocumentation: undefined, }, { @@ -68,7 +68,7 @@ describe('SafeDsDocumentationProvider', () => { code: ` fun myFunction(p: Int) `, - predicate: isSdsParameter, + predicate: isTslParameter, expectedDocumentation: undefined, }, { @@ -79,7 +79,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction() -> (res: String) `, - predicate: isSdsResult, + predicate: isTslResult, expectedDocumentation: testDocumentation, }, { @@ -91,7 +91,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction() -> (res: String) `, - predicate: isSdsResult, + predicate: isTslResult, expectedDocumentation: testDocumentation, }, { @@ -102,7 +102,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction() -> (res2: String) `, - predicate: isSdsResult, + predicate: isTslResult, expectedDocumentation: undefined, }, { @@ -110,7 +110,7 @@ describe('SafeDsDocumentationProvider', () => { code: ` fun myFunction() -> r: Int `, - predicate: isSdsResult, + predicate: isTslResult, expectedDocumentation: undefined, }, { @@ -122,7 +122,7 @@ describe('SafeDsDocumentationProvider', () => { */ class MyClass `, - predicate: isSdsTypeParameter, + predicate: isTslTypeParameter, expectedDocumentation: testDocumentation, }, { @@ -134,7 +134,7 @@ describe('SafeDsDocumentationProvider', () => { */ class MyClass `, - predicate: isSdsTypeParameter, + predicate: isTslTypeParameter, expectedDocumentation: testDocumentation, }, { @@ -146,7 +146,7 @@ describe('SafeDsDocumentationProvider', () => { */ class MyClass `, - predicate: isSdsTypeParameter, + predicate: isTslTypeParameter, expectedDocumentation: undefined, }, { @@ -154,7 +154,7 @@ describe('SafeDsDocumentationProvider', () => { code: ` fun myFunction() `, - predicate: isSdsTypeParameter, + predicate: isTslTypeParameter, expectedDocumentation: undefined, }, { @@ -170,7 +170,7 @@ describe('SafeDsDocumentationProvider', () => { */ fun myFunction(param: String) -> result: String `, - predicate: isSdsFunction, + predicate: isTslFunction, expectedDocumentation: expandToString` Lorem ipsum. @@ -201,7 +201,7 @@ describe('SafeDsDocumentationProvider', () => { fun myFunction2() `; - const node = await getNodeOfType(services, code, isSdsFunction); + const node = await getNodeOfType(services, code, isTslFunction); expect(documentationProvider.getDocumentation(node)).toMatch(/\[myFunction2\]\(.*\)/u); }); }); diff --git a/packages/ttsl-lang/tests/language/flow/model.test.ts b/packages/ttsl-lang/tests/language/flow/model.test.ts index cb849d6b..75cc4872 100644 --- a/packages/ttsl-lang/tests/language/flow/model.test.ts +++ b/packages/ttsl-lang/tests/language/flow/model.test.ts @@ -3,7 +3,7 @@ import { CallGraph } from '../../../src/language/flow/model.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; import { createSafeDsServices } from '../../../src/language/index.js'; import { EmptyFileSystem } from 'langium'; -import { isSdsModule, SdsCallable } from '../../../src/language/generated/ast.js'; +import { isTslModule, TslCallable } from '../../../src/language/generated/ast.js'; const services = (await createSafeDsServices(EmptyFileSystem, { omitBuiltins: true })).SafeDs; const code = ` @@ -12,10 +12,10 @@ const code = ` fun f3() `; -const module = await getNodeOfType(services, code, isSdsModule); -const f1 = module.members[0] as SdsCallable; -const f2 = module.members[1] as SdsCallable; -const f3 = module.members[2] as SdsCallable; +const module = await getNodeOfType(services, code, isTslModule); +const f1 = module.members[0] as TslCallable; +const f2 = module.members[1] as TslCallable; +const f3 = module.members[2] as TslCallable; describe('call graph model', () => { describe('streamCalledCallables', () => { diff --git a/packages/ttsl-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts b/packages/ttsl-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts index 720070b3..8a500246 100644 --- a/packages/ttsl-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts +++ b/packages/ttsl-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts @@ -1,13 +1,13 @@ import { describe, expect, it } from 'vitest'; import { AstUtils, isNamed } from 'langium'; import { - isSdsBlockLambda, - isSdsCall, - isSdsCallable, - isSdsExpressionLambda, - isSdsModule, - SdsCall, - SdsCallable, + isTslBlockLambda, + isTslCall, + isTslCallable, + isTslExpressionLambda, + isTslModule, + TslCall, + TslCallable, } from '../../../src/language/generated/ast.js'; import { createSafeDsServices } from '../../../src/language/index.js'; import { createCallGraphTests } from './creator.js'; @@ -28,13 +28,13 @@ describe('SafeDsCallGraphComputer', () => { throw test.error; } - const module = await getNodeOfType(services, test.code, isSdsModule); + const module = await getNodeOfType(services, test.code, isTslModule); for (const { location, expectedCallables } of test.expectedCallGraphs) { const node = AstUtils.streamAst(module).find((call) => isRangeEqual(call.$cstNode!.range, location.range), ); - if (!node || (!isSdsCall(node) && !isSdsCallable(node))) { + if (!node || (!isTslCall(node) && !isTslCallable(node))) { throw new Error(`Could not find call/callable at ${locationToString(location)}`); } @@ -55,16 +55,16 @@ describe('SafeDsCallGraphComputer', () => { }); }); -const getActualCallables = (node: SdsCall | SdsCallable): string[] => { +const getActualCallables = (node: TslCall | TslCallable): string[] => { return callGraphComputer .getCallGraph(node) .streamCalledCallables() .map((callable) => { if (callable && isNamed(callable)) { return callable.name; - } else if (isSdsBlockLambda(callable)) { + } else if (isTslBlockLambda(callable)) { return '$blockLambda'; - } else if (isSdsExpressionLambda(callable)) { + } else if (isTslExpressionLambda(callable)) { return '$expressionLambda'; } else { return 'undefined'; diff --git a/packages/ttsl-lang/tests/language/grammar/safe-ds-value-converter.test.ts b/packages/ttsl-lang/tests/language/grammar/safe-ds-value-converter.test.ts index 9731d630..d2320837 100644 --- a/packages/ttsl-lang/tests/language/grammar/safe-ds-value-converter.test.ts +++ b/packages/ttsl-lang/tests/language/grammar/safe-ds-value-converter.test.ts @@ -3,13 +3,13 @@ import { createSafeDsServices } from '../../../src/language/index.js'; import { EmptyFileSystem } from 'langium'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; import { - isSdsClass, - isSdsInt, - isSdsModule, - isSdsString, - isSdsTemplateStringEnd, - isSdsTemplateStringInner, - isSdsTemplateStringStart, + isTslClass, + isTslInt, + isTslModule, + isTslString, + isTslTemplateStringEnd, + isTslTemplateStringInner, + isTslTemplateStringStart, } from '../../../src/language/generated/ast.js'; import { escapeString } from '../../../src/language/grammar/safe-ds-value-converter.js'; @@ -22,7 +22,7 @@ describe('runConverter', () => { package \`foo\`.bar `; - const module = await getNodeOfType(services, code, isSdsModule); + const module = await getNodeOfType(services, code, isTslModule); expect(module.name).toBe('foo.bar'); }); @@ -31,7 +31,7 @@ describe('runConverter', () => { class \`MyClass\` `; - const firstClass = await getNodeOfType(services, code, isSdsClass); + const firstClass = await getNodeOfType(services, code, isTslClass); expect(firstClass.name).toBe('MyClass'); }); }); @@ -44,7 +44,7 @@ describe('runConverter', () => { } `; - const firstInt = await getNodeOfType(services, code, isSdsInt); + const firstInt = await getNodeOfType(services, code, isTslInt); expect(firstInt.value).toBe(123n); }); }); @@ -128,7 +128,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringStart = await getNodeOfType(services, code, isSdsString); + const firstTemplateStringStart = await getNodeOfType(services, code, isTslString); expect(firstTemplateStringStart.value).toBe('text'); }); @@ -139,7 +139,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringStart = await getNodeOfType(services, code, isSdsString); + const firstTemplateStringStart = await getNodeOfType(services, code, isTslString); expect(firstTemplateStringStart.value).toBe(unescaped); }); }); @@ -152,7 +152,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringStart = await getNodeOfType(services, code, isSdsTemplateStringStart); + const firstTemplateStringStart = await getNodeOfType(services, code, isTslTemplateStringStart); expect(firstTemplateStringStart.value).toBe('start'); }); @@ -163,7 +163,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringStart = await getNodeOfType(services, code, isSdsTemplateStringStart); + const firstTemplateStringStart = await getNodeOfType(services, code, isTslTemplateStringStart); expect(firstTemplateStringStart.value).toBe(unescaped); }); }); @@ -176,7 +176,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringInner = await getNodeOfType(services, code, isSdsTemplateStringInner); + const firstTemplateStringInner = await getNodeOfType(services, code, isTslTemplateStringInner); expect(firstTemplateStringInner.value).toBe('inner'); }); @@ -187,7 +187,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringInner = await getNodeOfType(services, code, isSdsTemplateStringInner); + const firstTemplateStringInner = await getNodeOfType(services, code, isTslTemplateStringInner); expect(firstTemplateStringInner.value).toBe(unescaped); }); }); @@ -200,7 +200,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringEnd = await getNodeOfType(services, code, isSdsTemplateStringEnd); + const firstTemplateStringEnd = await getNodeOfType(services, code, isTslTemplateStringEnd); expect(firstTemplateStringEnd.value).toBe('end'); }); @@ -211,7 +211,7 @@ describe('runConverter', () => { } `; - const firstTemplateStringEnd = await getNodeOfType(services, code, isSdsTemplateStringEnd); + const firstTemplateStringEnd = await getNodeOfType(services, code, isTslTemplateStringEnd); expect(firstTemplateStringEnd.value).toBe(unescaped); }); }); diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/argumentToParameter.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/argumentToParameter.test.ts index 91d671b2..9d618c1f 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/argumentToParameter.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/argumentToParameter.test.ts @@ -1,6 +1,6 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; -import { isSdsAbstractCall, SdsArgument } from '../../../../src/language/generated/ast.js'; +import { isTslAbstractCall, TslArgument } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices, getArguments } from '../../../../src/language/index.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -23,7 +23,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); const parameterNames = getArguments(call).map(parameterNameOrNull); expect(parameterNames).toStrictEqual([undefined]); }); @@ -37,7 +37,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); const parameterNames = getArguments(call).map(parameterNameOrNull); expect(parameterNames).toStrictEqual(['p2', 'p3', 'p1']); }); @@ -53,7 +53,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); const parameterNames = getArguments(call).map(parameterNameOrNull); expect(parameterNames).toStrictEqual(['p1', 'p2', 'p3']); }); @@ -67,7 +67,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); const parameterNames = getArguments(call).map(parameterNameOrNull); expect(parameterNames).toStrictEqual(['p2', undefined, undefined]); }); @@ -81,13 +81,13 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); const parameterNames = getArguments(call).map(parameterNameOrNull); expect(parameterNames).toStrictEqual(['p1', 'p2', undefined]); }); }); - const parameterNameOrNull = (node: SdsArgument): string | undefined => { + const parameterNameOrNull = (node: TslArgument): string | undefined => { const parameter = nodeMapper.argumentToParameter(node); return parameter?.name ?? undefined; }; diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/assigneeToAssignedObject.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/assigneeToAssignedObject.test.ts index 4ce91c25..4ab034a6 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/assigneeToAssignedObject.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/assigneeToAssignedObject.test.ts @@ -1,10 +1,10 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; import { - isSdsAbstractResult, - isSdsAssignment, - isSdsPlaceholder, - SdsAssignee, + isTslAbstractResult, + isTslAssignment, + isTslPlaceholder, + TslAssignee, } from '../../../../src/language/generated/ast.js'; import { getAssignees } from '../../../../src/language/helpers/nodeProperties.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -48,7 +48,7 @@ describe('SafeDsNodeMapper', () => { `, }, ])('should return undefined if nothing is assigned ($name)', async ({ code }) => { - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBeUndefined(); }); @@ -59,8 +59,8 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); - expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('SdsInt'); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); + expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('TslInt'); }); it('should return the entire RHS of an assignment if it is a call of a class', async () => { @@ -71,8 +71,8 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); - expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('SdsCall'); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); + expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('TslCall'); }); it('should return the entire RHS of an assignment if it is a call of an enum variant', async () => { @@ -85,8 +85,8 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); - expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('SdsCall'); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); + expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('TslCall'); }); it('should return the entire RHS of an assignment if it is not a call (unresolved reference)', async () => { @@ -96,8 +96,8 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); - expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('SdsReference'); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); + expect(nodeMapper.assigneeToAssignedObject(placeholder)?.$type).toBe('TslReference'); }); it.each([ @@ -173,17 +173,17 @@ describe('SafeDsNodeMapper', () => { ])( 'should return the corresponding result if the RHS is a call of a $name', async ({ code, expected, index = 0 }) => { - const assignment = await getNodeOfType(services, code, isSdsAssignment, index); + const assignment = await getNodeOfType(services, code, isTslAssignment, index); const abstractResultNames = getAssignees(assignment).map(abstractResultNameOrNull); expect(abstractResultNames).toStrictEqual(expected); }, ); - const abstractResultNameOrNull = (node: SdsAssignee): string | undefined => { + const abstractResultNameOrNull = (node: TslAssignee): string | undefined => { const assignedObject = nodeMapper.assigneeToAssignedObject(node); if (!assignedObject) { return undefined; - } else if (isSdsAbstractResult(assignedObject)) { + } else if (isTslAbstractResult(assignedObject)) { return assignedObject.name; } else { return assignedObject.$cstNode?.text; diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToCallable.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToCallable.test.ts index 3fca9123..9b532f0b 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToCallable.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToCallable.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { isSdsAbstractCall } from '../../../../src/language/generated/ast.js'; +import { isTslAbstractCall } from '../../../../src/language/generated/ast.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; import { NodeFileSystem } from 'langium/node'; import { createSafeDsServices } from '../../../../src/language/index.js'; @@ -24,7 +24,7 @@ describe('SafeDsNodeMapper', () => { pipeline myPipeline {} `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); expect(nodeMapper.callToCallable(call)?.$type).toBeUndefined(); }); @@ -36,8 +36,8 @@ describe('SafeDsNodeMapper', () => { class MyClass `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsAnnotation'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslAnnotation'); }); }); @@ -53,7 +53,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); expect(nodeMapper.callToCallable(call)?.$type).toBeUndefined(); }); @@ -66,7 +66,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); expect(nodeMapper.callToCallable(call)?.$type).toBeUndefined(); }); @@ -79,8 +79,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsAnnotation'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslAnnotation'); }); it('should return the called annotation (aliased)', async () => { @@ -93,8 +93,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsAnnotation'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslAnnotation'); }); it('should return the called block lambda (aliased)', async () => { @@ -105,8 +105,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsBlockLambda'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslBlockLambda'); }); it('should return the called callable type', async () => { @@ -116,8 +116,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsCallableType'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslCallableType'); }); it('should return the called callable type (aliased)', async () => { @@ -128,8 +128,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsCallableType'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslCallableType'); }); it('should return the called class', async () => { @@ -141,8 +141,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsClass'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslClass'); }); it('should return the called class (aliased)', async () => { @@ -155,8 +155,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsClass'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslClass'); }); it('should return the called enum variant', async () => { @@ -170,8 +170,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsEnumVariant'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslEnumVariant'); }); it('should return undefined (aliased enum variant without parameter)', async () => { @@ -186,7 +186,7 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); + const call = await getNodeOfType(services, code, isTslAbstractCall); expect(nodeMapper.callToCallable(call)).toBeUndefined(); }); @@ -202,8 +202,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsEnumVariant'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslEnumVariant'); }); it('should return the called expression lambda (aliased)', async () => { @@ -214,8 +214,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsExpressionLambda'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslExpressionLambda'); }); it('should return the called function', async () => { @@ -227,8 +227,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsFunction'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslFunction'); }); it('should return the called function (aliased)', async () => { @@ -241,8 +241,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsFunction'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslFunction'); }); it('should return the called segment', async () => { @@ -254,8 +254,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsSegment'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslSegment'); }); it('should return the called segment (aliased)', async () => { @@ -268,8 +268,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsSegment'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslSegment'); }); it('should ignore nullability (callable attribute, normal call)', async () => { @@ -285,8 +285,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsCallableType'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslCallableType'); }); it('should ignore nullability (method, normal call)', async () => { @@ -302,8 +302,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsFunction'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslFunction'); }); it('should ignore nullability (callable attribute, null-safe call)', async () => { @@ -319,8 +319,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsCallableType'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslCallableType'); }); it('should ignore nullability (method, null-safe call)', async () => { @@ -336,8 +336,8 @@ describe('SafeDsNodeMapper', () => { } `; - const call = await getNodeOfType(services, code, isSdsAbstractCall); - expect(nodeMapper.callToCallable(call)?.$type).toBe('SdsFunction'); + const call = await getNodeOfType(services, code, isTslAbstractCall); + expect(nodeMapper.callToCallable(call)?.$type).toBe('TslFunction'); }); }); }); diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToParameterValue.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToParameterValue.test.ts index f5174ede..9667343b 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToParameterValue.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/callToParameterValue.test.ts @@ -1,11 +1,11 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; import { - isSdsModule, - SdsAbstractCall, - SdsFunction, - SdsParameter, - SdsPipeline, + isTslModule, + TslAbstractCall, + TslFunction, + TslParameter, + TslPipeline, } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices, getModuleMembers, getParameters } from '../../../../src/language/index.js'; import { Constant, IntConstant } from '../../../../src/language/partialEvaluation/model.js'; @@ -25,11 +25,11 @@ const code = ` unresolved(); } `; -const module = await getNodeOfType(services, code, isSdsModule); -const myFunction = getModuleMembers(module)[0] as SdsFunction; +const module = await getNodeOfType(services, code, isTslModule); +const myFunction = getModuleMembers(module)[0] as TslFunction; const p1 = getParameters(myFunction)[0]!; const p2 = getParameters(myFunction)[1]!; -const myPipeline = module?.members[1] as SdsPipeline; +const myPipeline = module?.members[1] as TslPipeline; const call1 = callGraphComputer.getAllContainedCalls(myPipeline)[0]!; const call2 = callGraphComputer.getAllContainedCalls(myPipeline)[1]!; const call3 = callGraphComputer.getAllContainedCalls(myPipeline)[2]!; @@ -154,12 +154,12 @@ interface CallToParameterValueTest { /** * The abstract call to test. */ - call: SdsAbstractCall | undefined; + call: TslAbstractCall | undefined; /** * The parameter to test. */ - parameter: SdsParameter | string | undefined; + parameter: TslParameter | string | undefined; /** * The expected result. diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parameterToReferences.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parameterToReferences.test.ts index 5b3b1845..87eda9b5 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parameterToReferences.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parameterToReferences.test.ts @@ -1,6 +1,6 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; -import { isSdsParameter } from '../../../../src/language/generated/ast.js'; +import { isTslParameter } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices } from '../../../../src/language/index.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -18,7 +18,7 @@ describe('SafeDsNodeMapper', () => { fun myFunction(p1: Int, p2: Int = p1) `; - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(nodeMapper.parameterToReferences(parameter).toArray()).toHaveLength(1); }); @@ -30,7 +30,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(nodeMapper.parameterToReferences(parameter).toArray()).toHaveLength(2); }); @@ -44,7 +44,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(nodeMapper.parameterToReferences(parameter).toArray()).toHaveLength(2); }); @@ -53,7 +53,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p1: Int, p2: Int = p1) {}; `; - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(nodeMapper.parameterToReferences(parameter).toArray()).toHaveLength(1); }); @@ -65,7 +65,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(nodeMapper.parameterToReferences(parameter).toArray()).toHaveLength(2); }); @@ -77,7 +77,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(nodeMapper.parameterToReferences(parameter).toArray()).toHaveLength(1); }); }); diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parametersToArguments.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parametersToArguments.test.ts index 234e7ea4..60289775 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parametersToArguments.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/parametersToArguments.test.ts @@ -1,11 +1,11 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; import { - isSdsModule, - SdsArgument, - SdsFunction, - SdsParameter, - SdsPipeline, + isTslModule, + TslArgument, + TslFunction, + TslParameter, + TslPipeline, } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices, getArguments, getModuleMembers, getParameters } from '../../../../src/language/index.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -21,10 +21,10 @@ const code = ` myFunction(1, 2, p1 = 3, p3 = 4); } `; -const module = await getNodeOfType(services, code, isSdsModule); -const myFunction = getModuleMembers(module)[0] as SdsFunction; +const module = await getNodeOfType(services, code, isTslModule); +const myFunction = getModuleMembers(module)[0] as TslFunction; const p1 = getParameters(myFunction)[0]!; -const myPipeline = module?.members[1] as SdsPipeline; +const myPipeline = module?.members[1] as TslPipeline; const call1 = callGraphComputer.getAllContainedCalls(myPipeline)[0]!; const arg1 = getArguments(call1)[0]!; const arg2 = getArguments(call1)[1]!; @@ -97,15 +97,15 @@ interface ParametersToArgumentsTest { /** * The parameter to test. */ - parameters: SdsParameter[]; + parameters: TslParameter[]; /** * The arguments to test. */ - args: SdsArgument[]; + args: TslArgument[]; /** * The expected result. */ - expectedResult: [SdsParameter, SdsArgument][]; + expectedResult: [TslParameter, TslArgument][]; } diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/placeholdersToReferences.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/placeholdersToReferences.test.ts index f7468827..d5667e35 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/placeholdersToReferences.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/placeholdersToReferences.test.ts @@ -1,6 +1,6 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; -import { isSdsPlaceholder } from '../../../../src/language/generated/ast.js'; +import { isTslPlaceholder } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices } from '../../../../src/language/index.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -21,7 +21,7 @@ describe('SafeDsNodeMapper', () => { } `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); expect(nodeMapper.placeholderToReferences(placeholder).toArray()).toHaveLength(1); }); @@ -35,7 +35,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); expect(nodeMapper.placeholderToReferences(placeholder).toArray()).toHaveLength(2); }); @@ -53,7 +53,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); expect(nodeMapper.placeholderToReferences(placeholder).toArray()).toHaveLength(2); }); @@ -67,7 +67,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); expect(nodeMapper.placeholderToReferences(placeholder).toArray()).toHaveLength(2); }); @@ -82,7 +82,7 @@ describe('SafeDsNodeMapper', () => { }; `; - const placeholder = await getNodeOfType(services, code, isSdsPlaceholder); + const placeholder = await getNodeOfType(services, code, isTslPlaceholder); expect(nodeMapper.placeholderToReferences(placeholder).toArray()).toHaveLength(1); }); }); diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/resultToYields.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/resultToYields.test.ts index ee3d29e1..6841084d 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/resultToYields.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/resultToYields.test.ts @@ -1,6 +1,6 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; -import { isSdsResult } from '../../../../src/language/generated/ast.js'; +import { isTslResult } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices } from '../../../../src/language/index.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -16,7 +16,7 @@ describe('SafeDsNodeMapper', () => { it('should return an empty list if result is not in a segment', async () => { const code = `fun myFunction() -> r1: Int`; - const result = await getNodeOfType(services, code, isSdsResult); + const result = await getNodeOfType(services, code, isTslResult); expect(nodeMapper.resultToYields(result).toArray()).toStrictEqual([]); }); @@ -28,7 +28,7 @@ describe('SafeDsNodeMapper', () => { } `; - const result = await getNodeOfType(services, code, isSdsResult); + const result = await getNodeOfType(services, code, isTslResult); expect(nodeMapper.resultToYields(result).toArray()).toHaveLength(2); }); @@ -41,7 +41,7 @@ describe('SafeDsNodeMapper', () => { } `; - const result = await getNodeOfType(services, code, isSdsResult); + const result = await getNodeOfType(services, code, isTslResult); expect(nodeMapper.resultToYields(result).toArray()).toHaveLength(1); }); }); diff --git a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/typeArgumentToTypeParameter.test.ts b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/typeArgumentToTypeParameter.test.ts index ea194e05..39929dad 100644 --- a/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/typeArgumentToTypeParameter.test.ts +++ b/packages/ttsl-lang/tests/language/helpers/safe-ds-node-mapper/typeArgumentToTypeParameter.test.ts @@ -1,6 +1,6 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; -import { isSdsNamedType, isSdsUnionType, SdsTypeArgument } from '../../../../src/language/generated/ast.js'; +import { isTslNamedType, isTslUnionType, TslTypeArgument } from '../../../../src/language/generated/ast.js'; import { getTypeArguments } from '../../../../src/language/helpers/nodeProperties.js'; import { createSafeDsServices } from '../../../../src/language/index.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -22,7 +22,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: Unresolved) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual([undefined]); }); @@ -34,7 +34,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: C) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual([undefined]); }); @@ -46,7 +46,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: C) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual(['T2', 'T3', 'T1']); }); @@ -60,7 +60,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: Unresolved) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual([undefined]); }); @@ -72,7 +72,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: C) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType, 0); + const namedType = await getNodeOfType(services, code, isTslNamedType, 0); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual(['T1', 'T2', 'T3']); }); @@ -84,7 +84,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: C) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual(['T2', undefined, undefined]); }); @@ -96,7 +96,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: C) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); const parameterNames = getTypeArguments(namedType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual(['T1', 'T2', undefined]); }); @@ -108,7 +108,7 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: union) {} `; - const unionType = await getNodeOfType(services, code, isSdsUnionType); + const unionType = await getNodeOfType(services, code, isTslUnionType); const parameterNames = getTypeArguments(unionType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual([undefined, undefined]); }); @@ -120,13 +120,13 @@ describe('SafeDsNodeMapper', () => { segment mySegment(p: C>) {} `; - const unionType = await getNodeOfType(services, code, isSdsUnionType); + const unionType = await getNodeOfType(services, code, isTslUnionType); const parameterNames = getTypeArguments(unionType.typeArgumentList).map(typeParameterNameOrNull); expect(parameterNames).toStrictEqual([undefined, undefined]); }); }); - const typeParameterNameOrNull = (node: SdsTypeArgument): string | undefined => { + const typeParameterNameOrNull = (node: TslTypeArgument): string | undefined => { const typeParameter = nodeMapper.typeArgumentToTypeParameter(node); return typeParameter?.name ?? undefined; }; diff --git a/packages/ttsl-lang/tests/language/lsp/safe-ds-inlay-hint-provider.test.ts b/packages/ttsl-lang/tests/language/lsp/safe-ds-inlay-hint-provider.test.ts index d159820f..f0ac8434 100644 --- a/packages/ttsl-lang/tests/language/lsp/safe-ds-inlay-hint-provider.test.ts +++ b/packages/ttsl-lang/tests/language/lsp/safe-ds-inlay-hint-provider.test.ts @@ -188,7 +188,7 @@ const getActualSimpleInlayHints = async (code: string): Promise { - const testChecks = findTestChecks(code, URI.file('file:///test.sdstest'), { failIfFewerRangesThanComments: true }); + const testChecks = findTestChecks(code, URI.file('file:///test.Tsltest'), { failIfFewerRangesThanComments: true }); if (testChecks.isErr) { throw new Error(testChecks.error.message); } diff --git a/packages/ttsl-lang/tests/language/lsp/safe-ds-rename-provider.test.ts b/packages/ttsl-lang/tests/language/lsp/safe-ds-rename-provider.test.ts index 4f24dcd8..27f69ee6 100644 --- a/packages/ttsl-lang/tests/language/lsp/safe-ds-rename-provider.test.ts +++ b/packages/ttsl-lang/tests/language/lsp/safe-ds-rename-provider.test.ts @@ -2,7 +2,7 @@ import { NodeFileSystem } from 'langium/node'; import { afterEach, describe, expect, it } from 'vitest'; import { createSafeDsServices, getModuleMembers } from '../../../src/language/index.js'; import { clearDocuments } from 'langium/test'; -import { SdsModule } from '../../../src/language/generated/ast.js'; +import { TslModule } from '../../../src/language/generated/ast.js'; import { URI } from 'langium'; import { TextDocument } from 'vscode-languageserver-textdocument'; @@ -13,8 +13,8 @@ const langiumDocumentFactory = services.shared.workspace.LangiumDocumentFactory; const nameProvider = services.references.NameProvider; const renameProvider = services.lsp.RenameProvider!; -const resourceUri = 'file:///resource.sdsstub'; -const mainUri = 'file:///main.sdspipe'; +const resourceUri = 'file:///resource.Tslstub'; +const mainUri = 'file:///main.Tslpipe'; describe('SafeDsRenameProvider', async () => { const testCases: RenameProviderTest[] = [ @@ -267,7 +267,7 @@ describe('SafeDsRenameProvider', async () => { // Get the element to rename const firstDocument = documents[0]!; - const firstModule = firstDocument.parseResult.value as SdsModule; + const firstModule = firstDocument.parseResult.value as TslModule; const firstMember = getModuleMembers(firstModule)[0]; if (!firstMember) { throw new Error('No member to rename.'); diff --git a/packages/ttsl-lang/tests/language/partialEvaluation/canBeValueOfConstantParameter.test.ts b/packages/ttsl-lang/tests/language/partialEvaluation/canBeValueOfConstantParameter.test.ts index 677325e9..91890def 100644 --- a/packages/ttsl-lang/tests/language/partialEvaluation/canBeValueOfConstantParameter.test.ts +++ b/packages/ttsl-lang/tests/language/partialEvaluation/canBeValueOfConstantParameter.test.ts @@ -1,6 +1,6 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; -import { isSdsExpression } from '../../../src/language/generated/ast.js'; +import { isTslExpression } from '../../../src/language/generated/ast.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; import { createSafeDsServices } from '../../../src/language/index.js'; @@ -161,7 +161,7 @@ describe('SafeDsTypeChecker', async () => { } `; - const expression = await getNodeOfType(services, codeWithContext, isSdsExpression); + const expression = await getNodeOfType(services, codeWithContext, isTslExpression); expect(partialEvaluator.canBeValueOfConstantParameter(expression)).toBe(expected); }); }); diff --git a/packages/ttsl-lang/tests/language/partialEvaluation/model.test.ts b/packages/ttsl-lang/tests/language/partialEvaluation/model.test.ts index 0dcd0630..9ed42385 100644 --- a/packages/ttsl-lang/tests/language/partialEvaluation/model.test.ts +++ b/packages/ttsl-lang/tests/language/partialEvaluation/model.test.ts @@ -1,12 +1,12 @@ import { EmptyFileSystem } from 'langium'; import { describe, expect, it } from 'vitest'; import { - isSdsBlockLambda, - isSdsEnumVariant, - isSdsExpressionLambda, - isSdsResult, - isSdsSegment, - type SdsBlockLambdaResult, + isTslBlockLambda, + isTslEnumVariant, + isTslExpressionLambda, + isTslResult, + isTslSegment, + type TslBlockLambdaResult, } from '../../../src/language/generated/ast.js'; import { createSafeDsServices, getAbstractResults, getParameters } from '../../../src/language/index.js'; import { @@ -46,21 +46,21 @@ segment mySegment() -> (result1: Int, result2: Int) { segment mySegment2() {} `; -const enumVariantWithoutParameters = await getNodeOfType(services, code, isSdsEnumVariant, 0); -const enumVariantWithParameters = await getNodeOfType(services, code, isSdsEnumVariant, 1); +const enumVariantWithoutParameters = await getNodeOfType(services, code, isTslEnumVariant, 0); +const enumVariantWithParameters = await getNodeOfType(services, code, isTslEnumVariant, 1); const enumVariantParameter = getParameters(enumVariantWithParameters)[0]!; -const result1 = await getNodeOfType(services, code, isSdsResult, 0); -const result2 = await getNodeOfType(services, code, isSdsResult, 0); +const result1 = await getNodeOfType(services, code, isTslResult, 0); +const result2 = await getNodeOfType(services, code, isTslResult, 0); -const expressionLambda1 = await getNodeOfType(services, code, isSdsExpressionLambda, 0); -const expressionLambda2 = await getNodeOfType(services, code, isSdsExpressionLambda, 1); +const expressionLambda1 = await getNodeOfType(services, code, isTslExpressionLambda, 0); +const expressionLambda2 = await getNodeOfType(services, code, isTslExpressionLambda, 1); -const blockLambda1 = await getNodeOfType(services, code, isSdsBlockLambda, 0); -const blockLambdaResult1 = getAbstractResults(blockLambda1)[0]! as SdsBlockLambdaResult; +const blockLambda1 = await getNodeOfType(services, code, isTslBlockLambda, 0); +const blockLambdaResult1 = getAbstractResults(blockLambda1)[0]! as TslBlockLambdaResult; -const segment1 = await getNodeOfType(services, code, isSdsSegment, 0); -const segment2 = await getNodeOfType(services, code, isSdsSegment, 1); +const segment1 = await getNodeOfType(services, code, isTslSegment, 0); +const segment2 = await getNodeOfType(services, code, isTslSegment, 1); describe('partial evaluation model', async () => { const equalsTests: EqualsTest[] = [ diff --git a/packages/ttsl-lang/tests/language/purity/model.test.ts b/packages/ttsl-lang/tests/language/purity/model.test.ts index 157e8fef..5bb9a4d5 100644 --- a/packages/ttsl-lang/tests/language/purity/model.test.ts +++ b/packages/ttsl-lang/tests/language/purity/model.test.ts @@ -1,6 +1,6 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; -import { isSdsParameter } from '../../../src/language/generated/ast.js'; +import { isTslParameter } from '../../../src/language/generated/ast.js'; import { EndlessRecursion, FileRead, @@ -15,7 +15,7 @@ import { type EqualsTest, ToStringTest } from '../../helpers/testDescription.js' import { createSafeDsServices } from '../../../src/language/index.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; -const parameter = await getNodeOfType(services, 'fun f(p: Int)', isSdsParameter); +const parameter = await getNodeOfType(services, 'fun f(p: Int)', isTslParameter); describe('purity model', async () => { const equalsTests: EqualsTest[] = [ diff --git a/packages/ttsl-lang/tests/language/purity/safe-ds-purity-computer.test.ts b/packages/ttsl-lang/tests/language/purity/safe-ds-purity-computer.test.ts index cfd7b104..4915df26 100644 --- a/packages/ttsl-lang/tests/language/purity/safe-ds-purity-computer.test.ts +++ b/packages/ttsl-lang/tests/language/purity/safe-ds-purity-computer.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import { NodeFileSystem } from 'langium/node'; -import { isSdsCall, isSdsCallable, isSdsExpression, isSdsParameter } from '../../../src/language/generated/ast.js'; +import { isTslCall, isTslCallable, isTslExpression, isTslParameter } from '../../../src/language/generated/ast.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; import { createSafeDsServices } from '../../../src/language/index.js'; @@ -83,7 +83,7 @@ describe('SafeDsPurityComputer', async () => { expected: true, }, ])('should return whether a callable is pure ($testName)', async ({ code, expected }) => { - const callable = await getNodeOfType(services, code, isSdsCallable); + const callable = await getNodeOfType(services, code, isTslCallable); expect(purityComputer.isPureCallable(callable)).toBe(expected); }); }); @@ -189,7 +189,7 @@ describe('SafeDsPurityComputer', async () => { expected: true, }, ])('should return whether an expression is pure ($testName)', async ({ code, expected }) => { - const expression = await getNodeOfType(services, code, isSdsExpression); + const expression = await getNodeOfType(services, code, isTslExpression); expect(purityComputer.isPureExpression(expression)).toBe(expected); }); }); @@ -286,7 +286,7 @@ describe('SafeDsPurityComputer', async () => { expected: false, }, ])('should return whether a parameter is pure ($testName)', async ({ code, expected }) => { - const parameter = await getNodeOfType(services, code, isSdsParameter); + const parameter = await getNodeOfType(services, code, isTslParameter); expect(purityComputer.isPureParameter(parameter)).toBe(expected); }); }); @@ -376,7 +376,7 @@ describe('SafeDsPurityComputer', async () => { expected: false, }, ])('should return whether a callable has side effects ($testName)', async ({ code, expected }) => { - const callable = await getNodeOfType(services, code, isSdsCallable); + const callable = await getNodeOfType(services, code, isTslCallable); expect(purityComputer.callableHasSideEffects(callable)).toBe(expected); }); }); @@ -496,7 +496,7 @@ describe('SafeDsPurityComputer', async () => { expected: false, }, ])('should return whether an expression has side effects ($testName)', async ({ code, expected }) => { - const expression = await getNodeOfType(services, code, isSdsExpression); + const expression = await getNodeOfType(services, code, isTslExpression); expect(purityComputer.expressionHasSideEffects(expression)).toBe(expected); }); }); @@ -636,7 +636,7 @@ describe('SafeDsPurityComputer', async () => { expected: [], }, ])('should return the impurity reasons of a callable ($testName)', async ({ code, expected }) => { - const callable = await getNodeOfType(services, code, isSdsCallable); + const callable = await getNodeOfType(services, code, isTslCallable); const actual = purityComputer.getImpurityReasonsForCallable(callable).map((reason) => reason.toString()); expect(actual).toStrictEqual(expected); }); @@ -757,7 +757,7 @@ describe('SafeDsPurityComputer', async () => { expected: [], }, ])('should return the impurity reasons of an expression ($testName)', async ({ code, expected }) => { - const expression = await getNodeOfType(services, code, isSdsExpression); + const expression = await getNodeOfType(services, code, isTslExpression); const actual = purityComputer .getImpurityReasonsForExpression(expression) .map((reason) => reason.toString()); @@ -786,7 +786,7 @@ describe('SafeDsPurityComputer', async () => { g: Any = f() ) `, - isSdsCall, + isTslCall, ); expect(() => purityComputer.getImpurityReasonsForExpression(call)).not.toThrow(); diff --git a/packages/ttsl-lang/tests/language/runner/safe-ds-runner.test.ts b/packages/ttsl-lang/tests/language/runner/safe-ds-runner.test.ts index b0ff26f2..85bff951 100644 --- a/packages/ttsl-lang/tests/language/runner/safe-ds-runner.test.ts +++ b/packages/ttsl-lang/tests/language/runner/safe-ds-runner.test.ts @@ -31,18 +31,18 @@ describe('SafeDsRunner', async () => { }); }); describe('getMainModuleName', async () => { - it('sdspipe', async () => { + it('Tslpipe', async () => { const document = services.shared.workspace.LangiumDocumentFactory.fromString( '', - URI.file('/a-b c.sdspipe'), + URI.file('/a-b c.Tslpipe'), ); const mainModuleName = runner.getMainModuleName(document); expect(mainModuleName).toBe('a_b_c'); }); - it('sdstest', async () => { + it('Tsltest', async () => { const document = services.shared.workspace.LangiumDocumentFactory.fromString( '', - URI.file('/a-b c.sdstest'), + URI.file('/a-b c.Tsltest'), ); const mainModuleName = runner.getMainModuleName(document); expect(mainModuleName).toBe('a_b_c'); @@ -50,17 +50,17 @@ describe('SafeDsRunner', async () => { it('other', async () => { const document = services.shared.workspace.LangiumDocumentFactory.fromString( '', - URI.file('/a-b c.sdstest2'), + URI.file('/a-b c.Tsltest2'), ); const mainModuleName = runner.getMainModuleName(document); - expect(mainModuleName).toBe('a_b_c_sdstest2'); + expect(mainModuleName).toBe('a_b_c_Tsltest2'); }); }); describe('generateCodeForRunner', async () => { it('generateCodeForRunner', async () => { const document = services.shared.workspace.LangiumDocumentFactory.fromString( 'package a\n\npipeline mainpipeline {}', - URI.file('/b.sdstest'), + URI.file('/b.Tsltest'), ); const [programCodeMap] = runner.generateCodeForRunner(document, undefined); expect(JSON.stringify(programCodeMap).replaceAll('\\r\\n', '\\n')).toBe( diff --git a/packages/ttsl-lang/tests/language/scoping/scoping.test.ts b/packages/ttsl-lang/tests/language/scoping/scoping.test.ts index 8abe06e5..3b945e75 100644 --- a/packages/ttsl-lang/tests/language/scoping/scoping.test.ts +++ b/packages/ttsl-lang/tests/language/scoping/scoping.test.ts @@ -9,7 +9,7 @@ import { isLocationEqual, locationToString } from '../../../src/helpers/location import { loadDocuments } from '../../helpers/testResources.js'; import { createScopingTests, ExpectedReference } from './creator.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; -import { isSdsAnnotationCall, isSdsNamedType, isSdsReference } from '../../../src/language/generated/ast.js'; +import { isTslAnnotationCall, isTslNamedType, isTslReference } from '../../../src/language/generated/ast.js'; const services = (await createSafeDsServices(NodeFileSystem)).SafeDs; const builtinAnnotations = services.builtins.Annotations; @@ -82,7 +82,7 @@ describe('scoping', async () => { @PythonName(name: String) segment mySegment() {} `; - const annotationCall = await getNodeOfType(services, code, isSdsAnnotationCall); + const annotationCall = await getNodeOfType(services, code, isTslAnnotationCall); expectSameDocument(annotationCall.annotation?.ref, builtinAnnotations.PythonName); }); @@ -92,7 +92,7 @@ describe('scoping', async () => { segment mySegment(p: Any) {} `; - const namedType = await getNodeOfType(services, code, isSdsNamedType); + const namedType = await getNodeOfType(services, code, isTslNamedType); expectSameDocument(namedType.declaration?.ref, builtinClasses.Any); }); @@ -103,7 +103,7 @@ describe('scoping', async () => { @Target([AnnotationTarget.Annotation]) annotation MyAnnotation `; - const reference = await getNodeOfType(services, code, isSdsReference); + const reference = await getNodeOfType(services, code, isTslReference); expectSameDocument(reference.target?.ref, builtinEnums.AnnotationTarget); }); diff --git a/packages/ttsl-lang/tests/language/typing/model.test.ts b/packages/ttsl-lang/tests/language/typing/model.test.ts index e9be2a0a..da79ed23 100644 --- a/packages/ttsl-lang/tests/language/typing/model.test.ts +++ b/packages/ttsl-lang/tests/language/typing/model.test.ts @@ -1,6 +1,6 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; -import { isSdsClass, isSdsEnum, isSdsEnumVariant, isSdsFunction } from '../../../src/language/generated/ast.js'; +import { isTslClass, isTslEnum, isTslEnumVariant, isTslFunction } from '../../../src/language/generated/ast.js'; import { createSafeDsServices, getParameters, getResults, getTypeParameters } from '../../../src/language/index.js'; import { BooleanConstant, IntConstant, NullConstant } from '../../../src/language/partialEvaluation/model.js'; import { @@ -34,19 +34,19 @@ const code = ` } enum MyEnum2 {} `; -const callable1 = await getNodeOfType(services, code, isSdsFunction, 0); +const callable1 = await getNodeOfType(services, code, isTslFunction, 0); const parameter1 = getParameters(callable1)[0]!; const parameter2 = getParameters(callable1)[1]!; const result = getResults(callable1.resultList)[0]!; -const callable2 = await getNodeOfType(services, code, isSdsFunction, 1); -const class1 = await getNodeOfType(services, code, isSdsClass, 0); -const class2 = await getNodeOfType(services, code, isSdsClass, 1); +const callable2 = await getNodeOfType(services, code, isTslFunction, 1); +const class1 = await getNodeOfType(services, code, isTslClass, 0); +const class2 = await getNodeOfType(services, code, isTslClass, 1); const typeParameter1 = getTypeParameters(class2)[0]!; const typeParameter2 = getTypeParameters(class2)[1]!; -const enum1 = await getNodeOfType(services, code, isSdsEnum, 0); -const enum2 = await getNodeOfType(services, code, isSdsEnum, 1); -const enumVariant1 = await getNodeOfType(services, code, isSdsEnumVariant, 0); -const enumVariant2 = await getNodeOfType(services, code, isSdsEnumVariant, 1); +const enum1 = await getNodeOfType(services, code, isTslEnum, 0); +const enum2 = await getNodeOfType(services, code, isTslEnum, 1); +const enumVariant1 = await getNodeOfType(services, code, isTslEnumVariant, 0); +const enumVariant2 = await getNodeOfType(services, code, isTslEnumVariant, 1); describe('type model', async () => { const equalsTests: EqualsTest[] = [ diff --git a/packages/ttsl-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts b/packages/ttsl-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts index 76665955..43782d01 100644 --- a/packages/ttsl-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts +++ b/packages/ttsl-lang/tests/language/typing/safe-ds-class-hierarchy.test.ts @@ -1,11 +1,11 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; import { - isSdsAttribute, - isSdsClass, - isSdsFunction, - SdsClass, - type SdsClassMember, + isTslAttribute, + isTslClass, + isTslFunction, + TslClass, + type TslClassMember, } from '../../../src/language/generated/ast.js'; import { createSafeDsServices, getClassMembers } from '../../../src/language/index.js'; import { getNodeOfType } from '../../helpers/nodeFinder.js'; @@ -61,7 +61,7 @@ describe('SafeDsClassHierarchy', async () => { }); describe('streamProperSuperclasses', () => { - const properSuperclassesNames = (node: SdsClass | undefined) => + const properSuperclassesNames = (node: TslClass | undefined) => classHierarchy .streamProperSuperclasses(node) .map((clazz) => clazz.name) @@ -123,13 +123,13 @@ describe('SafeDsClassHierarchy', async () => { ]; it.each(testCases)('$testName', async ({ code, expected }) => { - const firstClass = await getNodeOfType(services, code, isSdsClass); + const firstClass = await getNodeOfType(services, code, isTslClass); expect(properSuperclassesNames(firstClass)).toStrictEqual(expected); }); }); describe('streamSuperclassMembers', () => { - const superclassMemberNames = (node: SdsClass | undefined) => + const superclassMemberNames = (node: TslClass | undefined) => classHierarchy .streamSuperclassMembers(node) .map((member) => member.name) @@ -192,7 +192,7 @@ describe('SafeDsClassHierarchy', async () => { ]; it.each(testCases)('$testName', async ({ code, index, expected }) => { - const firstClass = await getNodeOfType(services, code, isSdsClass, index); + const firstClass = await getNodeOfType(services, code, isTslClass, index); const anyMembers = getClassMembers(builtinClasses.Any).map((member) => member.name); expect(superclassMemberNames(firstClass)).toStrictEqual(expected.concat(anyMembers)); }); @@ -207,7 +207,7 @@ describe('SafeDsClassHierarchy', async () => { code: ` fun f() `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 0, expectedResultPredicate: isUndefined, }, @@ -218,7 +218,7 @@ describe('SafeDsClassHierarchy', async () => { attr a: Int } `, - memberPredicate: isSdsAttribute, + memberPredicate: isTslAttribute, index: 0, expectedResultPredicate: isUndefined, }, @@ -229,7 +229,7 @@ describe('SafeDsClassHierarchy', async () => { fun f() } `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 0, expectedResultPredicate: isUndefined, }, @@ -244,7 +244,7 @@ describe('SafeDsClassHierarchy', async () => { attr b: Int } `, - memberPredicate: isSdsAttribute, + memberPredicate: isTslAttribute, index: 0, expectedResultPredicate: isUndefined, }, @@ -259,7 +259,7 @@ describe('SafeDsClassHierarchy', async () => { fun g() } `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 0, expectedResultPredicate: isUndefined, }, @@ -274,7 +274,7 @@ describe('SafeDsClassHierarchy', async () => { static attr a: Int } `, - memberPredicate: isSdsAttribute, + memberPredicate: isTslAttribute, index: 0, expectedResultPredicate: isUndefined, }, @@ -289,7 +289,7 @@ describe('SafeDsClassHierarchy', async () => { static fun f() } `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 0, expectedResultPredicate: isUndefined, }, @@ -304,7 +304,7 @@ describe('SafeDsClassHierarchy', async () => { static attr a: Int } `, - memberPredicate: isSdsAttribute, + memberPredicate: isTslAttribute, index: 0, expectedResultPredicate: isUndefined, }, @@ -319,7 +319,7 @@ describe('SafeDsClassHierarchy', async () => { static fun f() } `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 0, expectedResultPredicate: isUndefined, }, @@ -334,9 +334,9 @@ describe('SafeDsClassHierarchy', async () => { attr a: Int } `, - memberPredicate: isSdsAttribute, + memberPredicate: isTslAttribute, index: 0, - expectedResultPredicate: isSdsAttribute, + expectedResultPredicate: isTslAttribute, }, { testName: 'method, superclass, match', @@ -349,9 +349,9 @@ describe('SafeDsClassHierarchy', async () => { fun f() } `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 0, - expectedResultPredicate: isSdsFunction, + expectedResultPredicate: isTslFunction, }, { testName: 'attribute, previous member with same name', @@ -365,7 +365,7 @@ describe('SafeDsClassHierarchy', async () => { attr a: Int } `, - memberPredicate: isSdsAttribute, + memberPredicate: isTslAttribute, index: 1, expectedResultPredicate: isUndefined, }, @@ -381,7 +381,7 @@ describe('SafeDsClassHierarchy', async () => { fun f() } `, - memberPredicate: isSdsFunction, + memberPredicate: isTslFunction, index: 1, expectedResultPredicate: isUndefined, }, @@ -418,7 +418,7 @@ interface GetOverriddenMemberTest { /** * A predicate that matches the member that should be used as input. */ - memberPredicate: (value: unknown) => value is SdsClassMember; + memberPredicate: (value: unknown) => value is TslClassMember; /** * The index of the member to use as input. diff --git a/packages/ttsl-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts b/packages/ttsl-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts index b07583d0..f6bd4d3c 100644 --- a/packages/ttsl-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts +++ b/packages/ttsl-lang/tests/language/typing/type checker/canBeTypeOfConstantParameter.test.ts @@ -1,6 +1,6 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; -import { isSdsClass, isSdsEnum, isSdsModule } from '../../../../src/language/generated/ast.js'; +import { isTslClass, isTslEnum, isTslModule } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices, getEnumVariants, getModuleMembers } from '../../../../src/language/index.js'; import { ClassType, EnumType, EnumVariantType, Type, UnknownType } from '../../../../src/language/typing/model.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -24,11 +24,11 @@ const code = ` Variant2(param: Int) } `; -const module = await getNodeOfType(services, code, isSdsModule); -const classes = getModuleMembers(module).filter(isSdsClass); +const module = await getNodeOfType(services, code, isTslModule); +const classes = getModuleMembers(module).filter(isTslClass); const myClassType = typeComputer.computeType(classes[0]) as ClassType; -const enums = getModuleMembers(module).filter(isSdsEnum); +const enums = getModuleMembers(module).filter(isTslEnum); const constantEnum = enums[0]; const normalEnum = enums[1]; const constantEnumType = typeComputer.computeType(constantEnum) as EnumType; diff --git a/packages/ttsl-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts b/packages/ttsl-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts index 247a85fc..340c93b3 100644 --- a/packages/ttsl-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts +++ b/packages/ttsl-lang/tests/language/typing/type checker/isSubOrSupertypeOf.test.ts @@ -1,13 +1,13 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; import { - isSdsAttribute, - isSdsClass, - isSdsEnum, - isSdsEnumVariant, - isSdsFunction, - isSdsModule, - SdsDeclaration, + isTslAttribute, + isTslClass, + isTslEnum, + isTslEnumVariant, + isTslFunction, + isTslModule, + TslDeclaration, } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices, @@ -67,8 +67,8 @@ const basic = async (): Promise => { } enum Enum2 `; - const module = await getNodeOfType(services, code, isSdsModule); - const functions = getModuleMembers(module).filter(isSdsFunction); + const module = await getNodeOfType(services, code, isTslModule); + const functions = getModuleMembers(module).filter(isTslFunction); const callableType1 = typeComputer.computeType(functions[0]); const callableType2 = typeComputer.computeType(functions[1]); const callableType3 = typeComputer.computeType(functions[2]); @@ -82,7 +82,7 @@ const basic = async (): Promise => { const callableType11 = typeComputer.computeType(functions[10]); const callableType12 = typeComputer.computeType(functions[11]); - const classes = getModuleMembers(module).filter(isSdsClass); + const classes = getModuleMembers(module).filter(isTslClass); const class1 = classes[0]; const class2 = classes[1]; const class3 = classes[2]; @@ -90,13 +90,13 @@ const basic = async (): Promise => { const classType2 = typeComputer.computeType(class2) as ClassType; const classType3 = typeComputer.computeType(class3) as ClassType; - const enums = getModuleMembers(module).filter(isSdsEnum); + const enums = getModuleMembers(module).filter(isTslEnum); const enum1 = enums[0]; const enum2 = enums[1]; const enumType1 = typeComputer.computeType(enum1) as EnumType; const enumType2 = typeComputer.computeType(enum2) as EnumType; - const enumVariants = AstUtils.streamAllContents(module).filter(isSdsEnumVariant).toArray(); + const enumVariants = AstUtils.streamAllContents(module).filter(isTslEnumVariant).toArray(); const enumVariant1 = enumVariants[0]; const enumVariant2 = enumVariants[1]; const enumVariantType1 = typeComputer.computeType(enumVariant1) as EnumVariantType; @@ -754,9 +754,9 @@ const classTypesWithTypeParameters = async (): Promise class SubclassFixedCovariant sub BaseClassCovariant class SubclassFixedContravariant sub BaseClassContravariant `; - const module = await getNodeOfType(services, code, isSdsModule); - const classes = getModuleMembers(module).filter(isSdsClass); - const attributes = getClassMembers(classes[0]).filter(isSdsAttribute); + const module = await getNodeOfType(services, code, isTslModule); + const classes = getModuleMembers(module).filter(isTslClass); + const attributes = getClassMembers(classes[0]).filter(isTslAttribute); const computeTypeOfAttributeWithName = computeTypeOfDeclarationWithName(attributes); @@ -1023,8 +1023,8 @@ const typeParameterTypes = async (): Promise => { Unresolved sub Unknown, > `; - const module = await getNodeOfType(services, code, isSdsModule); - const classes = getModuleMembers(module).filter(isSdsClass); + const module = await getNodeOfType(services, code, isTslModule); + const classes = getModuleMembers(module).filter(isTslClass); const typeParameters = getTypeParameters(classes[0]); const computeTypeOfTypeParameterWithName = computeTypeOfDeclarationWithName(typeParameters); @@ -1228,7 +1228,7 @@ describe('SafeDsTypeChecker', async () => { }); }); -const computeTypeOfDeclarationWithName = (declarations: T[]) => { +const computeTypeOfDeclarationWithName = (declarations: T[]) => { return (name: string): Type => { const result = declarations.find((declaration) => declaration.name === name); return typeComputer.computeType(result); diff --git a/packages/ttsl-lang/tests/language/typing/type computer/computeUpperBound.test.ts b/packages/ttsl-lang/tests/language/typing/type computer/computeUpperBound.test.ts index 916e1826..d4cd8235 100644 --- a/packages/ttsl-lang/tests/language/typing/type computer/computeUpperBound.test.ts +++ b/packages/ttsl-lang/tests/language/typing/type computer/computeUpperBound.test.ts @@ -1,6 +1,6 @@ import { NodeFileSystem } from 'langium/node'; import { describe, it } from 'vitest'; -import { isSdsClass, isSdsModule, SdsTypeParameter } from '../../../../src/language/generated/ast.js'; +import { isTslClass, isTslModule, TslTypeParameter } from '../../../../src/language/generated/ast.js'; import { createSafeDsServices, getModuleMembers, getTypeParameters } from '../../../../src/language/index.js'; import { Type, UnknownType } from '../../../../src/language/typing/model.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; @@ -19,9 +19,9 @@ const code = ` UnresolvedBounds sub unknown, > `; -const module = await getNodeOfType(services, code, isSdsModule); +const module = await getNodeOfType(services, code, isTslModule); -const classes = getModuleMembers(module).filter(isSdsClass); +const classes = getModuleMembers(module).filter(isTslClass); const typeParameters = getTypeParameters(classes[0]); const unbounded = typeParameters[0]!; @@ -67,7 +67,7 @@ interface ComputeUpperBoundTest { /** * The type parameter to get the bound for. */ - typeParameter: SdsTypeParameter; + typeParameter: TslTypeParameter; /** * The expected bound diff --git a/packages/ttsl-lang/tests/language/typing/type computer/streamSupertypes.test.ts b/packages/ttsl-lang/tests/language/typing/type computer/streamSupertypes.test.ts index 8aab8e68..603a3eb4 100644 --- a/packages/ttsl-lang/tests/language/typing/type computer/streamSupertypes.test.ts +++ b/packages/ttsl-lang/tests/language/typing/type computer/streamSupertypes.test.ts @@ -1,7 +1,7 @@ import { NodeFileSystem } from 'langium/node'; import { describe, expect, it } from 'vitest'; import { ClassType } from '../../../../src/language/typing/model.js'; -import { isSdsAttribute } from '../../../../src/language/generated/ast.js'; +import { isTslAttribute } from '../../../../src/language/generated/ast.js'; import { getNodeOfType } from '../../../helpers/nodeFinder.js'; import { AssertionError } from 'assert'; import { createSafeDsServices } from '../../../../src/language/index.js'; @@ -132,7 +132,7 @@ describe('streamProperSupertypes', async () => { ]; it.each(testCases)('$testName', async ({ code, expected }) => { - const firstAttribute = await getNodeOfType(services, code, isSdsAttribute); + const firstAttribute = await getNodeOfType(services, code, isTslAttribute); const type = typeComputer.computeType(firstAttribute); if (!(type instanceof ClassType)) { throw new AssertionError({ message: 'Expected type to be an instance of ClassType.', actual: type }); diff --git a/packages/ttsl-lang/tests/language/workspace/safe-ds-package-manager.test.ts b/packages/ttsl-lang/tests/language/workspace/safe-ds-package-manager.test.ts index 0200b35b..5668fe61 100644 --- a/packages/ttsl-lang/tests/language/workspace/safe-ds-package-manager.test.ts +++ b/packages/ttsl-lang/tests/language/workspace/safe-ds-package-manager.test.ts @@ -76,7 +76,7 @@ describe('SafeDsPackageManager', () => { }); it('should filter by node type if specified', () => { - const result = packageManager.getDeclarationsInPackage('myPackage1', { nodeType: 'SdsEnum' }); + const result = packageManager.getDeclarationsInPackage('myPackage1', { nodeType: 'TslEnum' }); expect(result.map((desc) => desc.name)).toStrictEqual(['Enum1']); }); @@ -103,7 +103,7 @@ describe('SafeDsPackageManager', () => { }); it('should filter by node type if specified', () => { - const result = packageManager.getDeclarationsInPackageOrSubpackage('myPackage1', { nodeType: 'SdsEnum' }); + const result = packageManager.getDeclarationsInPackageOrSubpackage('myPackage1', { nodeType: 'TslEnum' }); expect(result.map((desc) => desc.name)).toStrictEqual(['Enum1', 'Enum2']); }); diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/empty pipeline/generated/tests/generator/emptyPipeline/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/empty pipeline/generated/tests/generator/emptyPipeline/gen_input.py.map index 0d59bc04..ff83d01e 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/empty pipeline/generated/tests/generator/emptyPipeline/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/empty pipeline/generated/tests/generator/emptyPipeline/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test"],"mappings":"AAAA;;AAEA,IAASA,IAAI;IAAC,IAAE","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test"],"mappings":"AAAA;;AAEA,IAASA,IAAI;IAAC,IAAE","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/empty segment/generated/tests/generator/emptySegment/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/empty segment/generated/tests/generator/emptySegment/gen_input.py.map index 9f57b9aa..6de88b5a 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/empty segment/generated/tests/generator/emptySegment/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/empty segment/generated/tests/generator/emptySegment/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test"],"mappings":"AAAA;;AAEA,IAAQA,IAAI;IAAG,IAAE","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test"],"mappings":"AAAA;;AAEA,IAAQA,IAAI;IAAG,IAAE","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/parameter with python name/generated/tests/generator/parameterWithPythonName/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/parameter with python name/generated/tests/generator/parameterWithPythonName/gen_input.py.map index bbe73b1b..84eca513 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/parameter with python name/generated/tests/generator/parameterWithPythonName/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/parameter with python name/generated/tests/generator/parameterWithPythonName/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","param1","param2","param3","f1","a","b","c","f2"],"mappings":"AAAA;;AAKA,IAAQA,IAAI,CAACC,MAAM,EAA8BC,OAAM,EAA8BC,OAAM,CAAQ,CAAC;IAChGC,EAAE,CAAC,OAACC,CAAC,EAAOC,CAAC,EAAOC,CAAC,CAAQ,CAAC,EAAK,CAAC;IACjC,yBAACF,CAAC,EAAOC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAAE,IAAE;IAAlCC,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","param1","param2","param3","f1","a","b","c","f2"],"mappings":"AAAA;;AAKA,IAAQA,IAAI,CAACC,MAAM,EAA8BC,OAAM,EAA8BC,OAAM,CAAQ,CAAC;IAChGC,EAAE,CAAC,OAACC,CAAC,EAAOC,CAAC,EAAOC,CAAC,CAAQ,CAAC,EAAK,CAAC;IACjC,yBAACF,CAAC,EAAOC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAAE,IAAE;IAAlCC,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/pipeline with python name/generated/tests/generator/pipelineWithPythonName/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/pipeline with python name/generated/tests/generator/pipelineWithPythonName/gen_input.py.map index 236d7c4c..d9a1727d 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/pipeline with python name/generated/tests/generator/pipelineWithPythonName/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/pipeline with python name/generated/tests/generator/pipelineWithPythonName/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testpipeline","f"],"mappings":"AAAA;;AAKA,IAASA,aAAY;IACjBC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testpipeline","f"],"mappings":"AAAA;;AAKA,IAASA,aAAY;IACjBC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/segment with python name/generated/tests/generator/segmentWithPythonName/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/segment with python name/generated/tests/generator/segmentWithPythonName/gen_input.py.map index 2ab4bca4..28ef234b 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/segment with python name/generated/tests/generator/segmentWithPythonName/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/segment with python name/generated/tests/generator/segmentWithPythonName/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testsegment","f"],"mappings":"AAAA;;AAKA,IAAQA,YAAW;IACfC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testsegment","f"],"mappings":"AAAA;;AAKA,IAAQA,YAAW;IACfC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/two pipelines/generated/tests/generator/twoPipelines/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/two pipelines/generated/tests/generator/twoPipelines/gen_input.py.map index 8578f8a7..8857fa71 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/two pipelines/generated/tests/generator/twoPipelines/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/two pipelines/generated/tests/generator/twoPipelines/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test1","f","test2"],"mappings":"AAAA;;AAIA,IAASA,KAAK;IACVC,CAAC;;AAGL,IAASC,KAAK;IACVD,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test1","f","test2"],"mappings":"AAAA;;AAIA,IAASA,KAAK;IACVC,CAAC;;AAGL,IAASC,KAAK;IACVD,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/declarations/two segments/generated/tests/generator/twoSegments/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/declarations/two segments/generated/tests/generator/twoSegments/gen_input.py.map index a7053ee9..3e9d8b94 100644 --- a/packages/ttsl-lang/tests/resources/generation/declarations/two segments/generated/tests/generator/twoSegments/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/declarations/two segments/generated/tests/generator/twoSegments/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test1","a","b","f","test2","c"],"mappings":"AAAA;;AAIA,IAAQA,KAAK,CAACC,CAAC,EAAOC,CAAC,CAAQ,CAAC;IAC5BC,CAAC;;AAGL,IAAQC,KAAK,CAACH,CAAC,EAAOI,CAAC;IACnBF,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test1","a","b","f","test2","c"],"mappings":"AAAA;;AAIA,IAAQA,KAAK,CAACC,CAAC,EAAOC,CAAC,CAAQ,CAAC;IAC5BC,CAAC;;AAGL,IAAQC,KAAK,CAACH,CAAC,EAAOI,CAAC;IACnBF,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/block lambda result/generated/tests/generator/blockLambdaResult/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/block lambda result/generated/tests/generator/blockLambdaResult/gen_input.py.map index 12c2af08..311a2a0f 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/block lambda result/generated/tests/generator/blockLambdaResult/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/block lambda result/generated/tests/generator/blockLambdaResult/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["f1","l","h","f2","e1","d1","test","a","b","d","g","e"],"mappings":"AAAA;;AAMA,IAAQA,EAAE,CAACC,CAAC;IACRC,CAAC,CAACD,CAAC,CAAC,CAAC,EAAE,CAAC;;AAGZ,IAAQE,EAAE,CAACF,CAAC;IACRC,CAAC,CAACD,CAAC,CAAC,CAAC,EAAE,CAAC,EAAEG,CAAE;IACZF,CAAC,CAACD,CAAC,CAAC,CAAC,EAAE,CAAC,EAAEI,CAAE;;;;AAGhB,IAASC,IAAI;IAEN,yBAACC,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXT,EAAE,CAAC;IAGA,yBAACO,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QACX,0BAAMC,CAAC,GAAGD,CAAC;QAFZ,OACC,0BAAMD,CAAC,EACP,0BAAME,CAAC;IAFXR,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["f1","l","h","f2","e1","d1","test","a","b","d","g","e"],"mappings":"AAAA;;AAMA,IAAQA,EAAE,CAACC,CAAC;IACRC,CAAC,CAACD,CAAC,CAAC,CAAC,EAAE,CAAC;;AAGZ,IAAQE,EAAE,CAACF,CAAC;IACRC,CAAC,CAACD,CAAC,CAAC,CAAC,EAAE,CAAC,EAAEG,CAAE;IACZF,CAAC,CAACD,CAAC,CAAC,CAAC,EAAE,CAAC,EAAEI,CAAE;;;;AAGhB,IAASC,IAAI;IAEN,yBAACC,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXT,EAAE,CAAC;IAGA,yBAACO,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QACX,0BAAMC,CAAC,GAAGD,CAAC;QAFZ,OACC,0BAAMD,CAAC,EACP,0BAAME,CAAC;IAFXR,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/block lambda/generated/tests/generator/blockLambda/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/block lambda/generated/tests/generator/blockLambda/gen_input.py.map index d0140403..5b1f0e78 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/block lambda/generated/tests/generator/blockLambda/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/block lambda/generated/tests/generator/blockLambda/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","a","b","d","g","f1","f2","g2","f3","c"],"mappings":"AAAA;;AASA,IAASA,IAAI;IACN,yBAACC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAClB,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA,yBAACJ,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA;QAAG,IAAE;IAARC,EAAE,CAAC;IACG,yBAACL,CAAC,EAAOC,CAAC,CAAQ,CAAC;QACrB,0BAAMC,CAAC,GAAGC,CAAC;QADT,OACF,0BAAMD,CAAC;IADXI,EAAE,CAACC,EAAE,CAAC;IAGK,yBAACP,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAC1B,0BAAMC,CAAC,GAAGC,CAAC;QADJ,OACP,0BAAMD,CAAC;IADX,IAAQK,EAAE,CAAC;IAGXD,EAAE,CAACE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","a","b","d","g","f1","f2","g2","f3","c"],"mappings":"AAAA;;AASA,IAASA,IAAI;IACN,yBAACC,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAClB,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA,yBAACJ,CAAC,EAAOC,CAAC;QACT,0BAAMC,CAAC,GAAGC,CAAC;QADZ,OACC,0BAAMD,CAAC;IADXE,EAAE,CAAC;IAGA;QAAG,IAAE;IAARC,EAAE,CAAC;IACG,yBAACL,CAAC,EAAOC,CAAC,CAAQ,CAAC;QACrB,0BAAMC,CAAC,GAAGC,CAAC;QADT,OACF,0BAAMD,CAAC;IADXI,EAAE,CAACC,EAAE,CAAC;IAGK,yBAACP,CAAC,EAAOC,CAAC,CAAQ,CAAC;QAC1B,0BAAMC,CAAC,GAAGC,CAAC;QADJ,OACP,0BAAMD,CAAC;IADX,IAAQK,EAAE,CAAC;IAGXD,EAAE,CAACE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/call/generated/tests/generator/call/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/call/generated/tests/generator/call/gen_input.py.map index dbcf2fed..3c1bdd37 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/call/generated/tests/generator/call/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/call/generated/tests/generator/call/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","g","param2","h","i","j","k"],"mappings":"AAAA;;;;;;;;;;;;;;;AA0BA,IAASA,IAAI;IACTC,CAAC,CAAEC,CAAC,CAAC,CAAC,EArBNC,MAAM,CAqBE,CAAC;IACTF,CAAC,CAAEC,CAAC,CAAsB,CAAC,EAtB3BC,MAAM,CAsBQ,CAAC;IACfF,CAAC,CAAEG,CAAC,CAAC,CAAC,EAlBiBD,OAAM,CAkBrB,CAAC;IACTF,CAAC,CAAEG,CAAC,CAAsB,CAAC,EAnBJD,OAAM,CAmBf,CAAC;IACfF,CAAC,CAAEG,CAAC,CAAU,CAAC;IACb,KAAK;IACL,KAAK,GAAE,GAAG;IACZ,EAAQ,GAAG,EAAT,IAAI;IAEL,oBAAC,CAAFH,CAAC,UAADA,CAAC,CAAGC,CAAC,CAAC,CAAC,EA9BPC,MAAM,CA8BG,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGC,CAAC,CAAsB,CAAC,EA/B5BC,MAAM,CA+BS,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGG,CAAC,CAAC,CAAC,EA3BgBD,OAAM,CA2BpB,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGG,CAAC,CAAsB,CAAC,EA5BLD,OAAM,CA4Bd,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGG,CAAC,CAAU,CAAC;IACf,oBAAC,CAAFC,CAAC,UAAE,KAAK;IACP,oBAAC,CAAFC,CAAC,UAAE,KAAK,GAAE,GAAG;IACZ,oBAAC,CAAFC,CAAC,UAAD,EAAS,GAAG,EAAT,IAAI","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","g","param2","h","i","j","k"],"mappings":"AAAA;;;;;;;;;;;;;;;AA0BA,IAASA,IAAI;IACTC,CAAC,CAAEC,CAAC,CAAC,CAAC,EArBNC,MAAM,CAqBE,CAAC;IACTF,CAAC,CAAEC,CAAC,CAAsB,CAAC,EAtB3BC,MAAM,CAsBQ,CAAC;IACfF,CAAC,CAAEG,CAAC,CAAC,CAAC,EAlBiBD,OAAM,CAkBrB,CAAC;IACTF,CAAC,CAAEG,CAAC,CAAsB,CAAC,EAnBJD,OAAM,CAmBf,CAAC;IACfF,CAAC,CAAEG,CAAC,CAAU,CAAC;IACb,KAAK;IACL,KAAK,GAAE,GAAG;IACZ,EAAQ,GAAG,EAAT,IAAI;IAEL,oBAAC,CAAFH,CAAC,UAADA,CAAC,CAAGC,CAAC,CAAC,CAAC,EA9BPC,MAAM,CA8BG,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGC,CAAC,CAAsB,CAAC,EA/B5BC,MAAM,CA+BS,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGG,CAAC,CAAC,CAAC,EA3BgBD,OAAM,CA2BpB,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGG,CAAC,CAAsB,CAAC,EA5BLD,OAAM,CA4Bd,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAGG,CAAC,CAAU,CAAC;IACf,oBAAC,CAAFC,CAAC,UAAE,KAAK;IACP,oBAAC,CAAFC,CAAC,UAAE,KAAK,GAAE,GAAG;IACZ,oBAAC,CAAFC,CAAC,UAAD,EAAS,GAAG,EAAT,IAAI","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/constant/generated/tests/generator/constant/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/constant/generated/tests/generator/constant/gen_input.py.map index 5d4ee092..ce504c14 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/constant/generated/tests/generator/constant/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/constant/generated/tests/generator/constant/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","null"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAAC;IACFA,CAAC,CAAC;IACFA,CAAC,CAAC;IACFA,CAAC,CAACC,IAAI;IACND,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","null"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAAC;IACFA,CAAC,CAAC;IACFA,CAAC,CAAC;IACFA,CAAC,CAACC,IAAI;IACND,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/enum variant call/generated/tests/generator/enumVariantCall/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/enum variant call/generated/tests/generator/enumVariantCall/gen_input.py.map index f814e4aa..1a6302ec 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/enum variant call/generated/tests/generator/enumVariantCall/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/enum variant call/generated/tests/generator/enumVariantCall/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","myenum","variant1","variant2"],"mappings":"AAAA;;AASA,IAASA,IAAI;IACVC,CAAC,CAACC,MAAM,CAACC,QAAQ;IACjBF,CAAC,CAACC,MAAM,CAAEC,QAAQ;IAClBF,CAAC,CAACC,MAAM,CAACC,QAAQ;IACjBF,CAAC,CAACC,MAAM,CAAEC,QAAQ;IAClBF,CAAC,CAACC,MAAM,CAACE,QAAQ,CAAC,CAAC;IACnBH,CAAC,CAACC,MAAM,CAAEE,QAAQ,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","myenum","variant1","variant2"],"mappings":"AAAA;;AASA,IAASA,IAAI;IACVC,CAAC,CAACC,MAAM,CAACC,QAAQ;IACjBF,CAAC,CAACC,MAAM,CAAEC,QAAQ;IAClBF,CAAC,CAACC,MAAM,CAACC,QAAQ;IACjBF,CAAC,CAACC,MAAM,CAAEC,QAAQ;IAClBF,CAAC,CAACC,MAAM,CAACE,QAAQ,CAAC,CAAC;IACnBH,CAAC,CAACC,MAAM,CAAEE,QAAQ,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/expression lambda/generated/tests/generator/expressionLambda/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/expression lambda/generated/tests/generator/expressionLambda/gen_input.py.map index 38b178bd..eab38869 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/expression lambda/generated/tests/generator/expressionLambda/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/expression lambda/generated/tests/generator/expressionLambda/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","a","b"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,CAAG,CAAC,EAAK,CAAC;IACjBF,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,EAAK,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","a","b"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,CAAG,CAAC,EAAK,CAAC;IACjBF,CAAC,CAAC,OAACC,CAAC,EAAEC,CAAC,EAAK,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/indexed access/generated/tests/generator/indexedAccess/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/indexed access/generated/tests/generator/indexedAccess/gen_input.py.map index 3b1c01f2..0421ba7a 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/indexed access/generated/tests/generator/indexedAccess/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/indexed access/generated/tests/generator/indexedAccess/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","param1","param2","f"],"mappings":"AAAA;;;;;;;;;;;;;;;AAIA,IAAQA,IAAI,CAACC,MAAM,EAAaC,MAAM;IAClCC,CAAC,CAACF,MAAM,CAAC,CAAC;IACVE,CAAC,CAAO,8BAAC,CAAPD,MAAM,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","param1","param2","f"],"mappings":"AAAA;;;;;;;;;;;;;;;AAIA,IAAQA,IAAI,CAACC,MAAM,EAAaC,MAAM;IAClCC,CAAC,CAACF,MAAM,CAAC,CAAC;IACVE,CAAC,CAAO,8BAAC,CAAPD,MAAM,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/infix operation/generated/tests/generator/infixOperation/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/infix operation/generated/tests/generator/infixOperation/gen_input.py.map index 9f8b78db..12fe8644 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/infix operation/generated/tests/generator/infixOperation/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/infix operation/generated/tests/generator/infixOperation/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","or","g","and","h","i"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAUA,IAASA,IAAI;IACTC,CAAC,CAAKC,cAAE,CAANC,CAAC,IAAMA,CAAC;IACVF,CAAC,CAAKG,eAAG,CAAPD,CAAC,IAAOA,CAAC;IAEXF,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAG,EAACA,CAAC;IACXJ,CAAC,CAAC,CAAAI,CAAC,IAAG,QAAIA,CAAC;IAEXJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IAETJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IAETJ,CAAC,CAAK,iBAAE,CAANK,CAAC,IAAMA,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","or","g","and","h","i"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAUA,IAASA,IAAI;IACTC,CAAC,CAAKC,cAAE,CAANC,CAAC,IAAMA,CAAC;IACVF,CAAC,CAAKG,eAAG,CAAPD,CAAC,IAAOA,CAAC;IAEXF,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAG,EAACA,CAAC;IACXJ,CAAC,CAAC,CAAAI,CAAC,IAAG,QAAIA,CAAC;IAEXJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,EAAE,EAACA,CAAC;IACVJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IAETJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IACTJ,CAAC,CAAC,CAAAI,CAAC,IAAG,CAAC,EAACA,CAAC;IAETJ,CAAC,CAAK,iBAAE,CAANK,CAAC,IAAMA,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/lists/generated/tests/generator/lists/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/lists/generated/tests/generator/lists/gen_input.py.map index e143f429..540067ef 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/lists/generated/tests/generator/lists/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/lists/generated/tests/generator/lists/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","h"],"mappings":"AAAA;;AAMA,IAASA,IAAI;IACTC,CAAC,CAAC,EAAE;IACJA,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACVA,CAAC,CAAC,CAAC,CAAC,EAAEC,CAAC,IAAI,CAAAA,CAAC,IAAG,CAAC,EAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","h"],"mappings":"AAAA;;AAMA,IAASA,IAAI;IACTC,CAAC,CAAC,EAAE;IACJA,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACVA,CAAC,CAAC,CAAC,CAAC,EAAEC,CAAC,IAAI,CAAAA,CAAC,IAAG,CAAC,EAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/literals/generated/tests/generator/literals/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/literals/generated/tests/generator/literals/gen_input.py.map index 2be08079..d8f15757 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/literals/generated/tests/generator/literals/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/literals/generated/tests/generator/literals/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","true","false","null"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAACC,IAAI;IACND,CAAC,CAACE,KAAK;IACPF,CAAC,CAAC,GAAG;IACLA,CAAC,CAAC,CAAC;IACHA,CAAC,CAACG,IAAI;IACNH,CAAC,CAAC,EAAE;IACJA,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","true","false","null"],"mappings":"AAAA;;AAIA,IAASA,IAAI;IACTC,CAAC,CAACC,IAAI;IACND,CAAC,CAACE,KAAK;IACPF,CAAC,CAAC,GAAG;IACLA,CAAC,CAAC,CAAC;IACHA,CAAC,CAACG,IAAI;IACNH,CAAC,CAAC,EAAE;IACJA,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/maps/generated/tests/generator/maps/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/maps/generated/tests/generator/maps/gen_input.py.map index 9b985b86..6c773b68 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/maps/generated/tests/generator/maps/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/maps/generated/tests/generator/maps/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","g1","g2","h2","h1","g3"],"mappings":"AAAA;;AAYA,IAASA,IAAI;IACTC,EAAE,CAAC,EAAE;IACLC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IACtBA,EAAE,CAAC,CAACC,EAAE,IAAI,IAAI,EAAE,GAAG,EAAEC,EAAE;IACvBC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IACtBA,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAED,EAAE,IAAID,EAAE","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","g1","g2","h2","h1","g3"],"mappings":"AAAA;;AAYA,IAASA,IAAI;IACTC,EAAE,CAAC,EAAE;IACLC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IACtBA,EAAE,CAAC,CAACC,EAAE,IAAI,IAAI,EAAE,GAAG,EAAEC,EAAE;IACvBC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IACtBA,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAED,EAAE,IAAID,EAAE","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/member access/generated/tests/generator/memberAccess/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/member access/generated/tests/generator/memberAccess/gen_input.py.map index fdbfddee..91922594 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/member access/generated/tests/generator/memberAccess/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/member access/generated/tests/generator/memberAccess/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","g","h","result1","result2","c","a","b","factory","j","k","from_csv_file"],"mappings":"AAAA;;;;;;;;;;;;;;;AA4BA,IAASA,IAAI;IACTC,CAAC,CAACC,CAAC;IACHD,CAAC,CAACE,CAAC,GAAGC,CAAO;IACbH,CAAC,CAACE,CAAC,GAAGE,CAAO;IACbJ,CAAC,CAACK,CAAC,GAAGC,CAAC;IACPN,CAAC,CAACK,CAAC,GAAGE,CAAC;IACPP,CAAC,CAAU,6BAAC,CAAVQ,OAAO,KAAIF,CAAC;IACdN,CAAC,CAAU,6BAAC,CAAVQ,OAAO,KAAID,CAAC;IACdP,CAAC,CAAO,CAAC,GAAPK,CAAC;IACHL,CAAC,CAACK,CAAC,GAAGI,CAAC,CAAC,GAAG;IACXT,CAAC,CAACK,CAAC,GAAGK,EAAC,CAAC,KAAK;IACbV,CAAC,CAACK,CAAC,CAACM,aAAa,CAAC,SAAS","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","g","h","result1","result2","c","a","b","factory","j","k","from_csv_file"],"mappings":"AAAA;;;;;;;;;;;;;;;AA4BA,IAASA,IAAI;IACTC,CAAC,CAACC,CAAC;IACHD,CAAC,CAACE,CAAC,GAAGC,CAAO;IACbH,CAAC,CAACE,CAAC,GAAGE,CAAO;IACbJ,CAAC,CAACK,CAAC,GAAGC,CAAC;IACPN,CAAC,CAACK,CAAC,GAAGE,CAAC;IACPP,CAAC,CAAU,6BAAC,CAAVQ,OAAO,KAAIF,CAAC;IACdN,CAAC,CAAU,6BAAC,CAAVQ,OAAO,KAAID,CAAC;IACdP,CAAC,CAAO,CAAC,GAAPK,CAAC;IACHL,CAAC,CAACK,CAAC,GAAGI,CAAC,CAAC,GAAG;IACXT,CAAC,CAACK,CAAC,GAAGK,EAAC,CAAC,KAAK;IACbV,CAAC,CAACK,CAAC,CAACM,aAAa,CAAC,SAAS","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/parenthesized expression/generated/tests/generator/parenthesizedExpression/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/parenthesized expression/generated/tests/generator/parenthesizedExpression/gen_input.py.map index 508b1d92..c8a170fa 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/parenthesized expression/generated/tests/generator/parenthesizedExpression/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/parenthesized expression/generated/tests/generator/parenthesizedExpression/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","g"],"mappings":"AAAA;;AAMA,IAASA,IAAI;IACTC,CAAC,CAAEC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","g"],"mappings":"AAAA;;AAMA,IAASA,IAAI;IACTC,CAAC,CAAEC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/prefix operation/generated/tests/generator/prefixOperation/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/prefix operation/generated/tests/generator/prefixOperation/gen_input.py.map index 9a664068..c1f2fdf1 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/prefix operation/generated/tests/generator/prefixOperation/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/prefix operation/generated/tests/generator/prefixOperation/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","not","g","h"],"mappings":"AAAA;;AAQA,IAASA,IAAI;IACTC,CAAC,CAACC,GAAG,EAACC,CAAC;IACPF,CAAC,CAAC,CAAC,CAAAG,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","not","g","h"],"mappings":"AAAA;;AAQA,IAASA,IAAI;IACTC,CAAC,CAACC,GAAG,EAACC,CAAC;IACPF,CAAC,CAAC,CAAC,CAAAG,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/reference/generated/tests/generator/reference/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/reference/generated/tests/generator/reference/gen_input.py.map index e7e444c3..ced05b26 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/reference/generated/tests/generator/reference/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/reference/generated/tests/generator/reference/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","explainmodel"],"mappings":"AAAA;;AAQA,IAASA,IAAI;IACTC,CAAC,CAACC,aAAY","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","explainmodel"],"mappings":"AAAA;;AAQA,IAASA,IAAI;IACTC,CAAC,CAACC,aAAY","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/side effects/generated/tests/generator/sideEffects/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/side effects/generated/tests/generator/sideEffects/gen_input.py.map index 0046381d..654b1853 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/side effects/generated/tests/generator/sideEffects/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/side effects/generated/tests/generator/sideEffects/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["mysegment","param","f","result","test","null"],"mappings":"AAAA;;AAIA,IAAQA,SAAS,CAACC,KAAK;IACnBC,CAAC;IACD,YAAMC,MAAM,GAAGF,KAAK;IAFO,OAAG;;;;AAKlC,IAASG,IAAI;IACTJ,SAAS,CAAC;IACVA,SAAS,CAAC;IACVA,SAAS,CAAC;IACVA,SAAS,CAACK,IAAI;IACdL,SAAS,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["mysegment","param","f","result","test","null"],"mappings":"AAAA;;AAIA,IAAQA,SAAS,CAACC,KAAK;IACnBC,CAAC;IACD,YAAMC,MAAM,GAAGF,KAAK;IAFO,OAAG;;;;AAKlC,IAASG,IAAI;IACTJ,SAAS,CAAC;IACVA,SAAS,CAAC;IACVA,SAAS,CAAC;IACVA,SAAS,CAACK,IAAI;IACdL,SAAS,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/expressions/template string/generated/tests/generator/templateString/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/expressions/template string/generated/tests/generator/templateString/gen_input.py.map index 9333bd67..dbf94293 100644 --- a/packages/ttsl-lang/tests/resources/generation/expressions/template string/generated/tests/generator/templateString/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/expressions/template string/generated/tests/generator/templateString/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","g"],"mappings":"AAAA;;AAMA,IAASA,IAAI;IACTC,CAAC,CAAC,EAAA,SACHC,CAAC,EAAG,YACEA,CAAC,EAAG","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","g"],"mappings":"AAAA;;AAMA,IAASA,IAAI;IACTC,CAAC,CAAC,EAAA,SACHC,CAAC,EAAG,YACEA,CAAC,EAAG","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_context_same_package.py.map b/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_context_same_package.py.map index d79ad80d..cd6c46ee 100644 --- a/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_context_same_package.py.map +++ b/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_context_same_package.py.map @@ -1 +1 @@ -{"version":3,"sources":["context same package.sdstest"],"names":["segment1insamepackage","result","impurefunction","segment2insamepackage"],"mappings":"AAAA;;AAIA,IAAQA,qBAAqB;IACzB,YAAMC,MAAM,GAAGC,cAAc;IADD,OAAG;;AAInC,IAAQC,qBAAqB;IACzB,YAAMF,MAAM,GAAGC,cAAc;IADD,OAAG","file":"gen_context_same_package.py"} \ No newline at end of file +{"version":3,"sources":["context same package.Tsltest"],"names":["segment1insamepackage","result","impurefunction","segment2insamepackage"],"mappings":"AAAA;;AAIA,IAAQA,qBAAqB;IACzB,YAAMC,MAAM,GAAGC,cAAc;IADD,OAAG;;AAInC,IAAQC,qBAAqB;IACzB,YAAMF,MAAM,GAAGC,cAAc;IADD,OAAG","file":"gen_context_same_package.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_input.py.map index b5c506e3..787264a9 100644 --- a/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/imports/general/generated/tests/generator/imports/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","segment1insamepackage","segment2insamepackage","function1indifferentpackage","g","function1incompilationunitwithpythonmodule","h"],"mappings":"AAAA;;;;;;;;AASA,IAASA,IAAI;IACTC,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACE,qBAAqB;IACvBF,CAAC,CAACE,qBAAqB;IAEvBF,CAAC,CAACG,2BAA2B;IAC7BH,CAAC,CAACG,2BAA2B;IAC7BH,CAAC,CAACI,CAAC;IACHJ,CAAC,CAACI,CAAC;IAEHJ,CAAC,CAACK,0CAA0C;IAC5CL,CAAC,CAACK,0CAA0C;IAC5CL,CAAC,CAACM,CAAC;IACHN,CAAC,CAACM,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","segment1insamepackage","segment2insamepackage","function1indifferentpackage","g","function1incompilationunitwithpythonmodule","h"],"mappings":"AAAA;;;;;;;;AASA,IAASA,IAAI;IACTC,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACE,qBAAqB;IACvBF,CAAC,CAACE,qBAAqB;IAEvBF,CAAC,CAACG,2BAA2B;IAC7BH,CAAC,CAACG,2BAA2B;IAC7BH,CAAC,CAACI,CAAC;IACHJ,CAAC,CAACI,CAAC;IAEHJ,CAAC,CAACK,0CAA0C;IAC5CL,CAAC,CAACK,0CAA0C;IAC5CL,CAAC,CAACM,CAAC;IACHN,CAAC,CAACM,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/imports/wildcard/generated/tests/generator/wildcard/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/imports/wildcard/generated/tests/generator/wildcard/gen_input.py.map index ff643626..ff584bdf 100644 --- a/packages/ttsl-lang/tests/resources/generation/imports/wildcard/generated/tests/generator/wildcard/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/imports/wildcard/generated/tests/generator/wildcard/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","function1indifferentpackage","function2indifferentpackage","function1incompilationunitwithpythonmodule","function2incompilationunitwithpythonmodule"],"mappings":"AAAA;;;;;;;AAOA,IAASA,IAAI;IACTC,CAAC,CAACC,2BAA2B;IAC7BD,CAAC,CAACC,2BAA2B;IAC7BD,CAAC,CAACE,2BAA2B;IAC7BF,CAAC,CAACE,2BAA2B;IAE7BF,CAAC,CAACG,0CAA0C;IAC5CH,CAAC,CAACG,0CAA0C;IAC5CH,CAAC,CAACI,0CAA0C;IAC5CJ,CAAC,CAACI,0CAA0C","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","function1indifferentpackage","function2indifferentpackage","function1incompilationunitwithpythonmodule","function2incompilationunitwithpythonmodule"],"mappings":"AAAA;;;;;;;AAOA,IAASA,IAAI;IACTC,CAAC,CAACC,2BAA2B;IAC7BD,CAAC,CAACC,2BAA2B;IAC7BD,CAAC,CAACE,2BAA2B;IAC7BF,CAAC,CAACE,2BAA2B;IAE7BF,CAAC,CAACG,0CAA0C;IAC5CH,CAAC,CAACG,0CAA0C;IAC5CH,CAAC,CAACI,0CAA0C;IAC5CJ,CAAC,CAACI,0CAA0C","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file constant/generated/tests/generator/partialImpureDependencyFileConstant/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file constant/generated/tests/generator/partialImpureDependencyFileConstant/gen_input.py.map index d8bcf8c1..dc85fe2a 100644 --- a/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file constant/generated/tests/generator/partialImpureDependencyFileConstant/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file constant/generated/tests/generator/partialImpureDependencyFileConstant/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testpipeline","ifilewritea","ifilereada","ifilewriteb","ifilereadb","impurefilereadagain","impurefilereadagainb"],"mappings":"AAAA;;AAUA,IAASA,YAAY;IAEjB,kBAAsBC,WAAW;IACjC,mBAAuBA,WAAW;IAClC,sBAA0BC,UAAU;IAGpC,mBAAuBC,WAAW;IAClC,oBAAwBA,WAAW;IACnC,uBAA2BC,UAAU;IAGrC,SAAe,CAAAC,mBAAmB,EAAC,CAAC,EAACC,oBAAoB","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testpipeline","ifilewritea","ifilereada","ifilewriteb","ifilereadb","impurefilereadagain","impurefilereadagainb"],"mappings":"AAAA;;AAUA,IAASA,YAAY;IAEjB,kBAAsBC,WAAW;IACjC,mBAAuBA,WAAW;IAClC,sBAA0BC,UAAU;IAGpC,mBAAuBC,WAAW;IAClC,oBAAwBA,WAAW;IACnC,uBAA2BC,UAAU;IAGrC,SAAe,CAAAC,mBAAmB,EAAC,CAAC,EAACC,oBAAoB","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file parameter/generated/tests/generator/partialImpureDependencyFileParameter/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file parameter/generated/tests/generator/partialImpureDependencyFileParameter/gen_input.py.map index 74485ed8..82ce8ed5 100644 --- a/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file parameter/generated/tests/generator/partialImpureDependencyFileParameter/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/partial/impure dependency file parameter/generated/tests/generator/partialImpureDependencyFileParameter/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testpipeline","ifilewrite","ifileread","impurefilereadagain"],"mappings":"AAAA;;AAMA,IAASA,YAAY;IAEjB,kBAAsBC,UAAU,CAAC,OAAO;IACxC,mBAAuBA,UAAU,CAAC,OAAO;IACzC,sBAA0BC,SAAS,CAAC,OAAO;IAG3C,SAAe,CAAAC,mBAAmB,EAAC,CAAC,EAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testpipeline","ifilewrite","ifileread","impurefilereadagain"],"mappings":"AAAA;;AAMA,IAASA,YAAY;IAEjB,kBAAsBC,UAAU,CAAC,OAAO;IACxC,mBAAuBA,UAAU,CAAC,OAAO;IACzC,sBAA0BC,SAAS,CAAC,OAAO;IAG3C,SAAe,CAAAC,mBAAmB,EAAC,CAAC,EAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/partial/impure dependency/generated/tests/generator/partialImpureDependency/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/partial/impure dependency/generated/tests/generator/partialImpureDependency/gen_input.py.map index 4d67a870..1f45057d 100644 --- a/packages/ttsl-lang/tests/resources/generation/partial/impure dependency/generated/tests/generator/partialImpureDependency/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/partial/impure dependency/generated/tests/generator/partialImpureDependency/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testpipeline","i1","ifilewrite","nopartialevalint","r","fp","purevalueforimpure2","purevalueforimpure3","impurea2"],"mappings":"AAAA;;AAeA,IAASA,YAAY;IACjBC,EAAE,CAAC,CAAC;IAGJ,kBAAsBC,UAAU;IAChC,mBAAuBA,UAAU;IAEjC,sBAA0BC,gBAAgB,CAAC,CAAC;IAC5C,sBAA0B,CAAC;IAExB;QACCF,EAAE,CAAC,CAAC;QACJ,0BAAMG,CAAC,GAAG,CAAC;QAFZ,OAEC,0BAAMA,CAAC;IAFXC,EAAE,CAAC;IAIHJ,EAAE,CAAC,CAAC;IACJ,WAAeA,EAAE,CAACK,mBAAmB;IACrC,WAAeL,EAAE,CAACE,gBAAgB,CAACI,CAAmB;IACtDN,EAAE,CAAC,CAAC;IAGJ,SAAeA,EAAE,CAACO,QAAQ","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testpipeline","i1","ifilewrite","nopartialevalint","r","fp","purevalueforimpure2","purevalueforimpure3","impurea2"],"mappings":"AAAA;;AAeA,IAASA,YAAY;IACjBC,EAAE,CAAC,CAAC;IAGJ,kBAAsBC,UAAU;IAChC,mBAAuBA,UAAU;IAEjC,sBAA0BC,gBAAgB,CAAC,CAAC;IAC5C,sBAA0B,CAAC;IAExB;QACCF,EAAE,CAAC,CAAC;QACJ,0BAAMG,CAAC,GAAG,CAAC;QAFZ,OAEC,0BAAMA,CAAC;IAFXC,EAAE,CAAC;IAIHJ,EAAE,CAAC,CAAC;IACJ,WAAeA,EAAE,CAACK,mBAAmB;IACrC,WAAeL,EAAE,CAACE,gBAAgB,CAACI,CAAmB;IACtDN,EAAE,CAAC,CAAC;IAGJ,SAAeA,EAAE,CAACO,QAAQ","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/partial/pure dependency/generated/tests/generator/partialPureDependency/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/partial/pure dependency/generated/tests/generator/partialPureDependency/gen_input.py.map index 232e9d9b..af6e4ae8 100644 --- a/packages/ttsl-lang/tests/resources/generation/partial/pure dependency/generated/tests/generator/partialPureDependency/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/partial/pure dependency/generated/tests/generator/partialPureDependency/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testpipeline","false","null","g","boolean1","ldouble","lint","lnull","lstrmulti","z","f","g2","mapkey","mapvalue","nopartialevalint","listv1","listv3","list3","g3","list","o","value1","mapresult","listresult","g4","listvalue"],"mappings":"AAAA;;AAcA,IAASA,YAAY;IACjB,SAAaC,KAAK;IAGlB,UAAc,IAAI;IAGlB,OAAW,CAAC;IAGZ,QAAYC,IAAI;IAGhB,YAAgB;IAIhB,WAAe;IAGf,SAAaC,CAAC,CAACC,IAAQ,EAAEC,IAAO,EAAEC,CAAI,EAAEC,IAAK,EAAEC,aAAS;IAG9C;QACN,IAAQ,CAAC;QACT,KAAS,CAAC;QACV,IAAQ;QACR,KAAS;QACT,0BAAMC,CAAC,GAAG;QALJ,OAKN,0BAAMA,CAAC;IALX,IAAQ,CAAAC,CAAC,CAAC,uBAMP,CAAC,EAACA,CAAC,CAAC,SAAM,CAAC;IAcd,SAAa,KAAK;IAClB,WAAe,OAAO;IACtB,YAAgBC,EAAE,CAAC,CAACC,KAAM,EAAEC,OAAQ;IAMpC,SAAa,CAAC;IAEd,SAAaC,gBAAgB,CAACC,CAAM;IAEpC,OAAW,CAACA,CAAM;IAElB,QAAY,CAACC,MAAM;IACnB,YAAgBC,KAAK,CAAC,CAAC;IAEvB,aAAiBC,EAAE,CAACC,IAAI;IAIxB,SAAe,CAAO,CAAP,CAAA,CAAC,CAAAC,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,EAACC,MAAM,GAAC,CAAC,EAAwB,CAAvB,CAAAC,SAAS,EAAC,CAAC,EAACC,UAAU,GAAC,CAAC,EAACC,EAAE,CAACC,SAAS","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testpipeline","false","null","g","boolean1","ldouble","lint","lnull","lstrmulti","z","f","g2","mapkey","mapvalue","nopartialevalint","listv1","listv3","list3","g3","list","o","value1","mapresult","listresult","g4","listvalue"],"mappings":"AAAA;;AAcA,IAASA,YAAY;IACjB,SAAaC,KAAK;IAGlB,UAAc,IAAI;IAGlB,OAAW,CAAC;IAGZ,QAAYC,IAAI;IAGhB,YAAgB;IAIhB,WAAe;IAGf,SAAaC,CAAC,CAACC,IAAQ,EAAEC,IAAO,EAAEC,CAAI,EAAEC,IAAK,EAAEC,aAAS;IAG9C;QACN,IAAQ,CAAC;QACT,KAAS,CAAC;QACV,IAAQ;QACR,KAAS;QACT,0BAAMC,CAAC,GAAG;QALJ,OAKN,0BAAMA,CAAC;IALX,IAAQ,CAAAC,CAAC,CAAC,uBAMP,CAAC,EAACA,CAAC,CAAC,SAAM,CAAC;IAcd,SAAa,KAAK;IAClB,WAAe,OAAO;IACtB,YAAgBC,EAAE,CAAC,CAACC,KAAM,EAAEC,OAAQ;IAMpC,SAAa,CAAC;IAEd,SAAaC,gBAAgB,CAACC,CAAM;IAEpC,OAAW,CAACA,CAAM;IAElB,QAAY,CAACC,MAAM;IACnB,YAAgBC,KAAK,CAAC,CAAC;IAEvB,aAAiBC,EAAE,CAACC,IAAI;IAIxB,SAAe,CAAO,CAAP,CAAA,CAAC,CAAAC,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,CAAC,EAACC,MAAM,GAAC,CAAC,EAAwB,CAAvB,CAAAC,SAAS,EAAC,CAAC,EAACC,UAAU,GAAC,CAAC,EAACC,EAAE,CAACC,SAAS","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/partial/redundant impurity/generated/tests/generator/partialRedundantImpurity/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/partial/redundant impurity/generated/tests/generator/partialRedundantImpurity/gen_input.py.map index 88b01051..c9d1eb53 100644 --- a/packages/ttsl-lang/tests/resources/generation/partial/redundant impurity/generated/tests/generator/partialRedundantImpurity/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/partial/redundant impurity/generated/tests/generator/partialRedundantImpurity/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testpipeline","nopartialevalint","purevalue"],"mappings":"AAAA;;AAeA,IAASA,YAAY;IAMjB,YAAgBC,gBAAgB,CAAC,CAAC;IAalC,SAAe,CAAAC,SAAS,EAAC,CAAC,EAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testpipeline","nopartialevalint","purevalue"],"mappings":"AAAA;;AAeA,IAASA,YAAY;IAMjB,YAAgBC,gBAAgB,CAAC,CAAC;IAalC,SAAe,CAAAC,SAAS,EAAC,CAAC,EAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/python module/generated/special_module/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/python module/generated/special_module/gen_input.py.map index d4058545..8825658b 100644 --- a/packages/ttsl-lang/tests/resources/generation/python module/generated/special_module/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/python module/generated/special_module/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f"],"mappings":"AAAA;;AAMA,IAAQA,IAAI;IACRC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f"],"mappings":"AAAA;;AAMA,IAAQA,IAAI;IACRC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/call/generated/tests/generator/callWithRunnerIntegration/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/call/generated/tests/generator/callWithRunnerIntegration/gen_input.py.map index bf0e8287..259b64d6 100644 --- a/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/call/generated/tests/generator/callWithRunnerIntegration/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/call/generated/tests/generator/callWithRunnerIntegration/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["segment_a","a","result","test","f","g","param2","h","i","j","k","readfile","l","m"],"mappings":"AAAA;;;;;;;;;;;;;;;;AAiEA,IAAQA,SAAS,CAACC,CAAC;IACf,YAAMC,MAAM,GAAG,CAAAD,CAAC,EAAC,CAAC,EAAC,CAAC;IADE,OAAG;;;;AA9B7B,IAASE,IAAI;IACTC,CAAC,CAAE,uFAAAC,CAAC,CAAC,CAAC,EA9BNC,MAAM,CA8BE,CAAC,IAAJ,CAAC,EAAE,CAAC;IACTF,CAAC,CAAE,uFAAAC,CAAC,CAAsB,CAAC,EA/B3BC,MAAM,CA+BQ,CAAC,IAAW,CAAC,EAAb,CAAC;IACfF,CAAC,CAAE,uFAAAG,CAAC,CAAC,CAAC,EA3BiBD,OAAM,CA2BrB,CAAC,IAAJ,CAAC,EAAE,CAAC;IACTF,CAAC,CAAE,uFAAAG,CAAC,CAAsB,CAAC,EA5BJD,OAAM,CA4Bf,CAAC,IAAW,CAAC,EAAb,CAAC;IACfF,CAAC,CAAE,2EAAAG,CAAC,GAAU,CAAC,EA7BsB,CAAC;IA8BpC,KAAK;IACL,KAAK,GAAE,GAAG;IACZ,EAAQ,GAAG,EAAT,IAAI;IAEL,oBAAC,CAAFH,CAAC,UAADA,CAAC,CAAG,uFAAAC,CAAC,CAAC,CAAC,EAvCPC,MAAM,CAuCG,CAAC,IAAJ,CAAC,EAAE,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,uFAAAC,CAAC,CAAsB,CAAC,EAxC5BC,MAAM,CAwCS,CAAC,IAAW,CAAC,EAAb,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,uFAAAG,CAAC,CAAC,CAAC,EApCgBD,OAAM,CAoCpB,CAAC,IAAJ,CAAC,EAAE,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,uFAAAG,CAAC,CAAsB,CAAC,EArCLD,OAAM,CAqCd,CAAC,IAAW,CAAC,EAAb,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,2EAAAG,CAAC,GAAU,CAAC,EAtCqB,CAAC;IAuCrC,oBAAC,CAAFC,CAAC,UAAE,KAAK;IACP,oBAAC,CAAFC,CAAC,UAAE,KAAK,GAAE,GAAG;IACZ,oBAAC,CAAFC,CAAC,UAAD,EAAS,GAAG,EAAT,IAAI;IAEPN,CAAC,CAAC,kFAAAO,QAAQ,OAAR,iCAAU;IACZP,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAKD,SAAS,CAACC,CAAC;IACtBG,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAK,CAAA,CAAC,EAAC,CAAC,EAACD,SAAS,CAACC,CAAC;IAC1BG,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAK,2EAAAY,CAAC,GAAC,CAAA,CAAC,EAAC,CAAC,EAACb,SAAS,CAACC,CAAC;IAC5BG,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAK,CAAA,CAAC,EAAC,CAAC,EAAC,2EAAAY,CAAC,GAAC,2EAAAA,CAAC,GAAC,CAAA,CAAC,EAAC,CAAC,EAACb,SAAS,CAACC,CAAC;IAC9B,yBAACA,CAAC;QAAG,0BAAMC,MAAM,GAAGF,SAAS,CAACC,CAAC;QAA/B,OAAK,0BAAMC,MAAM;IAArBE,CAAC,CAACQ,CAAC,CAAC;IACA,yBAACX,CAAC;QAAG,0BAAMC,MAAM,GAAG,2EAAAW,CAAC,GAACb,SAAS,CAACC,CAAC;QAAjC,OAAK,0BAAMC,MAAM;IAArBE,CAAC,CAACQ,CAAC,CAAC;IACJR,CAAC,CAAC,2EAAAQ,CAAC,GAAC,OAACX,CAAC,EAAK,CAAA,CAAC,EAAC,CAAC,EAACA,CAAC;IACZ,yBAACA,CAAC;QAAG,0BAAMC,MAAM,GAAG,CAAA,CAAC,EAAC,CAAC,EAAC,2EAAAW,CAAC,GAACZ,CAAC;QAA3B,OAAK,0BAAMC,MAAM;IAArBE,CAAC,CAAC,2EAAAQ,CAAC,GAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["segment_a","a","result","test","f","g","param2","h","i","j","k","readfile","l","m"],"mappings":"AAAA;;;;;;;;;;;;;;;;AAiEA,IAAQA,SAAS,CAACC,CAAC;IACf,YAAMC,MAAM,GAAG,CAAAD,CAAC,EAAC,CAAC,EAAC,CAAC;IADE,OAAG;;;;AA9B7B,IAASE,IAAI;IACTC,CAAC,CAAE,uFAAAC,CAAC,CAAC,CAAC,EA9BNC,MAAM,CA8BE,CAAC,IAAJ,CAAC,EAAE,CAAC;IACTF,CAAC,CAAE,uFAAAC,CAAC,CAAsB,CAAC,EA/B3BC,MAAM,CA+BQ,CAAC,IAAW,CAAC,EAAb,CAAC;IACfF,CAAC,CAAE,uFAAAG,CAAC,CAAC,CAAC,EA3BiBD,OAAM,CA2BrB,CAAC,IAAJ,CAAC,EAAE,CAAC;IACTF,CAAC,CAAE,uFAAAG,CAAC,CAAsB,CAAC,EA5BJD,OAAM,CA4Bf,CAAC,IAAW,CAAC,EAAb,CAAC;IACfF,CAAC,CAAE,2EAAAG,CAAC,GAAU,CAAC,EA7BsB,CAAC;IA8BpC,KAAK;IACL,KAAK,GAAE,GAAG;IACZ,EAAQ,GAAG,EAAT,IAAI;IAEL,oBAAC,CAAFH,CAAC,UAADA,CAAC,CAAG,uFAAAC,CAAC,CAAC,CAAC,EAvCPC,MAAM,CAuCG,CAAC,IAAJ,CAAC,EAAE,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,uFAAAC,CAAC,CAAsB,CAAC,EAxC5BC,MAAM,CAwCS,CAAC,IAAW,CAAC,EAAb,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,uFAAAG,CAAC,CAAC,CAAC,EApCgBD,OAAM,CAoCpB,CAAC,IAAJ,CAAC,EAAE,CAAC;IACT,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,uFAAAG,CAAC,CAAsB,CAAC,EArCLD,OAAM,CAqCd,CAAC,IAAW,CAAC,EAAb,CAAC;IACf,oBAAC,CAAFF,CAAC,UAADA,CAAC,CAAG,2EAAAG,CAAC,GAAU,CAAC,EAtCqB,CAAC;IAuCrC,oBAAC,CAAFC,CAAC,UAAE,KAAK;IACP,oBAAC,CAAFC,CAAC,UAAE,KAAK,GAAE,GAAG;IACZ,oBAAC,CAAFC,CAAC,UAAD,EAAS,GAAG,EAAT,IAAI;IAEPN,CAAC,CAAC,kFAAAO,QAAQ,OAAR,iCAAU;IACZP,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAKD,SAAS,CAACC,CAAC;IACtBG,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAK,CAAA,CAAC,EAAC,CAAC,EAACD,SAAS,CAACC,CAAC;IAC1BG,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAK,2EAAAY,CAAC,GAAC,CAAA,CAAC,EAAC,CAAC,EAACb,SAAS,CAACC,CAAC;IAC5BG,CAAC,CAACQ,CAAC,CAAC,OAACX,CAAC,EAAK,CAAA,CAAC,EAAC,CAAC,EAAC,2EAAAY,CAAC,GAAC,2EAAAA,CAAC,GAAC,CAAA,CAAC,EAAC,CAAC,EAACb,SAAS,CAACC,CAAC;IAC9B,yBAACA,CAAC;QAAG,0BAAMC,MAAM,GAAGF,SAAS,CAACC,CAAC;QAA/B,OAAK,0BAAMC,MAAM;IAArBE,CAAC,CAACQ,CAAC,CAAC;IACA,yBAACX,CAAC;QAAG,0BAAMC,MAAM,GAAG,2EAAAW,CAAC,GAACb,SAAS,CAACC,CAAC;QAAjC,OAAK,0BAAMC,MAAM;IAArBE,CAAC,CAACQ,CAAC,CAAC;IACJR,CAAC,CAAC,2EAAAQ,CAAC,GAAC,OAACX,CAAC,EAAK,CAAA,CAAC,EAAC,CAAC,EAACA,CAAC;IACZ,yBAACA,CAAC;QAAG,0BAAMC,MAAM,GAAG,CAAA,CAAC,EAAC,CAAC,EAAC,2EAAAW,CAAC,GAACZ,CAAC;QAA3B,OAAK,0BAAMC,MAAM;IAArBE,CAAC,CAAC,2EAAAQ,CAAC,GAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/member access/generated/tests/generator/memberAccessWithRunnerIntegration/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/member access/generated/tests/generator/memberAccessWithRunnerIntegration/gen_input.py.map index 003e6b8e..6be49ddc 100644 --- a/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/member access/generated/tests/generator/memberAccessWithRunnerIntegration/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/runner integration/expressions/member access/generated/tests/generator/memberAccessWithRunnerIntegration/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","g","h","result1","result2","c","a","b","factory","j","k","from_csv_file"],"mappings":"AAAA;;;;;;;;;;;;;;;;AA4BA,IAASA,IAAI;IACTC,CAAC,CAAC,mFAAAC,CAAC;IACHD,CAAC,CAAC,mFAAAE,CAAC,UAAGC,CAAO;IACbH,CAAC,CAAC,mFAAAE,CAAC,UAAGE,CAAO;IACbJ,CAAC,CAAC,mFAAAK,CAAC,UAAGC,CAAC;IACPN,CAAC,CAAC,mFAAAK,CAAC,UAAGE,CAAC;IACPP,CAAC,CAAU,6BAAC,CAAV,yFAAAQ,OAAO,YAAIF,CAAC;IACdN,CAAC,CAAU,6BAAC,CAAV,yFAAAQ,OAAO,YAAID,CAAC;IACdP,CAAC,CAAC,iGAAM,CAAC,GAAP,mFAAAK,CAAC,aAAK,CAAC;IACTL,CAAC,CAAC,qFAAAK,CAAC,CAAGI,CAAC,GAAL,mFAAAJ,CAAC,WAAK,GAAG;IACXL,CAAC,CAAC,sFAAAK,CAAC,CAAGK,EAAC,GAAL,mFAAAL,CAAC,WAAK,KAAK;IACbL,CAAC,CAAC,iGAAAK,CAAC,CAACM,aAAa,GAAC,SAAS,IAAT,yBAAA,SAAS","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","g","h","result1","result2","c","a","b","factory","j","k","from_csv_file"],"mappings":"AAAA;;;;;;;;;;;;;;;;AA4BA,IAASA,IAAI;IACTC,CAAC,CAAC,mFAAAC,CAAC;IACHD,CAAC,CAAC,mFAAAE,CAAC,UAAGC,CAAO;IACbH,CAAC,CAAC,mFAAAE,CAAC,UAAGE,CAAO;IACbJ,CAAC,CAAC,mFAAAK,CAAC,UAAGC,CAAC;IACPN,CAAC,CAAC,mFAAAK,CAAC,UAAGE,CAAC;IACPP,CAAC,CAAU,6BAAC,CAAV,yFAAAQ,OAAO,YAAIF,CAAC;IACdN,CAAC,CAAU,6BAAC,CAAV,yFAAAQ,OAAO,YAAID,CAAC;IACdP,CAAC,CAAC,iGAAM,CAAC,GAAP,mFAAAK,CAAC,aAAK,CAAC;IACTL,CAAC,CAAC,qFAAAK,CAAC,CAAGI,CAAC,GAAL,mFAAAJ,CAAC,WAAK,GAAG;IACXL,CAAC,CAAC,sFAAAK,CAAC,CAAGK,EAAC,GAAL,mFAAAL,CAAC,WAAK,KAAK;IACbL,CAAC,CAAC,iGAAAK,CAAC,CAACM,aAAa,GAAC,SAAS,IAAT,yBAAA,SAAS","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_context_same_package.py.map b/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_context_same_package.py.map index 6d172254..24a4555a 100644 --- a/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_context_same_package.py.map +++ b/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_context_same_package.py.map @@ -1 +1 @@ -{"version":3,"sources":["context same package.sdstest"],"names":["segment1insamepackage","result","impurefunction","segment2insamepackage"],"mappings":"AAAA;;;;;;AAIA,IAAQA,qBAAqB;IACzB,YAAMC,MAAM,GAAG,2FAAAC,cAAc;IADD,OAAG;;AAInC,IAAQC,qBAAqB;IACzB,YAAMF,MAAM,GAAG,2FAAAC,cAAc;IADD,OAAG","file":"gen_context_same_package.py"} \ No newline at end of file +{"version":3,"sources":["context same package.Tsltest"],"names":["segment1insamepackage","result","impurefunction","segment2insamepackage"],"mappings":"AAAA;;;;;;AAIA,IAAQA,qBAAqB;IACzB,YAAMC,MAAM,GAAG,2FAAAC,cAAc;IADD,OAAG;;AAInC,IAAQC,qBAAqB;IACzB,YAAMF,MAAM,GAAG,2FAAAC,cAAc;IADD,OAAG","file":"gen_context_same_package.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_input.py.map index 39fdacc6..ca42f256 100644 --- a/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/runner integration/imports/general/generated/tests/generator/importsWithRunnerIntegration/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","segment1insamepackage","segment2insamepackage","function1indifferentpackage","g","function1incompilationunitwithpythonmodule","h"],"mappings":"AAAA;;;;;;;;;AASA,IAASA,IAAI;IACTC,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACE,qBAAqB;IACvBF,CAAC,CAACE,qBAAqB;IAEvBF,CAAC,CAAC,iHAAAG,2BAA2B;IAC7BH,CAAC,CAAC,iHAAAG,2BAA2B;IAC7BH,CAAC,CAAC,iHAAAI,CAAC;IACHJ,CAAC,CAAC,iHAAAI,CAAC;IAEHJ,CAAC,CAAC,2FAAAK,0CAA0C;IAC5CL,CAAC,CAAC,2FAAAK,0CAA0C;IAC5CL,CAAC,CAAC,2FAAAM,CAAC;IACHN,CAAC,CAAC,2FAAAM,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","segment1insamepackage","segment2insamepackage","function1indifferentpackage","g","function1incompilationunitwithpythonmodule","h"],"mappings":"AAAA;;;;;;;;;AASA,IAASA,IAAI;IACTC,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACC,qBAAqB;IACvBD,CAAC,CAACE,qBAAqB;IACvBF,CAAC,CAACE,qBAAqB;IAEvBF,CAAC,CAAC,iHAAAG,2BAA2B;IAC7BH,CAAC,CAAC,iHAAAG,2BAA2B;IAC7BH,CAAC,CAAC,iHAAAI,CAAC;IACHJ,CAAC,CAAC,iHAAAI,CAAC;IAEHJ,CAAC,CAAC,2FAAAK,0CAA0C;IAC5CL,CAAC,CAAC,2FAAAK,0CAA0C;IAC5CL,CAAC,CAAC,2FAAAM,CAAC;IACHN,CAAC,CAAC,2FAAAM,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/runner integration/imports/wildcard/generated/tests/generator/wildcardWithRunnerIntegration/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/runner integration/imports/wildcard/generated/tests/generator/wildcardWithRunnerIntegration/gen_input.py.map index d08dc91b..ea43a305 100644 --- a/packages/ttsl-lang/tests/resources/generation/runner integration/imports/wildcard/generated/tests/generator/wildcardWithRunnerIntegration/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/runner integration/imports/wildcard/generated/tests/generator/wildcardWithRunnerIntegration/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["test","f","function1indifferentpackage","function2indifferentpackage","function1incompilationunitwithpythonmodule","function2incompilationunitwithpythonmodule"],"mappings":"AAAA;;;;;;;;AAOA,IAASA,IAAI;IACTC,CAAC,CAAC,yHAAAC,2BAA2B;IAC7BD,CAAC,CAAC,yHAAAC,2BAA2B;IAC7BD,CAAC,CAAC,yHAAAE,2BAA2B;IAC7BF,CAAC,CAAC,yHAAAE,2BAA2B;IAE7BF,CAAC,CAAC,2FAAAG,0CAA0C;IAC5CH,CAAC,CAAC,2FAAAG,0CAA0C;IAC5CH,CAAC,CAAC,2FAAAI,0CAA0C;IAC5CJ,CAAC,CAAC,2FAAAI,0CAA0C","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["test","f","function1indifferentpackage","function2indifferentpackage","function1incompilationunitwithpythonmodule","function2incompilationunitwithpythonmodule"],"mappings":"AAAA;;;;;;;;AAOA,IAASA,IAAI;IACTC,CAAC,CAAC,yHAAAC,2BAA2B;IAC7BD,CAAC,CAAC,yHAAAC,2BAA2B;IAC7BD,CAAC,CAAC,yHAAAE,2BAA2B;IAC7BF,CAAC,CAAC,yHAAAE,2BAA2B;IAE7BF,CAAC,CAAC,2FAAAG,0CAA0C;IAC5CH,CAAC,CAAC,2FAAAG,0CAA0C;IAC5CH,CAAC,CAAC,2FAAAI,0CAA0C;IAC5CJ,CAAC,CAAC,2FAAAI,0CAA0C","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/runner integration/statements/assignment/generated/tests/generator/assignmentWithRunnerIntegration/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/runner integration/statements/assignment/generated/tests/generator/assignmentWithRunnerIntegration/gen_input.py.map index 24e2e88d..02a465fd 100644 --- a/packages/ttsl-lang/tests/resources/generation/runner integration/statements/assignment/generated/tests/generator/assignmentWithRunnerIntegration/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/runner integration/statements/assignment/generated/tests/generator/assignmentWithRunnerIntegration/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testsegment","g","_","c","f1","a","x","testpipeline","l","m","n","f2"],"mappings":"AAAA;;;;;;AA2BA,IAAQA,WAAW;IACLC,CAAC;IACX,GAAOC,CAAC,EAAE,YAAMC,CAAC,GAAGF,CAAC;IACrB,UAAQA,CAAC;IACTG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IALc,OAAG;;;;AApBzB,IAASC,YAAY;IACPN,CAAC;IACX,GAAOC,CAAC,EAAEA,CAAC,GAAGD,CAAC;IAAf;IACA,UAAQA,CAAC;IAAT;IACAG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IACJ,GAAO,GAAO,IAAQL,CAAC;IAAvB;IAAO;IAAO;IACdG,EAAE,CAACI,CAAC;IACJJ,EAAE,CAACK,CAAC;IACJL,EAAE,CAACM,CAAC;IAED;QACWT,CAAC;QACX,GAAOC,CAAC,EAAE,0BAAMC,CAAC,GAAGF,CAAC;QACrB,UAAQA,CAAC;QACTG,EAAE,CAACC,CAAC;QACJD,EAAE,CAACE,CAAC;QALL,OAEW,0BAAMH,CAAC;IAFrBQ,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testsegment","g","_","c","f1","a","x","testpipeline","l","m","n","f2"],"mappings":"AAAA;;;;;;AA2BA,IAAQA,WAAW;IACLC,CAAC;IACX,GAAOC,CAAC,EAAE,YAAMC,CAAC,GAAGF,CAAC;IACrB,UAAQA,CAAC;IACTG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IALc,OAAG;;;;AApBzB,IAASC,YAAY;IACPN,CAAC;IACX,GAAOC,CAAC,EAAEA,CAAC,GAAGD,CAAC;IAAf;IACA,UAAQA,CAAC;IAAT;IACAG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IACJ,GAAO,GAAO,IAAQL,CAAC;IAAvB;IAAO;IAAO;IACdG,EAAE,CAACI,CAAC;IACJJ,EAAE,CAACK,CAAC;IACJL,EAAE,CAACM,CAAC;IAED;QACWT,CAAC;QACX,GAAOC,CAAC,EAAE,0BAAMC,CAAC,GAAGF,CAAC;QACrB,UAAQA,CAAC;QACTG,EAAE,CAACC,CAAC;QACJD,EAAE,CAACE,CAAC;QALL,OAEW,0BAAMH,CAAC;IAFrBQ,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/statements/assignment/generated/tests/generator/assignment/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/statements/assignment/generated/tests/generator/assignment/gen_input.py.map index cdcaac21..b6039970 100644 --- a/packages/ttsl-lang/tests/resources/generation/statements/assignment/generated/tests/generator/assignment/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/statements/assignment/generated/tests/generator/assignment/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testsegment","g","_","c","f1","a","x","testpipeline","l","m","n","f2"],"mappings":"AAAA;;AA2BA,IAAQA,WAAW;IACLC,CAAC;IACX,GAAOC,CAAC,EAAE,YAAMC,CAAC,GAAGF,CAAC;IACrB,UAAQA,CAAC;IACTG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IALc,OAAG;;;;AApBzB,IAASC,YAAY;IACPN,CAAC;IACX,GAAOC,CAAC,EAAEA,CAAC,GAAGD,CAAC;IACf,UAAQA,CAAC;IACTG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IACJ,GAAO,GAAO,IAAQL,CAAC;IACvBG,EAAE,CAACI,CAAC;IACJJ,EAAE,CAACK,CAAC;IACJL,EAAE,CAACM,CAAC;IAED;QACWT,CAAC;QACX,GAAOC,CAAC,EAAE,0BAAMC,CAAC,GAAGF,CAAC;QACrB,UAAQA,CAAC;QACTG,EAAE,CAACC,CAAC;QACJD,EAAE,CAACE,CAAC;QALL,OAEW,0BAAMH,CAAC;IAFrBQ,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testsegment","g","_","c","f1","a","x","testpipeline","l","m","n","f2"],"mappings":"AAAA;;AA2BA,IAAQA,WAAW;IACLC,CAAC;IACX,GAAOC,CAAC,EAAE,YAAMC,CAAC,GAAGF,CAAC;IACrB,UAAQA,CAAC;IACTG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IALc,OAAG;;;;AApBzB,IAASC,YAAY;IACPN,CAAC;IACX,GAAOC,CAAC,EAAEA,CAAC,GAAGD,CAAC;IACf,UAAQA,CAAC;IACTG,EAAE,CAACC,CAAC;IACJD,EAAE,CAACE,CAAC;IACJ,GAAO,GAAO,IAAQL,CAAC;IACvBG,EAAE,CAACI,CAAC;IACJJ,EAAE,CAACK,CAAC;IACJL,EAAE,CAACM,CAAC;IAED;QACWT,CAAC;QACX,GAAOC,CAAC,EAAE,0BAAMC,CAAC,GAAGF,CAAC;QACrB,UAAQA,CAAC;QACTG,EAAE,CAACC,CAAC;QACJD,EAAE,CAACE,CAAC;QALL,OAEW,0BAAMH,CAAC;IAFrBQ,EAAE,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/statements/expression statement/generated/tests/generator/expressionStatement/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/statements/expression statement/generated/tests/generator/expressionStatement/gen_input.py.map index 125a90e0..1ef85039 100644 --- a/packages/ttsl-lang/tests/resources/generation/statements/expression statement/generated/tests/generator/expressionStatement/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/statements/expression statement/generated/tests/generator/expressionStatement/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testsegment","g","testpipeline","f"],"mappings":"AAAA;;AAcA,IAAQA,WAAW;IACfC,CAAC;;;;AATL,IAASC,YAAY;IACjBD,CAAC;IAEC;QACEA,CAAC;IADLE,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testsegment","g","testpipeline","f"],"mappings":"AAAA;;AAcA,IAAQA,WAAW;IACfC,CAAC;;;;AATL,IAASC,YAAY;IACjBD,CAAC;IAEC;QACEA,CAAC;IADLE,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-lang/tests/resources/generation/statements/statement without effect/generated/tests/generator/statementWithoutEffect/gen_input.py.map b/packages/ttsl-lang/tests/resources/generation/statements/statement without effect/generated/tests/generator/statementWithoutEffect/gen_input.py.map index 65d34c1e..2805beed 100644 --- a/packages/ttsl-lang/tests/resources/generation/statements/statement without effect/generated/tests/generator/statementWithoutEffect/gen_input.py.map +++ b/packages/ttsl-lang/tests/resources/generation/statements/statement without effect/generated/tests/generator/statementWithoutEffect/gen_input.py.map @@ -1 +1 @@ -{"version":3,"sources":["input.sdstest"],"names":["testsegment","testpipeline","f"],"mappings":"AAAA;;AAcA,IAAQA,WAAW;IAAG;;;;AAVtB,IAASC,YAAY;IAIf;QAAG;IAALC,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file +{"version":3,"sources":["input.Tsltest"],"names":["testsegment","testpipeline","f"],"mappings":"AAAA;;AAcA,IAAQA,WAAW;IAAG;;;;AAVtB,IAASC,YAAY;IAIf;QAAG;IAALC,CAAC,CAAC","file":"gen_input.py"} \ No newline at end of file diff --git a/packages/ttsl-vscode/img/safe-ds_file_icon_light.svg b/packages/ttsl-vscode/img/safe-ds_file_icon_light.svg index 12fb6f23..871582ea 100644 --- a/packages/ttsl-vscode/img/safe-ds_file_icon_light.svg +++ b/packages/ttsl-vscode/img/safe-ds_file_icon_light.svg @@ -3,6 +3,6 @@ - + diff --git a/packages/ttsl-vscode/src/extension/mainClient.ts b/packages/ttsl-vscode/src/extension/mainClient.ts index 7faa9fe5..178705f4 100644 --- a/packages/ttsl-vscode/src/extension/mainClient.ts +++ b/packages/ttsl-vscode/src/extension/mainClient.ts @@ -62,7 +62,7 @@ const startLanguageClient = function (context: vscode.ExtensionContext): Languag debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }, }; - const fileSystemWatcher = vscode.workspace.createFileSystemWatcher('**/*.{sdspipe,sdsstub,sdstest}'); + const fileSystemWatcher = vscode.workspace.createFileSystemWatcher('**/*.{Tslpipe,Tslstub,Tsltest}'); context.subscriptions.push(fileSystemWatcher); // Options to control the language client @@ -173,22 +173,22 @@ const runPipelineFile = async function (filePath: vscode.Uri | undefined, pipeli .filter( (document) => !( - ast.isSdsModule(document.parseResult.value) && - (document.parseResult.value).name === 'safeds.lang' + ast.isTslModule(document.parseResult.value) && + (document.parseResult.value).name === 'safeds.lang' ), ) .forEach((oldDocument) => { services.shared.workspace.LangiumDocuments.deleteDocument(oldDocument.uri); }); - const workspaceSdsFiles = await vscode.workspace.findFiles('**/*.{sdspipe,sdsstub,sdstest}'); + const workspaceTslFiles = await vscode.workspace.findFiles('**/*.{Tslpipe,Tslstub,Tsltest}'); // Load all documents - const unvalidatedSdsDocuments = await Promise.all( - workspaceSdsFiles.map((newDocumentUri) => + const unvalidatedTslDocuments = await Promise.all( + workspaceTslFiles.map((newDocumentUri) => services.shared.workspace.LangiumDocuments.getOrCreateDocument(newDocumentUri), ), ); // Validate them - const validationErrorMessage = await validateDocuments(services, unvalidatedSdsDocuments); + const validationErrorMessage = await validateDocuments(services, unvalidatedTslDocuments); if (validationErrorMessage) { vscode.window.showErrorMessage(validationErrorMessage); return; @@ -206,7 +206,7 @@ const runPipelineFile = async function (filePath: vscode.Uri | undefined, pipeli mainDocument = await services.shared.workspace.LangiumDocuments.getOrCreateDocument(pipelinePath); } - const firstPipeline = getModuleMembers(mainDocument.parseResult.value).find(ast.isSdsPipeline); + const firstPipeline = getModuleMembers(mainDocument.parseResult.value).find(ast.isTslPipeline); if (firstPipeline === undefined) { logError('Cannot execute: no pipeline found'); vscode.window.showErrorMessage('The current file cannot be executed, as no pipeline could be found.'); @@ -225,10 +225,10 @@ const commandRunPipelineFile = async function (filePath: vscode.Uri | undefined) }; const validateDocuments = async function ( - sdsServices: SafeDsServices, + TslServices: SafeDsServices, documents: LangiumDocument[], ): Promise { - await sdsServices.shared.workspace.DocumentBuilder.build(documents, { validation: true }); + await TslServices.shared.workspace.DocumentBuilder.build(documents, { validation: true }); const errors = documents.flatMap((validatedDocument) => { const validationInfo = {