From f6ae7924aa63240b1a810bbc626fa307105aa3d1 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 24 Oct 2018 12:07:45 +0200 Subject: [PATCH] [java] improves JShell error diagnostics --- .../execution/jshell/ExecuteJShellAction.java | 20 ++++-------------- .../execution/jshell/JShellDiagnostic.java | 21 ++++--------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/jshell/ExecuteJShellAction.java b/java/execution/impl/src/com/intellij/execution/jshell/ExecuteJShellAction.java index e10e27b684a1..ecc3295ee03d 100644 --- a/java/execution/impl/src/com/intellij/execution/jshell/ExecuteJShellAction.java +++ b/java/execution/impl/src/com/intellij/execution/jshell/ExecuteJShellAction.java @@ -1,24 +1,11 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.jshell; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.util.EditorUtil; @@ -96,6 +83,7 @@ class ExecuteJShellAction extends AnAction{ } } catch (Exception ex) { + Logger.getInstance(ExecuteJShellAction.class).warn(ex); JShellDiagnostic.notifyError(ex, project); } } @@ -132,7 +120,7 @@ class ExecuteJShellAction extends AnAction{ element = parent; } } - + return element != null? element : file; } } diff --git a/java/execution/impl/src/com/intellij/execution/jshell/JShellDiagnostic.java b/java/execution/impl/src/com/intellij/execution/jshell/JShellDiagnostic.java index cff3e225498d..8174b66dec2e 100644 --- a/java/execution/impl/src/com/intellij/execution/jshell/JShellDiagnostic.java +++ b/java/execution/impl/src/com/intellij/execution/jshell/JShellDiagnostic.java @@ -1,23 +1,10 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.jshell; import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; /** * @author Eugene Zhuravlev @@ -31,6 +18,6 @@ public class JShellDiagnostic { } public static void notifyError(Exception ex, final Project project) { - new Notification(NOTIFICATION_GROUP, TITLE, ex.getMessage(), NotificationType.ERROR).notify(project); + new Notification(NOTIFICATION_GROUP, TITLE, StringUtil.notNullize(ex.getMessage(), "internal error"), NotificationType.ERROR).notify(project); } -} +} \ No newline at end of file