1 11 package org.eclipse.jdt.internal.corext.refactoring.util; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.IAdaptable; 17 18 import org.eclipse.core.resources.IFile; 19 20 import org.eclipse.ltk.core.refactoring.Change; 21 import org.eclipse.ltk.core.refactoring.CompositeChange; 22 23 24 public class Changes { 25 26 public static IFile[] getModifiedFiles(Change[] changes) { 27 List result= new ArrayList (); 28 getModifiedFiles(result, changes); 29 return (IFile[]) result.toArray(new IFile[result.size()]); 30 } 31 32 private static void getModifiedFiles(List result, Change[] changes) { 33 for (int i= 0; i < changes.length; i++) { 34 Change change= changes[i]; 35 Object modifiedElement= change.getModifiedElement(); 36 if (modifiedElement instanceof IAdaptable) { 37 IFile file= (IFile)((IAdaptable)modifiedElement).getAdapter(IFile.class); 38 if (file != null) 39 result.add(file); 40 } 41 if (change instanceof CompositeChange) { 42 getModifiedFiles(result, ((CompositeChange)change).getChildren()); 43 } 44 } 45 } 46 } 47 | Popular Tags |