Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2012-10-18 16:38:10 +0000
committerMarkus Keller2012-10-18 16:38:10 +0000
commit2936d56ca3ac16b9addfd38534a409d92605e873 (patch)
tree831fa2f33a23071677cae10b1f03c783eee7ee6d
parent14a3b4da3bd058ec20a821f4cffc05bdf3608921 (diff)
downloadeclipse.jdt.ui-2936d56ca3ac16b9addfd38534a409d92605e873.tar.gz
eclipse.jdt.ui-2936d56ca3ac16b9addfd38534a409d92605e873.tar.xz
eclipse.jdt.ui-2936d56ca3ac16b9addfd38534a409d92605e873.zip
Bug 392135: [open type] Open type does not respect access restriction filters
UI follow-up to bug 218487
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeFilter.java22
-rw-r--r--org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeNameMatchCollector.java17
2 files changed, 22 insertions, 17 deletions
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeFilter.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeFilter.java
index 0c5ab32be9..400915e8e2 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeFilter.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,9 @@ import java.util.StringTokenizer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.search.TypeNameMatch;
import org.eclipse.jdt.ui.PreferenceConstants;
@@ -53,7 +55,19 @@ public class TypeFilter implements IPropertyChangeListener {
}
public static boolean isFiltered(TypeNameMatch match) {
- return getDefault().filter(match.getFullyQualifiedName());
+ boolean filteredByPattern= getDefault().filter(match.getFullyQualifiedName());
+ if (filteredByPattern)
+ return true;
+
+ int accessibility= match.getAccessibility();
+ switch (accessibility) {
+ case IAccessRule.K_NON_ACCESSIBLE:
+ return JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK));
+ case IAccessRule.K_DISCOURAGED:
+ return JavaCore.ENABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK));
+ default:
+ return false;
+ }
}
private StringMatcher[] fStringMatchers;
@@ -93,6 +107,10 @@ public class TypeFilter implements IPropertyChangeListener {
return getStringMatchers().length > 0;
}
+ /**
+ * @param fullTypeName fully-qualified type name
+ * @return <code>true</code> iff the given type is filtered out
+ */
public boolean filter(String fullTypeName) {
StringMatcher[] matchers= getStringMatchers();
for (int i= 0; i < matchers.length; i++) {
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeNameMatchCollector.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeNameMatchCollector.java
index 3589c730d6..7dec9cc15a 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeNameMatchCollector.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/TypeNameMatchCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,6 @@ import java.util.Collection;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.search.TypeNameMatch;
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
@@ -29,18 +27,7 @@ public class TypeNameMatchCollector extends TypeNameMatchRequestor {
}
private boolean inScope(TypeNameMatch match) {
- if (TypeFilter.isFiltered(match))
- return false;
-
- int accessibility= match.getAccessibility();
- switch (accessibility) {
- case IAccessRule.K_NON_ACCESSIBLE:
- return JavaCore.DISABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK));
- case IAccessRule.K_DISCOURAGED:
- return JavaCore.DISABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK));
- default:
- return true;
- }
+ return ! TypeFilter.isFiltered(match);
}
/* (non-Javadoc)

Back to the top