]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/core extension/org/eclipse/jdt/internal/corext/util/TypeNameMatchCollector.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / core extension / org / eclipse / jdt / internal / corext / util / TypeNameMatchCollector.java
CommitLineData
1b2798f6
EK
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
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.jdt.internal.corext.util;
12
13import java.util.Collection;
14
15import org.eclipse.core.runtime.Assert;
16
17import org.eclipse.jdt.core.IAccessRule;
18import org.eclipse.jdt.core.JavaCore;
19import org.eclipse.jdt.core.search.TypeNameMatch;
20import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
21
22public class TypeNameMatchCollector extends TypeNameMatchRequestor {
23
24 private final Collection<TypeNameMatch> fCollection;
25
26 public TypeNameMatchCollector(Collection<TypeNameMatch> collection) {
27 Assert.isNotNull(collection);
28 fCollection= collection;
29 }
30
31 private boolean inScope(TypeNameMatch match) {
32 if (TypeFilter.isFiltered(match))
33 return false;
34
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));
41 default:
42 return true;
43 }
44 }
45
46 /* (non-Javadoc)
47 * @see org.eclipse.jdt.core.search.TypeNameMatchRequestor#acceptTypeNameMatch(org.eclipse.jdt.core.search.TypeNameMatch)
48 */
49 @Override
50 public void acceptTypeNameMatch(TypeNameMatch match) {
51 if (inScope(match)) {
52 fCollection.add(match);
53 }
54 }
55
56}