From 952966d58bbbdf5698ed149828e420dc0ce6d161 Mon Sep 17 00:00:00 2001 From: irengrig Date: Thu, 11 Jun 2015 11:38:37 +0200 Subject: [PATCH 01/16] v8 log processing, allow to read only a part of random-sized-records file --- .../util/CloseableThrowableProcessor.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 platform/util/src/com/intellij/util/CloseableThrowableProcessor.java diff --git a/platform/util/src/com/intellij/util/CloseableThrowableProcessor.java b/platform/util/src/com/intellij/util/CloseableThrowableProcessor.java new file mode 100644 index 000000000000..d15fba49ba6c --- /dev/null +++ b/platform/util/src/com/intellij/util/CloseableThrowableProcessor.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2015 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 java.io.Closeable; + +/** + * @author Irina.Chernushina on 6/11/2015. + */ +public interface CloseableThrowableProcessor extends Closeable { + boolean process(S s) throws T; +} From 5ad3c32c70d86e61675eb53a8f696e714c7928aa Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 12 Jun 2015 09:46:29 +0300 Subject: [PATCH 02/16] Fix missing dark line at the bottom --- .../src/com/intellij/util/ui/MacUIUtil.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/MacUIUtil.java b/platform/util/src/com/intellij/util/ui/MacUIUtil.java index af3b55023539..b5899bc95c46 100644 --- a/platform/util/src/com/intellij/util/ui/MacUIUtil.java +++ b/platform/util/src/com/intellij/util/ui/MacUIUtil.java @@ -136,27 +136,16 @@ public class MacUIUtil { g.setColor(c.getBackground()); g.fillRect(x1, y1, width1, height1); - + if (!myEnabledComponent.isEnabled()) { ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); } g.setColor(new Color(100, 100, 100, 200)); - g.drawLine(x1, y1, x1 + width1 - 1, y1); - - g.setColor(new Color(212, 212, 212, 200)); - g.drawLine(x1, y1 + 1, x1 + width1 - 1, y1 + 1); + g.drawRect(x1, y1, width1 - 1, height1 - 1); g.setColor(Gray._225); - g.drawLine(x1 + 1, y1 + height1 - 1, x1 + width1 - 2, y1 + height1 - 1); - - g.setColor(new Color(30, 30, 30, 70)); - g.drawLine(x1, y1, x1, y1 + height1 - 1); - g.drawLine(x1 + width1 - 1, y1, x1 + width1 - 1, y1 + height1 - 1); - - g.setColor(new Color(30, 30, 30, 10)); - g.drawLine(x1 + 1, y1, x1 + 1, y1 + height1 - 1); - g.drawLine(x1 + width1 - 2, y1, x1 + width1 - 2, y1 + height1 - 1); + g.drawRect(x1 + 1, y1 + 1, width1 - 3, height1 - 3); if (myEnabledComponent.isEnabled() && myEnabledComponent.isVisible() && hasFocus(myEnabledComponent)) { paintTextFieldFocusRing((Graphics2D) g, new Rectangle(x1, y1, width1, height1)); From 7384bace1d32cda3a2029ae61c0f9963f296c06e Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 10:28:17 +0200 Subject: [PATCH 03/16] commented paths to license files (the files were removed because of IDEA-141315) --- build/conf/nsis/paths.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/conf/nsis/paths.nsi b/build/conf/nsis/paths.nsi index 0e9299aaffba..c9e28527f1ea 100644 --- a/build/conf/nsis/paths.nsi +++ b/build/conf/nsis/paths.nsi @@ -1,6 +1,6 @@ ; Installer images !define IMAGES_LOCATION "${BASE_DIR}\build\images\idea" -!define LICENSE_FILE "${BASE_DIR}\license\IDEA_license" +;!define LICENSE_FILE "${BASE_DIR}\license\IDEA_license" !define PRODUCT_PROPERTIES_FILE "${BASE_DIR}\out\release\dist.all\bin\idea.properties" !define PRODUCT_VM_OPTIONS_NAME idea*.exe.vmoptions !define PRODUCT_VM_OPTIONS_FILE "${BASE_DIR}\out\release\dist.win\bin\${PRODUCT_VM_OPTIONS_NAME}" \ No newline at end of file From 7d2bbf0473994ae22e856e6f04711fe8eac5c7c1 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 12 Jun 2015 11:57:44 +0300 Subject: [PATCH 04/16] fixed test for windows --- .../com/intellij/execution/process/ProcessWaitForTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/util/testSrc/com/intellij/execution/process/ProcessWaitForTest.java b/platform/util/testSrc/com/intellij/execution/process/ProcessWaitForTest.java index 4042b0b450b4..d596bce075e9 100644 --- a/platform/util/testSrc/com/intellij/execution/process/ProcessWaitForTest.java +++ b/platform/util/testSrc/com/intellij/execution/process/ProcessWaitForTest.java @@ -15,6 +15,7 @@ */ package com.intellij.execution.process; +import com.intellij.openapi.util.SystemInfo; import com.intellij.util.Consumer; import com.intellij.util.concurrency.Semaphore; import org.junit.Test; @@ -27,7 +28,7 @@ import static org.junit.Assert.assertTrue; public class ProcessWaitForTest { @Test(timeout = 10000) public void notification() throws IOException, InterruptedException { - File jvm = new File(System.getProperty("java.home"), "bin/java"); + File jvm = new File(System.getProperty("java.home") + (SystemInfo.isWindows ? "\\bin\\java.exe" : "/bin/java")); assertTrue(jvm.canExecute()); final Semaphore semaphore = new Semaphore(); From 85b5e31274a264f5b17a71914628f0f37d29cb35 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 11:06:26 +0200 Subject: [PATCH 05/16] force 'license' dir presence, event if empty --- build/scripts/dist.gant | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 652a97d759bf..510b77437f98 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -144,6 +144,9 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = include(name: "*.*") } } + + ant.mkdir(dir: "license") // in case the license directory is absent, create it + dir("license") { fileset(dir: "${home}/license") } From a632f157f34a691ee6c39694324d9a1306809926 Mon Sep 17 00:00:00 2001 From: Vyacheslav Karpukhin Date: Fri, 12 Jun 2015 11:26:48 +0200 Subject: [PATCH 06/16] Fixed XDebuggerUtilImpl --- .../xdebugger/impl/XDebuggerUtilImpl.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java index cb93462706f6..bc5288599510 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerUtilImpl.java @@ -33,7 +33,6 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.ui.popup.util.BaseListPopupStep; import com.intellij.openapi.util.AsyncResult; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -130,9 +129,9 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { @NotNull final XSourcePosition position, final boolean temporary, final RelativePoint relativePoint) { - return ApplicationManager.getApplication().runWriteAction(new Computable>() { + return new WriteAction>() { @Override - public AsyncResult compute() { + protected void run(@NotNull Result> result) throws Throwable { final VirtualFile file = position.getFile(); final int line = position.getLine(); final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager(); @@ -173,21 +172,25 @@ public class XDebuggerUtilImpl extends XDebuggerUtil { return FINAL_CHOICE; } }).show(relativePoint); - return res; + result.setResult(res); + return; } else { P properties = (P)variants.get(0).createProperties(); - return AsyncResult.done( - (XLineBreakpoint)breakpointManager.addLineBreakpoint(type, file.getUrl(), line, properties, temporary)); + result.setResult(AsyncResult.done( + (XLineBreakpoint)breakpointManager.addLineBreakpoint(type, file.getUrl(), line, properties, temporary))); + return; } } } P properties = type.createBreakpointProperties(file, line); - return AsyncResult.done((XLineBreakpoint)breakpointManager.addLineBreakpoint(type, file.getUrl(), line, properties, temporary)); + result.setResult(AsyncResult + .done((XLineBreakpoint)breakpointManager.addLineBreakpoint(type, file.getUrl(), line, properties, temporary))); + return; } - return AsyncResult.rejected(); + result.setResult(AsyncResult.rejected()); } - }); + }.execute().getResultObject(); } @Override From 939f5411d7710f9da86d6df330449f5b241fd8d5 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 11:38:49 +0200 Subject: [PATCH 07/16] force 'license' dir presence, event if empty, attempt 2 --- build/scripts/dist.gant | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 510b77437f98..60495187cc73 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -138,15 +138,14 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = notifyArtifactBuilt(paths.artifacts_jps) } + ant.mkdir(dir: "license") // in case the license directory is absent, create it + layout(paths.distAll) { dir("bin") { fileset(dir: "${home}/bin") { include(name: "*.*") } } - - ant.mkdir(dir: "license") // in case the license directory is absent, create it - dir("license") { fileset(dir: "${home}/license") } From bf5109fa38a4c4505045cfa3ce405e8a7dcf8f6e Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 11:45:05 +0200 Subject: [PATCH 08/16] force 'license' dir presence, event if empty, attempt 2 --- build/scripts/dist.gant | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 60495187cc73..7a7a3ee27b56 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -138,7 +138,7 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = notifyArtifactBuilt(paths.artifacts_jps) } - ant.mkdir(dir: "license") // in case the license directory is absent, create it + ant.mkdir(dir: paths.distAll + "/license") // in case the license directory is absent, create it layout(paths.distAll) { dir("bin") { From c1c90324ecfbaf6f3a794e0e73ece0c7b5e590bd Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 12:12:25 +0200 Subject: [PATCH 09/16] force source 'license' dir presence, event if empty --- build/scripts/dist.gant | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 7a7a3ee27b56..e07bfa65bf18 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -138,7 +138,7 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = notifyArtifactBuilt(paths.artifacts_jps) } - ant.mkdir(dir: paths.distAll + "/license") // in case the license directory is absent, create it +// ant.mkdir(dir: paths.distAll + "/license") // in case the license directory is absent, create it layout(paths.distAll) { dir("bin") { @@ -146,6 +146,9 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = include(name: "*.*") } } + + ant.mkdir(dir: "${home}/license") // in case the source license directory is absent, create it + dir("license") { fileset(dir: "${home}/license") } From e91635109c4972734f40031bd6475826e00efe4c Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 12:12:51 +0200 Subject: [PATCH 10/16] remove comment --- build/scripts/dist.gant | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index e07bfa65bf18..52b48afa2cec 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -138,8 +138,6 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = notifyArtifactBuilt(paths.artifacts_jps) } -// ant.mkdir(dir: paths.distAll + "/license") // in case the license directory is absent, create it - layout(paths.distAll) { dir("bin") { fileset(dir: "${home}/bin") { From f51820a27e13654faf844f78aa84f281ca7f37a1 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 12:45:14 +0200 Subject: [PATCH 11/16] force 'license' dir presence, event if empty in both source and destination locations --- build/scripts/dist.gant | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 52b48afa2cec..3be716082a8c 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -138,6 +138,12 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = notifyArtifactBuilt(paths.artifacts_jps) } + // in case the license directory is absent, create it + mkdir(dir: "${home}/license") + [paths.distWin, paths.distAll, paths.distUnix, paths.distMac].each { + ant.mkdir(dir: it + "/license") + } + layout(paths.distAll) { dir("bin") { fileset(dir: "${home}/bin") { @@ -145,8 +151,6 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = } } - ant.mkdir(dir: "${home}/license") // in case the source license directory is absent, create it - dir("license") { fileset(dir: "${home}/license") } From dca4a75642a00c718f8904316e77c32a5d8bc747 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Jun 2015 15:16:29 +0200 Subject: [PATCH 12/16] restoring 'license' dir for dbide and webstorm --- build/scripts/dist.gant | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 3be716082a8c..607a28263ff1 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -138,12 +138,6 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = notifyArtifactBuilt(paths.artifacts_jps) } - // in case the license directory is absent, create it - mkdir(dir: "${home}/license") - [paths.distWin, paths.distAll, paths.distUnix, paths.distMac].each { - ant.mkdir(dir: it + "/license") - } - layout(paths.distAll) { dir("bin") { fileset(dir: "${home}/bin") { @@ -152,7 +146,9 @@ def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = } dir("license") { - fileset(dir: "${home}/license") + fileset(dir: "${home}/license") { + exclude(name: "placeholder.txt") + } } fileset(file: "${home}/LICENSE.txt") fileset(file: "${home}/NOTICE.txt") From 4de06c31fbd8984c6fc0c59c12f95892a8e8802b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 9 Jun 2015 12:47:55 +0200 Subject: [PATCH 13/16] SSR: keep order of modifiers when replacing annotation --- .../com/intellij/structuralsearch/JavaReplaceHandler.java | 2 +- .../intellij/structuralsearch/StructuralReplaceTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java index b95b01fe08d0..2ae17d8756a9 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java @@ -269,7 +269,7 @@ public class JavaReplaceHandler extends StructuralReplaceHandler { if (firstChild instanceof PsiModifierList) { final PsiModifierList modifierList = (PsiModifierList)firstChild; for (PsiElement child : modifierList.getChildren()) { - elementParent.add(child); + elementParent.addBefore(child, elementToReplace); } } } diff --git a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java index 6c204de6ea05..8086ffc0d86a 100644 --- a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java +++ b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java @@ -2259,15 +2259,15 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase { public void testReplaceAnnotation() { String in = "@SuppressWarnings(\"ALL\")\n" + - "class A {}"; + "public class A {}"; String what = "@SuppressWarnings(\"ALL\")"; final String by1 = ""; - assertEquals("class A {}", replacer.testReplace(in, what, by1, options, false)); + assertEquals("public class A {}", replacer.testReplace(in, what, by1, options, false)); final String by2 = "@SuppressWarnings(\"NONE\") @Deprecated"; assertEquals("@SuppressWarnings(\"NONE\") @Deprecated\n" + - "class A {}", replacer.testReplace(in, what, by2, options, false)); + "public class A {}", replacer.testReplace(in, what, by2, options, false)); } public void testReplacePolyadicExpression() { From daad338196544c0e603edbb4e5ef270e882e8927 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 12 Jun 2015 17:34:58 +0200 Subject: [PATCH 14/16] EA-69413 (AIOOBE: AbstractMethodOverridesAbstractMethodInspection$AbstractMethodOverridesAbstractMethodVisitor.methodsHaveSameAnnotations) --- .../AbstractMethodOverridesAbstractMethodInspection.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java index 137374f12006..aeb7fc2e69b5 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/AbstractMethodOverridesAbstractMethodInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,6 +148,9 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect final PsiParameter[] superParameters = superParameterList.getParameters(); final PsiParameterList parameterList = method.getParameterList(); final PsiParameter[] parameters = parameterList.getParameters(); + if (parameters.length != superParameters.length) { + return false; + } for (int i = 0, length = superParameters.length; i < length; i++) { final PsiParameter superParameter = superParameters[i]; final PsiParameter parameter = parameters[i]; @@ -171,7 +174,7 @@ public class AbstractMethodOverridesAbstractMethodInspection extends BaseInspect final Set annotationsSet = new HashSet(Arrays.asList(superAnnotations)); for (PsiAnnotation annotation : annotations) { final String qualifiedName = annotation.getQualifiedName(); - if ("java.lang.Override".equals(qualifiedName)) { + if (CommonClassNames.JAVA_LANG_OVERRIDE.equals(qualifiedName)) { continue; } if (!annotationsSet.contains(annotation)) { From fab15d134c11d5d279ca382b56a1223f6a347a86 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 12 Jun 2015 18:52:31 +0300 Subject: [PATCH 15/16] methods to prevent App Nap when needed --- .../util/resources/misc/registry.properties | 3 +++ .../intellij/ui/mac/foundation/MacUtil.java | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 9f8ea66e2b7b..941f2f758cc6 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -74,6 +74,9 @@ idea.fix.mac.env=true idea.fix.mac.env.restartRequired=true idea.fix.mac.env.description=On Mac, use shell environment for external processes. +idea.mac.prevent.app.nap=false +idea.mac.prevent.app.nap.description=Prevent app nap during indexing and inspection + ide.x11.override.wm=true ide.appIcon.progress=true diff --git a/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java b/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java index 8ee9ee9206fb..58b6cdd53591 100644 --- a/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java +++ b/platform/util/src/com/intellij/ui/mac/foundation/MacUtil.java @@ -33,8 +33,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.concurrent.atomic.AtomicBoolean; -import static com.intellij.ui.mac.foundation.Foundation.invoke; -import static com.intellij.ui.mac.foundation.Foundation.toStringViaUTF8; +import static com.intellij.ui.mac.foundation.Foundation.*; /** * @author pegov @@ -192,4 +191,27 @@ public class MacUtil { } return windowTitle; } + + public static Object wakeUpNeo(String reason) { + // http://lists.apple.com/archives/java-dev/2014/Feb/msg00053.html + // https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/index.html#//apple_ref/c/tdef/NSActivityOptions + if (SystemInfo.isMacOSMavericks && Registry.is("idea.mac.prevent.app.nap")) { + ID processInfo = invoke("NSProcessInfo", "processInfo"); + ID activity = invoke(processInfo, "beginActivityWithOptions:reason:", + (0x00FFFFFFL & ~(1L << 20)) /* NSActivityUserInitiatedAllowingIdleSystemSleep */ | + 0xFF00000000L /* NSActivityLatencyCritical */, + nsString(reason)); + cfRetain(activity); + return activity; + } + return null; + } + + public static void matrixHasYou(Object activity) { + if (activity != null) { + ID processInfo = invoke("NSProcessInfo", "processInfo"); + invoke(processInfo, "endActivity:", activity); + cfRelease((ID)activity); + } + } } From 2123f478a4c002f3a3da50fc669c4be9143bc4f3 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 12 Jun 2015 20:27:06 +0300 Subject: [PATCH 16/16] prevent App Nap during progress indicators --- .../openapi/progress/util/AbstractProgressIndicatorBase.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java index af8546cb6147..2cf43d397fd4 100644 --- a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java +++ b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java @@ -23,6 +23,7 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.ui.mac.foundation.MacUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.DoubleArrayList; import com.intellij.util.containers.Stack; @@ -43,6 +44,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements private volatile boolean myFinished; private volatile boolean myIndeterminate; + private volatile Object myMacActivity; private Stack myTextStack; private DoubleArrayList myFractionStack; @@ -68,6 +70,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements myText = ""; myFraction = 0; myText2 = ""; + myMacActivity = MacUtil.wakeUpNeo(toString()); myRunning = true; } @@ -82,6 +85,8 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements LOG.assertTrue(myRunning, "stop() should be called only if start() called before"); myRunning = false; myFinished = true; + MacUtil.matrixHasYou(myMacActivity); + myMacActivity = null; } @Override