From d28b71647563b88da6d695931ddb83c287706574 Mon Sep 17 00:00:00 2001 From: pengzhile Date: Mon, 18 Oct 2021 20:57:39 +0800 Subject: [PATCH] fix for some plugins --- README.md | 2 +- build.gradle | 4 +- .../intellij/ier/common/PluginRecord.java | 24 ++++++++++ .../intellij/ier/common/Resetter.java | 3 ++ .../ier/plugins/MyBatisCodeHelper.java | 46 +++++++++++++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/zhile/research/intellij/ier/common/PluginRecord.java create mode 100644 src/main/java/io/zhile/research/intellij/ier/plugins/MyBatisCodeHelper.java diff --git a/README.md b/README.md index ca2c769..8784742 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Reset Your IDE Eval Information -1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.3.0-064755.zip). +1. Download and install plugin from [Download Link](https://plugins.zhile.io/files/ide-eval-resetter-2.3.1-6b4c51.zip). * Alternative installation method: * Add "Custom Plugin Repository": `https://plugins.zhile.io` manually (`Settings/Preferences` -> `Plugins`) * Search and install plugin: `IDE Eval Reset` diff --git a/build.gradle b/build.gradle index 20446ed..30b25e7 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'io.zhile.research.intellij' -version '2.3.0' +version '2.3.1' sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -29,6 +29,8 @@ intellij { patchPluginXml { changeNotes = """
+Release v2.3.1
+  1. fix for some plugins
 Release v2.3.0
   1. fix for 2021.2.3
 Release v2.2.4
diff --git a/src/main/java/io/zhile/research/intellij/ier/common/PluginRecord.java b/src/main/java/io/zhile/research/intellij/ier/common/PluginRecord.java
new file mode 100644
index 0000000..cf9c289
--- /dev/null
+++ b/src/main/java/io/zhile/research/intellij/ier/common/PluginRecord.java
@@ -0,0 +1,24 @@
+package io.zhile.research.intellij.ier.common;
+
+import com.intellij.ide.plugins.IdeaPluginDescriptor;
+import com.intellij.ide.plugins.PluginManager;
+
+import java.util.List;
+
+abstract public class PluginRecord implements EvalRecord {
+    public void test(List list) {
+        for (IdeaPluginDescriptor descriptor : PluginManager.getPlugins()) {
+            if (descriptor.getName().equals(getName())) {
+                list.add(this);
+                break;
+            }
+        }
+    }
+
+    abstract public String getName();
+
+    @Override
+    public String toString() {
+        return "PLUGIN: " + getName();
+    }
+}
diff --git a/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java b/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java
index 8caf6f5..837c3b0 100644
--- a/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java
+++ b/src/main/java/io/zhile/research/intellij/ier/common/Resetter.java
@@ -11,6 +11,7 @@ import io.zhile.research.intellij.ier.helper.AppHelper;
 import io.zhile.research.intellij.ier.helper.Constants;
 import io.zhile.research.intellij.ier.helper.NotificationHelper;
 import io.zhile.research.intellij.ier.helper.ReflectionHelper;
+import io.zhile.research.intellij.ier.plugins.MyBatisCodeHelper;
 import org.jdom.Attribute;
 import org.jdom.Element;
 
@@ -155,6 +156,8 @@ public class Resetter {
             }
         }
 
+        new MyBatisCodeHelper().test(list);
+
         return list;
     }
 
diff --git a/src/main/java/io/zhile/research/intellij/ier/plugins/MyBatisCodeHelper.java b/src/main/java/io/zhile/research/intellij/ier/plugins/MyBatisCodeHelper.java
new file mode 100644
index 0000000..b59c55e
--- /dev/null
+++ b/src/main/java/io/zhile/research/intellij/ier/plugins/MyBatisCodeHelper.java
@@ -0,0 +1,46 @@
+package io.zhile.research.intellij.ier.plugins;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.components.PersistentStateComponent;
+import io.zhile.research.intellij.ier.common.PluginRecord;
+import io.zhile.research.intellij.ier.helper.ReflectionHelper;
+
+import java.lang.reflect.Method;
+
+public final class MyBatisCodeHelper extends PluginRecord {
+    private static final String PLUGIN_NAME = "MyBatisCodeHelperPro (Marketplace Edition)";
+
+    @Override
+    public void reset() throws Exception {
+        PersistentStateComponent component = (PersistentStateComponent) ApplicationManager.getApplication().getComponent("MyBatisCodeHelper");
+        if (null == component) {
+            return;
+        }
+
+        Object state = component.getState();
+        if (null == state) {
+            return;
+        }
+
+        Method method = ReflectionHelper.getMethod(state.getClass(), "getProfile");
+        if (null == method) {
+            return;
+        }
+
+        Object profile = method.invoke(state);
+        method = ReflectionHelper.getMethod(profile.getClass(), "setValid", boolean.class);
+        if (null != method) {
+            method.invoke(profile, true);
+        }
+
+        method = ReflectionHelper.getMethod(profile.getClass(), "setTheUsageCount", String.class);
+        if (null != method) {
+            method.invoke(profile, "-1");
+        }
+    }
+
+    @Override
+    public String getName() {
+        return PLUGIN_NAME;
+    }
+}