added "new PHP project" shortcut to PHP perspective
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPDocumentProvider.java
index f79b536..22c26b6 100644 (file)
@@ -73,7 +73,7 @@ import org.eclipse.ui.texteditor.MarkerAnnotation;
 import org.eclipse.ui.texteditor.MarkerUtilities;
 import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
 
-/** 
+/**
  * The PHPDocumentProvider provides the IDocuments used by java editors.
  */
 
@@ -83,95 +83,95 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                         */
 
   /**
-                * Bundle of all required informations to allow working copy management. 
+                * Bundle of all required informations to allow working copy management.
                 */
        /**
-        * Bundle of all required informations to allow working copy management. 
+        * Bundle of all required informations to allow working copy management.
         */
        static protected class CompilationUnitInfo extends FileInfo {
                public ICompilationUnit fCopy;
        }
-       
+
        /**
         * Annotation model dealing with java marker annotations and temporary problems.
         * Also acts as problem requestor for its compilation unit. Initialiy inactive. Must explicitly be
         * activated.
         */
        protected static class CompilationUnitAnnotationModel extends ResourceMarkerAnnotationModel implements IProblemRequestor, IProblemRequestorExtension {
-               
+
                private static class ProblemRequestorState {
                        boolean fInsideReportingSequence= false;
                        List fReportedProblems;
                }
-               
+
                private ThreadLocal fProblemRequestorState= new ThreadLocal();
                private int fStateCount= 0;
-               
+
                private ICompilationUnit fCompilationUnit;
                private List fGeneratedAnnotations;
                private IProgressMonitor fProgressMonitor;
                private boolean fIsActive= false;
-               
+
                private ReverseMap fReverseMap= new ReverseMap();
-               private List fPreviouslyOverlaid= null; 
+               private List fPreviouslyOverlaid= null;
                private List fCurrentlyOverlaid= new ArrayList();
 
-               
+
                public CompilationUnitAnnotationModel(IResource resource) {
                        super(resource);
                }
-               
+
                public void setCompilationUnit(ICompilationUnit unit)  {
                        fCompilationUnit= unit;
                }
-               
+
                protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
                        String markerType= MarkerUtilities.getMarkerType(marker);
                        if (markerType != null && markerType.startsWith(JavaMarkerAnnotation.JAVA_MARKER_TYPE_PREFIX))
                                return new JavaMarkerAnnotation(marker);
                        return super.createMarkerAnnotation(marker);
                }
-               
+
                /*
                 * @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent()
                 */
                protected AnnotationModelEvent createAnnotationModelEvent() {
                        return new CompilationUnitAnnotationModelEvent(this, getResource());
                }
-               
+
                protected Position createPositionFromProblem(IProblem problem) {
                        int start= problem.getSourceStart();
                        if (start < 0)
                                return null;
-                               
+
                        int length= problem.getSourceEnd() - problem.getSourceStart() + 1;
                        if (length < 0)
                                return null;
-                               
+
                        return new Position(start, length);
                }
-               
+
                /*
                 * @see IProblemRequestor#beginReporting()
                 */
                public void beginReporting() {
                        ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
                        if (state == null)
-                               internalBeginReporting(false);                          
+                               internalBeginReporting(false);
                }
-               
+
                /*
-                * @see org.eclipse.jdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
+                * @see net.sourceforge.phpdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
                 */
                public void beginReportingSequence() {
                        ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
                        if (state == null)
                                internalBeginReporting(true);
                }
-               
+
                /**
                 * Sets up the infrastructure necessary for problem reporting.
-                * 
+                *
                 * @param insideReportingSequence <code>true</code> if this method
                 *            call is issued from inside a reporting sequence
                 */
@@ -198,7 +198,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                        state.fReportedProblems.add(problem);
                        }
                }
-               
+
                /*
                 * @see IProblemRequestor#endReporting()
                 */
@@ -207,16 +207,16 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                        if (state != null && !state.fInsideReportingSequence)
                                internalEndReporting(state);
                }
-               
+
                /*
-                * @see org.eclipse.jdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
+                * @see net.sourceforge.phpdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
                 */
                public void endReportingSequence() {
                        ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
                        if (state != null && state.fInsideReportingSequence)
                                internalEndReporting(state);
                }
