diff --git a/build.gradle b/build.gradle index a3589eaa..64f5adbb 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,8 @@ def allInitDependencies = [ 'coderules:solutions:jetbrains.mps.logic.reactor:copyDependencies', 'coderules:solutions:jetbrains.mps.logic.test:copyDependencies', 'coderules:solutions:jetbrains.mps.coderules.typechecking:copyDependencies', - 'coderules:solutions:jetbrains.mps.coderules:copyDependencies' ] + 'coderules:solutions:jetbrains.mps.coderules:copyDependencies', + 'coderules:solutions:jetbrains.mps.coderules.ideaplugin:makeDependencies' ] task setup(dependsOn: allInitDependencies) { doLast { diff --git a/build.xml b/build.xml index a1995fbd..39becda4 100644 --- a/build.xml +++ b/build.xml @@ -43,6 +43,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1407,35 +1442,29 @@ - - - + + + - - - - - - - - - - - - - + + + + + + + - + - + @@ -1445,8 +1474,8 @@ - - + + @@ -2559,35 +2588,29 @@ - - - + + + - - - - - - - - - - - - - + + + + + + + - + - + @@ -2597,8 +2620,8 @@ - - + + @@ -3486,7 +3509,7 @@ - + @@ -3637,7 +3660,7 @@ - + @@ -3693,7 +3716,7 @@ - + @@ -3727,6 +3750,24 @@ + + + + + + + + + + + + + + + + + + @@ -4088,7 +4129,7 @@ - + @@ -4163,6 +4204,7 @@ + @@ -4317,7 +4359,7 @@ - + @@ -4352,6 +4394,7 @@ + @@ -4399,7 +4442,7 @@ - + @@ -4434,6 +4477,7 @@ + @@ -4480,7 +4524,7 @@ - + @@ -4515,6 +4559,7 @@ + @@ -4620,7 +4665,7 @@ - + @@ -4655,6 +4700,7 @@ + @@ -4699,7 +4745,7 @@ - + @@ -4734,6 +4780,7 @@ + @@ -4833,7 +4880,7 @@ - + @@ -4869,6 +4916,7 @@ + @@ -5464,7 +5512,7 @@ - + @@ -5473,8 +5521,11 @@ - + + + + @@ -5493,8 +5544,6 @@ - - @@ -5508,11 +5557,11 @@ + - @@ -5577,7 +5626,7 @@ - + @@ -5613,6 +5662,7 @@ + @@ -5788,7 +5838,7 @@ - + diff --git a/coderules/solutions/jetbrains.mps.coderules.build/models/jetbrains.mps.coderules.build.mps b/coderules/solutions/jetbrains.mps.coderules.build/models/jetbrains.mps.coderules.build.mps index c2d33890..e89e7d00 100644 --- a/coderules/solutions/jetbrains.mps.coderules.build/models/jetbrains.mps.coderules.build.mps +++ b/coderules/solutions/jetbrains.mps.coderules.build/models/jetbrains.mps.coderules.build.mps @@ -455,7 +455,7 @@ - + @@ -481,7 +481,6 @@ - @@ -489,8 +488,8 @@ - - + + @@ -549,8 +548,8 @@ - - + + @@ -3660,6 +3659,16 @@ + + + + + + + + + + @@ -3716,8 +3725,27 @@ - + + + + + + + + + + + + + + + + + + + + @@ -3959,8 +3987,27 @@ - + + + + + + + + + + + + + + + + + + + + diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/build.gradle b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/build.gradle new file mode 100644 index 00000000..befe08cf --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/build.gradle @@ -0,0 +1,12 @@ +configurations { + codeRules +} + +dependencies { +} + +task makeDependencies (type: JavaCompile) { + source = fileTree(dir: 'source', include: '**/*.java') + destinationDirectory = file('classes') + classpath = fileTree(dir: '../../../MPS_HOME/lib', include: '**/*.jar') +} diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/jetbrains.mps.coderules.ideaplugin.msd b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/jetbrains.mps.coderules.ideaplugin.msd index a7af056d..d69d184a 100644 --- a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/jetbrains.mps.coderules.ideaplugin.msd +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/jetbrains.mps.coderules.ideaplugin.msd @@ -1,15 +1,21 @@ - + + + + - + + + + 3f233e7f-b8a6-46d2-a57f-795d56775243(Annotations) diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/models/jetbrains.mps.coderules.ideaplugin.mps b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/models/jetbrains.mps.coderules.ideaplugin.mps index 941474c1..695bd105 100644 --- a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/models/jetbrains.mps.coderules.ideaplugin.mps +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/models/jetbrains.mps.coderules.ideaplugin.mps @@ -1,6 +1,7 @@ + diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/CoderulesOptions.java b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/CoderulesOptions.java new file mode 100644 index 00000000..08b97fa6 --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/CoderulesOptions.java @@ -0,0 +1,17 @@ +package jetbrains.mps.coderules.ideaplugin; + +/*Generated by MPS */ + + +public class CoderulesOptions { + public static final String PREFIX = "mps.coderules."; + + public static void registerDefaultProviders(Config config) { + config.registerProvider(Config.Level.USER, PREFIX, (String key) -> { + + return null; + + }); + } + +} diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/Config.java b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/Config.java new file mode 100644 index 00000000..4dbc63ad --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/Config.java @@ -0,0 +1,247 @@ +package jetbrains.mps.coderules.ideaplugin; + +/*Generated by MPS */ + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import jetbrains.mps.internal.collections.runtime.MapSequence; +import jetbrains.mps.internal.collections.runtime.ListSequence; +import java.util.ArrayList; + +/** + * Represents options as key-value pairs. Supports traditional levels of overrides: default/system/user/ui. + * Every level allows any number of providers, each responsible for a specific key prefix. + */ +public class Config { + + /** + * DEFAULT - options built in into code + * SYSTEM - options delivered with the app + * USER - options overridden by user + * UI - options overridden in the UI + */ + public enum Level { + DEFAULT(), + SYSTEM(), + USER(), + UI(), + TEST() + } + + public interface OptionsProvider { + + Object getOption(String key); + + } + + public interface Option { + + T get(Config config); + + } + + private static Config INSTANCE = null; + + public static void init() { + if (INSTANCE == null) { + INSTANCE = new Config(new EffectiveOptions()); + } + } + + public static void dispose() { + INSTANCE.clearAll(); + INSTANCE = null; + } + + /** + * Returns the instance to share the default (hardcoded) options. + * + * @deprecated + */ + @Deprecated + public static Config getInstance() { + return INSTANCE; + } + + /** + * Returns a copy of this instance with the state that is not shared. All updates to either this or the + * returned instance will not reflect in the other one. + */ + public Config copy() { + return new Config(effectiveOptions); + } + + /** + * Creates new instance with hardcoded default options. + * Used from tests. + */ + public static Config create() { + return new Config(new EffectiveOptions()); + } + + /** + * Used from tests. + */ + public void reset(Level lvl) { + this.effectiveOptions = effectiveOptions.reset(lvl); + } + + /** + * A prefix is defined as a string matching the following RE: "([a-zA-Z0-9]*\.)+" . + */ + public void registerProvider(Level level, String prefix, OptionsProvider provider) { + this.effectiveOptions = effectiveOptions.registerProvider(level, prefix, provider); + } + + public void clearProvider(Level lvl, String prefix) { + this.effectiveOptions = effectiveOptions.clearProvider(lvl, prefix); + } + + public final Object getOption(String key) { + return effectiveOptions.getOption(key); + } + + protected void clearAll() { + if (effectiveOptions != null) { + effectiveOptions.clearAll(); + } + } + + private Config(EffectiveOptions options) { + this.effectiveOptions = options; + } + + private static class Options { + + protected Options() { + this.prefix2provider = new HashMap<>(); + } + + private Options(Options copyFrom) { + this.prefix2provider = new HashMap(copyFrom.prefix2provider); + } + + protected final Object primGetOption(String key, List allPrefixes) { + OptionsProvider lookupProvider = lookupProvider(allPrefixes); + if (lookupProvider != null) { + Object option = lookupProvider.getOption(key); + if (option != null) { + return option; + } + } + return null; + } + + protected Options putProvider(String prefix, OptionsProvider provider) { + Options newOptions = new Options(this); + newOptions.prefix2provider.put(prefix, provider); + return newOptions; + } + + protected Options clearProvider(String prefix) { + Options newOptions = new Options(this); + newOptions.prefix2provider.remove(prefix); + return newOptions; + } + + protected OptionsProvider lookupProvider(List prefixes) { + for (String p : prefixes) { + if (prefix2provider.containsKey(p)) { + return prefix2provider.get(p); + } + } + return null; + } + + private Map prefix2provider; + + } + + private static class EffectiveOptions { + + protected EffectiveOptions() { + this.allOptions = MapSequence.fromMap(new HashMap()); + for (Config.Level lvl : Config.Level.values()) { + MapSequence.fromMap(allOptions).put(lvl, new Options()); + } + } + + private EffectiveOptions(EffectiveOptions copyFrom) { + this.allOptions = new HashMap(copyFrom.allOptions); + } + + protected Object getOption(String key) { + List allPrefixes = allPrefixes(key); + for (int i = Config.Level.values().length - 1; i >= 0; i--) { + Config.Level level = Config.Level.values()[i]; + Object option = check_gqj4j5_a0b0b0f33(MapSequence.fromMap(allOptions).get(level), key, allPrefixes); + if (option != null) { + return option; + } + } + return null; + } + + protected final EffectiveOptions reset(Config.Level startFrom) { + EffectiveOptions newEffOptions = new EffectiveOptions(this); + for (Config.Level lvl : Config.Level.values()) { + if (lvl.ordinal() >= startFrom.ordinal()) { + MapSequence.fromMap(newEffOptions.allOptions).put(lvl, new Options()); + } + } + return newEffOptions; + } + + protected EffectiveOptions registerProvider(Config.Level level, String prefix, OptionsProvider provider) { + EffectiveOptions newEffOptions = new EffectiveOptions(this); + MapSequence.fromMap(newEffOptions.allOptions).put(level, check_gqj4j5_a0b0j33(MapSequence.fromMap(newEffOptions.allOptions).get(level), prefix, provider)); + return newEffOptions; + } + + protected EffectiveOptions clearProvider(Config.Level level, String prefix) { + EffectiveOptions newEffOptions = new EffectiveOptions(this); + MapSequence.fromMap(newEffOptions.allOptions).put(level, check_gqj4j5_a0b0l33(MapSequence.fromMap(newEffOptions.allOptions).get(level), prefix)); + return newEffOptions; + } + + protected void clearAll() { + MapSequence.fromMap(allOptions).clear(); + } + + private List allPrefixes(String key) { + List result = ListSequence.fromList(new ArrayList()); + while (key.length() > 0) { + int lastDot = key.lastIndexOf("."); + if (lastDot < 0) { + break; + } + ListSequence.fromList(result).addElement(key.substring(0, lastDot + 1)); + key = key.substring(0, lastDot); + } + return result; + } + + private Map allOptions; + private static Object check_gqj4j5_a0b0b0f33(Options checkedDotOperand, String key, List allPrefixes) { + if (null != checkedDotOperand) { + return checkedDotOperand.primGetOption(key, allPrefixes); + } + return null; + } + private static Options check_gqj4j5_a0b0j33(Options checkedDotOperand, String prefix, OptionsProvider provider) { + if (null != checkedDotOperand) { + return checkedDotOperand.putProvider(prefix, provider); + } + return null; + } + private static Options check_gqj4j5_a0b0l33(Options checkedDotOperand, String prefix) { + if (null != checkedDotOperand) { + return checkedDotOperand.clearProvider(prefix); + } + return null; + } + } + + private EffectiveOptions effectiveOptions; +} diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingOptions.java b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingOptions.java new file mode 100644 index 00000000..35bb32b1 --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingOptions.java @@ -0,0 +1,125 @@ +package jetbrains.mps.coderules.ideaplugin; + +/*Generated by MPS */ + +import java.util.Map; +import jetbrains.mps.internal.collections.runtime.MapSequence; + +public class TypecheckingOptions { + public static final String PREFIX = "mps.coderules.typechecking."; + + public static final String OPTION_TYPECHECKING_ENABLED = "mps.coderules.typechecking.enabled"; + public static final String OPTION_TYPECHECKING_WATCHING = "mps.coderules.typechecking.watching"; + public static final String OPTION_TYPECHECKING_REPORTING = "mps.coderules.typechecking.report"; + public static final String OPTION_TYPECHECKING_TRACE = "mps.coderules.typechecking.trace"; + + public static final Config.Option TYPECHECKING_ENABLED = new Config.Option() { + @Override + public Boolean get(Config config) { + return (Boolean) config.getOption(OPTION_TYPECHECKING_ENABLED); + } + }; + public static final Config.Option TYPECHECKING_WATCHING = new Config.Option() { + @Override + public Boolean get(Config config) { + return (Boolean) config.getOption(OPTION_TYPECHECKING_WATCHING); + } + }; + public static final Config.Option TYPECHECKING_REPORTING = new Config.Option() { + @Override + public Boolean get(Config config) { + return (Boolean) config.getOption(OPTION_TYPECHECKING_REPORTING); + } + }; + public static final Config.Option TYPECHECKING_TRACE = new Config.Option() { + @Override + public Boolean get(Config config) { + return (Boolean) config.getOption(OPTION_TYPECHECKING_TRACE); + } + }; + public static final Config.Option COLLECT_TRACES = new Config.Option() { + @Override + public Boolean get(Config config) { + if (Boolean.TRUE != config.getOption(OPTION_TYPECHECKING_REPORTING)) { + return Boolean.FALSE; + } + return (Boolean) config.getOption(OPTION_TYPECHECKING_TRACE); + } + }; + + private static Config USER_CONFIG; + + private TypecheckingOptions() { + } + + public static Config getUserConfig() { + if (USER_CONFIG == null) { + USER_CONFIG = Config.create(); + registerDefaultProviders(USER_CONFIG); + } + return USER_CONFIG; + } + + public static Config getParamConfig(Map paramMap) { + Config config = getUserConfig().copy(); + registerParamMapProvider(config, paramMap); + return config; + } + + private static void registerDefaultProviders(Config config) { + CoderulesOptions.registerDefaultProviders(config); + + config.registerProvider(Config.Level.USER, PREFIX, (String key) -> { + + if (OPTION_TYPECHECKING_ENABLED.equals(key)) { + return Boolean.valueOf(System.getProperty(OPTION_TYPECHECKING_ENABLED, "false")); + + } + + if (OPTION_TYPECHECKING_WATCHING.equals(key)) { + return Boolean.valueOf(System.getProperty(OPTION_TYPECHECKING_WATCHING, "false")); + + } + + if (OPTION_TYPECHECKING_REPORTING.equals(key)) { + return Boolean.valueOf(System.getProperty(OPTION_TYPECHECKING_REPORTING, "false")); + + } + + if (OPTION_TYPECHECKING_TRACE.equals(key)) { + return Boolean.valueOf(System.getProperty(OPTION_TYPECHECKING_TRACE, "false")); + + } + + return null; + }); + } + + public static void registerParamMapProvider(Config config, final Map paramMap) { + config.registerProvider(Config.Level.UI, PREFIX, (String key) -> { + + if (OPTION_TYPECHECKING_ENABLED.equals(key)) { + + return (MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_ENABLED) != null ? MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_ENABLED) : false); + } + + if (OPTION_TYPECHECKING_WATCHING.equals(key)) { + return (MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_WATCHING) != null ? MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_WATCHING) : false); + + } + + if (OPTION_TYPECHECKING_REPORTING.equals(key)) { + return (MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_REPORTING) != null ? MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_REPORTING) : false); + + } + + if (OPTION_TYPECHECKING_TRACE.equals(key)) { + return (MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_TRACE) != null ? MapSequence.fromMap(paramMap).get(OPTION_TYPECHECKING_TRACE) : false); + + } + + return null; + }); + } + +} diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingSettings.java b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingSettings.java new file mode 100644 index 00000000..d92a41b0 --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingSettings.java @@ -0,0 +1,83 @@ +package jetbrains.mps.coderules.ideaplugin; + +/*Generated by MPS */ + +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.application.ApplicationManager; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; + +@com.intellij.openapi.components.State(name = "TypecheckingSettings", storages = @Storage(value = "typecheckingSettings.xml") +) +public class TypecheckingSettings implements PersistentStateComponent { + + public static class State { + public boolean myIsEnabled; + public boolean myIsWatching; + public boolean myIsReporting; + public boolean myIsTracing; + } + + /** + * Only available in case the plugin is not loaded, that is when the code is loaded from source module + */ + private static TypecheckingSettings SINGLETON_INSTANCE = new TypecheckingSettings(); + + private State myState = new State(); + + public TypecheckingSettings() { + } + + public static TypecheckingSettings getInstace() { + TypecheckingSettings service = ApplicationManager.getApplication().getService(TypecheckingSettings.class); + if (service == null) { + // workaround for running from sources + return SINGLETON_INSTANCE; + } + return service; + } + + @Nullable + @Override + public State getState() { + return myState; + } + + @Override + public void loadState(@NotNull State state) { + this.myState = state; + } + + public boolean isTypecheckingEnabled() { + return myState.myIsEnabled; + } + + public boolean setTypecheckingEnabled(boolean yes) { + return myState.myIsEnabled = yes; + } + + public boolean isWatchingEnabled() { + return myState.myIsWatching; + } + + public boolean setWatchingEnabled(boolean yes) { + return myState.myIsWatching = yes; + } + + public boolean isReportingEnabled() { + return myState.myIsReporting; + } + + public boolean setReportingEnabled(boolean yes) { + return myState.myIsReporting = yes; + } + + public boolean isTracingEnabled() { + return myState.myIsTracing; + } + + public boolean setTracingEnabled(boolean yes) { + return myState.myIsTracing = yes; + } +} diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingSettingsPage.java b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingSettingsPage.java new file mode 100644 index 00000000..5955953d --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/TypecheckingSettingsPage.java @@ -0,0 +1,228 @@ +package jetbrains.mps.coderules.ideaplugin; + +/*Generated by MPS */ + +import javax.swing.JPanel; +import com.intellij.openapi.options.SearchableConfigurable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.NonNls; +import com.intellij.openapi.util.NlsContexts; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.Nullable; +import javax.swing.JComponent; +import com.intellij.openapi.options.ConfigurationException; +import javax.swing.BoxLayout; +import com.intellij.ui.components.JBCheckBox; +import java.awt.event.ItemListener; +import java.awt.event.ItemEvent; +import javax.swing.Box; +import com.intellij.ui.IdeBorderFactory; +import com.intellij.util.ui.JBUI; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JCheckBox; + +public class TypecheckingSettingsPage extends JPanel implements SearchableConfigurable { + + public TypecheckingSettingsPage() { + TypecheckingSettings settings = TypecheckingSettings.getInstace(); + init(); + } + + @NotNull + @NonNls + @Override + public String getId() { + return "preferences.typecheckingSettings"; + } + @NlsContexts.ConfigurableName + @Contract(pure = true) + @Override + public String getDisplayName() { + return "Typechecking"; + } + @Nullable + @Override + public JComponent createComponent() { + return this; + } + @Override + public boolean isModified() { + TypecheckingSettings settings = TypecheckingSettings.getInstace(); + boolean modified = false; + modified |= settings.isTypecheckingEnabled() != this.isTypecheckingEnabled(); + modified |= settings.isWatchingEnabled() != this.isWatchingEnabled(); + modified |= settings.isReportingEnabled() != this.isReportingEnabled(); + modified |= settings.isTracingEnabled() != this.isTracingEnabled(); + return modified; + } + @Override + public void apply() throws ConfigurationException { + TypecheckingSettings settings = TypecheckingSettings.getInstace(); + settings.setTypecheckingEnabled(this.isTypecheckingEnabled()); + settings.setWatchingEnabled(this.isWatchingEnabled()); + settings.setReportingEnabled(this.isReportingEnabled()); + settings.setTracingEnabled(this.isTracingEnabled()); + } + @Override + public void reset() { + TypecheckingSettings settings = TypecheckingSettings.getInstace(); + this.setTypecheckingEnabled(settings.isTypecheckingEnabled()); + this.setWatchingEnabled(settings.isWatchingEnabled()); + this.setReportingEnabled(settings.isReportingEnabled()); + this.setTracingEnabled(settings.isTracingEnabled()); + } + private void init() { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + this.enableTypecheckingCheckbox = new JBCheckBox("Enable experimental typechecking with Coderules"); + this.enableWatchingCheckbox = new JBCheckBox("Watch model changes and collect updates"); + this.enableReportingCheckbox = new JBCheckBox("Report evaluation results"); + this.enableTraceCheckbox = new JBCheckBox("Collect trace events"); + + ItemListener updater = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + updateEnabledState(); + } + }; + enableTypecheckingCheckbox.addItemListener(updater); + enableWatchingCheckbox.addItemListener(updater); + enableReportingCheckbox.addItemListener(updater); + + { + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + mainPanel.add(Box.createHorizontalGlue()); + mainPanel.setBorder(IdeBorderFactory.createTitledBorder("Typechecking", false)); + + { + JPanel subpanel = new JPanel(); + subpanel.setLayout(new BoxLayout(subpanel, BoxLayout.Y_AXIS)); + subpanel.add(Box.createVerticalStrut(0)); + subpanel.setBorder(JBUI.Borders.emptyLeft(20)); + + subpanel.add(this.enableTypecheckingCheckbox); + + mainPanel.add(subpanel); + } + + add(mainPanel); + + // ---------- + + JPanel editorPanel = new JPanel(); + editorPanel.setLayout(new BoxLayout(editorPanel, BoxLayout.Y_AXIS)); + editorPanel.add(Box.createHorizontalGlue()); + editorPanel.setBorder(IdeBorderFactory.createTitledBorder("Editor integration", false)); + + { + JPanel subpanel = new JPanel(); + subpanel.setLayout(new BoxLayout(subpanel, BoxLayout.Y_AXIS)); + subpanel.add(Box.createVerticalStrut(0)); + subpanel.setBorder(JBUI.Borders.emptyLeft(20)); + + subpanel.add(this.enableWatchingCheckbox); + + editorPanel.add(subpanel); + } + + add(editorPanel); + + // --------- + + JPanel advancedPanel = new JPanel(); + advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS)); + advancedPanel.add(Box.createHorizontalGlue()); + advancedPanel.setBorder(IdeBorderFactory.createTitledBorder("Advanced", false)); + + { + JPanel subpanel = new JPanel(); + subpanel.setLayout(new BoxLayout(subpanel, BoxLayout.Y_AXIS)); + subpanel.add(Box.createVerticalStrut(0)); + subpanel.setBorder(JBUI.Borders.emptyLeft(20)); + + subpanel.add(new JLabel("When evaluating Coderules program:")); + + { + JPanel subsubpanel = new JPanel(); + subsubpanel.setLayout(new BoxLayout(subsubpanel, BoxLayout.Y_AXIS)); + subsubpanel.add(Box.createVerticalStrut(0)); + subsubpanel.setBorder(JBUI.Borders.emptyLeft(20)); + + subsubpanel.add(this.enableReportingCheckbox); + + subsubpanel.add(this.enableTraceCheckbox); + + JPanel warnPanel = new JPanel(); + warnPanel.setLayout(new BoxLayout(warnPanel, BoxLayout.Y_AXIS)); + warnPanel.add(Box.createVerticalStrut(5)); + warnPanel.setBorder(JBUI.Borders.emptyLeft(25)); + + { + JLabel warnLabel = new JLabel("Using this option may result in excessive memory consumption"); + Font font = warnLabel.getFont(); + warnLabel.setFont(font.deriveFont(font.getSize2D() * 0.9f)); + warnLabel.setEnabled(false); + + warnPanel.add(warnLabel); + } + + subsubpanel.add(warnPanel); + + subpanel.add(subsubpanel); + } + + advancedPanel.add(subpanel); + } + + add(advancedPanel); + } + } + + public boolean isTypecheckingEnabled() { + return enableTypecheckingCheckbox.isSelected(); + } + + public boolean isWatchingEnabled() { + return enableWatchingCheckbox.isSelected(); + } + + public boolean isTracingEnabled() { + return enableTraceCheckbox.isSelected(); + } + + public boolean isReportingEnabled() { + return enableReportingCheckbox.isSelected(); + } + + public void setTypecheckingEnabled(boolean yes) { + this.enableTypecheckingCheckbox.setSelected(yes); + updateEnabledState(); + } + + public void setWatchingEnabled(boolean yes) { + this.enableWatchingCheckbox.setSelected(yes); + updateEnabledState(); + } + + public void setReportingEnabled(boolean yes) { + this.enableReportingCheckbox.setSelected(yes); + } + + public void setTracingEnabled(boolean yes) { + this.enableTraceCheckbox.setSelected(yes); + } + + private void updateEnabledState() { + this.enableWatchingCheckbox.setEnabled(this.enableTypecheckingCheckbox.isSelected()); + this.enableReportingCheckbox.setEnabled(this.enableTypecheckingCheckbox.isSelected()); + this.enableTraceCheckbox.setEnabled(this.enableTypecheckingCheckbox.isSelected() && this.enableReportingCheckbox.isSelected()); + } + + private JCheckBox enableTypecheckingCheckbox; + private JCheckBox enableWatchingCheckbox; + private JCheckBox enableReportingCheckbox; + private JCheckBox enableTraceCheckbox; + +} diff --git a/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/trace.info b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/trace.info new file mode 100644 index 00000000..8796061e --- /dev/null +++ b/coderules/solutions/jetbrains.mps.coderules.ideaplugin/source/jetbrains/mps/coderules/ideaplugin/trace.info @@ -0,0 +1,765 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/fitch/build.xml b/samples/fitch/build.xml index 93ddcaf6..15587067 100644 --- a/samples/fitch/build.xml +++ b/samples/fitch/build.xml @@ -1561,7 +1561,7 @@ - + diff --git a/samples/lambdacalc/build.xml b/samples/lambdacalc/build.xml index 4c4001a7..b0a637fb 100644 --- a/samples/lambdacalc/build.xml +++ b/samples/lambdacalc/build.xml @@ -550,7 +550,7 @@ - + diff --git a/samples/mpscore/build.xml b/samples/mpscore/build.xml index 6beb9154..b4c1f229 100644 --- a/samples/mpscore/build.xml +++ b/samples/mpscore/build.xml @@ -10264,7 +10264,7 @@ - + diff --git a/settings.gradle b/settings.gradle index d7eec2a5..4688c804 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,6 +2,7 @@ include 'coderules:solutions:jetbrains.mps.logic.reactor' include 'coderules:solutions:jetbrains.mps.logic.test' include 'coderules:solutions:jetbrains.mps.coderules.typechecking' include 'coderules:solutions:jetbrains.mps.coderules' +include 'coderules:solutions:jetbrains.mps.coderules.ideaplugin' include 'samples:mpscore' include 'samples:lambdacalc' include 'samples:fitch'