Skip to content

Commit

Permalink
Merge branch 'V2020'
Browse files Browse the repository at this point in the history
# Conflicts:
#	mybatis-idea-plugin/build.gradle
#	mybatis-idea-plugin/src/main/resources/META-INF/plugin.xml
  • Loading branch information
[email protected] committed Apr 4, 2023
2 parents 29aee35 + 29136d9 commit 0f0dd06
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 25 deletions.
3 changes: 2 additions & 1 deletion mybatis-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {


group 'com.plugins.mybatislog.agent'
version '1.0.18'
version '1.0.19'

java {
sourceCompatibility = "1.8"
Expand All @@ -42,6 +42,7 @@ java {
dependencies {
implementation 'org.javatuples:javatuples:1.2'
implementation 'org.javassist:javassist:3.29.2-GA'
implementation 'com.google.code.gson:gson:2.9.1'
// compile project(":probe-agent") 另一种引入工程的方式
implementation fileTree(dir: 'libs', includes: ['*jar'])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import com.plugins.mybaitslog.IClassFileTransformer;
import javassist.*;

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;

/**
* A <code>RawSqlSourceMonitor</code> Class
*
Expand Down
2 changes: 1 addition & 1 deletion mybatis-idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {
}

group 'com.plugins.mybaitslog.idea.plugin'
version '5.0.0'
version '5.0.2'

dependencies {
compileOnly 'org.jetbrains:annotations:24.0.1'
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import com.intellij.ide.util.PropertiesComponent;

import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -44,6 +47,10 @@ public static class Idea {
put("other", "252,255,253");
}};

public static final ArrayList<String> AddOpens = new ArrayList<String>() {{
add("--add-opens java.base/java.lang=ALL-UNNAMED");
}};

/**
* 获取关键字常量配置
*
Expand Down Expand Up @@ -72,11 +79,18 @@ public static void setStartup(int value) {
PropertiesComponent.getInstance().setValue(DB_STARTUP_KEY, value, 1);
}

/**
* 获取启动过滤
*/
public static boolean getStartup() {
final int anInt = PropertiesComponent.getInstance().getInt(DB_STARTUP_KEY, 1);
return anInt == 1;
}

/**
* 设置配置
*
* @param type
* @param type 值
*/
public static Color getColor(String type) {
final String s = ColorMap.get(type);
Expand All @@ -95,13 +109,16 @@ public static void setColor(String type, Color value) {
PropertiesComponent.getInstance().setValue("color:" + type, color);
}

public static ArrayList<String> getAddOpens() {
final String value = PropertiesComponent.getInstance().getValue("addOpens:", String.join(";", AddOpens));
return new ArrayList<String>(Arrays.asList(value.split(";")));
}

/**
* 获取启动过滤
*/
public static boolean getStartup() {
final int anInt = PropertiesComponent.getInstance().getInt(DB_STARTUP_KEY, 1);
return anInt == 1;
public static void setAddOpens(String opens) {
final List<String> openlist = Arrays.asList(opens.split("\n"));
PropertiesComponent.getInstance().setValue("addOpens:", String.join(";", openlist));
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
Expand All @@ -19,6 +20,7 @@ public class PerRun extends JavaProgramPatcher {
private Set<String> stringSet = new HashSet<String>() {{
add("org.jetbrains.idea.maven.execution");
}};

//com.intellij.execution.junit
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
Expand All @@ -44,7 +46,13 @@ public void patchJavaParameters(Executor executor, RunProfile configuration, Jav
if (null != agentCoreJarPath) {
//RunConfiguration runConfiguration = (RunConfiguration) configuration;
ParametersList vmParametersList = javaParameters.getVMParametersList();
//JDK17的改进
if (version.compareTo(JavaSdkVersion.JDK_17) >= 0) {
final ArrayList<String> addOpens = Config.Idea.getAddOpens();
vmParametersList.addAll(addOpens);
}
vmParametersList.prepend("-javaagent:" + agentCoreJarPath);
//
//vmParametersList.addParametersString("-javaagent:\"" + agentCoreJarPath + "\"");
//vmParametersList.addNotEmptyProperty("guide-idea-plugin-probe.projectId", runConfiguration.getProject().getLocationHash());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static String getJarPathByStartWith() {
if ("lib".equals(listFile.getName())) {
final File[] fileslib = listFile.listFiles();
for (File file : fileslib) {
if ("mybatis-agent-1.0.18-all.jar".equals(file.getName())) {
if ("mybatis-agent-1.0.19-all.jar".equals(file.getName())) {
return file.toPath().toString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="468" height="255"/>
<xy x="48" y="54" width="482" height="341"/>
</constraints>
<properties>
<maximumSize width="264" height="157"/>
Expand Down Expand Up @@ -44,7 +44,7 @@
</component>
</children>
</grid>
<grid id="ff265" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="ff265" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand Down Expand Up @@ -185,6 +185,24 @@
</grid>
</children>
</grid>
<component id="a6ec3" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Java17+"/>
</properties>
</component>
<component id="b8bbd" class="javax.swing.JTextArea" binding="addOpensTextArea">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties>
<text value="--add-opens java.base/java.lang=ALL-UNNAMED"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import com.intellij.ui.ColorChooser;
import com.plugins.mybaitslog.Config;
import com.plugins.mybaitslog.gui.compone.MyColorButton;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
Expand All @@ -32,6 +30,7 @@ public class FilterSetting extends JDialog {
private JPanel jpanel_delect;
private JPanel jpanel_insert;
private JPanel jpanel_other;
private JTextArea addOpensTextArea;


/**
Expand All @@ -51,6 +50,7 @@ public FilterSetting(Project project) {
getRootPane().setDefaultButton(buttonOK);

//region 自定义控件
addOpensTextArea.setText(String.join("\n", Config.Idea.getAddOpens()));
String[] colorname = {"select", "update", "delect", "insert", "other"};
for (String s : colorname) {
final MyColorButton myColorButton = new MyColorButton(Config.Idea.getColor(s));
Expand Down Expand Up @@ -105,6 +105,8 @@ private void onColor(Project project, String type, MyColorButton myColorButton)
*/
private void onOK(Project project) {
String preparing = this.preparingTextField.getText();
String addOpens = this.addOpensTextArea.getText();
Config.Idea.setAddOpens(addOpens);
Config.Idea.setParameters(preparing, Config.Idea.PARAMETERS);
Config.Idea.setStartup(startupCheckBox.isSelected() ? 1 : 0);
this.setVisible(false);
Expand Down
25 changes: 18 additions & 7 deletions mybatis-idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<vendor email="[email protected]" url="https://github.com/Link-Kou/intellij-mybaitslog">linkkou</vendor>

<!-- 插件版本 -->
<version>5.0.0</version>
<version>5.0.2</version>
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="201"/>
<!-- 插件的描述 -->
Expand All @@ -13,18 +13,29 @@
<p><b>Output the MyBatis log information with formatting</b></p>
<ul>
<h3>English:</h3>
<li>Restore mybatis/ibatis sql log to original whole executable sql.</li>
<li>Plugin generate sql statements with replace ? to the really param value.</li>
<li>Support all SQL formatted output for all databases above mybatis/ibatis(3.2.0+)</li>
<li>Support all SQL formatted output for all databases above MyBatis3.2.0</li>
<li>This is a MybaitLog output plugin that lets you feel silky</li>
<h3>中文:</h3>
<li>恢复mybatis/ibatis sql日志到原始的整个可执行sql。</li>
<li>插件使用replace生成sql语句中的?到真正的值</li>
<li>支持mybatis/ibatis(3.2.0+)以上所有SQL的语句的正常格式化输出</li>
<li>支持MyBatis3.2.0以上所有数据库的所有SQL格式化输出</li>
<li>这是一个让你感受丝滑的MybaitLog输出插件</li>
<p>
<a title="To Github" href="https://github.com/Link-Kou/intellij-mybaitslog"><img src="https://raw.githubusercontent.com/Link-Kou/intellij-mybaitslog/master/image/2020-03-25_09-28-47.jpg" width="558" alt="image"></a>
</p>
</ul>
]]></description>

<!-- 插件的功能 -->
<change-notes><![CDATA[
<ul>
<p>5.0.2</p>
<li>改进JDK17的支持</li>
<li>Improved support for JDK17</li>
</ul>
<ul>
<p>5.0.1</p>
<li>修正GSON未依赖的BUG</li>
<li>Fixed a BUG where GSON was not dependent</li>
</ul>
<ul>
<p>5.0.0</p>
<li>支持MyBatis输出的Sql进行格式化</li>
Expand Down

0 comments on commit 0f0dd06

Please sign in to comment.