Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,51 @@
package com.avaloq.tools.ddk.check.ui.builder;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.xtext.xbase.ui.builder.XbaseBuilderConfigurationBlock;

import com.avaloq.tools.ddk.xtext.ui.BuilderParticipantMasterSwitch;


/**
* UI for configuring Check compiler.
* UI for configuring Check compiler. Adds the workspace-wide DDK generation master switch on top of the stock options.
*/
@SuppressWarnings("restriction")
public class CheckBuilderConfigurationBlock extends XbaseBuilderConfigurationBlock {

private BuilderParticipantMasterSwitch masterSwitch;

@Override
protected Control doCreateContents(final Composite parent) {
if (getProject() != null) {
return super.doCreateContents(parent); // project property page: the master switch is workspace-wide only
}
masterSwitch = new BuilderParticipantMasterSwitch(parent, super::doCreateContents);
return masterSwitch.getControl();
}

@Override
protected void createGeneralSectionItems(final Composite composite) {
super.createGeneralSectionItems(composite);
addCheckBox(composite, "Generate as DSL internal checks (not SCA plugin)", CheckBuilderPreferenceAccess.PREF_GENERATE_LANGUAGE_INTERNAL_CHECKS, BOOLEAN_VALUES, 0); //$NON-NLS-1$
}

@Override
public boolean performOk() {
final boolean rebuildRequired = masterSwitch != null && masterSwitch.save();
final boolean result = super.performOk();
if (rebuildRequired) {
getBuildJob(getProject()).schedule(); // re-enabling generation: rebuild to catch up on changes made while it was off
}
return result;
}

@Override
public void performDefaults() {
if (masterSwitch != null) {
masterSwitch.restoreDefaults();
}
super.performDefaults();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class CheckBuilderParticipant extends ConditionalBuilderParticipant {

@Override
public void build(final IBuildContext context, final IProgressMonitor monitor) throws CoreException {
if (!isBuilderParticipantEnabled() && context.getBuildType() != BuildType.CLEAN) {
return;
}
if (!isEnabled(context)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.builder;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;


/**
* Access to the workspace-wide setting that disables code generation by the builder participants of all DDK languages at once. The setting is shared by all DDK
* languages (a single boolean in the {@code com.avaloq.tools.ddk} instance preference node) and is surfaced as the master switch on each language's Compiler
* preference page. As a plain boolean preference it defaults to {@code false} (generation enabled), so behavior is unchanged unless a user opts in.
*/
public final class BuilderParticipantSettings {

/** Preference node shared by all DDK languages. */
public static final String QUALIFIER = "com.avaloq.tools.ddk"; //$NON-NLS-1$

/** Boolean preference key; {@code true} disables generation by all DDK builder participants on workspace builds. */
public static final String PREF_DISABLE_BUILDER_PARTICIPANTS = "disableBuilderParticipants"; //$NON-NLS-1$

private static final Logger LOGGER = LogManager.getLogger(BuilderParticipantSettings.class);

private BuilderParticipantSettings() {
// static utility
}

/**
* Returns whether generation by the DDK builder participants is disabled workspace-wide.
*
* @return {@code true} if the master switch disables generation, {@code false} otherwise (the default)
*/
public static boolean isGenerationDisabled() {
return InstanceScope.INSTANCE.getNode(QUALIFIER).getBoolean(PREF_DISABLE_BUILDER_PARTICIPANTS, false);
}

/**
* Sets whether generation by the DDK builder participants is disabled workspace-wide.
*
* @param disabled
* {@code true} to disable generation for all DDK languages, {@code false} to re-enable it
*/
public static void setGenerationDisabled(final boolean disabled) {
final Preferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
node.putBoolean(PREF_DISABLE_BUILDER_PARTICIPANTS, disabled);
try {
node.flush();
} catch (BackingStoreException e) {
LOGGER.error("Could not persist the DDK builder participant master switch", e); //$NON-NLS-1$
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.builder;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.xtext.builder.BuilderParticipant;
import org.eclipse.xtext.resource.IResourceDescription.Delta;
import org.eclipse.xtext.resource.IResourceServiceProvider;
Expand All @@ -22,6 +24,29 @@ public class ConditionalBuilderParticipant extends BuilderParticipant {

private static final String GENERATION_FILE_SRC_DIRECTORY = "src"; //$NON-NLS-1$

@Override
public void build(final IBuildContext context, final IProgressMonitor monitor) throws CoreException {
if (!isBuilderParticipantEnabled() && context.getBuildType() != BuildType.CLEAN) {
return;
}
super.build(context, monitor);
}

/**
* Determines whether DDK builder participants should regenerate their artifacts on workspace builds. Disabled workspace-wide for all DDK languages at once by
* the master switch on the languages' Compiler preference pages (see {@link BuilderParticipantSettings}); enabled by default.
* <p>
* Note that the switch governs every {@code ConditionalBuilderParticipant} descendant that delegates to {@code super.build(...)} — including participants of
* downstream languages built on this class. Subclasses overriding {@link #build(IBuildContext, IProgressMonitor)} without delegating to {@code super} must
* check this method themselves to be covered by the switch. Explicit {@code CLEAN} builds are exempt from the gate: while the switch disables regeneration, a
* Project &gt; Clean still deletes the generated artifacts (which then stay deleted until the switch is re-enabled).
*
* @return {@code true} if generation should run, {@code false} if the DDK-wide master switch disables it
*/
protected boolean isBuilderParticipantEnabled() {
return !BuilderParticipantSettings.isGenerationDisabled();
}

/**
* Checks whether {@link BuilderParticipant} should run for a given {@link Delta} and it has no errors.
*
Expand Down
1 change: 1 addition & 0 deletions com.avaloq.tools.ddk.xtext.export.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Require-Bundle: org.eclipse.xtext.ui,
org.eclipse.ui.editors,
org.eclipse.ui,
org.eclipse.xtext.builder,
com.avaloq.tools.ddk.xtext.builder,
org.antlr.runtime,
com.avaloq.tools.ddk.xtext.expression.ui,
com.avaloq.tools.ddk.xtext.export,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@
package com.avaloq.tools.ddk.xtext.export.ui;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.builder.IXtextBuilderParticipant;
import org.eclipse.xtext.builder.preferences.BuilderConfigurationBlock;
import org.eclipse.xtext.ui.editor.outline.impl.OutlineFilterAndSorter.IComparator;
import org.eclipse.xtext.ui.editor.templates.CrossReferenceTemplateVariableResolver;

import com.avaloq.tools.ddk.xtext.export.ui.builder.ExportBuilderConfigurationBlock;
import com.avaloq.tools.ddk.xtext.export.ui.builder.ExportBuilderParticipant;
import com.avaloq.tools.ddk.xtext.export.ui.outline.ExportOutlineNodeComparator;
import com.avaloq.tools.ddk.xtext.ui.templates.KeywordAwareCrossReferenceTemplateVariableResolver;


/**
* Use this class to register components to be used within the IDE.
*/
@SuppressWarnings("restriction")
public class ExportUiModule extends com.avaloq.tools.ddk.xtext.export.ui.AbstractExportUiModule {
public ExportUiModule(final AbstractUIPlugin plugin) {
super(plugin);
Expand All @@ -41,4 +46,23 @@ public Class<? extends CrossReferenceTemplateVariableResolver> bindCrossReferenc
// CHECKSTYLE:ON
return ExportOutlineNodeComparator.class;
}

/**
* Binds the Export builder participant, which honors the per-language preference allowing regeneration to be disabled on a workspace build.
*
* @return the {@link ExportBuilderParticipant} class
*/
@Override
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
return ExportBuilderParticipant.class;
}

/**
* Binds the Export builder configuration block, which contributes the "disable the builder participant on workspace build" checkbox to the Compiler page.
*
* @return the {@link ExportBuilderConfigurationBlock} class
*/
public Class<? extends BuilderConfigurationBlock> bindBuilderConfigurationBlock() {
return ExportBuilderConfigurationBlock.class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.export.ui.builder;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.xtext.builder.preferences.BuilderConfigurationBlock;

import com.avaloq.tools.ddk.xtext.ui.BuilderParticipantMasterSwitch;


/**
* UI for configuring the Export compiler. Adds the workspace-wide DDK generation master switch on top of the stock options.
*/
@SuppressWarnings("restriction")
public class ExportBuilderConfigurationBlock extends BuilderConfigurationBlock {

private BuilderParticipantMasterSwitch masterSwitch;

@Override
protected Control doCreateContents(final Composite parent) {
if (getProject() != null) {
return super.doCreateContents(parent); // project property page: the master switch is workspace-wide only
}
masterSwitch = new BuilderParticipantMasterSwitch(parent, super::doCreateContents);
return masterSwitch.getControl();
}

@Override
public boolean performOk() {
final boolean rebuildRequired = masterSwitch != null && masterSwitch.save();
final boolean result = super.performOk();
if (rebuildRequired) {
getBuildJob(getProject()).schedule(); // re-enabling generation: rebuild to catch up on changes made while it was off
}
return result;
}

@Override
public void performDefaults() {
if (masterSwitch != null) {
masterSwitch.restoreDefaults();
}
super.performDefaults();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.xtext.export.ui.builder;

import com.avaloq.tools.ddk.xtext.builder.ConditionalBuilderParticipant;


/**
* A builder participant for the Export language. Honors the workspace-wide DDK master switch that disables regeneration of the generated artifacts on workspace
* builds (see {@link ConditionalBuilderParticipant#isBuilderParticipantEnabled()}).
*/
public class ExportBuilderParticipant extends ConditionalBuilderParticipant {

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.xtext.builder.IXtextBuilderParticipant;
import org.eclipse.xtext.builder.preferences.BuilderConfigurationBlock;
import org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper;
import org.eclipse.xtext.ui.editor.templates.CrossReferenceTemplateVariableResolver;
import org.eclipse.xtext.xtext.generator.model.project.IXtextProjectConfig;
import org.eclipse.xtext.xtext.generator.model.project.XtextProjectConfig;

import com.avaloq.tools.ddk.xtext.format.ui.builder.FormatBuilderConfigurationBlock;
import com.avaloq.tools.ddk.xtext.format.ui.builder.FormatBuilderParticipant;
import com.avaloq.tools.ddk.xtext.format.ui.hyperlinking.FormatHyperlinkHelper;
import com.avaloq.tools.ddk.xtext.ui.templates.KeywordAwareCrossReferenceTemplateVariableResolver;
Expand All @@ -25,6 +27,7 @@
/**
* Use this class to register components to be used within the Eclipse IDE.
*/
@SuppressWarnings("restriction")
public class FormatUiModule extends AbstractFormatUiModule {

public FormatUiModule(final AbstractUIPlugin plugin) {
Expand Down Expand Up @@ -55,6 +58,17 @@ public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant()
return FormatBuilderParticipant.class;
}

/**
* Binds the Format-specific builder configuration block, which contributes the "disable the builder participant on workspace build" checkbox to the Compiler
* page.
*
* @return the Format builder configuration block
*/
@Override
public Class<? extends BuilderConfigurationBlock> bindBuilderConfigurationBlock() {
return FormatBuilderConfigurationBlock.class;
}

@Override
public void configure(final Binder binder) {
super.configure(binder);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/

package com.avaloq.tools.ddk.xtext.format.ui.builder;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.xtext.xbase.ui.builder.XbaseBuilderConfigurationBlock;

import com.avaloq.tools.ddk.xtext.ui.BuilderParticipantMasterSwitch;


/**
* UI for configuring the Format compiler. Adds the workspace-wide DDK generation master switch on top of the stock options.
*/
@SuppressWarnings("restriction")
public class FormatBuilderConfigurationBlock extends XbaseBuilderConfigurationBlock {

private BuilderParticipantMasterSwitch masterSwitch;

@Override
protected Control doCreateContents(final Composite parent) {
if (getProject() != null) {
return super.doCreateContents(parent); // project property page: the master switch is workspace-wide only
}
masterSwitch = new BuilderParticipantMasterSwitch(parent, super::doCreateContents);
return masterSwitch.getControl();
}

@Override
public boolean performOk() {
final boolean rebuildRequired = masterSwitch != null && masterSwitch.save();
final boolean result = super.performOk();
if (rebuildRequired) {
getBuildJob(getProject()).schedule(); // re-enabling generation: rebuild to catch up on changes made while it was off
}
return result;
}

@Override
public void performDefaults() {
if (masterSwitch != null) {
masterSwitch.restoreDefaults();
}
super.performDefaults();
}

}
Loading