From f869c824a01d5be53435546dcc2468ae224dc24a Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 24 Aug 2016 11:50:23 +0300 Subject: [PATCH 1/5] javadoc for MergingUpdateQueue --- .../util/ui/update/MergingUpdateQueue.java | 26 +++++++++++++++++-- .../com/intellij/util/ui/update/Update.java | 11 ++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java b/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java index 9c805bcaaa9b..d2fb7c82e148 100644 --- a/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java +++ b/platform/platform-api/src/com/intellij/util/ui/update/MergingUpdateQueue.java @@ -38,6 +38,14 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +/** + * Use this class to postpone tasks execution and optionally merge identical tasks. This is needed e.g. to reflect in UI status of some + * background activity: it doesn't make sense and would be inefficient to update UI 1000 times per second, so it's better to postpone 'update UI' + * task execution for e.g. 500ms and if new updates are added during this period they can be simply ignored. + * + *

+ * Create instance of this class and use {@link #queue(Update)} method to add new tasks. + */ public class MergingUpdateQueue implements Runnable, Disposable, Activatable { public static final JComponent ANY_COMPONENT = new JComponent() { }; @@ -96,6 +104,16 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable { executeInDispatchThread ? Alarm.ThreadToUse.SWING_THREAD : Alarm.ThreadToUse.POOLED_THREAD); } + /** + * @param name name of this queue, used only for debugging purposes + * @param mergingTimeSpan time (in milliseconds) for which execution of tasks will be postponed + * @param isActive if {@code true} the queue will execute tasks otherwise it'll just collect the + * @param modalityStateComponent makes sense only if {@code thread} is {@linkplain Alarm.ThreadToUse#SWING_THREAD SWING_THREAD}, in that + * case the tasks will be processed in {@link ModalityState} corresponding the given component + * @param parent if not {@code null} the queue will be disposed when the given parent is disposed + * @param activationComponent if not {@code null} the tasks will be processing only when the given component is showing + * @param thread specifies on which thread the tasks are executed + */ public MergingUpdateQueue(@NonNls @NotNull String name, int mergingTimeSpan, boolean isActive, @@ -159,12 +177,13 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable { return myPassThrough; } + /** + * @param passThrough if {@code true} the tasks won't be postponed but executed immediately instead (this is default mode for tests) + */ public final void setPassThrough(boolean passThrough) { myPassThrough = passThrough; } - - public void activate() { showNotify(); } @@ -321,6 +340,9 @@ public class MergingUpdateQueue implements Runnable, Disposable, Activatable { } } + /** + * Adds a task to be executed. + */ public void queue(@NotNull final Update update) { if (myDisposed) return; diff --git a/platform/platform-api/src/com/intellij/util/ui/update/Update.java b/platform/platform-api/src/com/intellij/util/ui/update/Update.java index 8e076eaa8f09..3f2347810a30 100644 --- a/platform/platform-api/src/com/intellij/util/ui/update/Update.java +++ b/platform/platform-api/src/com/intellij/util/ui/update/Update.java @@ -19,6 +19,12 @@ import org.jetbrains.annotations.NonNls; import java.util.Arrays; +/** + * Describes a task for {@link MergingUpdateQueue}. Equal tasks (instances with the equal {@code identity} objects) are merged, i.e. + * only the first of them is executed. If some tasks are more generic than others override {@link #canEat(Update)} method. + * + * @see MergingUpdateQueue + */ public abstract class Update extends ComparableObject.Impl implements Runnable { public static final int LOW_PRIORITY = 999; @@ -77,6 +83,11 @@ public abstract class Update extends ComparableObject.Impl implements Runnable { return myPriority; } + /** + * Override this method and return {@code true} if this task is more generic than the passed {@code update}, e.g. this tasks repaint the + * whole frame and the passed task repaint some component on the frame. In that case the less generic tasks will be removed from the queue + * before execution. + */ public boolean canEat(Update update) { return false; } From 3e64ee313183de86fd09ce1a7fd771c8e6fb4fd8 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 24 Aug 2016 11:50:36 +0300 Subject: [PATCH 2/5] fix exception on text selection --- .../src/com/intellij/openapi/editor/impl/CaretImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java index 255105e94d5a..252400a7bece 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java @@ -258,8 +258,8 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable { int columnShift = _columnShift; if (withSelection && lineShift == 0) { if (columnShift == -1) { - if (myEditor.getInlayModel().hasInlineElementAt( - new VisualPosition(myVisibleCaret.line, myVisibleCaret.column - (hasSelection() && myOffset == getSelectionEnd() ? 2 : 1)))) { + int column = myVisibleCaret.column - (hasSelection() && myOffset == getSelectionEnd() ? 2 : 1); + if (column >= 0 && myEditor.getInlayModel().hasInlineElementAt(new VisualPosition(myVisibleCaret.line, column))) { columnShift = -2; } } From 324452daf057aa58e9efe65b715913a3bbdaff52 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 23 Aug 2016 21:34:23 +0300 Subject: [PATCH 3/5] unused parameters: show applicable fix --- .../deadCode/UnusedDeclarationPresentation.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java index 4f31761469ac..7dc55f6430a4 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java @@ -191,7 +191,11 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta } } - return showFixes ? myQuickFixActions : QuickFixAction.EMPTY; + if (showFixes) { + final QuickFixAction[] fixes = super.getQuickFixes(refElements, allowedDescriptors); + return fixes != null ? ArrayUtil.mergeArrays(fixes, myQuickFixActions) : myQuickFixActions; + } + return QuickFixAction.EMPTY; } final QuickFixAction[] myQuickFixActions; From 97ef84693d407b77b6860a21305c18f5419485db Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 24 Aug 2016 12:02:23 +0300 Subject: [PATCH 4/5] paired inspection tools: repeat scopes configured for local tool if self is not enabled --- .../codeInspection/ex/GlobalInspectionContextImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index ba73ca831ddd..aa16bf133356 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -71,6 +71,7 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.psi.*; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.GuiUtils; @@ -705,7 +706,14 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp if (batchInspection != null && !myTools.containsKey(batchShortName)) { // add to existing inspections to run InspectionProfileEntry batchTool = batchInspection.getTool(); - Tools newTool = new ToolsImpl(batchInspection, batchInspection.getDefaultLevel(), true, true); + final ScopeToolState defaultState = tool.getDefaultState(); + ToolsImpl newTool = new ToolsImpl(batchInspection, defaultState.getLevel(), true, defaultState.isEnabled()); + for (ScopeToolState state : tool.getTools()) { + final NamedScope scope = state.getScope(getProject()); + if (scope != null) { + newTool.addTool(scope, batchInspection, state.isEnabled(), state.getLevel()); + } + } if (batchTool instanceof LocalInspectionTool) localTools.add(newTool); else if (batchTool instanceof GlobalSimpleInspectionTool) globalSimpleTools.add(newTool); else if (batchTool instanceof GlobalInspectionTool) globalTools.add(newTool); From 61fe8a8a78b66428f2b38c357c7c8e186a224a05 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 24 Aug 2016 11:15:34 +0200 Subject: [PATCH 5/5] IDEA-CR-13232 remove additional newline --- .../impl/providers/masterKey/EnterPasswordComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java index 20b9d0b884af..dc08f97fd29f 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/EnterPasswordComponent.java @@ -47,7 +47,7 @@ public class EnterPasswordComponent extends PasswordComponentBase { note = "The passwords will be stored in IDE configuration files with weak protection (" + subNote + ")."; } - myPromptLabel.setText("Master password is required to convert saved passwords.

" + note + ""); + myPromptLabel.setText("Master password is required to convert saved passwords.
" + note + ""); if (ApplicationManager.getApplication().isUnitTestMode()) { myPasswordField.setText("pass");