-               
+
                private void internalEndReporting(ProblemRequestorState state) {
                        int stateCount= 0;
                        synchronized(getLockObject()) {
@@ -224,53 +224,53 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                stateCount= fStateCount;
                                fProblemRequestorState.set(null);
                        }
-                       
+
                        if (stateCount == 0 && isActive())
                                reportProblems(state.fReportedProblems);
                }
-               
+
                /**
                 * Signals the end of problem reporting.
                 */
                private void reportProblems(List reportedProblems) {
                        if (fProgressMonitor != null && fProgressMonitor.isCanceled())
                                return;
-                               
+
                        boolean temporaryProblemsChanged= false;
-                       
+
                        synchronized (getLockObject()) {
-                               
+
                                boolean isCanceled= false;
 
                                fPreviouslyOverlaid= fCurrentlyOverlaid;
                                fCurrentlyOverlaid= new ArrayList();
 
                                if (fGeneratedAnnotations.size() > 0) {
-                                       temporaryProblemsChanged= true; 
+                                       temporaryProblemsChanged= true;
                                        removeAnnotations(fGeneratedAnnotations, false, true);
                                        fGeneratedAnnotations.clear();
                                }
-                               
+
                                if (reportedProblems != null && reportedProblems.size() > 0) {
-                                                                                       
+
                                        Iterator e= reportedProblems.iterator();
                                        while (e.hasNext()) {
-                                               
+
                                                if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
                                                        isCanceled= true;
                                                        break;
                                                }
-                                                       
+
                                                IProblem problem= (IProblem) e.next();
                                                Position position= createPositionFromProblem(problem);
                                                if (position != null) {
-                                                       
+
                                                        try {
                                                                ProblemAnnotation annotation= new ProblemAnnotation(problem, fCompilationUnit);
-                                                               overlayMarkers(position, annotation);                                                           
+                                                               overlayMarkers(position, annotation);
                                                                addAnnotation(annotation, position, false);
                                                                fGeneratedAnnotations.add(annotation);
-                                                       
+
                                                                temporaryProblemsChanged= true;
                                                        } catch (BadLocationException x) {
                                                                // ignore invalid position
@@ -278,11 +278,11 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                                }
                                        }
                                }
-                               
+
                                removeMarkerOverlays(isCanceled);
                                fPreviouslyOverlaid= null;
                        }
-                               
+
                        if (temporaryProblemsChanged)
                                fireModelChanged();
                }
@@ -296,9 +296,9 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                        JavaMarkerAnnotation annotation= (JavaMarkerAnnotation) e.next();
                                        annotation.setOverlay(null);
                                }
-                       }                       
+                       }
                }
-               
+
                /**
                 * Overlays value with problem annotation.
                 * @param problemAnnotation
@@ -314,7 +314,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                        } else {
                        }
                }
-               
+
                private void  overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
                        Object value= getAnnotations(position);
                        if (value instanceof List) {
@@ -325,14 +325,14 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                setOverlay(value, problemAnnotation);
                        }
                }
-               
+
                /**
                 * Tells this annotation model to collect temporary problems from now on.
                 */
                private void startCollectingProblems() {
-                       fGeneratedAnnotations= new ArrayList();  
+                       fGeneratedAnnotations= new ArrayList();
                }
-               
+
                /**
                 * Tells this annotation model to no longer collect temporary problems.
                 */
@@ -341,21 +341,21 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                removeAnnotations(fGeneratedAnnotations, true, true);
                        fGeneratedAnnotations= null;
                }
-               
+
                /*
                 * @see IProblemRequestor#isActive()
                 */
                public boolean isActive() {
                        return fIsActive;
                }
-               
+
                /*
                 * @see IProblemRequestorExtension#setProgressMonitor(IProgressMonitor)
                 */
                public void setProgressMonitor(IProgressMonitor monitor) {
                        fProgressMonitor= monitor;
                }
-               
+
                /*
                 * @see IProblemRequestorExtension#setIsActive(boolean)
                 */
@@ -368,15 +368,15 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                        stopCollectingProblems();
                        }
                }
-               
+
                private Object getAnnotations(Position position) {
                        return fReverseMap.get(position);
                }
-                                       
+
                /*
                 * @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
                 */
-               protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {                          
+               protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
                        super.addAnnotation(annotation, position, fireModelChanged);
 
                        Object cached= fReverseMap.get(position);
@@ -392,7 +392,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                fReverseMap.put(position, list);
                        }
                }
