mirror of https://gitee.com/makejava/EasyCode.git
修复实时调试时可能会出现空指针异常
This commit is contained in:
parent
c52e93a18b
commit
dad911fb9b
64
build.gradle
64
build.gradle
|
@ -3,18 +3,23 @@ buildscript {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://plugins.gradle.org/m2/' }
|
maven { url 'https://plugins.gradle.org/m2/' }
|
||||||
maven { url 'https://oss.sonatype.org/content/repositories/releases/' }
|
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 {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.intellij' version '0.7.3'
|
id 'org.jetbrains.intellij' version '0.7.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
group 'com.sjhy'
|
group 'com.sjhy'
|
||||||
version '1.2.6.RELEASE'
|
version '1.2.5-java.RELEASE'
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
@ -25,22 +30,47 @@ repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
// http://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/prerequisites.html
|
||||||
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
|
// https://plugins.jetbrains.com/docs/intellij/gradle-guide.html 官网gradle构建教程
|
||||||
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'
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://github.com/JetBrains/gradle-intellij-plugin/
|
|
||||||
intellij {
|
intellij {
|
||||||
version = 'IU-2020.1.2'
|
// 插件名称
|
||||||
plugins = ['java', 'DatabaseTools']
|
pluginName 'EasyCode'
|
||||||
updateSinceUntilBuild = false
|
// 沙箱目录位置,用于保存IDEA的设置,默认在build文件下面,防止clean,放在根目录下。
|
||||||
downloadSources = true
|
|
||||||
sandboxDirectory = "${rootProject.rootDir}/idea-sandbox"
|
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'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,8 @@ public interface AbstractGroup<T, E extends AbstractItem<E>> {
|
||||||
*
|
*
|
||||||
* @return {@link T}
|
* @return {@link T}
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
default T cloneObj() {
|
default T cloneObj() {
|
||||||
//noinspection unchecked
|
|
||||||
return (T) CloneUtils.cloneByJson(this);
|
return (T) CloneUtils.cloneByJson(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class LocalFileExportImportSettingsServiceImpl implements ExportImportSet
|
||||||
public void exportConfig(SettingsStorageDTO settingsStorage) {
|
public void exportConfig(SettingsStorageDTO settingsStorage) {
|
||||||
// 1.选择储存位置
|
// 1.选择储存位置
|
||||||
FileSaverDialog saveFileDialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Save Config As Json", "Save to"), ProjectUtils.getCurrProject());
|
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) {
|
if (saveFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,10 @@ import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.editor.EditorFactory;
|
import com.intellij.openapi.editor.EditorFactory;
|
||||||
import com.intellij.openapi.editor.ex.EditorEx;
|
import com.intellij.openapi.editor.ex.EditorEx;
|
||||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
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.ComboBox;
|
||||||
import com.intellij.openapi.ui.DialogBuilder;
|
import com.intellij.openapi.ui.DialogBuilder;
|
||||||
import com.intellij.openapi.ui.Messages;
|
import com.intellij.openapi.ui.Messages;
|
||||||
import com.intellij.openapi.util.Conditions;
|
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.ui.components.JBLabel;
|
||||||
import com.intellij.util.ExceptionUtil;
|
import com.intellij.util.ExceptionUtil;
|
||||||
import com.intellij.util.ReflectionUtil;
|
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 code = CodeGenerateService.getInstance(ProjectUtils.getCurrProject()).generate(new Template("temp", editorComponent.getFile().getCode()), tableInfo);
|
||||||
|
String fileName = editorComponent.getFile().getName();
|
||||||
// 创建编辑框
|
// 创建编辑框
|
||||||
EditorFactory editorFactory = EditorFactory.getInstance();
|
EditorFactory editorFactory = EditorFactory.getInstance();
|
||||||
PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(ProjectUtils.getCurrProject());
|
Document document = editorFactory.createDocument(code);
|
||||||
String fileName = editorComponent.getFile().getName();
|
|
||||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName);
|
|
||||||
PsiFile psiFile = psiFileFactory.createFileFromText(fileName, fileType, code, 0, true);
|
|
||||||
// 标识为模板,让velocity跳过语法校验
|
// 标识为模板,让velocity跳过语法校验
|
||||||
psiFile.getViewProvider().putUserData(FileTemplateManager.DEFAULT_TEMPLATE_PROPERTIES, FileTemplateManager.getInstance(ProjectUtils.getCurrProject()).getDefaultProperties());
|
document.putUserData(FileTemplateManager.DEFAULT_TEMPLATE_PROPERTIES, FileTemplateManager.getInstance(ProjectUtils.getCurrProject()).getDefaultProperties());
|
||||||
Document document = PsiDocumentManager.getInstance(ProjectUtils.getCurrProject()).getDocument(psiFile);
|
|
||||||
assert document != null;
|
|
||||||
Editor editor = editorFactory.createViewer(document, ProjectUtils.getCurrProject());
|
Editor editor = editorFactory.createViewer(document, ProjectUtils.getCurrProject());
|
||||||
// 配置编辑框
|
// 配置编辑框
|
||||||
EditorSettingsInit.init(editor);
|
EditorSettingsInit.init(editor);
|
||||||
|
|
Loading…
Reference in New Issue