From 9ff611fa154710f65a741a6fc806c86188933d85 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 30 Jul 2012 22:35:51 +0200 Subject: [PATCH] avoid duplication --- .../completion/ShowHideIntentionIconLookupAction.java | 10 +++++++--- .../intellij/codeInsight/lookup/impl/LookupImpl.java | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/ShowHideIntentionIconLookupAction.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/ShowHideIntentionIconLookupAction.java index 111571f8a9d9..a2092c7ce254 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/ShowHideIntentionIconLookupAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/ShowHideIntentionIconLookupAction.java @@ -23,15 +23,19 @@ import com.intellij.openapi.util.registry.Registry; * @author Konstantin Bulenkov */ public class ShowHideIntentionIconLookupAction extends LookupElementAction { - private static final String KEY = "completion.show.intention.icon"; + static final String KEY = "completion.show.intention.icon"; public ShowHideIntentionIconLookupAction() { - super(AllIcons.Actions.IntentionBulb, (Registry.is(KEY) ? "Never show" : "Show") + " intention icon"); + super(AllIcons.Actions.IntentionBulb, (shouldShowLookupHint() ? "Never show" : "Show") + " intention icon"); + } + + public static boolean shouldShowLookupHint() { + return Registry.is(KEY); } @Override public Result performLookupAction() { - Registry.get(KEY).setValue(!Registry.is(KEY)); + Registry.get(KEY).setValue(!shouldShowLookupHint()); return Result.REFRESH_ITEM; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java index 4b28756d4474..07c6a07f5ea4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupImpl.java @@ -950,7 +950,8 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable @Override public void run() { assert !myDisposed; - if (!Registry.is("completion.show.intention.icon") || ((CompletionExtender)myList.getExpandableItemsHandler()).isShowing()) { + if (!ShowHideIntentionIconLookupAction.shouldShowLookupHint() || + ((CompletionExtender)myList.getExpandableItemsHandler()).isShowing()) { return; } myElementHint = new LookupHint();