From 04cfbe0c30538fdd9fcd3d9fcccedc927fe54cf2 Mon Sep 17 00:00:00 2001 From: Fedor Isakov Date: Fri, 2 Sep 2022 15:42:48 +0200 Subject: [PATCH] Add an option to enable/disable profiling --- .../jetbrains.mps.coderules.ideaplugin.mps | 453 ++++++- .../ideaplugin/CoderulesOptions.java | 17 +- .../mps/coderules/ideaplugin/Config.java | 2 + .../ideaplugin/TypecheckingOptions.java | 20 +- .../ideaplugin/TypecheckingSettings.java | 11 + .../ideaplugin/TypecheckingSettingsPage.java | 18 + .../mps/coderules/ideaplugin/trace.info | 1192 +++++++++-------- 7 files changed, 1126 insertions(+), 587 deletions(-) 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 183354cc..2823e8d1 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 @@ -24,7 +24,6 @@ - @@ -320,8 +319,13 @@ - - + + + + + + + @@ -329,8 +333,13 @@ - - + + + + + + + @@ -338,8 +347,13 @@ - - + + + + + + + @@ -347,8 +361,13 @@ - - + + + + + + + @@ -927,6 +946,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1136,6 +1225,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1166,11 +1331,43 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -2691,6 +2888,11 @@ + + + + + @@ -3044,6 +3246,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3279,6 +3526,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -3373,6 +3643,22 @@ + + + + + + + + + + + + + + + + @@ -3459,6 +3745,22 @@ + + + + + + + + + + + + + + + + @@ -3557,6 +3859,24 @@ + + + + + + + + + + + + + + + + + + @@ -4460,6 +4780,23 @@ + + + + + + + + + + + + + + + + + @@ -4560,6 +4897,24 @@ + + + + + + + + + + + + + + + + + + @@ -4699,6 +5054,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4790,6 +5173,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4821,6 +5241,13 @@ + + + + + + + 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 index 08b97fa6..20dab5d3 100644 --- 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 @@ -2,15 +2,30 @@ package jetbrains.mps.coderules.ideaplugin; /*Generated by MPS */ +import jetbrains.mps.annotations.GeneratedClass; +@GeneratedClass(node = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)/3625063056952761380", model = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)") public class CoderulesOptions { public static final String PREFIX = "mps.coderules."; + public static final String OPTION_PROFILING_ENABLED = PREFIX + "profiling"; + + public static final Config.Option PROFILING_ENABLED = new Config.Option() { + @Override + public Boolean get(Config config) { + return (Boolean) config.getOption(OPTION_PROFILING_ENABLED); + } + }; + public static void registerDefaultProviders(Config config) { config.registerProvider(Config.Level.USER, PREFIX, (String key) -> { - return null; + if (OPTION_PROFILING_ENABLED.equals(key)) { + return Boolean.valueOf(System.getProperty(OPTION_PROFILING_ENABLED, "false")); + } + + 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 index 4dbc63ad..ffe9663b 100644 --- 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 @@ -2,6 +2,7 @@ package jetbrains.mps.coderules.ideaplugin; /*Generated by MPS */ +import jetbrains.mps.annotations.GeneratedClass; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,6 +14,7 @@ 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. */ +@GeneratedClass(node = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)/8406119028231319109", model = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)") public class Config { /** 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 index 0bac09af..4858b225 100644 --- 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 @@ -2,14 +2,16 @@ package jetbrains.mps.coderules.ideaplugin; /*Generated by MPS */ +import jetbrains.mps.annotations.GeneratedClass; +@GeneratedClass(node = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)/8406119028234017931", model = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)") 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 String OPTION_TYPECHECKING_ENABLED = PREFIX + "enabled"; + public static final String OPTION_TYPECHECKING_WATCHING = PREFIX + "watching"; + public static final String OPTION_TYPECHECKING_REPORTING = PREFIX + "report"; + public static final String OPTION_TYPECHECKING_TRACE = PREFIX + "trace"; public static final Config.Option TYPECHECKING_ENABLED = new Config.Option() { @Override @@ -87,6 +89,16 @@ public class TypecheckingOptions { return null; }); + + config.registerProvider(Config.Level.USER, CoderulesOptions.PREFIX, (String key) -> { + TypecheckingSettings settings = TypecheckingSettings.getInstace(); + if (CoderulesOptions.OPTION_PROFILING_ENABLED.equals(key)) { + return settings.isProfilingEnabled(); + } + + return null; + }); + } private static void registerDefaultProviders(Config config) { 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 index d92a41b0..45186096 100644 --- 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 @@ -3,6 +3,7 @@ package jetbrains.mps.coderules.ideaplugin; /*Generated by MPS */ import com.intellij.openapi.components.Storage; +import jetbrains.mps.annotations.GeneratedClass; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.application.ApplicationManager; import org.jetbrains.annotations.Nullable; @@ -10,6 +11,7 @@ import org.jetbrains.annotations.NotNull; @com.intellij.openapi.components.State(name = "TypecheckingSettings", storages = @Storage(value = "typecheckingSettings.xml") ) +@GeneratedClass(node = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)/3041510341143971994", model = "r:835f8ea3-a800-4588-a80b-1de6d47c2098(jetbrains.mps.coderules.ideaplugin)") public class TypecheckingSettings implements PersistentStateComponent { public static class State { @@ -17,6 +19,7 @@ public class TypecheckingSettings implements PersistentStateComponent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - + + + + + - - + + - - - + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + - + - - - + + + + + - + - + - - + + + + + - + - - - - + - + + - - - + - + - - + + + + - + - + - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - + + - - + + - + - + - - + + - + - - + + - + - - - - + + + + - - - - - - - + + + + + + + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - + + + + + + + - - + + - - - - - - - + + + - - - - - - + + + + + + + + + +