Skip to content

Commit

Permalink
Merge pull request #403 from freon4dsl/fix-brackets
Browse files Browse the repository at this point in the history
Bracket projections did not work anymore.
  • Loading branch information
joswarmer authored Nov 18, 2024
2 parents 0784709 + a0d2593 commit 04b8fe5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/core-svelte/src/lib/styles/freon-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,7 @@ dropdown-component {
.text-dropdown-component .text-component-text {
color: lightgreen;
}

.brackets {
color: gray;
}
4 changes: 4 additions & 0 deletions packages/core-svelte/src/lib/styles/freon-light.css
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,7 @@
.text-dropdown-component .text-component-input {
color: green;
}

.brackets {
color: darkgray;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import {
} from "./boxproviderhelpers/index.js";

export class BoxProviderTemplate {
// To be able to add a projections for showing/hiding brackets to binary expression, this dummy projection is used.
private static dummyProjection: FreEditNormalProjection = new FreEditNormalProjection();
// To be able to add a projections for showing/hiding brackets to binary expression, this projection is used.
private static bracketProjection: FreEditNormalProjection = new FreEditNormalProjection();
// The classes, functions, etc. to import are collected during the creation of the content for the generated file,
// to avoid unused imports. All imports are stored in the following three variables.
public modelImports: string[] = []; // imports from ../language/gen
Expand Down Expand Up @@ -106,6 +106,15 @@ export class BoxProviderTemplate {
ListUtil.addListIfNotPresent(allProjections, myBoxProjections);
ListUtil.addListIfNotPresent(allProjections, myTableProjections);

if (concept instanceof FreMetaBinaryExpressionConcept) {
// if concept is a binary expression, handle it differently
// add the projection to show/hide brackets
BoxProviderTemplate.bracketProjection.name = Names.brackets;
myBoxProjections.splice(0, 0, BoxProviderTemplate.bracketProjection);
}
ListUtil.addListIfNotPresent(allProjections, myBoxProjections);
ListUtil.addListIfNotPresent(allProjections, myTableProjections);

// build the core of the box provider class, to be used in the template
const coreText: string = new BoxProviderCoreTextTemplate().generateCoreTemplate(
myBoxProjections,
Expand All @@ -125,10 +134,6 @@ export class BoxProviderTemplate {
// build the text for the box projections or the special text for the binary expressions
let boxText: string;
if (concept instanceof FreMetaBinaryExpressionConcept) {
// if concept is a binary expression, handle it differently
// add the projection to show/hide brackets
BoxProviderTemplate.dummyProjection.name = Names.brackets;
myBoxProjections.splice(0, 0, BoxProviderTemplate.dummyProjection);
boxText = this.generateForBinExp(language, editDef.getDefaultProjectiongroup()?.findExtrasForType(concept));
} else {
boxText = myBoxProjections
Expand Down Expand Up @@ -241,9 +246,9 @@ export class BoxProviderTemplate {
isFreBinaryExpression(this._node.freOwnerDescriptor().owner)
) {
return BoxFactory.horizontalLayout(this._node, "brackets", '', [
BoxUtil.labelBox(this._node, "(", "bracket-open", {selectable: true} ),
BoxUtil.labelBox(this._node, "(", "bracket-open", {selectable: false, cssClass: "brackets"} ),
binBox,
BoxUtil.labelBox(this._node, ")", "bracket-close", {selectable: true} )
BoxUtil.labelBox(this._node, ")", "bracket-close", {selectable: false, cssClass: "brackets"} )
]);
} else {
return binBox;
Expand Down

0 comments on commit 04b8fe5

Please sign in to comment.