-               
+
                /*
                 * @see AnnotationModel#removeAllAnnotations(boolean)
                 */
@@ -400,7 +400,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                        super.removeAllAnnotations(fireModelChanged);
                        fReverseMap.clear();
                }
-               
+
                /*
                 * @see AnnotationModel#removeAnnotation(Annotation, boolean)
                 */
@@ -420,9 +420,9 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                        super.removeAnnotation(annotation, fireModelChanged);
                }
        }
-  
-   
-  
+
+
+
   protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
 
     private ListenerList fListenerList;
@@ -467,27 +467,27 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
         * Annotation representating an <code>IProblem</code>.
         */
        static protected class ProblemAnnotation extends Annotation implements IJavaAnnotation, IAnnotationPresentation {
-               
+
                private static final String SPELLING_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.spelling";
 
                //XXX: To be fully correct these constants should be non-static
-               /** 
+               /**
                 * The layer in which task problem annotations are located.
                 */
                private static final int TASK_LAYER;
-               /** 
+               /**
                 * The layer in which info problem annotations are located.
                 */
                private static final int INFO_LAYER;
-               /** 
+               /**
                 * The layer in which warning problem annotations representing are located.
                 */
                private static final int WARNING_LAYER;
-               /** 
+               /**
                 * The layer in which error problem annotations representing are located.
                 */
                private static final int ERROR_LAYER;
-               
+
                static {
                        AnnotationPreferenceLookup lookup= EditorsUI.getAnnotationPreferenceLookup();
                        TASK_LAYER= computeLayer("org.eclipse.ui.workbench.texteditor.task", lookup); //$NON-NLS-1$
@@ -495,7 +495,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                        WARNING_LAYER= computeLayer("net.sourceforge.phpdt.ui.warning", lookup); //$NON-NLS-1$
                        ERROR_LAYER= computeLayer("net.sourceforge.phpdt.ui.error", lookup); //$NON-NLS-1$
                }
-               
+
                private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
                        Annotation annotation= new Annotation(annotationType, false, null);
                        AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
@@ -508,19 +508,19 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
 //             private static Image fgQuickFixImage;
 //             private static Image fgQuickFixErrorImage;
 //             private static boolean fgQuickFixImagesInitialized= false;
-               
+
                private ICompilationUnit fCompilationUnit;
                private List fOverlaids;
                private IProblem fProblem;
                private Image fImage;
                private boolean fQuickFixImagesInitialized= false;
                private int fLayer= IAnnotationAccessExtension.DEFAULT_LAYER;
-               
+
                public ProblemAnnotation(IProblem problem, ICompilationUnit cu) {
-                       
+
                        fProblem= problem;
                        fCompilationUnit= cu;
-                       
+
                        if (SpellProblem.Spelling == fProblem.getID()) {
                                setType(SPELLING_ANNOTATION_TYPE);
                                fLayer= WARNING_LAYER;
@@ -538,14 +538,14 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                fLayer= INFO_LAYER;
                        }
                }
-               
+
                /*
                 * @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer()
                 */
                public int getLayer() {
                        return fLayer;
                }
-               
+
                private void initializeImages() {
                        // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18936
 //                     if (!fQuickFixImagesInitialized) {
@@ -567,7 +567,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                private boolean indicateQuixFixableProblems() {
                        return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
                }
-               
+
                /*
                 * @see Annotation#paint
                 */
@@ -583,14 +583,14 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                        initializeImages();
                        return fImage;
                }
-               
+
                /*
                 * @see IJavaAnnotation#getMessage()
                 */
                public String getText() {
                        return fProblem.getMessage();
                }
-               
+
                /*
                 * @see IJavaAnnotation#getArguments()
                 */
@@ -610,25 +610,25 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                 */
                public boolean isProblem() {
                        String type= getType();
-                       return  JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(type)  || 
+                       return  JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(type)  ||
                                                JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(type) ||
                                                SPELLING_ANNOTATION_TYPE.equals(type);
                }
-               
+
                /*
                 * @see IJavaAnnotation#hasOverlay()
                 */
                public boolean hasOverlay() {
                        return false;
                }
-               
+
                /*
-                * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#getOverlay()
+                * @see net.sourceforge.phpdt.internal.ui.javaeditor.IJavaAnnotation#getOverlay()
                 */
                public IJavaAnnotation getOverlay() {
                        return null;
                }
-               
+
                /*
                 * @see IJavaAnnotation#addOverlaid(IJavaAnnotation)
                 */
@@ -648,7 +648,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                        fOverlaids= null;
                        }
                }
