Skip to content

Commit

Permalink
ci: another try to generate langium files before linting
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Apr 7, 2023
1 parent 906e7bd commit 2e85b86
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 install langium && npm run langium:generate
cwd: workspace
16 changes: 9 additions & 7 deletions DSL-langium/langium-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion DSL-langium/language-configuration.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
Expand Down
1 change: 0 additions & 1 deletion DSL-langium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion DSL-langium/src/cli/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export const generatePython = function (module: SdsModule, filePath: string, des
}
fs.writeFileSync(generatedFilePath, toString(fileNode));
return generatedFilePath;
}
};
4 changes: 2 additions & 2 deletions DSL-langium/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 19 additions & 20 deletions DSL-langium/src/language-server/safe-ds-module.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand All @@ -27,8 +33,8 @@ export type SafeDsServices = LangiumServices & SafeDsAddedServices
*/
export const SafeDsModule: Module<SafeDsServices, PartialLangiumServices & SafeDsAddedServices> = {
validation: {
SafeDsValidator: () => new SafeDsValidator()
}
SafeDsValidator: () => new SafeDsValidator(),
},
};

/**
Expand All @@ -47,19 +53,12 @@ export const SafeDsModule: Module<SafeDsServices, PartialLangiumServices & SafeD
* @returns An object wrapping the shared services and the language-specific services
*/
export const createSafeDsServices = function (context: DefaultSharedModuleContext): {
shared: LangiumSharedServices,
SafeDs: SafeDsServices
shared: LangiumSharedServices;
SafeDs: SafeDsServices;
} {
const shared = inject(
createDefaultSharedModule(context),
SafeDsGeneratedSharedModule
);
const SafeDs = inject(
createDefaultModule({ shared }),
SafeDsGeneratedModule,
SafeDsModule
);
const shared = inject(createDefaultSharedModule(context), SafeDsGeneratedSharedModule);
const SafeDs = inject(createDefaultModule({ shared }), SafeDsGeneratedModule, SafeDsModule);
shared.ServiceRegistry.register(SafeDs);
registerValidationChecks(SafeDs);
return { shared, SafeDs };
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const registerValidationChecks = function (services: SafeDsServices) {
// Person: validator.checkPersonStartsWithCapital
};
registry.register(checks, validator);
}
};

/**
* Implementation of custom validations.
Expand Down
4 changes: 2 additions & 2 deletions DSL-langium/tests/grammar/IssueFinderTest.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//class IssueFinderTest {
// class IssueFinderTest {
//
// @com.google.inject.Inject
// private lateinit var parseHelper: com.larsreimann.safeds.testing.ParseHelper
Expand Down Expand Up @@ -160,4 +160,4 @@
// parsingResult.eResource().eAdapters().add(com.larsreimann.safeds.emf.OriginalFilePath(filePath.toString()))
// return validationHelper.validate(parsingResult)
// }
//}
// }
4 changes: 2 additions & 2 deletions DSL-langium/tests/helpers/testMarker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Opening test marker.
*/
export const OPEN = '\u00BB' // »
export const OPEN = '\u00BB'; // »

/**
* Closing test marker.
*/
export const CLOSE = '\u00AB' // «
export const CLOSE = '\u00AB'; // «
4 changes: 2 additions & 2 deletions DSL-langium/tests/helpers/testResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const resourcesPath = path.join(__dirname, '..', 'resources');
*/
export const resolvePathRelativeToResources = (pathRelativeToResources: string) => {
return path.join(resourcesPath, pathRelativeToResources);
}
};

/**
* Lists all Safe-DS files in the given directory relative to `tests/resources/`.
Expand All @@ -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 });
};
14 changes: 3 additions & 11 deletions DSL-langium/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"lib": [
"ESNext"
],
"lib": ["ESNext"],
"sourceMap": true,
"outDir": "out",
"strict": true,
Expand All @@ -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"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -74,7 +74,7 @@ fun StandardLanguage.xtext2langium(outputPath: String) {
this.addFragment(
Xtext2LangiumFragment().apply {
setOutputPath(outputPath)
}
},
)
}

Expand Down

0 comments on commit 2e85b86

Please sign in to comment.