1 11 package org.eclipse.jdt.internal.corext.refactoring.util; 12 13 import java.util.Arrays ; 14 import java.util.Collection ; 15 import java.util.HashMap ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 import java.util.Map ; 19 import java.util.Set ; 20 21 import org.eclipse.core.resources.IFile; 22 23 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; 24 import org.eclipse.ltk.core.refactoring.Change; 25 import org.eclipse.ltk.core.refactoring.CompositeChange; 26 import org.eclipse.ltk.core.refactoring.TextChange; 27 import org.eclipse.ltk.core.refactoring.TextFileChange; 28 29 public class QualifiedNameSearchResult { 30 31 private Map fChanges; 32 33 public QualifiedNameSearchResult() { 34 fChanges= new HashMap (); 35 } 36 37 public TextChange getChange(IFile file) { 38 TextChange result= (TextChange)fChanges.get(file); 39 if (result == null) { 40 result= new TextFileChange(file.getName(), file); 41 fChanges.put(file, result); 42 } 43 return result; 44 } 45 46 public TextChange[] getAllChanges() { 47 Collection values= fChanges.values(); 48 return (TextChange[])values.toArray(new TextChange[values.size()]); 49 } 50 51 public IFile[] getAllFiles() { 52 Set keys= fChanges.keySet(); 53 return (IFile[])keys.toArray(new IFile[keys.size()]); 54 } 55 56 public Change getSingleChange(IFile[] alreadyTouchedFiles) { 57 Collection values= fChanges.values(); 58 if (values.size() == 0) 59 return null; 60 61 CompositeChange result= new CompositeChange(RefactoringCoreMessages.QualifiedNameSearchResult_change_name); 62 result.markAsSynthetic(); 63 List files= Arrays.asList(alreadyTouchedFiles); 64 for (Iterator iter= values.iterator(); iter.hasNext();) { 65 TextFileChange change= (TextFileChange)iter.next(); 66 if (!files.contains(change.getFile())) { 67 result.add(change); 68 } 69 } 70 return result; 71 } 72 } 73 | Popular Tags |