From db4c1d20923245ec3eb151500df030e9bd49ba32 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Fri, 7 Apr 2023 21:07:31 +0200 Subject: [PATCH] ci: another try to generate langium files before linting --- .mega-linter.yml | 2 +- DSL-langium/langium-config.json | 16 ++++---- DSL-langium/language-configuration.json | 2 +- DSL-langium/package.json | 1 - DSL-langium/src/cli/generator.ts | 2 +- DSL-langium/src/cli/index.ts | 4 +- .../src/language-server/safe-ds-module.ts | 39 +++++++++---------- .../validation/safe-ds-validator.ts | 2 +- DSL-langium/tests/grammar/IssueFinderTest.kt | 4 +- DSL-langium/tests/helpers/testMarker.ts | 4 +- DSL-langium/tests/helpers/testResources.ts | 4 +- DSL-langium/tsconfig.json | 14 ++----- .../XtextConfigurationDsl.kt | 4 +- 13 files changed, 45 insertions(+), 53 deletions(-) diff --git a/.mega-linter.yml b/.mega-linter.yml index 238af7c99..dfa6f3622 100644 --- a/.mega-linter.yml +++ b/.mega-linter.yml @@ -19,5 +19,5 @@ JSON_PRETTIER_FILE_EXTENSIONS: PRE_COMMANDS: - command: npm install @lars-reimann/eslint-config @lars-reimann/prettier-config cwd: workspace - - command: cd DSL-langium & npm run langium:generate + - command: cd DSL-langium && npm run langium:generate cwd: workspace diff --git a/DSL-langium/langium-config.json b/DSL-langium/langium-config.json index 5e315ed88..6ded9333a 100644 --- a/DSL-langium/langium-config.json +++ b/DSL-langium/langium-config.json @@ -1,12 +1,14 @@ { "projectName": "SafeDs", - "languages": [{ - "id": "safe-ds", - "grammar": "src/language-server/grammar/safe-ds.langium", - "fileExtensions": [".sdspipe", ".sdsschema", ".sdsstub", ".sdstest"], - "textMate": { - "out": "syntaxes/safe-ds.tmLanguage.json" + "languages": [ + { + "id": "safe-ds", + "grammar": "src/language-server/grammar/safe-ds.langium", + "fileExtensions": [".sdspipe", ".sdsschema", ".sdsstub", ".sdstest"], + "textMate": { + "out": "syntaxes/safe-ds.tmLanguage.json" + } } - }], + ], "out": "src/language-server/generated" } diff --git a/DSL-langium/language-configuration.json b/DSL-langium/language-configuration.json index 98b2e769a..b5e3d7dc2 100644 --- a/DSL-langium/language-configuration.json +++ b/DSL-langium/language-configuration.json @@ -1,7 +1,7 @@ { "comments": { "lineComment": "//", - "blockComment": [ "/*", "*/" ] + "blockComment": ["/*", "*/"] }, "brackets": [ ["{", "}"], diff --git a/DSL-langium/package.json b/DSL-langium/package.json index 4bc31bbb3..ae77a7f72 100644 --- a/DSL-langium/package.json +++ b/DSL-langium/package.json @@ -69,7 +69,6 @@ "devDependencies": { "@types/node": "~16.18.11", "@types/vscode": "~1.67.0", - "langium-cli": "~1.1.0", "typescript": "~4.9.5", "vitest": "^0.29.8" diff --git a/DSL-langium/src/cli/generator.ts b/DSL-langium/src/cli/generator.ts index 1dffb1443..2c6c8f9cd 100644 --- a/DSL-langium/src/cli/generator.ts +++ b/DSL-langium/src/cli/generator.ts @@ -17,4 +17,4 @@ export const generatePython = function (module: SdsModule, filePath: string, des } fs.writeFileSync(generatedFilePath, toString(fileNode)); return generatedFilePath; -} +}; diff --git a/DSL-langium/src/cli/index.ts b/DSL-langium/src/cli/index.ts index 2261cf978..c90cd83c1 100644 --- a/DSL-langium/src/cli/index.ts +++ b/DSL-langium/src/cli/index.ts @@ -17,10 +17,10 @@ export const generateAction = async (fileName: string, opts: GenerateOptions): P export type GenerateOptions = { destination?: string; -} +}; // eslint-disable-next-line import/no-default-export, func-names -export default function(): void { +export default function (): void { const program = new Command(); program diff --git a/DSL-langium/src/language-server/safe-ds-module.ts b/DSL-langium/src/language-server/safe-ds-module.ts index 23256922a..744db53b2 100644 --- a/DSL-langium/src/language-server/safe-ds-module.ts +++ b/DSL-langium/src/language-server/safe-ds-module.ts @@ -1,6 +1,12 @@ import { - createDefaultModule, createDefaultSharedModule, DefaultSharedModuleContext, inject, - LangiumServices, LangiumSharedServices, Module, PartialLangiumServices + createDefaultModule, + createDefaultSharedModule, + DefaultSharedModuleContext, + inject, + LangiumServices, + LangiumSharedServices, + Module, + PartialLangiumServices, } from 'langium'; import { SafeDsGeneratedModule, SafeDsGeneratedSharedModule } from './generated/module'; import { SafeDsValidator, registerValidationChecks } from './validation/safe-ds-validator'; @@ -10,15 +16,15 @@ import { SafeDsValidator, registerValidationChecks } from './validation/safe-ds- */ export type SafeDsAddedServices = { validation: { - SafeDsValidator: SafeDsValidator - } -} + SafeDsValidator: SafeDsValidator; + }; +}; /** * Union of Langium default services and your custom services - use this as constructor parameter * of custom service classes. */ -export type SafeDsServices = LangiumServices & SafeDsAddedServices +export type SafeDsServices = LangiumServices & SafeDsAddedServices; /** * Dependency injection module that overrides Langium default services and contributes the @@ -27,8 +33,8 @@ export type SafeDsServices = LangiumServices & SafeDsAddedServices */ export const SafeDsModule: Module = { validation: { - SafeDsValidator: () => new SafeDsValidator() - } + SafeDsValidator: () => new SafeDsValidator(), + }, }; /** @@ -47,19 +53,12 @@ export const SafeDsModule: Module { return path.join(resourcesPath, pathRelativeToResources); -} +}; /** * Lists all Safe-DS files in the given directory relative to `tests/resources/`. @@ -30,5 +30,5 @@ export const listTestResources = (pathRelativeToResources: string) => { const pattern = `**/*.{${fileExtensions.join(',')}}`; const cwd = resolvePathRelativeToResources(pathRelativeToResources); - return globSync(pattern, {cwd, nodir: true, withFileTypes: true}) + return globSync(pattern, { cwd, nodir: true, withFileTypes: true }); }; diff --git a/DSL-langium/tsconfig.json b/DSL-langium/tsconfig.json index 130dff9c6..577644349 100644 --- a/DSL-langium/tsconfig.json +++ b/DSL-langium/tsconfig.json @@ -2,9 +2,7 @@ "compilerOptions": { "target": "ES6", "module": "commonjs", - "lib": [ - "ESNext" - ], + "lib": ["ESNext"], "sourceMap": true, "outDir": "out", "strict": true, @@ -16,12 +14,6 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, - "include": [ - "src/**/*.ts", - "tests/**/*.ts" - ], - "exclude": [ - "out", - "node_modules" - ] + "include": ["src/**/*.ts", "tests/**/*.ts"], + "exclude": ["out", "node_modules"] } diff --git a/DSL/buildSrc/src/main/kotlin/com/larsreimann/safeds/xtextConfiguration/XtextConfigurationDsl.kt b/DSL/buildSrc/src/main/kotlin/com/larsreimann/safeds/xtextConfiguration/XtextConfigurationDsl.kt index 1299f9021..6f2ce6cb8 100644 --- a/DSL/buildSrc/src/main/kotlin/com/larsreimann/safeds/xtextConfiguration/XtextConfigurationDsl.kt +++ b/DSL/buildSrc/src/main/kotlin/com/larsreimann/safeds/xtextConfiguration/XtextConfigurationDsl.kt @@ -2,6 +2,7 @@ package com.larsreimann.safeds.xtextConfiguration +import io.typefox.xtext2langium.Xtext2LangiumFragment import org.eclipse.emf.mwe.utils.DirectoryCleaner import org.eclipse.emf.mwe.utils.ProjectMapping import org.eclipse.emf.mwe.utils.StandaloneSetup @@ -13,7 +14,6 @@ import org.eclipse.xtext.xtext.generator.DefaultGeneratorModule import org.eclipse.xtext.xtext.generator.StandardLanguage import org.eclipse.xtext.xtext.generator.XtextGenerator import org.eclipse.xtext.xtext.generator.model.project.StandardProjectConfig -import io.typefox.xtext2langium.Xtext2LangiumFragment fun workflow(init: Workflow.() -> Unit): Workflow { return Workflow().apply(init) @@ -74,7 +74,7 @@ fun StandardLanguage.xtext2langium(outputPath: String) { this.addFragment( Xtext2LangiumFragment().apply { setOutputPath(outputPath) - } + }, ) }