-               
+
                /*
                 * @see IJavaAnnotation#getOverlaidIterator()
                 */
@@ -657,18 +657,18 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
                                return fOverlaids.iterator();
                        return null;
                }
-               
+
                /*
-                * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#getCompilationUnit()
+                * @see net.sourceforge.phpdt.internal.ui.javaeditor.IJavaAnnotation#getCompilationUnit()
                 */
                public ICompilationUnit getCompilationUnit() {
                        return fCompilationUnit;
                }
        }
-       
+
+
   /**
-                * Internal structure for mapping positions to some value. 
+                * Internal structure for mapping positions to some value.
                 * The reason for this specific structure is that positions can
                 * change over time. Thus a lookup is based on value and not
                 * on hash value.
@@ -834,21 +834,11 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
   private GlobalAnnotationModelListener fGlobalAnnotationModelListener;
 
   public PHPDocumentProvider() {
-//     setParentDocumentProvider(new TextFileDocumentProvider(new JavaStorageDocumentProvider()));             
-//     
-//     fPropertyListener= new IPropertyChangeListener() {
-//             public void propertyChange(PropertyChangeEvent event) {
-//                     if (HANDLE_TEMPORARY_PROBLEMS.equals(event.getProperty()))
-//                             enableHandlingTemporaryProblems();
-//             }
-//     };
-//     fGlobalAnnotationModelListener= new GlobalAnnotationModelListener();
-//     PHPeclipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener);
-       
-       IDocumentProvider provider= new TextFileDocumentProvider(new JavaStorageDocumentProvider());
+//     IDocumentProvider provider= new TextFileDocumentProvider(new JavaStorageDocumentProvider());
+       IDocumentProvider provider= new TextFileDocumentProvider();
        provider= new ForwardingDocumentProvider(IPHPPartitions.PHP_PARTITIONING, new JavaDocumentSetupParticipant(), provider);
        setParentDocumentProvider(provider);
-       
+
        fGlobalAnnotationModelListener= new GlobalAnnotationModelListener();
        fPropertyListener= new IPropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
@@ -869,7 +859,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
 
   /**
    * Creates a compilation unit from the given file.
-   * 
+   *
    * @param file the file from which to create the compilation unit
    */
   protected ICompilationUnit createCompilationUnit(IFile file) {
@@ -878,7 +868,7 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
       return (ICompilationUnit) element;
     return null;
   }
-  
+
 
   /*
         * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createEmptyFileInfo()
@@ -1040,92 +1030,92 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
        protected FileInfo createFileInfo(Object element) throws CoreException {
                if (!(element instanceof IFileEditorInput))
                        return null;
-                       
+
                IFileEditorInput input= (IFileEditorInput) element;
                ICompilationUnit original= createCompilationUnit(input.getFile());
                if (original == null)
                        return null;
-               
+
                FileInfo info= super.createFileInfo(element);
                if (!(info instanceof CompilationUnitInfo))
                        return null;
-                       
+
                CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
                setUpSynchronization(cuInfo);
-                       
+
                IProblemRequestor requestor= cuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) cuInfo.fModel : null;
 
                original.becomeWorkingCopy(requestor, getProgressMonitor());
                cuInfo.fCopy= original;
-               
+
                if (cuInfo.fModel instanceof CompilationUnitAnnotationModel)   {
                        CompilationUnitAnnotationModel model= (CompilationUnitAnnotationModel) cuInfo.fModel;
                        model.setCompilationUnit(cuInfo.fCopy);
-               } 
-               
+               }
+
                if (cuInfo.fModel != null)
                        cuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);
-               
+
                if (requestor instanceof IProblemRequestorExtension) {
                        IProblemRequestorExtension extension= (IProblemRequestorExtension) requestor;
                        extension.setIsActive(isHandlingTemporaryProblems());
                }
-               
+
                return cuInfo;
        }
-       
+
     private void setUpSynchronization(CompilationUnitInfo cuInfo) {
         IDocument document= cuInfo.fTextFileBuffer.getDocument();
         IAnnotationModel model= cuInfo.fModel;
-        
+
         if (document instanceof ISynchronizable && model instanceof ISynchronizable) {
             Object lock= ((ISynchronizable) document).getLockObject();
             ((ISynchronizable) model).setLockObject(lock);
         }
     }
-    
+
     /*
         * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disposeFileInfo(java.lang.Object, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo)
         */
        protected void disposeFileInfo(Object element, FileInfo info) {
                if (info instanceof CompilationUnitInfo) {
                        CompilationUnitInfo cuInfo= (CompilationUnitInfo) info;
-                       
+
                        try  {
                            cuInfo.fCopy.discardWorkingCopy();
                        } catch (JavaModelException x)  {
                            handleCoreException(x, x.getMessage());
-                       }                       
-                       
+                       }
+
                        if (cuInfo.fModel != null)
                                cuInfo.fModel.removeAnnotationModelListener(fGlobalAnnotationModelListener);
                }
                super.disposeFileInfo(element, info);
        }
