54db23d6a7c904dbd131bb9e9bf0b462b01be122
[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.IFolder;
8 import org.eclipse.core.resources.IResource;
9 import org.eclipse.core.resources.IResourceVisitor;
10 import org.eclipse.core.runtime.CoreException;
11
12 public class PHPElementVisitor implements IResourceVisitor {
13         protected List phpFiles = new ArrayList();
14
15         public PHPElementVisitor() {
16                 super();
17         }
18
19         public boolean visit(IResource resource) throws CoreException {
20                 switch (resource.getType()) {
21                         case IResource.PROJECT :
22                                 return true;
23
24                         case IResource.FOLDER :
25                                 return true;
26
27                         case IResource.FILE :
28                                 IFile fileResource = (IFile) resource;
29                                 if ( "php".equals(fileResource.getFileExtension()) ||
30              "php3".equals(fileResource.getFileExtension()) ||
31              "php4".equals(fileResource.getFileExtension()) ) {
32                                         phpFiles.add(fileResource);
33                                         return true;
34                                 }
35
36                         default :
37                                 return false;
38                 }
39         }
40         
41         public Object[] getCollectedPHPFiles() {
42                 return phpFiles.toArray();
43         }
44 }