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