-       
+
   protected void commitWorkingCopy(IProgressMonitor monitor, Object element, CompilationUnitInfo info, boolean overwrite) throws CoreException {
     synchronized (info.fCopy) {
                info.fCopy.reconcile();
        }
-       
+
        IDocument document= info.fTextFileBuffer.getDocument();
        IResource resource= info.fCopy.getResource();
-       
+
        Assert.isTrue(resource instanceof IFile);
        if (!resource.exists()) {
                // underlying resource has been deleted, just recreate file, ignore the rest
                createFileFromDocument(monitor, (IFile) resource, document);
                return;
        }
-       
+
        if (fSavePolicy != null)
                fSavePolicy.preSave(info.fCopy);
-       
+
        try {
-               
+
                fIsAboutToSave= true;
                info.fCopy.commitWorkingCopy(overwrite, monitor);
-                       
+
        } catch (CoreException x) {
                // inform about the failure
                fireElementStateChangeFailed(element);
@@ -1137,27 +1127,27 @@ public class PHPDocumentProvider extends TextFileDocumentProvider implements ICo
        } finally {
                fIsAboutToSave= false;
        }
-       
+
        // If here, the dirty state of the editor will change to "not dirty".
        // Thus, the state changing flag will be reset.
        if (info.fModel instanceof AbstractMarkerAnnotationModel) {
                AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
                model.updateMarkers(document);
        }
-       
+
        if (fSavePolicy != null) {
                ICompilationUnit unit= fSavePolicy.postSave(info.fCopy);
                if (unit != null && info.fModel instanceof AbstractMarkerAnnotationModel) {
                        IResource r= unit.getResource();
                        IMarker[] markers= r.findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
                        if (markers != null && markers.length > 0) {
-                               AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;                                               
+                               AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
                                for (int i= 0; i < markers.length; i++)
                                        model.updateMarker(document, markers[i], null);
                        }
                }
        }
-       
+
 }
 
 /*
@@ -1223,7 +1213,7 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
 //      if (setDocumentContent(document, (IEditorInput) element, getEncoding(element))) {
 //        initializeDocument(document, (IEditorInput) element);
 //
-//        //   
+//        //
 //        //    IDocument document = super.createDocument(element);
 //        //    if (document != null) {
 //        //        IDocumentPartitioner partitioner = null;
@@ -1282,7 +1272,7 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
   /**
    * Creates a line tracker working with the same line delimiters as the document
    * of the given element. Assumes the element to be managed by this document provider.
-   * 
+   *
    * @param element the element serving as blue print
    * @return a line tracker based on the same line delimiters as the element's document
    */
@@ -1363,56 +1353,56 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
 //  protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
 //    if (element == null)
 //      return;
-//    
-//    ElementInfo elementInfo= getElementInfo(element);                
+//
+//    ElementInfo elementInfo= getElementInfo(element);
 //    if (elementInfo instanceof CompilationUnitInfo) {
 //      CompilationUnitInfo info= (CompilationUnitInfo) elementInfo;
-//      
+//
 //      IDocument document;
 //      IStatus status= null;
-//      
+//
 //      try {
