diff --git a/build.gradle b/build.gradle index c30f8e0..10aec2e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,18 +3,23 @@ buildscript { mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } maven { url 'https://oss.sonatype.org/content/repositories/releases/' } - maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' } - maven { url 'https://dl.bintray.com/jetbrains/intellij-third-party-dependencies/' } + } + // https://github.com/JetBrains/gradle-intellij-plugin/ 关注开发插件版本 + dependencies { + classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.7.3" } } +//2.1 插件配置 +// 这两个插件是必备 plugins { id 'java' id 'org.jetbrains.intellij' version '0.7.3' } + group 'com.sjhy' -version '1.2.6.RELEASE' +version '1.2.5-java.RELEASE' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -25,22 +30,47 @@ repositories { mavenCentral() } -dependencies { - compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6' - testCompile 'junit:junit:4.12' - // lombok - compileOnly 'org.projectlombok:lombok:1.18.12' - annotationProcessor 'org.projectlombok:lombok:1.18.12' - testCompileOnly 'org.projectlombok:lombok:1.18.12' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.12' -} +// http://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/prerequisites.html +// https://plugins.jetbrains.com/docs/intellij/gradle-guide.html 官网gradle构建教程 -// See https://github.com/JetBrains/gradle-intellij-plugin/ intellij { - version = 'IU-2020.1.2' - plugins = ['java', 'DatabaseTools'] - updateSinceUntilBuild = false - downloadSources = true +// 插件名称 + pluginName 'EasyCode' + // 沙箱目录位置,用于保存IDEA的设置,默认在build文件下面,防止clean,放在根目录下。 sandboxDirectory = "${rootProject.rootDir}/idea-sandbox" + // 开发环境运行时使用的版本 + version '2021.2.2' + // 社区版 +// type 'IC' + // 企业版 + type 'IU' + // 各种IDEA版本去这里找 + // https://www.jetbrains.com/intellij-repository/releases + // 依赖的插件 + plugins = ['java', 'DatabaseTools'] + //Disables updating since-build attribute in plugin.xml + updateSinceUntilBuild false + downloadSources = true +} + +dependencies { + // jackson工具 + compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6' + // guava工具 +// compile 'com.google.guava:guava:29.0-jre' + // velocity支持 +// compile 'org.apache.velocity:velocity:1.7' + // groovy支持 +// compile 'org.codehaus.groovy:groovy:3.0.2' + // beetl支持 +// compile 'com.ibeetl:beetl:3.3.0.RELEASE' + // freemarker支持 +// compile 'org.freemarker:freemarker:2.3.30' + // lombok 支持 + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' + // 测试用例 + testCompile 'junit:junit:4.12' } diff --git a/src/main/java/com/sjhy/plugin/entity/AbstractGroup.java b/src/main/java/com/sjhy/plugin/entity/AbstractGroup.java index 526f3ed..0cc93a5 100644 --- a/src/main/java/com/sjhy/plugin/entity/AbstractGroup.java +++ b/src/main/java/com/sjhy/plugin/entity/AbstractGroup.java @@ -58,8 +58,8 @@ public interface AbstractGroup> { * * @return {@link T} */ + @SuppressWarnings("unchecked") default T cloneObj() { - //noinspection unchecked return (T) CloneUtils.cloneByJson(this); } } diff --git a/src/main/java/com/sjhy/plugin/service/impl/LocalFileExportImportSettingsServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/LocalFileExportImportSettingsServiceImpl.java index cd72306..60aa1de 100644 --- a/src/main/java/com/sjhy/plugin/service/impl/LocalFileExportImportSettingsServiceImpl.java +++ b/src/main/java/com/sjhy/plugin/service/impl/LocalFileExportImportSettingsServiceImpl.java @@ -44,7 +44,7 @@ public class LocalFileExportImportSettingsServiceImpl implements ExportImportSet public void exportConfig(SettingsStorageDTO settingsStorage) { // 1.选择储存位置 FileSaverDialog saveFileDialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Save Config As Json", "Save to"), ProjectUtils.getCurrProject()); - VirtualFileWrapper saveFile = saveFileDialog.save(null, "EasyCodeConfig.json"); + VirtualFileWrapper saveFile = saveFileDialog.save((VirtualFile) null, "EasyCodeConfig.json"); if (saveFile == null) { return; } diff --git a/src/main/java/com/sjhy/plugin/ui/component/RealtimeDebugComponent.java b/src/main/java/com/sjhy/plugin/ui/component/RealtimeDebugComponent.java index 71a95cf..c41a3a7 100644 --- a/src/main/java/com/sjhy/plugin/ui/component/RealtimeDebugComponent.java +++ b/src/main/java/com/sjhy/plugin/ui/component/RealtimeDebugComponent.java @@ -14,15 +14,10 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.ui.ComboBox; import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Conditions; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiFileFactory; import com.intellij.ui.components.JBLabel; import com.intellij.util.ExceptionUtil; import com.intellij.util.ReflectionUtil; @@ -129,17 +124,12 @@ public class RealtimeDebugComponent { } // 生成代码 String code = CodeGenerateService.getInstance(ProjectUtils.getCurrProject()).generate(new Template("temp", editorComponent.getFile().getCode()), tableInfo); - + String fileName = editorComponent.getFile().getName(); // 创建编辑框 EditorFactory editorFactory = EditorFactory.getInstance(); - PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(ProjectUtils.getCurrProject()); - String fileName = editorComponent.getFile().getName(); - FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName); - PsiFile psiFile = psiFileFactory.createFileFromText(fileName, fileType, code, 0, true); + Document document = editorFactory.createDocument(code); // 标识为模板,让velocity跳过语法校验 - psiFile.getViewProvider().putUserData(FileTemplateManager.DEFAULT_TEMPLATE_PROPERTIES, FileTemplateManager.getInstance(ProjectUtils.getCurrProject()).getDefaultProperties()); - Document document = PsiDocumentManager.getInstance(ProjectUtils.getCurrProject()).getDocument(psiFile); - assert document != null; + document.putUserData(FileTemplateManager.DEFAULT_TEMPLATE_PROPERTIES, FileTemplateManager.getInstance(ProjectUtils.getCurrProject()).getDefaultProperties()); Editor editor = editorFactory.createViewer(document, ProjectUtils.getCurrProject()); // 配置编辑框 EditorSettingsInit.init(editor);