1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.util;
13 import java.util.Collection;
15 import org.eclipse.core.runtime.Assert;
17 import org.eclipse.jdt.core.IAccessRule;
18 import org.eclipse.jdt.core.JavaCore;
19 import org.eclipse.jdt.core.search.TypeNameMatch;
20 import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
22 public class TypeNameMatchCollector extends TypeNameMatchRequestor {
24 private final Collection<TypeNameMatch> fCollection;
26 public TypeNameMatchCollector(Collection<TypeNameMatch> collection) {
27 Assert.isNotNull(collection);
28 fCollection= collection;
31 private boolean inScope(TypeNameMatch match) {
32 if (TypeFilter.isFiltered(match))
35 int accessibility= match.getAccessibility();
36 switch (accessibility) {
37 case IAccessRule.K_NON_ACCESSIBLE:
38 return JavaCore.DISABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK));
39 case IAccessRule.K_DISCOURAGED:
40 return JavaCore.DISABLED.equals(JavaCore.getOption(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK));
47 * @see org.eclipse.jdt.core.search.TypeNameMatchRequestor#acceptTypeNameMatch(org.eclipse.jdt.core.search.TypeNameMatch)
50 public void acceptTypeNameMatch(TypeNameMatch match) {
52 fCollection.add(match);