Skip to content

Commit

Permalink
IDEA-21206 "Usages of" ignore "Show import statements"
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim.Mossienko authored and Maxim.Mossienko committed Mar 11, 2010
1 parent bd8c90d commit bc02158
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@

<extensionPoint name="usageFilteringRuleProvider"
interface="com.intellij.usages.rules.UsageFilteringRuleProvider"/>
<extensionPoint name="importFilteringRule"
interface="com.intellij.usages.rules.ImportFilteringRule"/>
<extensionPoint name="usageGroupingRuleProvider"
interface="com.intellij.usages.rules.UsageGroupingRuleProvider"/>
<extensionPoint name="usageTypeProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* 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.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
Expand All @@ -25,25 +25,25 @@
* @author yole
*/
@State(
name = "JavaUsageViewSettings",
name = "ImportFilteringUsageViewSetting",
storages = {
@Storage(
id ="other",
file = "$APP_CONFIG$/other.xml"
)}
)
public class JavaUsageViewSettings implements PersistentStateComponent<JavaUsageViewSettings> {
public static JavaUsageViewSettings getInstance() {
return ServiceManager.getService(JavaUsageViewSettings.class);
public class ImportFilteringUsageViewSetting implements PersistentStateComponent<ImportFilteringUsageViewSetting> {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<UsageFilteringRule> rules = new ArrayList<UsageFilteringRule>();
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()]);
}
Expand Down Expand Up @@ -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;
}
}

}
Original file line number Diff line number Diff line change
@@ -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<ImportFilteringRule> EP_NAME = ExtensionPointName.create("com.intellij.importFilteringRule");
}
7 changes: 4 additions & 3 deletions resources/src/META-INF/IdeaPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,10 @@
<fileStructureGroupRuleProvider implementation="com.intellij.usages.impl.rules.JavaClassGroupRuleProvider"/>
<fileStructureGroupRuleProvider implementation="com.intellij.usages.impl.rules.JavaMethodGroupRuleProvider"/>
<usageTypeProvider implementation="com.intellij.usages.impl.rules.JavaUsageTypeProvider"/>
<usageFilteringRuleProvider implementation="com.intellij.usages.impl.rules.JavaUsageFilteringRuleProvider"/>
<applicationService serviceInterface="com.intellij.usages.impl.rules.JavaUsageViewSettings"
serviceImplementation="com.intellij.usages.impl.rules.JavaUsageViewSettings"/>
<importFilteringRule implementation="com.intellij.usages.impl.rules.ImportFilteringRule"/>
<usageFilteringRuleProvider implementation="com.intellij.usages.impl.ImportUsageFilteringRuleProvider"/>
<applicationService serviceInterface="com.intellij.usages.impl.ImportFilteringUsageViewSetting"
serviceImplementation="com.intellij.usages.impl.ImportFilteringUsageViewSetting"/>

<treeStructureProvider implementation="com.intellij.ide.projectView.impl.ClassesTreeStructureProvider"/>

Expand Down

0 comments on commit bc02158

Please sign in to comment.