da79e2459af75871350a799cc8c23ef39701a7a2
[phpeclipse.git] / net.sourceforge.phpeclipse / 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 ( "php".equals(fileResource.getFileExtension()) ||
29              "php3".equals(fileResource.getFileExtension()) ||
30              "php4".equals(fileResource.getFileExtension()) ) {
31                                         phpFiles.add(fileResource);
32                                         return true;
33                                 }
34
35                         default :
36                                 return false;
37                 }
38         }
39         
40         public Object[] getCollectedPHPFiles() {
41                 return phpFiles.toArray();
42         }
43 }