From be02d792b5183c6204211a27fa84e7bfa40514a6 Mon Sep 17 00:00:00 2001 From: lkqm Date: Wed, 5 Jan 2022 13:56:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=80=E5=A5=97=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=A4=9A=E7=A7=8D=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../com/sjhy/plugin/dto/TableInfoSettingsDTO.java | 5 ++--- src/main/java/com/sjhy/plugin/entity/TableInfo.java | 5 +++-- .../plugin/service/impl/CodeGenerateServiceImpl.java | 4 +++- src/main/resources/META-INF/easycode-java.xml | 12 ++++++++++++ src/main/resources/META-INF/plugin.xml | 9 +-------- 6 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 src/main/resources/META-INF/easycode-java.xml diff --git a/build.gradle b/build.gradle index 39a04cf..805a6f9 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { } group 'com.sjhy' -version '1.2.5-java.RELEASE' +version '1.2.5.RELEASE' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java b/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java index d5b43f5..60a56ee 100644 --- a/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java +++ b/src/main/java/com/sjhy/plugin/dto/TableInfoSettingsDTO.java @@ -95,12 +95,11 @@ public class TableInfoSettingsDTO { return; } DbTable dbTable = tableInfo.getObj(); - PsiClass psiClass = tableInfo.getPsiClassObj(); String key; if (dbTable != null) { key = generateKey(dbTable); - } else if (psiClass != null) { - key = generateKey(psiClass); + } else if (tableInfo.getPsiClassObj() != null) { + key = generateKey((PsiClass) tableInfo.getPsiClassObj()); } else { return; } diff --git a/src/main/java/com/sjhy/plugin/entity/TableInfo.java b/src/main/java/com/sjhy/plugin/entity/TableInfo.java index 7286b6a..169ad13 100644 --- a/src/main/java/com/sjhy/plugin/entity/TableInfo.java +++ b/src/main/java/com/sjhy/plugin/entity/TableInfo.java @@ -2,7 +2,6 @@ package com.sjhy.plugin.entity; import com.fasterxml.jackson.annotation.JsonIgnore; import com.intellij.database.psi.DbTable; -import com.intellij.psi.PsiClass; import lombok.Data; import java.util.List; @@ -24,9 +23,11 @@ public class TableInfo { /** * 原始对象(从实体生成) + * + * Note: 实际类型是com.intellij.psi.PsiClass,为了避免velocity反射出现ClassNotFound,写为Object类型 */ @JsonIgnore - private PsiClass psiClassObj; + private Object psiClassObj; /** * 表名(首字母大写) diff --git a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java index b8eeabe..de41c39 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/CodeGenerateServiceImpl.java @@ -7,6 +7,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; +import com.intellij.psi.PsiClass; import com.intellij.util.ReflectionUtil; import com.sjhy.plugin.dict.GlobalDict; import com.sjhy.plugin.dto.GenerateOptions; @@ -80,7 +81,8 @@ public class CodeGenerateServiceImpl implements CodeGenerateService { if (selectedTableInfo.getObj() != null) { Messages.showInfoMessage(selectedTableInfo.getObj().getName() + "表配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); } else if (selectedTableInfo.getPsiClassObj() != null) { - Messages.showInfoMessage(selectedTableInfo.getPsiClassObj().getName() + "类配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); + PsiClass psiClassObj = (PsiClass) selectedTableInfo.getPsiClassObj(); + Messages.showInfoMessage(psiClassObj.getName() + "类配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); } else { Messages.showInfoMessage("配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO); } diff --git a/src/main/resources/META-INF/easycode-java.xml b/src/main/resources/META-INF/easycode-java.xml new file mode 100644 index 0000000..9e59791 --- /dev/null +++ b/src/main/resources/META-INF/easycode-java.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e7549e0..3ccf5ac 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -234,8 +234,7 @@ com.intellij.modules.lang com.intellij.database - - com.intellij.modules.java + com.intellij.modules.java @@ -262,12 +261,6 @@ - - - - -