changed how special variables are detected
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / builder / ParserVisitor.java
1 package net.sourceforge.phpeclipse.builder;
2
3 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
4 import net.sourceforge.phpeclipse.phpeditor.PHPParserAction;
5
6 import org.eclipse.core.resources.IFile;
7 import org.eclipse.core.resources.IResource;
8 import org.eclipse.core.resources.IResourceDelta;
9 import org.eclipse.core.resources.IResourceDeltaVisitor;
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.IProgressMonitor;
12 import org.eclipse.core.runtime.OperationCanceledException;
13
14 /**
15  *
16  * @see org.eclipse.core.resources.IResourceDelta
17  * @see org.eclipse.core.resources.IResourceDeltaVisitor
18  */
19 public class ParserVisitor implements IResourceDeltaVisitor {
20   final IProgressMonitor fMonitor;
21   public ParserVisitor(IProgressMonitor monitor) {
22     fMonitor = monitor;
23   }
24   
25         protected void checkCancel() {
26                                 if (fMonitor.isCanceled()) {
27                                          throw new OperationCanceledException();
28                                 }
29                  }
30   /** 
31    * Visits the given resource delta.
32    * 
33    * @return <code>true</code> if the resource delta's children should
34    *            be visited; <code>false</code> if they should be skipped.
35    * @exception CoreException if the visit fails for some reason.
36    */
37   public boolean visit(IResourceDelta delta) throws CoreException {
38
39     IResource resource = delta.getResource();
40     int resourceType = resource.getType();
41                 checkCancel();
42                 
43     switch (delta.getKind()) {
44       case IResourceDelta.ADDED :
45         if (resourceType == IResource.FILE) {
46           if ((resource.getFileExtension() != null)
47             && PHPFileUtil.isPHPFile((IFile) resource)) {
48                                                 fMonitor.worked(1);
49             fMonitor.subTask("Parsing: " + resource.getFullPath());
50             PHPParserAction.parseFile((IFile) resource);
51           }
52         }
53         break;
54
55       case IResourceDelta.CHANGED :
56         if (resourceType == IResource.FILE) {
57           if ((resource.getFileExtension() != null)
58             && PHPFileUtil.isPHPFile((IFile) resource)) {
59                                         fMonitor.worked(1);
60             fMonitor.subTask("Parsing: " + resource.getFullPath());
61             PHPParserAction.parseFile((IFile) resource);
62           }
63         }
64         break;
65
66       case IResourceDelta.REMOVED :
67         }
68     return true; // carry on
69   }
70
71 }