Skip to content

Commit

Permalink
made generation less restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
annekekleppe committed Jun 26, 2024
1 parent 6878673 commit d35ef75
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 41 deletions.
24 changes: 9 additions & 15 deletions packages/meta/src/commandline/FreonGenerateAllAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,10 @@ export class FreonGenerateAllAction extends FreonGenerateAction {
try {
if (this.typerFiles.length > 0) {
typer = new FreTyperMerger(this.language).parseMulti(this.typerFiles);
if (!!typer) {
this.typerGenerator.language = this.language;
this.typerGenerator.outputfolder = this.outputFolder;
this.typerGenerator.generate(typer);
}
}
this.typerGenerator.language = this.language;
this.typerGenerator.outputfolder = this.outputFolder;
this.typerGenerator.generate(typer);
} catch (e: unknown) {
if (e instanceof Error) {
LOG2USER.error("Stopping typer generation because of errors: " + e.message + "\n" + e.stack);
Expand Down Expand Up @@ -160,12 +158,10 @@ export class FreonGenerateAllAction extends FreonGenerateAction {
try {
if (this.scopeFiles.length > 0) {
scoper = new ScoperParser(this.language).parseMulti(this.scopeFiles);
if (!!scoper) {
this.scoperGenerator.language = this.language;
this.scoperGenerator.outputfolder = this.outputFolder;
this.scoperGenerator.generate(scoper);
}
}
this.scoperGenerator.language = this.language;
this.scoperGenerator.outputfolder = this.outputFolder;
this.scoperGenerator.generate(scoper);
} catch (e: unknown) {
if (e instanceof Error) {
LOG2USER.error("Stopping scoper generation because of errors: " + e.message + "\n" + e.stack);
Expand All @@ -183,12 +179,10 @@ export class FreonGenerateAllAction extends FreonGenerateAction {
try {
if (this.validFiles.length > 0) {
validator = new ValidatorParser(this.language).parseMulti(this.validFiles);
if (!!validator) {
this.validatorGenerator.language = this.language;
this.validatorGenerator.outputfolder = this.outputFolder;
this.validatorGenerator.generate(validator);
}
}
this.validatorGenerator.language = this.language;
this.validatorGenerator.outputfolder = this.outputFolder;
this.validatorGenerator.generate(validator);
} catch (e: unknown) {
if (e instanceof Error) {
LOG2USER.error("Stopping validator generation because of errors: " + e.message + "\n" + e.stack);
Expand Down
2 changes: 1 addition & 1 deletion packages/meta/src/commandline/FreonGenerateScoper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class FreonGenerateScoper extends FreonGeneratePartAction {
documentation:
"Generates TypeScript code for the scoper of language defined in the .ast files. " + "The scoper definition is found in the .scope files."
});
this.scoperGenerator = new ScoperGenerator();
}

generate(): void {
Expand All @@ -23,7 +24,6 @@ export class FreonGenerateScoper extends FreonGeneratePartAction {
if (this.language === null || this.language === undefined) {
return;
}
this.scoperGenerator = new ScoperGenerator();
this.scoperGenerator.language = this.language;
this.scoperGenerator.outputfolder = this.outputFolder;

Expand Down
12 changes: 6 additions & 6 deletions packages/meta/src/scoperdef/generator/ScoperGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ScoperGenerator {
protected scoperGenFolder: string = '';
protected scoperFolder: string = '';

generate(scopedef: ScopeDef): void {
generate(scopedef: ScopeDef | undefined): void {
if (this.language === null) {
LOGGER.error("Cannot generate scoper because language is not set.");
return;
Expand All @@ -29,14 +29,14 @@ export class ScoperGenerator {
scopedef.namespaces.push(MetaElementReference.create<FreMetaModelDescription>(this.language.modelConcept, "FreModelDescription"));
}

const generationStatus = new GenerationStatus();
const generationStatus: GenerationStatus = new GenerationStatus();
this.getFolderNames();
const name = scopedef ? scopedef.scoperName + " " : "";
const name: string = scopedef ? scopedef.scoperName + " " : "";
LOGGER.log("Generating scoper " + name + "in folder " + this.scoperGenFolder);

const scoper = new ScoperTemplate();
const scoperDefTemplate = new ScoperDefTemplate();
const customScoperTemplate = new CustomScoperTemplate();
const scoper: ScoperTemplate = new ScoperTemplate();
const scoperDefTemplate: ScoperDefTemplate = new ScoperDefTemplate();
const customScoperTemplate: CustomScoperTemplate = new CustomScoperTemplate();

// Prepare folders
FileUtil.createDirIfNotExisting(this.scoperFolder);
Expand Down
4 changes: 2 additions & 2 deletions packages/meta/src/typerdef/generator/FreonTyperGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LOG2USER } from "../../utils/UserLogger";
import { FreTypeConceptMaker } from "./templates/FreTypeConceptMaker";
import { TyperDefTemplate } from "./templates/TyperDefTemplate";

const LOGGER = new MetaLogger("FreonTyperGenerator").mute();
const LOGGER = new MetaLogger("FreonTyperGenerator");

/**
* This class generates the implementation for a typer definition.
Expand All @@ -23,7 +23,7 @@ export class FreonTyperGenerator {
protected typerConceptsFolder: string = '';
protected typerFolder: string = '';

generate(typerdef: TyperDef): void {
generate(typerdef: TyperDef | undefined): void {
if (this.language === null) {
LOGGER.error("Cannot generate typer because language is not set.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class FreTyperPartTemplate {
imports: string[] = [];
importedClassifiers: FreMetaClassifier[] = []; // holds all classifiers that need to be imported, either from LANGUAGE_GEN_FOLDER, or from TYPER_CONCEPTS_FOLDER

generateTyperPart(language: FreMetaLanguage, typerdef: TyperDef, relativePath: string): string {
generateTyperPart(language: FreMetaLanguage, typerdef: TyperDef | undefined, relativePath: string): string {
if (!!typerdef) {
return this.generateFromDefinition(typerdef, language, relativePath);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ValidatorGenerator {
protected validatorGenFolder: string = '';
protected validatorFolder: string = '';

generate(validdef: ValidatorDef): void {
generate(validdef: ValidatorDef| undefined): void {
if (this.language === null) {
LOGGER.error("Cannot generate validator because language is not set.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class ValidatorTemplate {
validatorInterfaceName: string = Names.FreValidator;
typerInterfaceName: string = Names.FreTyper;

generateValidator(language: FreMetaLanguage, validdef: ValidatorDef, relativePath: string): string {
const doValidDef = validdef !== null && validdef !== undefined;
generateValidator(language: FreMetaLanguage, validdef: ValidatorDef | undefined, relativePath: string): string {
const doValidDef: boolean = validdef !== null && validdef !== undefined;

const allLangConcepts: string = Names.allConcepts();
const generatedClassName: string = Names.validator(language);
Expand Down Expand Up @@ -101,7 +101,7 @@ export class ValidatorTemplate {
}`;
}

generateGenIndex(language: FreMetaLanguage, validdef: ValidatorDef): string {
generateGenIndex(language: FreMetaLanguage, validdef: ValidatorDef | undefined): string {
return `
export * from "./${Names.nonOptionalsChecker(language)}";
export * from "./${Names.validator(language)}";
Expand Down
2 changes: 1 addition & 1 deletion packages/meta/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
// "strict": true, /* Enable all strict type-checking options. */
// "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* Enable strict null checks. */
"strictFunctionTypes": true, /* Enable strict checking of function types. */
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/Calculator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/DocuProject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/Education/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/MpsExpressions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/Octopus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/PiLanguage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/TaxRules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/UndoTester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "npm run generate && tsc && rollup --config",
"install-local": "npm install --registry http://localhost:4873",
"generate": "bash ../../../scripts/freon-samples-dev.sh -v all -d src/defs -o src/",
"clean-gen": "bash ../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-gen": "bash ../../../scripts/freon-samples-dev.sh clean-it -d src/defs -o src/",
"clean-config": "rm */config/FreonConfiguration.ts",
"clean-custom": "rm */*/Custom*.ts",
"clean-all": "npm run clean-gen && npm run clean-config && npm run clean-custom"
Expand Down
4 changes: 2 additions & 2 deletions packages/webapp-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"!dist/**/*.spec.*"
],
"dependencies": {
"@freon4dsl/core": "0.7.0-beta"
"@freon4dsl/core": "0.7.0-beta",
"svelte": "^4.2.17"
},
"devDependencies": {
"@material/theme": "^14.0.0",
Expand Down Expand Up @@ -81,7 +82,6 @@
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"publint": "^0.2.8",
"sass": "^1.77.6",
"svelte": "^4.2.17",
"svelte-check": "^3.8.0",
"typescript": "^5.4.5",
"vite": "^5.2.12"
Expand Down

0 comments on commit d35ef75

Please sign in to comment.