-//        
+//
 //        ICompilationUnit original= (ICompilationUnit) info.fCopy.getOriginalElement();
 //        IResource resource= original.getResource();
 //        if (resource instanceof IFile) {
-//          
+//
 //          IFile file= (IFile) resource;
-//          
+//
 //          try {
 //            refreshFile(file, monitor);
 //          } catch (CoreException x) {
 //            handleCoreException(x, PHPEditorMessages.getString("CompilationUnitDocumentProvider.error.resetDocument")); //$NON-NLS-1$
 //          }
-//          
+//
 //          IFileEditorInput input= new FileEditorInput(file);
 //          document= super.createDocument(input);
-//          
+//
 //        } else {
 //          document= createEmptyDocument();
 //        }
-//        
+//
 //      } catch (CoreException x) {
 //        document= createEmptyDocument();
 //        status= x.getStatus();
 //      }
-//      
+//
 //      fireElementContentAboutToBeReplaced(element);
-//      
+//
 //      removeUnchangedElementListeners(element, info);
 //      info.fDocument.set(document.get());
 //      info.fCanBeSaved= false;
 //      info.fStatus= status;
 //      addUnchangedElementListeners(element, info);
-//      
+//
 //      fireElementContentReplaced(element);
 //      fireElementDirtyStateChanged(element, false);
-//      
+//
 //    } else {
 //      super.doResetDocument(element, monitor);
 //    }
 //  }
-  
+
   /*
    * @see AbstractDocumentProvider#resetDocument(Object)
    */
@@ -1471,7 +1461,7 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
   /**
         * Saves the content of the given document to the given element.
         * This is only performed when this provider initiated the save.
-        * 
+        *
         * @param monitor the progress monitor
         * @param element the element to which to save
         * @param document the document to save
@@ -1502,7 +1492,7 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
   }
   /**
    * Returns the underlying resource for the given element.
-   * 
+   *
    * @param the element
    * @return the underlying resource of the given element
    */
@@ -1515,10 +1505,10 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
 //  }
 
        /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#getWorkingCopy(java.lang.Object)
+        * @see net.sourceforge.phpdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#getWorkingCopy(java.lang.Object)
         */
        public ICompilationUnit getWorkingCopy(Object element) {
-               FileInfo fileInfo= getFileInfo(element);                
+               FileInfo fileInfo= getFileInfo(element);
                if (fileInfo instanceof CompilationUnitInfo) {
                        CompilationUnitInfo info= (CompilationUnitInfo) fileInfo;
                        return info.fCopy;
@@ -1528,7 +1518,7 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
 
 
   /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#shutdown()
+        * @see net.sourceforge.phpdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#shutdown()
         */
        public void shutdown() {
                PHPeclipsePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
@@ -1572,25 +1562,25 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
   public void removeGlobalAnnotationModelListener(IAnnotationModelListener listener) {
     fGlobalAnnotationModelListener.removeListener(listener);
   }
+
        /**
         * Computes the scheduling rule needed to create or modify a resource. If
-        * the resource exists, its modify rule is returned. If it does not, the 
+        * the resource exists, its modify rule is returned. If it does not, the
         * resource hierarchy is iterated towards the workspace root to find the
         * first parent of <code>toCreateOrModify</code> that exists. Then the
         * 'create' rule for the last non-existing resource is returned.
         * <p>
         * XXX This is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=67601
-        * IResourceRuleFactory.createRule should iterate the hierarchy itself. 
+        * IResourceRuleFactory.createRule should iterate the hierarchy itself.
         * </p>
-        * <p> 
+        * <p>
         * XXX to be replaced by call to TextFileDocumentProvider.computeSchedulingRule after 3.0
         * </p>
-        * 
+        *
         * @param toCreateOrModify the resource to create or modify
         * @return the minimal scheduling rule needed to modify or create a resource
         */
-       private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
+   protected ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
                IResourceRuleFactory factory= ResourcesPlugin.getWorkspace().getRuleFactory();
                if (toCreateOrModify.exists()) {
                        return factory.modifyRule(toCreateOrModify);
@@ -1600,7 +1590,7 @@ protected DocumentProviderOperation createSaveOperation(final Object element, fi
                                toCreateOrModify= parent;
                                parent= toCreateOrModify.getParent();
                        } while (parent != null && !parent.exists());
-                       
+
                        return factory.createRule(toCreateOrModify);
                }
        }