Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 25ff03d024562437b6d9f85c70d5784f6663cf7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*******************************************************************************
 * Copyright (c) 2006 Sybase, Inc. 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
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.common.ui.internal.dialogfield;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.search.IJavaSearchScope;

/**
 * @author mengbo
 * @version 1.5
 */
public class JavaSearchScopeDecorator implements IJavaSearchScope {
	JavaSearchScope[] _scopes = new JavaSearchScope[0];

	public JavaSearchScopeDecorator(IProject project, List superTypes) {
		List scopeList = new ArrayList();
		if (superTypes != null) {
			for (int i = 0; i < superTypes.size(); i++) {
				scopeList.add(new JavaSearchScope(project, superTypes.get(i)
						.toString()));
			}
		}
		_scopes = (JavaSearchScope[]) scopeList
				.toArray(new JavaSearchScope[scopeList.size()]);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#encloses(java.lang.String)
	 */
	public boolean encloses(String resourcePath) {
		for (int i = 0; i < _scopes.length; i++) {
			if (_scopes[i].encloses(resourcePath) == true) {
				return true;
			}
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#encloses(org.eclipse.jdt.core.IJavaElement)
	 */
	public boolean encloses(IJavaElement element) {
		for (int i = 0; i < _scopes.length; i++) {
			if (_scopes[i].encloses(element) == true) {
				return true;
			}
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#enclosingProjectsAndJars()
	 */
	public IPath[] enclosingProjectsAndJars() {
		Set set = new HashSet();
		for (int i = 0; i < _scopes.length; i++) {
			set.addAll(Arrays.asList(_scopes[i].enclosingProjectsAndJars()));
		}
		return (IPath[]) set.toArray(new IPath[set.size()]);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#includesBinaries()
	 */
	public boolean includesBinaries() {
		for (int i = 0; i < _scopes.length; i++) {
			if (_scopes[i].includesBinaries() == true) {
				return true;
			}
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#includesClasspaths()
	 */
	public boolean includesClasspaths() {
		for (int i = 0; i < _scopes.length; i++) {
			if (_scopes[i].includesClasspaths() == true) {
				return true;
			}
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#setIncludesBinaries(boolean)
	 */
	public void setIncludesBinaries(boolean includesBinaries) {
		for (int i = 0; i < _scopes.length; i++) {
			_scopes[i].setIncludesBinaries(includesBinaries);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jdt.core.search.IJavaSearchScope#setIncludesClasspaths(boolean)
	 */
	public void setIncludesClasspaths(boolean includesClasspaths) {
		for (int i = 0; i < _scopes.length; i++) {
			_scopes[i].setIncludesClasspaths(includesClasspaths);
		}
	}

}

Back to the top