Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Source Maps for Code Generation #714

Merged
merged 21 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f087d2a
feat: add tracing information to code generation
WinPlay02 Oct 31, 2023
e4596f1
feat: add option to generate source maps
WinPlay02 Oct 31, 2023
85f7e29
fix: Add changes from package-lock
WinPlay02 Oct 31, 2023
128ac7f
style: apply automated linter fixes
megalinter-bot Oct 31, 2023
6596b05
Merge branch 'generator-source-maps' of https://github.com/Safe-DS/DS…
WinPlay02 Oct 31, 2023
2fca0ed
test: added source maps as expected files
WinPlay02 Oct 31, 2023
2f08831
fix: remove sourcesContent from sourcemaps as tests would differ on d…
WinPlay02 Oct 31, 2023
cea4b00
Merge branch 'main' of https://github.com/Safe-DS/DSL into generator-…
WinPlay02 Oct 31, 2023
033dad7
test: fix coverage
WinPlay02 Oct 31, 2023
c51ac72
style: apply automated linter fixes
megalinter-bot Oct 31, 2023
963c2ae
Merge branch 'main' into generator-source-maps
WinPlay02 Nov 2, 2023
d6f3663
feat: source maps now matches convention
WinPlay02 Nov 2, 2023
e3d964d
Merge branch 'generator-source-maps' of https://github.com/Safe-DS/DS…
WinPlay02 Nov 2, 2023
58095f9
fix: only check relative path, when filtering skipped tests
WinPlay02 Nov 2, 2023
43e8294
style: apply automated linter fixes
megalinter-bot Nov 2, 2023
4538078
Merge branch 'main' of https://github.com/Safe-DS/DSL into generator-…
WinPlay02 Nov 2, 2023
6124433
fix: globs with only one extension didn't work
WinPlay02 Nov 2, 2023
7509405
refactor: accept GenerateOptions in generator service, rename Generat…
WinPlay02 Nov 2, 2023
6b87808
Merge branch 'generator-source-maps' of https://github.com/Safe-DS/DS…
WinPlay02 Nov 2, 2023
7a15620
style: apply automated linter fixes
megalinter-bot Nov 2, 2023
666ef96
Update packages/safe-ds-lang/tests/helpers/testResources.test.ts
lars-reimann Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions packages/safe-ds-cli/src/cli/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import fs from 'node:fs';
import path from 'node:path';
import { extractDocument } from './cli-util.js';

export const generate = async (fileName: string, opts: GenerateOptions): Promise<void> => {
export const generate = async (fileName: string, opts: CliGenerateOptions): Promise<void> => {
const services = (await createSafeDsServicesWithBuiltins(NodeFileSystem)).SafeDs;
const document = await extractDocument(fileName, services);
const destination = opts.destination ?? path.join(path.dirname(fileName), 'generated');
const generatedFiles = services.generation.PythonGenerator.generate(document, URI.file(path.resolve(destination)));
const generatedFiles = services.generation.PythonGenerator.generate(document, {
destination: URI.file(path.resolve(destination)),
createSourceMaps: opts.sourcemaps,
});

for (const file of generatedFiles) {
const fsPath = URI.parse(file.uri).fsPath;
Expand All @@ -25,6 +28,8 @@ export const generate = async (fileName: string, opts: GenerateOptions): Promise
console.log(chalk.green(`Python code generated successfully.`));
};

export interface GenerateOptions {
export interface CliGenerateOptions {
destination?: string;
sourcemaps: boolean;
quiet: boolean;
}
1 change: 1 addition & 0 deletions packages/safe-ds-cli/src/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ program
.option('-d, --destination <dir>', 'destination directory of generation')
.option('-r, --root <dir>', 'source root folder')
.option('-q, --quiet', 'whether the program should print something', false)
.option('-s, --sourcemaps', 'whether source maps should be generated', false)
.description('generate Python code')
.action(generate);

Expand Down
1 change: 1 addition & 0 deletions packages/safe-ds-lang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"chevrotain": "^11.0.3",
"glob": "^10.3.10",
"langium": "^2.1.0",
"source-map": "^0.7.4",
"vscode-languageserver": "^9.0.1",
"vscode-languageserver-textdocument": "^1.0.11"
},
Expand Down
Loading