1 11 package org.eclipse.jdt.internal.corext.refactoring.participants; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.core.runtime.CoreException; 17 18 import org.eclipse.core.resources.IProject; 19 import org.eclipse.core.resources.IResource; 20 21 public class ResourceProcessors { 22 23 public static String [] computeAffectedNatures(IResource resource) throws CoreException { 24 IProject project= resource.getProject(); 25 Set result= new HashSet (); 26 Set visitedProjects= new HashSet (); 27 computeNatures(result, visitedProjects, project); 28 return (String [])result.toArray(new String [result.size()]); 29 } 30 31 public static String [] computeAffectedNatures(IResource[] resources) throws CoreException { 32 Set result= new HashSet (); 33 Set visitedProjects= new HashSet (); 34 for (int i= 0; i < resources.length; i++) { 35 computeNatures(result, visitedProjects, resources[i].getProject()); 36 } 37 return (String [])result.toArray(new String [result.size()]); 38 } 39 40 private static void computeNatures(Set result, Set visitedProjects, IProject focus) throws CoreException { 41 if (visitedProjects.contains(focus)) 42 return; 43 String [] pns= focus.getDescription().getNatureIds(); 44 for (int p = 0; p < pns.length; p++) { 45 result.add(pns[p]); 46 } 47 visitedProjects.add(focus); 48 IProject[] referencing= focus.getReferencingProjects(); 49 for (int i= 0; i < referencing.length; i++) { 50 computeNatures(result, visitedProjects, referencing[i]); 51 } 52 } 53 } 54 | Popular Tags |