From 237ba73f28dd8bc06069e8b2e247e2e8b625243f Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 28 Nov 2014 15:05:50 +0300 Subject: [PATCH 01/24] #WEB-7236 fixed --- .../com/intellij/openapi/editor/impl/ContextMenuImpl.java | 8 ++------ .../browsers/actions/OpenInBrowserBaseGroupAction.java | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ContextMenuImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ContextMenuImpl.java index cbe6da5379cf..c6d567927861 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/ContextMenuImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/ContextMenuImpl.java @@ -116,17 +116,13 @@ public class ContextMenuImpl extends JPanel implements Disposable { } private void toggleContextToolbar(final boolean show) { - final Component toolbar = myComponent.getComponent(0); - final int count = ((Container)toolbar).getComponentCount(); - if (count == 0) { + myActionToolbar.updateActionsImmediately(); + if (((Container)myActionToolbar).getComponentCount() == 0) { return; } if (myShow != show) { myShow = show; - if (myShow && myActionToolbar != null) { - myActionToolbar.updateActionsImmediately(); - } restartTimer(); } } diff --git a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java index 482828c24c5e..5298e0e7b90e 100644 --- a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java +++ b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java @@ -80,7 +80,7 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup @Override public void update(@NotNull AnActionEvent e) { - e.getPresentation().setVisible(!WebBrowserManager.getInstance().getBrowsers().isEmpty()); + e.getPresentation().setVisible(!WebBrowserManager.getInstance().getActiveBrowsers().isEmpty()); } } } \ No newline at end of file From ba152a9e619bf5339bddd94dee72486dac464ab6 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 28 Nov 2014 15:35:24 +0300 Subject: [PATCH 02/24] allow disabling browser hover in editor #WEB-461 fixed --- .../ide/browsers/BrowserSettingsPanel.form | 16 ++++++++++++---- .../ide/browsers/BrowserSettingsPanel.java | 13 ++++++++++--- .../intellij/ide/browsers/WebBrowserManager.java | 15 ++++++++++++++- .../actions/OpenInBrowserBaseGroupAction.java | 3 ++- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.form b/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.form index 23d7bf2ea873..bf543f19e594 100644 --- a/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.form +++ b/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.form @@ -1,6 +1,6 @@
- + @@ -11,7 +11,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -53,12 +53,20 @@ - + + + + + + + + + diff --git a/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.java b/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.java index 6869262765c4..497dae2e9f66 100644 --- a/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.java +++ b/xml/impl/src/com/intellij/ide/browsers/BrowserSettingsPanel.java @@ -25,6 +25,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.Comparing; import com.intellij.ui.ListCellRendererWrapper; import com.intellij.ui.TitledSeparator; +import com.intellij.ui.components.JBCheckBox; import com.intellij.util.Function; import com.intellij.util.PathUtil; import com.intellij.util.ui.ColumnInfo; @@ -144,6 +145,7 @@ final class BrowserSettingsPanel { private JComponent browsersTable; private ComboBox defaultBrowserPolicyComboBox; + private JBCheckBox showBrowserHover; private TableModelEditor browsersEditor; @@ -321,7 +323,9 @@ final class BrowserSettingsPanel { GeneralSettings generalSettings = GeneralSettings.getInstance(); DefaultBrowserPolicy defaultBrowserPolicy = getDefaultBrowser(); - if (browserManager.getDefaultBrowserPolicy() != defaultBrowserPolicy || generalSettings.isConfirmExtractFiles() != confirmExtractFiles.isSelected()) { + if (browserManager.getDefaultBrowserPolicy() != defaultBrowserPolicy || + generalSettings.isConfirmExtractFiles() != confirmExtractFiles.isSelected() || + browserManager.isShowBrowserHover() != showBrowserHover.isSelected()) { return true; } @@ -345,6 +349,7 @@ final class BrowserSettingsPanel { settings.setConfirmExtractFiles(confirmExtractFiles.isSelected()); WebBrowserManager browserManager = WebBrowserManager.getInstance(); + browserManager.setShowBrowserHover(showBrowserHover.isSelected()); browserManager.defaultBrowserPolicy = getDefaultBrowser(); browserManager.setList(browsersEditor.apply()); } @@ -354,14 +359,16 @@ final class BrowserSettingsPanel { } public void reset() { - DefaultBrowserPolicy defaultBrowserPolicy = WebBrowserManager.getInstance().getDefaultBrowserPolicy(); + final WebBrowserManager browserManager = WebBrowserManager.getInstance(); + DefaultBrowserPolicy defaultBrowserPolicy = browserManager.getDefaultBrowserPolicy(); DefaultBrowserPolicy effectiveDefaultBrowserPolicy = defaultBrowserPolicy == DefaultBrowserPolicy.SYSTEM && !BrowserLauncherAppless.canUseSystemDefaultBrowserPolicy() ? DefaultBrowserPolicy.ALTERNATIVE : defaultBrowserPolicy; defaultBrowserPolicyComboBox.setSelectedItem(effectiveDefaultBrowserPolicy); GeneralSettings settings = GeneralSettings.getInstance(); confirmExtractFiles.setSelected(settings.isConfirmExtractFiles()); - browsersEditor.reset(WebBrowserManager.getInstance().getList()); + showBrowserHover.setSelected(browserManager.isShowBrowserHover()); + browsersEditor.reset(browserManager.getList()); customPathValue = settings.getBrowserPath(); alternativeBrowserPathField.setEnabled(effectiveDefaultBrowserPolicy == DefaultBrowserPolicy.ALTERNATIVE); diff --git a/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java b/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java index 0b2ba6cb18c1..6aa389382484 100644 --- a/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java +++ b/xml/impl/src/com/intellij/ide/browsers/WebBrowserManager.java @@ -51,7 +51,7 @@ public class WebBrowserManager extends SimpleModificationTracker implements Pers ); private List browsers; - + private boolean myShowBrowserHover = true; DefaultBrowserPolicy defaultBrowserPolicy = DefaultBrowserPolicy.SYSTEM; public WebBrowserManager() { @@ -103,6 +103,9 @@ public class WebBrowserManager extends SimpleModificationTracker implements Pers if (defaultBrowserPolicy != DefaultBrowserPolicy.SYSTEM) { state.setAttribute("default", defaultBrowserPolicy.name().toLowerCase(Locale.ENGLISH)); } + if (!myShowBrowserHover) { + state.setAttribute("showHover", "false"); + } for (ConfigurableWebBrowser browser : browsers) { Element entry = new Element("browser"); @@ -206,6 +209,8 @@ public class WebBrowserManager extends SimpleModificationTracker implements Pers } } + myShowBrowserHover = !"false".equals(element.getAttributeValue("showHover")); + List list = new ArrayList(); for (Element child : element.getChildren("browser")) { BrowserFamily family = readFamily(child.getAttributeValue("family")); @@ -388,4 +393,12 @@ public class WebBrowserManager extends SimpleModificationTracker implements Pers } return null; } + + public void setShowBrowserHover(boolean showBrowserHover) { + myShowBrowserHover = showBrowserHover; + } + + public boolean isShowBrowserHover() { + return myShowBrowserHover; + } } \ No newline at end of file diff --git a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java index 5298e0e7b90e..446462185774 100644 --- a/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java +++ b/xml/impl/src/com/intellij/ide/browsers/actions/OpenInBrowserBaseGroupAction.java @@ -80,7 +80,8 @@ public abstract class OpenInBrowserBaseGroupAction extends ComputableActionGroup @Override public void update(@NotNull AnActionEvent e) { - e.getPresentation().setVisible(!WebBrowserManager.getInstance().getActiveBrowsers().isEmpty()); + final WebBrowserManager browserManager = WebBrowserManager.getInstance(); + e.getPresentation().setVisible(browserManager.isShowBrowserHover() && !browserManager.getActiveBrowsers().isEmpty()); } } } \ No newline at end of file From f4056fec8ad8c9d245738ada20de492602188179 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 28 Nov 2014 15:40:05 +0300 Subject: [PATCH 03/24] cleanup --- .../editorconfig/plugincomponents/EditorConfigNotifier.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/editorconfig/src/org/editorconfig/plugincomponents/EditorConfigNotifier.java b/plugins/editorconfig/src/org/editorconfig/plugincomponents/EditorConfigNotifier.java index 2e044435002b..b189d3ddd433 100644 --- a/plugins/editorconfig/src/org/editorconfig/plugincomponents/EditorConfigNotifier.java +++ b/plugins/editorconfig/src/org/editorconfig/plugincomponents/EditorConfigNotifier.java @@ -27,8 +27,4 @@ public class EditorConfigNotifier { Notifications.Bus.notify(new Notification("editorconfig", "EditorConfig", message, type), project); PropertiesComponent.getInstance(project).setValue(LAST_NOTIFICATION_STATUS, id); } - - public void info(Project project, String message) { - doNotify(project, message, message, NotificationType.INFORMATION); - } } From 46223378c95df08f32e9eeb7c672f51047c932dc Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 28 Nov 2014 16:11:22 +0300 Subject: [PATCH 04/24] fix NPE in notification on IOError #WEB-14085 fixed --- plugins/editorconfig/src/org/editorconfig/Utils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/editorconfig/src/org/editorconfig/Utils.java b/plugins/editorconfig/src/org/editorconfig/Utils.java index 1f08a0752f91..96daf4059285 100644 --- a/plugins/editorconfig/src/org/editorconfig/Utils.java +++ b/plugins/editorconfig/src/org/editorconfig/Utils.java @@ -24,7 +24,11 @@ public class Utils { } public static void invalidConfigMessage(Project project, String configValue, String configKey, String filePath) { - EditorConfigNotifier.getInstance().error(project, configValue, "\"" + configValue + "\" is not a valid value" + (!configKey.isEmpty() ? " for " + configKey : "") + " for file " + filePath); + final String message = configValue != null ? + "\"" + configValue + "\" is not a valid value" + (!configKey.isEmpty() ? " for " + configKey : "") + " for file " + filePath : + "Failed to read .editorconfig file"; + configValue = configValue != null ? configValue : "ioError"; + EditorConfigNotifier.getInstance().error(project, configValue, message); } public static String getFilePath(Project project, VirtualFile file) { From 9582043c338d987e19193c5cfe8d53e9a3b3003d Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 28 Nov 2014 13:06:30 +0100 Subject: [PATCH 05/24] disable deep parameter delete for super calls only --- .../refactoring/safeDelete/JavaSafeDeleteProcessor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java index 6c35b08a0ed3..d2535ce6bee3 100644 --- a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java @@ -41,6 +41,7 @@ import com.intellij.refactoring.JavaRefactoringSettings; import com.intellij.refactoring.RefactoringBundle; import com.intellij.refactoring.changeSignature.inCallers.JavaCallerChooser; import com.intellij.refactoring.safeDelete.usageInfo.*; +import com.intellij.refactoring.util.RefactoringChangeUtil; import com.intellij.refactoring.util.RefactoringMessageUtil; import com.intellij.refactoring.util.RefactoringUIUtil; import com.intellij.usageView.UsageInfo; @@ -747,7 +748,7 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase { PsiElement element = reference.getElement(); if (element != null) { JavaSafeDeleteDelegate.EP.forLanguage(element.getLanguage()).createUsageInfoForParameter(reference, usages, parameter, method); - if (!parameter.isVarArgs()) { + if (!parameter.isVarArgs() && !RefactoringChangeUtil.isSuperMethodCall(element.getParent())) { final PsiParameter paramInCaller = SafeDeleteJavaCallerChooser.isTheOnlyOneParameterUsage(element.getParent(), parameterIndex, method); if (paramInCaller != null) { final PsiMethod callerMethod = (PsiMethod)paramInCaller.getDeclarationScope(); From 9f267597cf0db76dc1067e7e7fd842ab30a39f24 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 28 Nov 2014 13:27:03 +0100 Subject: [PATCH 06/24] infer nullity: do not suggest @Nullable/@NotNull based on lambda return statements inside --- .../codeInspection/inferNullity/NullityInferrer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/inferNullity/NullityInferrer.java b/java/java-impl/src/com/intellij/codeInspection/inferNullity/NullityInferrer.java index 7ce5e3f36183..e17215baea5b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/inferNullity/NullityInferrer.java +++ b/java/java-impl/src/com/intellij/codeInspection/inferNullity/NullityInferrer.java @@ -422,6 +422,9 @@ public class NullityInferrer { //so as not to drill into anonymous classes } + @Override + public void visitLambdaExpression(PsiLambdaExpression expression) {} + @Override public void visitReturnStatement(@NotNull PsiReturnStatement statement) { super.visitReturnStatement(statement); @@ -491,8 +494,10 @@ public class NullityInferrer { final boolean[] sometimesReturnsNull = new boolean[1]; body.accept(new JavaRecursiveElementWalkingVisitor() { @Override - public void visitClass(PsiClass aClass) { - } + public void visitClass(PsiClass aClass) {} + + @Override + public void visitLambdaExpression(PsiLambdaExpression expression) {} @Override public void visitElement(PsiElement element) { From f40a2e3442ff762a37c7ecde0f4c6616b1f9f140 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 28 Nov 2014 13:43:58 +0100 Subject: [PATCH 07/24] invert boolean: skip lambda returns --- .../invertBoolean/InvertBooleanProcessor.java | 6 ++++-- .../invertBoolean/booleanReturnInsideLambda.java | 12 ++++++++++++ .../booleanReturnInsideLambda_after.java | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda.java create mode 100644 java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda_after.java diff --git a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java index df2efc6f4440..cf45aa459c02 100644 --- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java @@ -116,8 +116,10 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor { } @Override - public void visitClass(PsiClass aClass) { - } + public void visitClass(PsiClass aClass) {} + + @Override + public void visitLambdaExpression(PsiLambdaExpression expression) {} }); } } else if (myElement instanceof PsiParameter && ((PsiParameter)myElement).getDeclarationScope() instanceof PsiMethod) { diff --git a/java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda.java b/java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda.java new file mode 100644 index 000000000000..3b6e5768ba52 --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda.java @@ -0,0 +1,12 @@ +class C { + interface I { + boolean b(); + } + + private boolean bool() { + I i = () -> { + return true; + }; + return false; + } +} diff --git a/java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda_after.java b/java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda_after.java new file mode 100644 index 000000000000..7a399fc2e798 --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/booleanReturnInsideLambda_after.java @@ -0,0 +1,12 @@ +class C { + interface I { + boolean b(); + } + + private boolean boolInverted() { + I i = () -> { + return true; + }; + return true; + } +} From a673a50d6d63e85cceca95446bb8b174285ae2f6 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 28 Nov 2014 14:00:30 +0100 Subject: [PATCH 08/24] extract method object: do not touch return statements in nested lambdas --- .../ExtractMethodObjectProcessor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java index 0cf023394880..f2c2c9515a85 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java @@ -271,6 +271,12 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { public void visitReturnStatement(PsiReturnStatement statement) { returnStatements.add(statement); } + + @Override + public void visitClass(PsiClass aClass) {} + + @Override + public void visitLambdaExpression(PsiLambdaExpression expression) {} }); if (myExtractProcessor.generatesConditionalExit()) { for (int i = 0; i < returnStatements.size() - 1; i++) { @@ -307,8 +313,10 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor { } @Override - public void visitClass(PsiClass aClass) { - } + public void visitClass(PsiClass aClass) {} + + @Override + public void visitLambdaExpression(PsiLambdaExpression expression) {} @Override public void visitDeclarationStatement(final PsiDeclarationStatement statement) { From ffe86ed1a4e3d7daf1e4d4fb779f38b0ff276292 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 14:27:42 +0100 Subject: [PATCH 09/24] remove private constructor --- .../platform-api/src/com/intellij/util/ContentsUtil.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/ContentsUtil.java b/platform/platform-api/src/com/intellij/util/ContentsUtil.java index 44a8e0aa7ecd..8b7f52f29913 100644 --- a/platform/platform-api/src/com/intellij/util/ContentsUtil.java +++ b/platform/platform-api/src/com/intellij/util/ContentsUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -15,13 +15,10 @@ */ package com.intellij.util; -import com.intellij.ui.content.ContentManager; import com.intellij.ui.content.Content; +import com.intellij.ui.content.ContentManager; public class ContentsUtil { - private ContentsUtil() { - } - public static void addOrReplaceContent(ContentManager manager, Content content, boolean select) { final String contentName = content.getDisplayName(); From 5299d4ec7cdd54af6b14093741a4be512dc243ac Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 14:28:50 +0100 Subject: [PATCH 10/24] add utility class to work with tabbed content --- .../src/com/intellij/util/ContentUtilEx.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 platform/platform-impl/src/com/intellij/util/ContentUtilEx.java diff --git a/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java b/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java new file mode 100644 index 000000000000..b3882333861b --- /dev/null +++ b/platform/platform-impl/src/com/intellij/util/ContentUtilEx.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2014 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. + */ +package com.intellij.util; + +import com.intellij.openapi.Disposable; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Pair; +import com.intellij.ui.content.Content; +import com.intellij.ui.content.ContentManager; +import com.intellij.ui.content.TabbedContent; +import com.intellij.ui.content.impl.TabbedContentImpl; + +import javax.swing.*; +import java.util.ArrayList; + +/** + * @author Konstantin Bulenkov + */ +public class ContentUtilEx extends ContentsUtil { + public static void addTabbedContent(ContentManager manager, JComponent contentComponent, String groupPrefix, String tabName, boolean select) { + TabbedContent tabbedContent = null; + for (Content content : manager.getContents()) { + if (content instanceof TabbedContent && content.getTabName().startsWith(groupPrefix + ": ")) { + tabbedContent = (TabbedContent)content; + break; + } + } + + if (tabbedContent == null) { + final Disposable disposable = Disposer.newDisposable(); + tabbedContent = new TabbedContentImpl(contentComponent, tabName, true, groupPrefix); + ContentsUtil.addOrReplaceContent(manager, tabbedContent, select); + Disposer.register(tabbedContent, disposable); + } else { + for (Pair tab : new ArrayList>(tabbedContent.getTabs())) { + if (Comparing.equal(tab.second, contentComponent)) { + tabbedContent.removeContent(tab.second); + } + } + if (select) { + manager.setSelectedContent(tabbedContent, true, true); + } + tabbedContent.addContent(contentComponent, tabName, true); + } + } +} From d92c41b6336b05b61db5d934b062611a7594510a Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 14:29:24 +0100 Subject: [PATCH 11/24] equals/hashCode based on VirtualFile --- .../openapi/vcs/history/FileHistoryPanelImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index c319b3fca6ee..44b2aa1d2acd 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -1774,6 +1774,17 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { } } + @Override + public boolean equals(Object obj) { + return obj instanceof FileHistoryPanelImpl && Comparing.equal(((FileHistoryPanelImpl)obj).getVirtualFile(), getVirtualFile()); + } + + @Override + public int hashCode() { + final VirtualFile file = getVirtualFile(); + return file == null ? 0 : file.hashCode(); + } + private class MyToggleAction extends ToggleAction implements DumbAware { public MyToggleAction() { From 612b11e0a8fee0faf57c98e1be3df82e72a68fd1 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 14:30:31 +0100 Subject: [PATCH 12/24] refactor History tab management. Use ContentUtilEx --- .../history/FileHistorySessionPartner.java | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java index 6cc8373a9cc8..9ccef5c100e0 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java @@ -15,12 +15,8 @@ */ package com.intellij.openapi.vcs.history; -import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.FilePath; @@ -35,15 +31,12 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; import com.intellij.ui.content.ContentManager; -import com.intellij.ui.content.TabbedContent; -import com.intellij.ui.content.impl.TabbedContentImpl; import com.intellij.util.BufferedListConsumer; import com.intellij.util.Consumer; +import com.intellij.util.ContentUtilEx; import com.intellij.util.ContentsUtil; import org.jetbrains.annotations.NotNull; -import javax.swing.*; -import java.util.ArrayList; import java.util.List; /** @@ -141,30 +134,7 @@ public class FileHistorySessionPartner implements VcsAppendableHistorySessionPar assert toolWindow != null : "Version Control ToolWindow should be available at this point."; if (Registry.is("vcs.merge.toolwindows")) { - Content history = null; - for (Content content : toolWindow.getContentManager().getContents()) { - if (content.getTabName().startsWith("History: ")) { - history = content; - break; - } - } - - if (history == null) { - final Disposable disposable = Disposer.newDisposable(); - history = new TabbedContentImpl(myFileHistoryPanel, myFileHistoryPanel.getVirtualFile().getName(), true, "History"); - ContentsUtil.addOrReplaceContent(contentManager, history, true); - Disposer.register(history, disposable); - } else { - TabbedContent tabbedContent = (TabbedContent)history; - String fileName = myFileHistoryPanel.getVirtualFile().getName(); - for (Pair tab : new ArrayList>(tabbedContent.getTabs())) { - if (Comparing.equal(((FileHistoryPanelImpl)tab.second).getVirtualFile(), myFileHistoryPanel.getVirtualFile())) { - tabbedContent.removeContent(tab.second); - } - } - toolWindow.getContentManager().setSelectedContent(tabbedContent, true, true); - tabbedContent.addContent(myFileHistoryPanel, fileName, true); - } + ContentUtilEx.addTabbedContent(toolWindow.getContentManager(), myFileHistoryPanel, "History", myFileHistoryPanel.getVirtualFile().getName(), true); } else { Content content = ContentFactory.SERVICE.getInstance().createContent(myFileHistoryPanel, actionName, true); ContentsUtil.addOrReplaceContent(contentManager, content, true); From 13b15efbe2a569a74b79eb6ccb0be8b21ad075be Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 28 Nov 2014 16:55:49 +0300 Subject: [PATCH 13/24] IDEA-133329 Settings: second-level dialog uses big error message from the main Settings dialog --- .../openapi/options/newEditor/ConfigurableEditor.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java index a4b6cf60c1a2..5b8b7073649d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/ConfigurableEditor.java @@ -29,6 +29,7 @@ import com.intellij.openapi.options.*; import com.intellij.openapi.options.ex.ConfigurableCardPanel; import com.intellij.openapi.options.ex.ConfigurableVisitor; import com.intellij.openapi.options.ex.ConfigurableWrapper; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.ActionCallback; import com.intellij.ui.JBColor; import com.intellij.ui.RelativeFont; @@ -87,6 +88,7 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT myResetAction.putValue(Action.SHORT_DESCRIPTION, RESET_DESCRIPTION); myResetAction.setEnabled(false); myErrorLabel.setOpaque(true); + myErrorLabel.setEnabled(parent instanceof SettingsEditor); myErrorLabel.setVisible(false); myErrorLabel.setVerticalTextPosition(SwingConstants.TOP); myErrorLabel.setBorder(BorderFactory.createEmptyBorder(10, 15, 15, 15)); @@ -228,8 +230,13 @@ class ConfigurableEditor extends AbstractEditor implements AnActionListener, AWT myErrorLabel.setVisible(false); return true; } - myErrorLabel.setText("Changes were not applied because of the following error:
" + exception.getMessage()); - myErrorLabel.setVisible(true); + if (myErrorLabel.isEnabled()) { + myErrorLabel.setText("" + exception.getTitle() + ":
" + exception.getMessage()); + myErrorLabel.setVisible(true); + } + else { + Messages.showMessageDialog(this, exception.getMessage(), exception.getTitle(), Messages.getErrorIcon()); + } return false; } From fce9507a12e7489c2124d61b6b6540ca77d06528 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 28 Nov 2014 17:02:09 +0300 Subject: [PATCH 14/24] use CommonShortcuts constants --- .../com/intellij/xdebugger/impl/ui/BreakpointEditor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java index 776688aaba89..5a88c5ee1441 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java @@ -102,9 +102,9 @@ public class BreakpointEditor { done(); } }; - doneAction.registerCustomShortcutSet(new CompositeShortcutSet(CustomShortcutSet.fromString("ESCAPE"), - CustomShortcutSet.fromString("ENTER"), - CustomShortcutSet.fromString("control ENTER")), myMainPanel); + doneAction.registerCustomShortcutSet(new CompositeShortcutSet(CommonShortcuts.ESCAPE, + CommonShortcuts.ENTER, + CommonShortcuts.CTRL_ENTER), myMainPanel); } private void done() { From 1d6f2590bf0b27c068a71787c6f23557412acd86 Mon Sep 17 00:00:00 2001 From: Andrey Vokin Date: Fri, 28 Nov 2014 17:09:40 +0300 Subject: [PATCH 15/24] Preprocessing Live Template. Assert info added when not inline template replaced by inline one --- .../com/intellij/codeInsight/template/impl/TemplateState.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index ff7f2a75d4ac..7832ace7357c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -333,7 +333,8 @@ public class TemplateState implements Disposable { PsiFile file = getPsiFile(); preprocessTemplate(file, myEditor.getCaretModel().getOffset()); myPrevTemplate = myTemplate; - assert !myTemplate.isInline(); + LOG.assertTrue(!myTemplate.isInline(), + "current template: " + presentTemplate(myTemplate) + ", previous template: " + presentTemplate(myPrevTemplate)); int caretOffset = myEditor.getCaretModel().getOffset(); myTemplateRange = myDocument.createRangeMarker(caretOffset, caretOffset); From b59d3db9bf122ffecb39fed9bfe2e7600c593c9c Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 15:16:35 +0100 Subject: [PATCH 16/24] use CommonShortcuts --- .../src/com/intellij/ui/AbstractFieldPanel.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/AbstractFieldPanel.java b/platform/platform-api/src/com/intellij/ui/AbstractFieldPanel.java index 60309cee6bfe..8a81e8b85da4 100644 --- a/platform/platform-api/src/com/intellij/ui/AbstractFieldPanel.java +++ b/platform/platform-api/src/com/intellij/ui/AbstractFieldPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -17,7 +17,7 @@ package com.intellij.ui; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CustomShortcutSet; +import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.FixedSizeButton; @@ -30,7 +30,6 @@ import javax.swing.event.DocumentEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; import java.util.ArrayList; /** @@ -204,7 +203,7 @@ public abstract class AbstractFieldPanel extends JPanel { public void actionPerformed(AnActionEvent e) { doOKAction(); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), myTextArea); + }.registerCustomShortcutSet(CommonShortcuts.ENTER, myTextArea); return ScrollPaneFactory.createScrollPane(myTextArea); } From 2d6aa5857ce326a61a3908343ff2eb5e63e20614 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 15:17:14 +0100 Subject: [PATCH 17/24] use CommonShortcuts --- .../xdebugger/impl/breakpoints/ui/BreakpointsDialog.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java index 549149ff952f..5f628bd48763 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java @@ -52,7 +52,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.awt.event.KeyEvent; import java.util.*; import java.util.List; @@ -272,7 +271,7 @@ public class BreakpointsDialog extends DialogWrapper { navigate(true); close(OK_EXIT_CODE); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), tree); + }.registerCustomShortcutSet(CommonShortcuts.ENTER, tree); new AnAction("BreakpointDialog.ShowSource") { @Override From db7f1ee5ba9eda5721a85467ffe8d7d50d8a6bd5 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 15:18:01 +0100 Subject: [PATCH 18/24] use CommonShortcuts.ENTER --- .../src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java index 8420102220df..92f04fc804ec 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java @@ -349,7 +349,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi group.add(new AnAction("Edit Shortcut", "Edit Shortcut", AllIcons.ToolbarDecorator.Edit) { { - registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), myActionsTree.getTree()); + registerCustomShortcutSet(CommonShortcuts.ENTER, myActionsTree.getTree()); } @Override From 5b27e3c5eeb463bb263fe33e3d9e3cd649a0ef3b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 15:18:45 +0100 Subject: [PATCH 19/24] use CommonShortcuts --- .../com/intellij/ui/popup/util/MasterDetailPopupBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java index c3f71bd8103b..984b512fb254 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/MasterDetailPopupBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -380,7 +380,7 @@ public class MasterDetailPopupBuilder implements MasterController { public void actionPerformed(AnActionEvent e) { chooseItemWithEnterOrDoubleClick(); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), list); + }.registerCustomShortcutSet(CommonShortcuts.ENTER, list); new AnAction() { @Override public void actionPerformed(AnActionEvent e) { From f0a876431afa1c944cbe58c652990f3d7753322c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 28 Nov 2014 15:19:55 +0100 Subject: [PATCH 20/24] show setting with generate annotations right on extract method dialog --- .../dataFlow/DataFlowInspectionBase.java | 15 ------------- .../extractMethod/ExtractMethodDialog.java | 15 ++++++++++++- .../extractMethod/ExtractMethodProcessor.java | 21 ++++++++++++++----- .../CastWhenDuplicateReplacement_after.java | 3 +++ ...arargsShouldNotChangeReturnType_after.java | 3 +++ .../CodeDuplicatesWithOutputValue1_after.java | 3 +++ .../CodeDuplicatesWithOutputValue_after.java | 3 +++ .../CodeDuplicatesWithReturn2_after.java | 3 +++ .../CodeDuplicatesWithReturn_after.java | 3 +++ .../ExpressionDuplicates_after.java | 3 +++ .../ExtractFromTryFinally_after.java | 3 +++ .../FromLambdaBodyWithReturn_after.java | 3 +++ .../NullableCheckDontMissFinal_after.java | 3 +++ .../extractMethod/ReturnFromTry_after.java | 3 +++ .../extractMethod/SCR15815_after.java | 3 +++ .../extractMethod/ThisCall_after.java | 3 +++ ...arDeclAfterExpressionExtraction_after.java | 3 +++ .../util/resources/misc/registry.properties | 5 +---- 18 files changed, 73 insertions(+), 25 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java index 75927fc9b872..c5f7de6925c4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DataFlowInspectionBase.java @@ -134,21 +134,6 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool { }; analyzeDfaWithNestedClosures(scope, holder, dfaRunner, Arrays.asList(dfaRunner.createMemoryState()), onTheFly); } - - @Nullable - public static Collection getNullableReturn(PsiMethod method) { - final StandardDataFlowRunner dfaRunner = new StandardDataFlowRunner(); - final DataFlowInstructionVisitor visitor = new DataFlowInstructionVisitor(dfaRunner); - final PsiCodeBlock body = method.getBody(); - if (body == null) { - return null; - } - final RunnerResult rc = dfaRunner.analyzeMethod(body, visitor); - if (rc == RunnerResult.OK) { - return visitor.getProblems(NullabilityProblem.nullableReturn); - } - return null; - } private void analyzeDfaWithNestedClosures(PsiElement scope, ProblemsHolder holder, diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java index 7283acaecafb..70fab8c5c78b 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java @@ -61,7 +61,8 @@ import java.awt.event.*; */ @SuppressWarnings("MethodMayBeStatic") public class ExtractMethodDialog extends DialogWrapper implements AbstractExtractDialog { - public static final String EXTRACT_METHOD_DEFAULT_VISIBILITY = "extract.method.default.visibility"; + private static final String EXTRACT_METHOD_DEFAULT_VISIBILITY = "extract.method.default.visibility"; + public static final String EXTRACT_METHOD_GENERATE_ANNOTATIONS = "extractMethod.generateAnnotations"; private final Project myProject; private final PsiType myReturnType; private final PsiTypeParameterList myTypeParameterList; @@ -75,6 +76,7 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac private final MethodSignatureComponent mySignature; private final JCheckBox myMakeStatic; protected JCheckBox myMakeVarargs; + protected JCheckBox myGenerateAnnotations; private JCheckBox myCbChainedConstructor; private final InputVariables myVariableData; @@ -196,6 +198,10 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac if (containingMethod != null && containingMethod.hasModifierProperty(PsiModifier.PUBLIC)) { PropertiesComponent.getInstance(myProject).setValue(EXTRACT_METHOD_DEFAULT_VISIBILITY, getVisibility()); } + + if (myGenerateAnnotations != null) { + PropertiesComponent.getInstance(myProject).setValue(EXTRACT_METHOD_GENERATE_ANNOTATIONS, String.valueOf(myGenerateAnnotations.isSelected())); + } super.doOKAction(); } @@ -287,6 +293,13 @@ public class ExtractMethodDialog extends DialogWrapper implements AbstractExtrac optionsPanel.add(myMakeVarargs); } + if (!(myReturnType instanceof PsiPrimitiveType) && PsiUtil.isLanguageLevel5OrHigher(myTargetClass)) { + final boolean isSelected = PropertiesComponent.getInstance(myProject).getBoolean(EXTRACT_METHOD_GENERATE_ANNOTATIONS, true); + myGenerateAnnotations = new JCheckBox("Generate annotations", isSelected); + //todo update signature?! + optionsPanel.add(myGenerateAnnotations); + } + if (myCbChainedConstructor != null) { optionsPanel.add(myCbChainedConstructor); myCbChainedConstructor.setBorder(emptyBorder); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java index 50b028158593..369bb26c99d7 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java @@ -31,6 +31,7 @@ import com.intellij.codeInspection.dataFlow.*; import com.intellij.codeInspection.dataFlow.instructions.BranchingInstruction; import com.intellij.codeInspection.dataFlow.instructions.Instruction; import com.intellij.ide.DataManager; +import com.intellij.ide.util.PropertiesComponent; import com.intellij.ide.util.PsiClassListCellRenderer; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -867,15 +868,25 @@ public class ExtractMethodProcessor implements MatchProvider { } } - if (isNullabilityCheckApplicable() && !(newMethod.getReturnType() instanceof PsiPrimitiveType) && - PsiUtil.isLanguageLevel5OrHigher(newMethod) && Registry.is("annotate.extracted.method.nullable.when.applicable", true)) { + if (isNullabilityCheckApplicable() && !(newMethod.getReturnType() instanceof PsiPrimitiveType) && PsiUtil.isLanguageLevel5OrHigher(newMethod) && + PropertiesComponent.getInstance(myProject).getBoolean(ExtractMethodDialog.EXTRACT_METHOD_GENERATE_ANNOTATIONS, true)) { final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject); final PsiClass nullableAnnotationClass = JavaPsiFacade.getInstance(myProject).findClass(manager.getDefaultNullable(), GlobalSearchScope.allScope(myProject)); if (nullableAnnotationClass != null) { - final Collection nullableReturn = DataFlowInspectionBase.getNullableReturn(newMethod); - if (nullableReturn != null && !nullableReturn.isEmpty()) { - final AddNullableNotNullAnnotationFix annotationFix = new AddNullableAnnotationFix(newMethod); + final Nullness nullness = DfaUtil.inferMethodNullity(newMethod); + AddNullableNotNullAnnotationFix annotationFix; + switch (nullness) { + case NOT_NULL: + annotationFix = new AddNotNullAnnotationFix(newMethod); + break; + case NULLABLE: + annotationFix = new AddNullableAnnotationFix(newMethod); + break; + default: + annotationFix = null; + } + if (annotationFix != null) { annotationFix.invoke(myProject, myTargetClass.getContainingFile(), newMethod, newMethod); } } diff --git a/java/java-tests/testData/refactoring/extractMethod/CastWhenDuplicateReplacement_after.java b/java/java-tests/testData/refactoring/extractMethod/CastWhenDuplicateReplacement_after.java index 106ec29fb405..dbe5a20546ce 100644 --- a/java/java-tests/testData/refactoring/extractMethod/CastWhenDuplicateReplacement_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/CastWhenDuplicateReplacement_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + class Test { void foo(Object x) { @@ -5,6 +7,7 @@ class Test { if (x instanceof String) x = newMethod((String) x); } + @NotNull private String newMethod(String x) { return x.substring(1); } diff --git a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesVarargsShouldNotChangeReturnType_after.java b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesVarargsShouldNotChangeReturnType_after.java index 97652c778c1e..cabf2a5a0c1d 100644 --- a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesVarargsShouldNotChangeReturnType_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesVarargsShouldNotChangeReturnType_after.java @@ -1,9 +1,12 @@ +import org.jetbrains.annotations.NotNull; + class Test { void foo() { bar(newMethod()); baz(newMethod()); } + @NotNull private String newMethod() { return String.valueOf(1); } diff --git a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue1_after.java b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue1_after.java index 81ebc6806331..6ac023628408 100644 --- a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue1_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue1_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + import java.util.*; class C { @@ -11,6 +13,7 @@ class C { System.out.println("l1 = " + l1 + ", l2 = " + l2); } + @NotNull private List newMethod(Object[] array) { List l1 = null; l1 = new ArrayList(Arrays.asList(array)); diff --git a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue_after.java b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue_after.java index 9b0dca12e8ea..bd8e0b719009 100644 --- a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithOutputValue_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + import java.util.*; class C { @@ -11,6 +13,7 @@ class C { System.out.println("l1 = " + l1 + ", l2 = " + l2); } + @NotNull private List newMethod(Object[] array) { return new ArrayList(Arrays.asList(array)); } diff --git a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn2_after.java b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn2_after.java index 7ccc2380d719..e6bc2850b072 100644 --- a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn2_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn2_after.java @@ -1,9 +1,12 @@ +import org.jetbrains.annotations.NotNull; + class C { String method(Object o) { System.out.println(o); return newMethod(o); } + @NotNull private String newMethod(Object o) { Integer i = new Integer(o.hashCode()); return i.toString(); diff --git a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn_after.java b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn_after.java index 9901f3b87d6c..86c3e46763be 100644 --- a/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/CodeDuplicatesWithReturn_after.java @@ -1,9 +1,12 @@ +import org.jetbrains.annotations.NotNull; + class C { String method(Object o) { System.out.println(o); return newMethod(o); } + @NotNull private String newMethod(Object o) { Integer i = new Integer(o.hashCode()); return i.toString(); diff --git a/java/java-tests/testData/refactoring/extractMethod/ExpressionDuplicates_after.java b/java/java-tests/testData/refactoring/extractMethod/ExpressionDuplicates_after.java index a564ab13bded..83aa1d0b7f68 100644 --- a/java/java-tests/testData/refactoring/extractMethod/ExpressionDuplicates_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/ExpressionDuplicates_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + import java.util.*; class C { @@ -8,6 +10,7 @@ class C { List l1 = newMethod(new Object[0]); } + @NotNull private ArrayList newMethod(Object[] o) { return new ArrayList(Arrays.asList(o)); } diff --git a/java/java-tests/testData/refactoring/extractMethod/ExtractFromTryFinally_after.java b/java/java-tests/testData/refactoring/extractMethod/ExtractFromTryFinally_after.java index 52900ce6ee0d..fae271959f7d 100644 --- a/java/java-tests/testData/refactoring/extractMethod/ExtractFromTryFinally_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/ExtractFromTryFinally_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + public class S { { String s; @@ -8,6 +10,7 @@ public class S { System.out.print(s); } + @NotNull private String newMethod() { String s; s = ""; diff --git a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBodyWithReturn_after.java b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBodyWithReturn_after.java index 9b5d3d680a66..f3441791c8bd 100644 --- a/java/java-tests/testData/refactoring/extractMethod/FromLambdaBodyWithReturn_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/FromLambdaBodyWithReturn_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + class Test { interface I { String foo(); @@ -8,6 +10,7 @@ class Test { }; } + @NotNull private String newMethod() { return "42"; } diff --git a/java/java-tests/testData/refactoring/extractMethod/NullableCheckDontMissFinal_after.java b/java/java-tests/testData/refactoring/extractMethod/NullableCheckDontMissFinal_after.java index 217f9f4f955a..94013e366942 100644 --- a/java/java-tests/testData/refactoring/extractMethod/NullableCheckDontMissFinal_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/NullableCheckDontMissFinal_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + class Test { void foo() { final String str = newMethod(); @@ -9,6 +11,7 @@ class Test { } } + @NotNull private String newMethod() { final String str = ""; if (str == "") { diff --git a/java/java-tests/testData/refactoring/extractMethod/ReturnFromTry_after.java b/java/java-tests/testData/refactoring/extractMethod/ReturnFromTry_after.java index 4621ab2ba5c8..ce3d365100e9 100644 --- a/java/java-tests/testData/refactoring/extractMethod/ReturnFromTry_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/ReturnFromTry_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + class A { public String method() { try { @@ -9,6 +11,7 @@ class A { return ""; } + @NotNull private String newMethod() { try { return ""; diff --git a/java/java-tests/testData/refactoring/extractMethod/SCR15815_after.java b/java/java-tests/testData/refactoring/extractMethod/SCR15815_after.java index 23a53de82e87..9d0877031ae0 100644 --- a/java/java-tests/testData/refactoring/extractMethod/SCR15815_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/SCR15815_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + public class Foo { static Foo f1 = new Foo(){ @@ -6,6 +8,7 @@ public class Foo { } }; + @NotNull private static String newMethod() { return "a" + "b"; } diff --git a/java/java-tests/testData/refactoring/extractMethod/ThisCall_after.java b/java/java-tests/testData/refactoring/extractMethod/ThisCall_after.java index e30db827fa05..5f954d13db6e 100644 --- a/java/java-tests/testData/refactoring/extractMethod/ThisCall_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/ThisCall_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + public class A { A(String s) { } @@ -6,6 +8,7 @@ public class A { this(newMethod()); } + @NotNull private static String newMethod() { return "a"; } diff --git a/java/java-tests/testData/refactoring/extractMethod/VarDeclAfterExpressionExtraction_after.java b/java/java-tests/testData/refactoring/extractMethod/VarDeclAfterExpressionExtraction_after.java index cb7aeffa679d..fdf2963c9797 100644 --- a/java/java-tests/testData/refactoring/extractMethod/VarDeclAfterExpressionExtraction_after.java +++ b/java/java-tests/testData/refactoring/extractMethod/VarDeclAfterExpressionExtraction_after.java @@ -1,3 +1,5 @@ +import org.jetbrains.annotations.NotNull; + class BasicLazyResolveTest { @@ -9,6 +11,7 @@ class BasicLazyResolveTest { } + @NotNull private Object newMethod() { return new Object() { diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index fa0d5c9a4253..bb4706fc1df6 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -497,7 +497,4 @@ editor.config.stop.at.project.root=true editor.config.stop.at.project.root.description=Stops searching for .editorconfig at project root (requires project reopening) JDK8042508.bug.fixed=false -JDK8042508.bug.fixed.description=Disable check for type variable until javac bug is fixed - -annotate.extracted.method.nullable.when.applicable=true -annotate.extracted.method.nullable.when.applicable.description=Enables @Nullable annotation on newly extracted method when applicable +JDK8042508.bug.fixed.description=Disable check for type variable until javac bug is fixed \ No newline at end of file From e65a4ceabb22b7d9df8cb8261e0480aac2ace7c4 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 28 Nov 2014 15:33:06 +0100 Subject: [PATCH 21/24] use CommonShortcuts.ESCAPE --- .../impl/src/com/intellij/debugger/ui/impl/TipManager.java | 6 +++--- .../intellij/openapi/ui/impl/DialogWrapperPeerImpl.java | 2 +- .../designer/designSurface/InplaceEditingLayer.java | 7 +++---- .../src/com/intellij/designer/palette/PalettePanel.java | 5 ++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/TipManager.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/TipManager.java index df91efed9579..7cc7cdbb47e0 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/TipManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/TipManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -20,7 +20,7 @@ import com.intellij.ide.FrameStateManager; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CustomShortcutSet; +import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Weighted; @@ -289,7 +289,7 @@ public class TipManager implements Disposable, PopupMenuListener { }); final HideTooltipAction hide = new HideTooltipAction(); - hide.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), myComponent); + hide.registerCustomShortcutSet(CommonShortcuts.ESCAPE, myComponent); Disposer.register(this, new Disposable() { @Override public void dispose() { diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java index edeacb23222c..87ccc2e11f4b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/impl/DialogWrapperPeerImpl.java @@ -438,7 +438,7 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra final AnCancelAction anCancelAction = new AnCancelAction(); final JRootPane rootPane = getRootPane(); - anCancelAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), rootPane); + anCancelAction.registerCustomShortcutSet(CommonShortcuts.ESCAPE, rootPane); myDisposeActions.add(new Runnable() { @Override public void run() { diff --git a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/InplaceEditingLayer.java b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/InplaceEditingLayer.java index 04860dfebc0d..2fd7aad346bc 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/designSurface/InplaceEditingLayer.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/designSurface/InplaceEditingLayer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -24,7 +24,7 @@ import com.intellij.designer.propertyTable.PropertyEditor; import com.intellij.designer.propertyTable.PropertyEditorListener; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CustomShortcutSet; +import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; @@ -40,7 +40,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.FocusEvent; -import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; @@ -125,7 +124,7 @@ public class InplaceEditingLayer extends JComponent { public void actionPerformed(AnActionEvent e) { finishEditing(false); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), myInplaceComponent); + }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, myInplaceComponent); myEditors = new ArrayList(); diff --git a/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java b/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java index f81baca17551..f48dfa4b9320 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/palette/PalettePanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -34,7 +34,6 @@ import java.awt.dnd.DragSourceListener; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -89,7 +88,7 @@ public class PalettePanel extends JPanel implements DataProvider, PaletteToolWin public void actionPerformed(AnActionEvent e) { clearActiveItem(); } - }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), scrollPane); + }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, scrollPane); if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { DragSource.getDefaultDragSource().addDragSourceListener(myDragSourceListener); From 6fe6353215deb8dc1c459fc099e7ffa4f3fc378b Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 28 Nov 2014 17:44:22 +0300 Subject: [PATCH 22/24] registry option to switch scrollbars to full width --- .../openapi/editor/impl/EditorMarkupModelImpl.java | 10 ++++++++-- platform/util/resources/misc/registry.properties | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java index 3503cb60cb04..5a77cf7a3b9f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java @@ -592,8 +592,14 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark } } else { - int half = getThickness() / 2; - int shift = isMirrored() ? -half + 2 : half - 1; + int shift; + if (Registry.is("editor.full.width.scrollbar")) { + shift = isMirrored() ? -myMinMarkHeight + 1 : myMinMarkHeight; + } + else { + int half = getThickness() / 2; + shift = isMirrored() ? -half + 2 : half - 1; + } g.translate(shift, 0); super.paintThumb(g, c, thumbBounds); g.translate(-shift, 0); diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index bb4706fc1df6..b7d8f4d5a81c 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -490,6 +490,9 @@ editor.caret.width.restartRequired=true editor.transparent.scrollbar=true editor.transparent.scrollbar.description=Don't paint background for editor scroll bars +editor.full.width.scrollbar=false +editor.full.size.scrollbar.description=Increase width of the vertical scrollbar to fit marks width + editor.xcode.like.scrollbar=false editor.xcode.like.scrollbar.description=Enables auto-hideable Xcode-like editor stripes From f8b3393fe7b18532336d7cc2cfae790d4241b857 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Fri, 28 Nov 2014 17:48:44 +0300 Subject: [PATCH 23/24] IDEA-90936 Force project make option before launch in run configuration --- .../options/CompileStepBeforeRun.java | 8 +- .../options/MakeProjectStepBeforeRun.java | 108 ++++++++++++++++++ .../src/messages/ExecutionBundle.properties | 1 + resources/src/idea/RichPlatformPlugin.xml | 1 + 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 java/execution/impl/src/com/intellij/compiler/options/MakeProjectStepBeforeRun.java diff --git a/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java b/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java index 124220d75966..b0d878f9bea9 100644 --- a/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java +++ b/java/execution/impl/src/com/intellij/compiler/options/CompileStepBeforeRun.java @@ -102,7 +102,11 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider { + public static final Key ID = Key.create("MakeProject"); + + private final Project myProject; + + public MakeProjectStepBeforeRun(@NotNull Project project) { + myProject = project; + } + + @Override + public Key getId() { + return ID; + } + + @Override + public String getName() { + return ExecutionBundle.message("before.launch.make.project.step"); + } + + @Override + public String getDescription(MakeProjectBeforeRunTask task) { + return getName(); + } + @Override + public Icon getIcon() { + return AllIcons.Actions.Compile; + } + + @Override + public Icon getTaskIcon(MakeProjectBeforeRunTask task) { + return AllIcons.Actions.Compile; + } + + public boolean configureTask(RunConfiguration runConfiguration, MakeProjectBeforeRunTask task) { + return false; + } + + @Override + public boolean canExecuteTask(RunConfiguration configuration, MakeProjectBeforeRunTask task) { + return true; + } + + public boolean executeTask(DataContext context, final RunConfiguration configuration, final ExecutionEnvironment env, MakeProjectBeforeRunTask task) { + return CompileStepBeforeRun.doMake(myProject, configuration, env, false, true); + } + + public boolean isConfigurable() { + return false; + } + + @Nullable + public static RunConfiguration getRunConfiguration(final CompileContext context) { + return getRunConfiguration(context.getCompileScope()); + } + + @Nullable + public static RunConfiguration getRunConfiguration(final CompileScope compileScope) { + return compileScope.getUserData(CompileStepBeforeRun.RUN_CONFIGURATION); + } + + + public MakeProjectBeforeRunTask createTask(RunConfiguration runConfiguration) { + return !(runConfiguration instanceof RemoteConfiguration) && runConfiguration instanceof RunProfileWithCompileBeforeLaunchOption + ? new MakeProjectBeforeRunTask() + : null; + } + + public static class MakeProjectBeforeRunTask extends BeforeRunTask { + public MakeProjectBeforeRunTask() { + super(ID); + } + } +} diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index a98190c6a751..b2f05abc66bd 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -323,6 +323,7 @@ configuration.action.chooser.title=Choose configuration type to run env.vars.checkbox.title=&Include parent environment variables before.launch.compile.step=Make +before.launch.make.project.step=Make Project before.launch.compile.step.no.error.check=Make, no error check execute.before.run.debug.dialog.title=Execute {0} Before Run/Debug diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index c125b2a5f651..67a2f01437ac 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -330,6 +330,7 @@ + From 14658744be21e45a69c1adc749ad610573d2abd0 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Fri, 28 Nov 2014 17:58:06 +0300 Subject: [PATCH 24/24] @Nullable annotation & NPE fix --- .../intellij/openapi/editor/colors/EditorColorsScheme.java | 2 ++ .../openapi/editor/colors/impl/DefaultColorsScheme.java | 1 + .../openapi/editor/colors/impl/EditorColorsSchemeImpl.java | 2 ++ .../lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java | 6 +++++- .../openapi/editor/colors/impl/DelegateColorScheme.java | 1 + .../src/com/intellij/openapi/editor/impl/EditorImpl.java | 1 + .../platform-impl/src/com/intellij/ui/EditorTextField.java | 1 + .../plugins/terminal/JBTerminalSystemSettingsProvider.java | 1 + 8 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index c54b44153f91..d19658d588fb 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -21,6 +21,7 @@ import com.intellij.openapi.options.Scheme; import com.intellij.openapi.util.JDOMExternalizable; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -36,6 +37,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextA @NotNull Color getDefaultForeground(); + @Nullable Color getColor(ColorKey key); void setColor(ColorKey key, Color color); diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java index 54b6d061eee8..7c907d1c607b 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java @@ -53,6 +53,7 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl return attrs; } + @Nullable @Override public Color getColor(ColorKey key) { if (key == null) return null; diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java index c4bf8be2ca4c..1fc6e1fa4f06 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java @@ -24,6 +24,7 @@ import com.intellij.openapi.options.ExternalInfo; import com.intellij.openapi.options.ExternalizableScheme; import com.intellij.openapi.util.Comparing; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -73,6 +74,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte return myAttributesMap.containsKey(key); } + @Nullable @Override public Color getColor(ColorKey key) { if (myColorsMap.containsKey(key)) { diff --git a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java index 7401472ef171..fca1bd208643 100644 --- a/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java +++ b/platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java @@ -359,7 +359,11 @@ public class Bookmark implements Navigatable { } private static boolean darkBackground() { - return ColorUtil.isDark(EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND)); + Color gutterBackground = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND); + if (gutterBackground == null) { + gutterBackground = EditorColors.GUTTER_BACKGROUND.getDefaultColor(); + } + return ColorUtil.isDark(gutterBackground); } private static class MyGutterIconRenderer extends GutterIconRenderer { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java index de856c86aee5..1089d5e54e3e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java @@ -72,6 +72,7 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getDefaultForeground(); } + @Nullable @Override public Color getColor(ColorKey key) { return myDelegate.getColor(key); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index a4e0e7a4be1d..40eb995f1dbd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -6068,6 +6068,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi myOwnAttributes.put(key, attributes); } + @Nullable @Override public Color getColor(ColorKey key) { if (myOwnColors.containsKey(key)) return myOwnColors.get(key); diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java index 5c1bffb8ee56..45e41537f673 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java @@ -493,6 +493,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); if (!isEnabled()) { editor.setColorsScheme(new DelegateColorScheme(colorsScheme) { + @Nullable @Override public Color getColor(ColorKey key) { return super.getColor(key); diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java index dbc4ee5c13b6..b805b7863780 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java @@ -308,6 +308,7 @@ public class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvi return getGlobal().getDefaultForeground(); } + @Nullable @Override public Color getColor(ColorKey key) { if (myOwnColors.containsKey(key)) return myOwnColors.get(key);