From bc02158fe2b7d474d9656296ee06d3dabea31571 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Thu, 11 Mar 2010 19:51:21 +0300 Subject: [PATCH] IDEA-21206 "Usages of" ignore "Show import statements" --- .../impl/rules/ImportFilteringRule.java | 5 ++-- .../src/META-INF/LangExtensionPoints.xml | 2 ++ .../impl/ImportFilteringUsageViewSetting.java | 14 +++++----- .../ImportUsageFilteringRuleProvider.java | 18 ++++++------ .../usages/rules/ImportFilteringRule.java | 28 +++++++++++++++++++ resources/src/META-INF/IdeaPlugin.xml | 7 +++-- 6 files changed, 52 insertions(+), 22 deletions(-) rename java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageViewSettings.java => platform/usageView/src/com/intellij/usages/impl/ImportFilteringUsageViewSetting.java (70%) rename java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageFilteringRuleProvider.java => platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java (82%) create mode 100644 platform/usageView/src/com/intellij/usages/rules/ImportFilteringRule.java diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java b/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java index f8b67400ed11d..4f9f7a931cebb 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java +++ b/java/java-impl/src/com/intellij/usages/impl/rules/ImportFilteringRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2010 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. @@ -22,13 +22,12 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.usages.Usage; import com.intellij.usages.rules.PsiElementUsage; -import com.intellij.usages.rules.UsageFilteringRule; /** * @author Eugene Zhuravlev * Date: Jan 17, 2005 */ -public class ImportFilteringRule implements UsageFilteringRule{ +public class ImportFilteringRule extends com.intellij.usages.rules.ImportFilteringRule { public boolean isVisible(Usage usage) { if (usage instanceof PsiElementUsage) { final PsiElement psiElement = ((PsiElementUsage)usage).getElement(); diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index 51dc6c039dbf0..ef80aa6699b63 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -313,6 +313,8 @@ + { - public static JavaUsageViewSettings getInstance() { - return ServiceManager.getService(JavaUsageViewSettings.class); +public class ImportFilteringUsageViewSetting implements PersistentStateComponent { + public static ImportFilteringUsageViewSetting getInstance() { + return ServiceManager.getService(ImportFilteringUsageViewSetting.class); } public boolean SHOW_IMPORTS = true; - public JavaUsageViewSettings getState() { + public ImportFilteringUsageViewSetting getState() { return this; } - public void loadState(final JavaUsageViewSettings state) { + public void loadState(final ImportFilteringUsageViewSetting state) { XmlSerializerUtil.copyBean(state, this); } } diff --git a/java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageFilteringRuleProvider.java b/platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java similarity index 82% rename from java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageFilteringRuleProvider.java rename to platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java index 08760947db0b5..3920bdf28cff2 100644 --- a/java/java-impl/src/com/intellij/usages/impl/rules/JavaUsageFilteringRuleProvider.java +++ b/platform/usageView/src/com/intellij/usages/impl/ImportUsageFilteringRuleProvider.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.usages.impl.rules; +package com.intellij.usages.impl; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.CustomShortcutSet; +import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.IconLoader; import com.intellij.usageView.UsageViewBundle; +import com.intellij.usages.rules.ImportFilteringRule; import com.intellij.usages.UsageView; -import com.intellij.usages.impl.RuleAction; -import com.intellij.usages.impl.UsageViewImpl; import com.intellij.usages.rules.UsageFilteringRule; import com.intellij.usages.rules.UsageFilteringRuleProvider; import org.jetbrains.annotations.NotNull; @@ -32,17 +32,18 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** * @author yole */ -public class JavaUsageFilteringRuleProvider implements UsageFilteringRuleProvider { +public class ImportUsageFilteringRuleProvider implements UsageFilteringRuleProvider { @NotNull public UsageFilteringRule[] getActiveRules(@NotNull final Project project) { final List rules = new ArrayList(); - if (!JavaUsageViewSettings.getInstance().SHOW_IMPORTS) { - rules.add(new ImportFilteringRule()); + if (!ImportFilteringUsageViewSetting.getInstance().SHOW_IMPORTS) { + rules.addAll(Arrays.asList(Extensions.getExtensions(ImportFilteringRule.EP_NAME))); } return rules.toArray(new UsageFilteringRule[rules.size()]); } @@ -73,12 +74,11 @@ private ShowImportsAction(UsageViewImpl view) { } protected boolean getOptionValue() { - return JavaUsageViewSettings.getInstance().SHOW_IMPORTS; + return ImportFilteringUsageViewSetting.getInstance().SHOW_IMPORTS; } protected void setOptionValue(boolean value) { - JavaUsageViewSettings.getInstance().SHOW_IMPORTS = value; + ImportFilteringUsageViewSetting.getInstance().SHOW_IMPORTS = value; } } - } diff --git a/platform/usageView/src/com/intellij/usages/rules/ImportFilteringRule.java b/platform/usageView/src/com/intellij/usages/rules/ImportFilteringRule.java new file mode 100644 index 0000000000000..5ab8a7da65c67 --- /dev/null +++ b/platform/usageView/src/com/intellij/usages/rules/ImportFilteringRule.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2010 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.usages.rules; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.usages.rules.UsageFilteringRule; + +/** + * User: Maxim.Mossienko + * Date: 11.03.2010 + * Time: 19:08:33 + */ +public abstract class ImportFilteringRule implements UsageFilteringRule { + public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.importFilteringRule"); +} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 4e524219c134c..7207661d27842 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1036,9 +1036,10 @@ - - + + +