01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.corext.refactoring.participants;
11:
12: import java.util.HashSet;
13: import java.util.Set;
14:
15: import org.eclipse.core.runtime.CoreException;
16:
17: import org.eclipse.jdt.core.IJavaElement;
18: import org.eclipse.jdt.core.IJavaProject;
19: import org.eclipse.jdt.core.IMember;
20:
21: import org.eclipse.jdt.internal.corext.util.JdtFlags;
22:
23: /**
24: * Utility class to deal with Java element processors.
25: */
26: public class JavaProcessors {
27:
28: public static String[] computeAffectedNatures(IJavaElement element)
29: throws CoreException {
30: if (element instanceof IMember) {
31: IMember member = (IMember) element;
32: if (JdtFlags.isPrivate(member)) {
33: return element.getJavaProject().getProject()
34: .getDescription().getNatureIds();
35: }
36: }
37: IJavaProject project = element.getJavaProject();
38: return ResourceProcessors.computeAffectedNatures(project
39: .getProject());
40: }
41:
42: public static String[] computeAffectedNaturs(IJavaElement[] elements)
43: throws CoreException {
44: Set result = new HashSet();
45: for (int i = 0; i < elements.length; i++) {
46: String[] natures = computeAffectedNatures(elements[i]);
47: for (int j = 0; j < natures.length; j++) {
48: result.add(natures[j]);
49: }
50: }
51: return (String[]) result.toArray(new String[result.size()]);
52: }
53: }
|