275bd57410d9be6f5cb4e7f9d5ad3778091c077f
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / internal / ui / util / PHPElementVisitor.java
1 package net.sourceforge.phpdt.internal.ui.util;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.eclipse.core.resources.IFile;
7 import org.eclipse.core.resources.IResource;
8 import org.eclipse.core.resources.IResourceVisitor;
9 import org.eclipse.core.runtime.CoreException;
10
11 public class PHPElementVisitor implements IResourceVisitor {
12         protected List phpFiles = new ArrayList();
13
14         public PHPElementVisitor() {
15                 super();
16         }
17
18         public boolean visit(IResource resource) throws CoreException {
19                 switch (resource.getType()) {
20                 case IResource.PROJECT:
21                         return true;
22
23                 case IResource.FOLDER:
24                         return true;
25
26                 case IResource.FILE:
27                         IFile fileResource = (IFile) resource;
28                         if (PHPFileUtil.isPHPFile(fileResource)) {
29                                 phpFiles.add(fileResource);
30                                 return true;
31                         }
32
33                 default:
34                         return false;
35                 }
36         }
37
38         public Object[] getCollectedPHPFiles() {
39                 return phpFiles.toArray();
40         }
41 }