4a9d12d1215a513c498cc0da1202bfca55684353
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPUnitEditor.java
1 package net.sourceforge.phpeclipse.phpeditor;
2
3 import java.lang.reflect.InvocationTargetException;
4 import java.text.MessageFormat;
5 import java.util.ArrayList;
6 import java.util.Iterator;
7 import java.util.List;
8
9 import net.sourceforge.phpdt.core.ICompilationUnit;
10 import net.sourceforge.phpdt.core.IJavaElement;
11 import net.sourceforge.phpdt.core.ISourceRange;
12 import net.sourceforge.phpdt.core.ISourceReference;
13 import net.sourceforge.phpdt.core.JavaCore;
14 import net.sourceforge.phpdt.core.JavaModelException;
15 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
16 import net.sourceforge.phpdt.internal.ui.actions.AddBlockCommentAction;
17 import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
18 import net.sourceforge.phpdt.internal.ui.actions.RemoveBlockCommentAction;
19 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
20 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
21 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
22 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
23 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
24 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI.ExitFlags;
25 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
26 import net.sourceforge.phpdt.ui.PreferenceConstants;
27 import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
28 import net.sourceforge.phpdt.ui.text.JavaTextTools;
29 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
30
31 import org.eclipse.core.resources.IFile;
32 import org.eclipse.core.resources.IWorkspace;
33 import org.eclipse.core.resources.IWorkspaceRoot;
34 import org.eclipse.core.resources.ResourcesPlugin;
35 import org.eclipse.core.runtime.CoreException;
36 import org.eclipse.core.runtime.IPath;
37 import org.eclipse.core.runtime.IProgressMonitor;
38 import org.eclipse.core.runtime.IStatus;
39 import org.eclipse.core.runtime.Preferences;
40
41 import net.sourceforge.phpdt.internal.ui.text.java.IJavaReconcilingListener;
42
43 import org.eclipse.jface.action.Action;
44 import org.eclipse.jface.action.IAction;
45 import org.eclipse.jface.action.IMenuManager;
46 import org.eclipse.jface.dialogs.Dialog;
47 import org.eclipse.jface.dialogs.ErrorDialog;
48 import org.eclipse.jface.dialogs.IMessageProvider;
49 import org.eclipse.jface.dialogs.MessageDialog;
50 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
51 import org.eclipse.jface.preference.IPreferenceStore;
52 import org.eclipse.jface.preference.PreferenceConverter;
53 import org.eclipse.jface.text.BadLocationException;
54 import org.eclipse.jface.text.DocumentCommand;
55 import org.eclipse.jface.text.IDocument;
56 import org.eclipse.jface.text.ILineTracker;
57 import org.eclipse.jface.text.IRegion;
58 import org.eclipse.jface.text.ITextOperationTarget;
59 import org.eclipse.jface.text.ITextSelection;
60 import org.eclipse.jface.text.ITextViewerExtension;
61 import org.eclipse.jface.text.ITypedRegion;
62 import org.eclipse.jface.text.IWidgetTokenKeeper;
63 import org.eclipse.jface.text.contentassist.ContentAssistant;
64 import org.eclipse.jface.text.contentassist.IContentAssistant;
65 import org.eclipse.jface.text.source.IAnnotationModel;
66 import org.eclipse.jface.text.source.IOverviewRuler;
67 import org.eclipse.jface.text.source.ISourceViewer;
68 import org.eclipse.jface.text.source.IVerticalRuler;
69 import org.eclipse.jface.text.source.SourceViewerConfiguration;
70 import org.eclipse.jface.util.PropertyChangeEvent;
71 import org.eclipse.jface.viewers.ISelectionProvider;
72 import org.eclipse.jface.window.Window;
73 import org.eclipse.swt.SWT;
74 import org.eclipse.swt.custom.VerifyKeyListener;
75 import org.eclipse.swt.events.VerifyEvent;
76 import org.eclipse.swt.graphics.Color;
77 import org.eclipse.swt.graphics.Point;
78 import org.eclipse.swt.graphics.RGB;
79 import org.eclipse.swt.widgets.Composite;
80 import org.eclipse.swt.widgets.Display;
81 import org.eclipse.swt.widgets.Shell;
82 import org.eclipse.ui.IEditorInput;
83 import org.eclipse.ui.IFileEditorInput;
84 import org.eclipse.ui.actions.ActionContext;
85 import org.eclipse.ui.actions.ActionGroup;
86 import org.eclipse.ui.actions.WorkspaceModifyOperation;
87 import org.eclipse.ui.dialogs.SaveAsDialog;
88 import org.eclipse.ui.editors.text.IStorageDocumentProvider;
89 import org.eclipse.ui.help.WorkbenchHelp;
90 import org.eclipse.ui.part.FileEditorInput;
91 import org.eclipse.ui.texteditor.ContentAssistAction;
92 import org.eclipse.ui.texteditor.IDocumentProvider;
93 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
94 import org.eclipse.ui.texteditor.TextOperationAction;
95 /*******************************************************************************
96  * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This
97  * program and the accompanying materials are made available under the terms of
98  * the Common Public License v1.0 which accompanies this distribution, and is
99  * available at http://www.eclipse.org/legal/cpl-v10.html
100  * 
101  * Contributors: IBM Corporation - Initial implementation Klaus Hartlage -
102  * www.eclipseproject.de
103  ******************************************************************************/
104 /**
105  * PHP specific text editor.
106  */
107 public class PHPUnitEditor extends PHPEditor{ //implements IJavaReconcilingListener {
108         interface ITextConverter {
109                 void customizeDocumentCommand(IDocument document,
110                                 DocumentCommand command);
111         };
112         //  class AdaptedRulerLayout extends Layout {
113         //
114         //    protected int fGap;
115         //    protected AdaptedSourceViewer fAdaptedSourceViewer;
116         //
117         //    protected AdaptedRulerLayout(int gap, AdaptedSourceViewer asv) {
118         //      fGap = gap;
119         //      fAdaptedSourceViewer = asv;
120         //    }
121         //
122         //    protected Point computeSize(Composite composite, int wHint, int hHint,
123         // boolean flushCache) {
124         //      Control[] children = composite.getChildren();
125         //      Point s = children[children.length - 1].computeSize(SWT.DEFAULT,
126         // SWT.DEFAULT, flushCache);
127         //      if (fAdaptedSourceViewer.isVerticalRulerVisible())
128         //        s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
129         //      return s;
130         //    }
131         //
132         //    protected void layout(Composite composite, boolean flushCache) {
133         //      Rectangle clArea = composite.getClientArea();
134         //      if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
135         //
136         //        StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
137         //        Rectangle trim = textWidget.computeTrim(0, 0, 0, 0);
138         //        int scrollbarHeight = trim.height;
139         //
140         //        IVerticalRuler vr = fAdaptedSourceViewer.getVerticalRuler();
141         //        int vrWidth = vr.getWidth();
142         //
143         //        int orWidth = 0;
144         //        if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
145         //          OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
146         //          orWidth = or.getWidth();
147         //          or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight,
148         // orWidth, clArea.height - 3 * scrollbarHeight);
149         //        }
150         //
151         //        textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth
152         // -
153         // 2 * fGap, clArea.height);
154         //        vr.getControl().setBounds(0, 0, vrWidth, clArea.height -
155         // scrollbarHeight);
156         //
157         //      } else {
158         //        StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
159         //        textWidget.setBounds(0, 0, clArea.width, clArea.height);
160         //      }
161         //    }
162         //  };
163         //
164         //  class AdaptedSourceViewer extends SourceViewer { // extends
165         // JavaCorrectionSourceViewer {
166         //
167         //    private List fTextConverters;
168         //
169         //    private OverviewRuler fOverviewRuler;
170         //    private boolean fIsOverviewRulerVisible;
171         //    /** The viewer's overview ruler hovering controller */
172         //    private AbstractHoverInformationControlManager
173         // fOverviewRulerHoveringController;
174         //
175         //    private boolean fIgnoreTextConverters = false;
176         //
177         //    private IVerticalRuler fCachedVerticalRuler;
178         //    private boolean fCachedIsVerticalRulerVisible;
179         //
180         //    public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int
181         // styles) {
182         //      super(parent, ruler, styles); //, CompilationUnitEditor.this);
183         //
184         //      fCachedVerticalRuler = ruler;
185         //      fCachedIsVerticalRulerVisible = (ruler != null);
186         //      fOverviewRuler = new OverviewRuler(VERTICAL_RULER_WIDTH);
187         //
188         //      delayedCreateControl(parent, styles);
189         //    }
190         //
191         //    /*
192         //     * @see ISourceViewer#showAnnotations(boolean)
193         //     */
194         //    public void showAnnotations(boolean show) {
195         //      fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
196         //      // super.showAnnotations(show);
197         //    }
198         //
199         //    public IContentAssistant getContentAssistant() {
200         //      return fContentAssistant;
201         //    }
202         //
203         //    /*
204         //     * @see ITextOperationTarget#doOperation(int)
205         //     */
206         //    public void doOperation(int operation) {
207         //
208         //      if (getTextWidget() == null)
209         //        return;
210         //
211         //      switch (operation) {
212         //        case CONTENTASSIST_PROPOSALS :
213         //          String msg = fContentAssistant.showPossibleCompletions();
214         //          setStatusLineErrorMessage(msg);
215         //          return;
216         //        case UNDO :
217         //          fIgnoreTextConverters = true;
218         //          break;
219         //        case REDO :
220         //          fIgnoreTextConverters = true;
221         //          break;
222         //      }
223         //
224         //      super.doOperation(operation);
225         //    }
226         //
227         //    public void insertTextConverter(ITextConverter textConverter, int index)
228         // {
229         //      throw new UnsupportedOperationException();
230         //    }
231         //
232         //    public void addTextConverter(ITextConverter textConverter) {
233         //      if (fTextConverters == null) {
234         //        fTextConverters = new ArrayList(1);
235         //        fTextConverters.add(textConverter);
236         //      } else if (!fTextConverters.contains(textConverter))
237         //        fTextConverters.add(textConverter);
238         //    }
239         //
240         //    public void removeTextConverter(ITextConverter textConverter) {
241         //      if (fTextConverters != null) {
242         //        fTextConverters.remove(textConverter);
243         //        if (fTextConverters.size() == 0)
244         //          fTextConverters = null;
245         //      }
246         //    }
247         //
248         //    /*
249         //     * @see TextViewer#customizeDocumentCommand(DocumentCommand)
250         //     */
251         //    protected void customizeDocumentCommand(DocumentCommand command) {
252         //      super.customizeDocumentCommand(command);
253         //      if (!fIgnoreTextConverters && fTextConverters != null) {
254         //        for (Iterator e = fTextConverters.iterator(); e.hasNext();)
255         //           ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(),
256         // command);
257         //      }
258         //      fIgnoreTextConverters = false;
259         //    }
260         //
261         //    public IVerticalRuler getVerticalRuler() {
262         //      return fCachedVerticalRuler;
263         //    }
264         //
265         //    public boolean isVerticalRulerVisible() {
266         //      return fCachedIsVerticalRulerVisible;
267         //    }
268         //
269         //    public OverviewRuler getOverviewRuler() {
270         //      return fOverviewRuler;
271         //    }
272         //
273         //    /*
274         //     * @see TextViewer#createControl(Composite, int)
275         //     */
276         //    protected void createControl(Composite parent, int styles) {
277         //      // do nothing here
278         //    }
279         //
280         //    protected void delayedCreateControl(Composite parent, int styles) {
281         //      //create the viewer
282         //      super.createControl(parent, styles);
283         //
284         //      Control control = getControl();
285         //      if (control instanceof Composite) {
286         //        Composite composite = (Composite) control;
287         //        composite.setLayout(new AdaptedRulerLayout(GAP_SIZE, this));
288         //        fOverviewRuler.createControl(composite, this);
289         //      }
290         //    }
291         //    protected void ensureOverviewHoverManagerInstalled() {
292         //      if (fOverviewRulerHoveringController == null && fAnnotationHover != null
293         // && fHoverControlCreator != null) {
294         //        fOverviewRulerHoveringController =
295         //          new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover,
296         // fHoverControlCreator);
297         //        fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
298         //      }
299         //    }
300         //
301         //    public void hideOverviewRuler() {
302         //      fIsOverviewRulerVisible = false;
303         //      Control control = getControl();
304         //      if (control instanceof Composite) {
305         //        Composite composite = (Composite) control;
306         //        composite.layout();
307         //      }
308         //      if (fOverviewRulerHoveringController != null) {
309         //        fOverviewRulerHoveringController.dispose();
310         //        fOverviewRulerHoveringController = null;
311         //      }
312         //    }
313         //
314         //    public void showOverviewRuler() {
315         //      fIsOverviewRulerVisible = true;
316         //      Control control = getControl();
317         //      if (control instanceof Composite) {
318         //        Composite composite = (Composite) control;
319         //        composite.layout();
320         //      }
321         //      ensureOverviewHoverManagerInstalled();
322         //    }
323         //
324         //    public boolean isOverviewRulerVisible() {
325         //      return fIsOverviewRulerVisible;
326         //    }
327         //
328         //    /*
329         //     * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
330         //     */
331         //    public void setDocument(
332         //      IDocument document,
333         //      IAnnotationModel annotationModel,
334         //      int visibleRegionOffset,
335         //      int visibleRegionLength) {
336         //      super.setDocument(document, annotationModel, visibleRegionOffset,
337         // visibleRegionLength);
338         //      fOverviewRuler.setModel(annotationModel);
339         //    }
340         //
341         //    // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
342         //    public void updateIndentationPrefixes() {
343         //      SourceViewerConfiguration configuration = getSourceViewerConfiguration();
344         //      String[] types = configuration.getConfiguredContentTypes(this);
345         //      for (int i = 0; i < types.length; i++) {
346         //        String[] prefixes = configuration.getIndentPrefixes(this, types[i]);
347         //        if (prefixes != null && prefixes.length > 0)
348         //          setIndentPrefixes(prefixes, types[i]);
349         //      }
350         //    }
351         //
352         //    /*
353         //     * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
354         //     */
355         //    public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
356         //      if (WorkbenchHelp.isContextHelpDisplayed())
357         //        return false;
358         //      return super.requestWidgetToken(requester);
359         //    }
360         //
361         //    /*
362         //     * @see
363         // org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
364         //     */
365         //    public void configure(SourceViewerConfiguration configuration) {
366         //      super.configure(configuration);
367         //      // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
368         // IDocument.DEFAULT_CONTENT_TYPE);
369         //    }
370         //
371         //    protected void handleDispose() {
372         //      fOverviewRuler = null;
373         //
374         //      if (fOverviewRulerHoveringController != null) {
375         //        fOverviewRulerHoveringController.dispose();
376         //        fOverviewRulerHoveringController = null;
377         //      }
378         //
379         //      super.handleDispose();
380         //    }
381         //
382         //  };
383         class AdaptedSourceViewer extends JavaSourceViewer {
384                 private List fTextConverters;
385                 private boolean fIgnoreTextConverters = false;
386                 //                      private JavaCorrectionAssistant fCorrectionAssistant;
387                 public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
388                         super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
389                 }
390 //              public AdaptedSourceViewer(Composite parent,
391 //                              IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
392 //                              boolean showAnnotationsOverview, int styles) {
393 //                      super(parent, verticalRuler, overviewRuler,
394 //                                      showAnnotationsOverview, styles);
395 //              }
396                 public IContentAssistant getContentAssistant() {
397                         return fContentAssistant;
398                 }
399                 /*
400                  * @see ITextOperationTarget#doOperation(int)
401                  */
402                 public void doOperation(int operation) {
403                         if (getTextWidget() == null)
404                                 return;
405                         switch (operation) {
406                                 case CONTENTASSIST_PROPOSALS :
407                                         String msg = fContentAssistant.showPossibleCompletions();
408                                         setStatusLineErrorMessage(msg);
409                                         return;
410                                 //                                      case CORRECTIONASSIST_PROPOSALS:
411                                 //                                              fCorrectionAssistant.showPossibleCompletions();
412                                 //                                              return;
413                                 case UNDO :
414                                         fIgnoreTextConverters = true;
415                                         break;
416                                 case REDO :
417                                         fIgnoreTextConverters = true;
418                                         break;
419                         }
420                         super.doOperation(operation);
421                 }
422                 /*
423                  * @see ITextOperationTarget#canDoOperation(int)
424                  */
425                 public boolean canDoOperation(int operation) {
426                         //                              if (operation == CORRECTIONASSIST_PROPOSALS)
427                         //                                      return isEditable();
428                         return super.canDoOperation(operation);
429                 }
430                 /*
431                  * @see TextViewer#handleDispose()
432                  */
433                 protected void handleDispose() {
434                         //                              if (fCorrectionAssistant != null) {
435                         //                                      fCorrectionAssistant.uninstall();
436                         //                                      fCorrectionAssistant= null;
437                         //                              }
438                         super.handleDispose();
439                 }
440                 public void insertTextConverter(ITextConverter textConverter, int index) {
441                         throw new UnsupportedOperationException();
442                 }
443                 public void addTextConverter(ITextConverter textConverter) {
444                         if (fTextConverters == null) {
445                                 fTextConverters = new ArrayList(1);
446                                 fTextConverters.add(textConverter);
447                         } else if (!fTextConverters.contains(textConverter))
448                                 fTextConverters.add(textConverter);
449                 }
450                 public void removeTextConverter(ITextConverter textConverter) {
451                         if (fTextConverters != null) {
452                                 fTextConverters.remove(textConverter);
453                                 if (fTextConverters.size() == 0)
454                                         fTextConverters = null;
455                         }
456                 }
457                 /*
458                  * @see TextViewer#customizeDocumentCommand(DocumentCommand)
459                  */
460                 protected void customizeDocumentCommand(DocumentCommand command) {
461                         super.customizeDocumentCommand(command);
462                         if (!fIgnoreTextConverters && fTextConverters != null) {
463                                 for (Iterator e = fTextConverters.iterator(); e.hasNext();)
464                                         ((ITextConverter) e.next()).customizeDocumentCommand(
465                                                         getDocument(), command);
466                         }
467                         fIgnoreTextConverters = false;
468                 }
469                 // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
470                 public void updateIndentationPrefixes() {
471                         SourceViewerConfiguration configuration = getSourceViewerConfiguration();
472                         String[] types = configuration.getConfiguredContentTypes(this);
473                         for (int i = 0; i < types.length; i++) {
474                                 String[] prefixes = configuration.getIndentPrefixes(this,
475                                                 types[i]);
476                                 if (prefixes != null && prefixes.length > 0)
477                                         setIndentPrefixes(prefixes, types[i]);
478                         }
479                 }
480                 /*
481                  * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
482                  */
483                 public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
484                         if (WorkbenchHelp.isContextHelpDisplayed())
485                                 return false;
486                         return super.requestWidgetToken(requester);
487                 }
488                 /*
489                  * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
490                  */
491                 public void configure(SourceViewerConfiguration configuration) {
492                         super.configure(configuration);
493                         //                              fCorrectionAssistant= new
494                         // JavaCorrectionAssistant(CompilationUnitEditor.this);
495                         //                              fCorrectionAssistant.install(this);
496                         //TODO install SmartBracesAutoEditStrategy
497                         //                              prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this),
498                         // IDocument.DEFAULT_CONTENT_TYPE);
499                 }
500         };
501         static class TabConverter implements ITextConverter {
502                 private int fTabRatio;
503                 private ILineTracker fLineTracker;
504                 public TabConverter() {
505                 }
506                 public void setNumberOfSpacesPerTab(int ratio) {
507                         fTabRatio = ratio;
508                 }
509                 public void setLineTracker(ILineTracker lineTracker) {
510                         fLineTracker = lineTracker;
511                 }
512                 private int insertTabString(StringBuffer buffer, int offsetInLine) {
513                         if (fTabRatio == 0)
514                                 return 0;
515                         int remainder = offsetInLine % fTabRatio;
516                         remainder = fTabRatio - remainder;
517                         for (int i = 0; i < remainder; i++)
518                                 buffer.append(' ');
519                         return remainder;
520                 }
521                 public void customizeDocumentCommand(IDocument document,
522                                 DocumentCommand command) {
523                         String text = command.text;
524                         if (text == null)
525                                 return;
526                         int index = text.indexOf('\t');
527                         if (index > -1) {
528                                 StringBuffer buffer = new StringBuffer();
529                                 fLineTracker.set(command.text);
530                                 int lines = fLineTracker.getNumberOfLines();
531                                 try {
532                                         for (int i = 0; i < lines; i++) {
533                                                 int offset = fLineTracker.getLineOffset(i);
534                                                 int endOffset = offset + fLineTracker.getLineLength(i);
535                                                 String line = text.substring(offset, endOffset);
536                                                 int position = 0;
537                                                 if (i == 0) {
538                                                         IRegion firstLine = document
539                                                                         .getLineInformationOfOffset(command.offset);
540                                                         position = command.offset - firstLine.getOffset();
541                                                 }
542                                                 int length = line.length();
543                                                 for (int j = 0; j < length; j++) {
544                                                         char c = line.charAt(j);
545                                                         if (c == '\t') {
546                                                                 position += insertTabString(buffer, position);
547                                                         } else {
548                                                                 buffer.append(c);
549                                                                 ++position;
550                                                         }
551                                                 }
552                                         }
553                                         command.text = buffer.toString();
554                                 } catch (BadLocationException x) {
555                                 }
556                         }
557                 }
558         };
559         private static class ExitPolicy implements LinkedPositionUI.ExitPolicy {
560                 final char fExitCharacter;
561                 public ExitPolicy(char exitCharacter) {
562                         fExitCharacter = exitCharacter;
563                 }
564                 /*
565                  * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionManager,
566                  *      org.eclipse.swt.events.VerifyEvent, int, int)
567                  */
568                 public ExitFlags doExit(LinkedPositionManager manager,
569                                 VerifyEvent event, int offset, int length) {
570                         if (event.character == fExitCharacter) {
571                                 if (manager.anyPositionIncludes(offset, length))
572                                         return new ExitFlags(LinkedPositionUI.COMMIT
573                                                         | LinkedPositionUI.UPDATE_CARET, false);
574                                 else
575                                         return new ExitFlags(LinkedPositionUI.COMMIT, true);
576                         }
577                         switch (event.character) {
578                                 case '\b' :
579                                         if (manager.getFirstPosition().length == 0)
580                                                 return new ExitFlags(0, false);
581                                         else
582                                                 return null;
583                                 case '\n' :
584                                 case '\r' :
585                                         return new ExitFlags(LinkedPositionUI.COMMIT, true);
586                                 default :
587                                         return null;
588                         }
589                 }
590         }
591         private static class BracketLevel {
592                 int fOffset;
593                 int fLength;
594                 LinkedPositionManager fManager;
595                 LinkedPositionUI fEditor;
596         };
597         private class BracketInserter
598                         implements
599                                 VerifyKeyListener,
600                                 LinkedPositionUI.ExitListener {
601                 private boolean fCloseBracketsPHP = true;
602                 private boolean fCloseStringsPHP = true;
603                 private boolean fCloseBracketsHTML = true;
604                 private boolean fCloseStringsHTML = true;
605                 private int fOffset;
606                 private int fLength;
607                 public void setCloseBracketsPHPEnabled(boolean enabled) {
608                         fCloseBracketsPHP = enabled;
609                 }
610                 public void setCloseStringsPHPEnabled(boolean enabled) {
611                         fCloseStringsPHP = enabled;
612                 }
613                 public void setCloseBracketsHTMLEnabled(boolean enabled) {
614                         fCloseBracketsHTML = enabled;
615                 }
616                 public void setCloseStringsHTMLEnabled(boolean enabled) {
617                         fCloseStringsHTML = enabled;
618                 }
619                 private boolean hasIdentifierToTheRight(IDocument document, int offset) {
620                         try {
621                                 int end = offset;
622                                 IRegion endLine = document.getLineInformationOfOffset(end);
623                                 int maxEnd = endLine.getOffset() + endLine.getLength();
624                                 while (end != maxEnd
625                                                 && Character.isWhitespace(document.getChar(end)))
626                                         ++end;
627                                 return end != maxEnd
628                                                 && Scanner.isPHPIdentifierPart(document.getChar(end));
629                         } catch (BadLocationException e) {
630                                 // be conservative
631                                 return true;
632                         }
633                 }
634                 private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
635                         try {
636                                 int start = offset;
637                                 IRegion startLine = document.getLineInformationOfOffset(start);
638                                 int minStart = startLine.getOffset();
639                                 while (start != minStart
640                                                 && Character.isWhitespace(document.getChar(start - 1)))
641                                         --start;
642                                 return start != minStart
643                                                 && Scanner.isPHPIdentifierPart(document
644                                                                 .getChar(start - 1));
645                         } catch (BadLocationException e) {
646                                 return true;
647                         }
648                 }
649                 private boolean hasCharacterToTheRight(IDocument document, int offset,
650                                 char character) {
651                         try {
652                                 int end = offset;
653                                 IRegion endLine = document.getLineInformationOfOffset(end);
654                                 int maxEnd = endLine.getOffset() + endLine.getLength();
655                                 while (end != maxEnd
656                                                 && Character.isWhitespace(document.getChar(end)))
657                                         ++end;
658                                 return end != maxEnd && document.getChar(end) == character;
659                         } catch (BadLocationException e) {
660                                 // be conservative
661                                 return true;
662                         }
663                 }
664                 /*
665                  * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
666                  */
667                 public void verifyKey(VerifyEvent event) {
668                         if (!event.doit)
669                                 return;
670                         final ISourceViewer sourceViewer = getSourceViewer();
671                         IDocument document = sourceViewer.getDocument();
672                         final Point selection = sourceViewer.getSelectedRange();
673                         final int offset = selection.x;
674                         final int length = selection.y;
675                         try {
676                                 ITypedRegion partition = document.getPartition(offset);
677                                 String type = partition.getType();
678                                 if (type.equals(IPHPPartitions.PHP_PARTITIONING)) {
679                                         switch (event.character) {
680                                                 case '(' :
681                                                         if (hasCharacterToTheRight(document, offset
682                                                                         + length, '('))
683                                                                 return;
684                                                 // fall through
685                                                 case '[' :
686                                                         if (!fCloseBracketsPHP)
687                                                                 return;
688                                                         if (hasIdentifierToTheRight(document, offset
689                                                                         + length))
690                                                                 return;
691                                                 // fall through
692                                                 case '"' :
693                                                         if (event.character == '"') {
694                                                                 if (!fCloseStringsPHP)
695                                                                         return;
696                                                                 // changed for statements like echo "" print ""
697                                                                 //    if (hasIdentifierToTheLeft(document, offset)
698                                                                 // ||
699                                                                 // hasIdentifierToTheRight(document, offset +
700                                                                 // length))
701                                                                 if (hasIdentifierToTheRight(document, offset
702                                                                                 + length))
703                                                                         return;
704                                                         }
705                                                         //     ITypedRegion partition=
706                                                         // document.getPartition(offset);
707                                                         //       if (!
708                                                         // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
709                                                         // &&
710                                                         // (partition.getOffset() != offset))
711                                                         //         return;
712                                                         final char character = event.character;
713                                                         final char closingCharacter = getPeerCharacter(character);
714                                                         final StringBuffer buffer = new StringBuffer();
715                                                         buffer.append(character);
716                                                         buffer.append(closingCharacter);
717                                                         document.replace(offset, length, buffer.toString());
718                                                         LinkedPositionManager manager = new LinkedPositionManager(
719                                                                         document);
720                                                         manager.addPosition(offset + 1, 0);
721                                                         fOffset = offset;
722                                                         fLength = 2;
723                                                         LinkedPositionUI editor = new LinkedPositionUI(
724                                                                         sourceViewer, manager);
725                                                         editor.setCancelListener(this);
726                                                         editor.setExitPolicy(new ExitPolicy(
727                                                                         closingCharacter));
728                                                         editor.setFinalCaretOffset(offset + 2);
729                                                         editor.enter();
730                                                         IRegion newSelection = editor.getSelectedRegion();
731                                                         sourceViewer.setSelectedRange(newSelection
732                                                                         .getOffset(), newSelection.getLength());
733                                                         event.doit = false;
734                                         }
735                                 } else if (type.equals(IPHPPartitions.HTML)
736                                                 || type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
737                                         switch (event.character) {
738                                                 case '(' :
739                                                         if (hasCharacterToTheRight(document, offset
740                                                                         + length, '('))
741                                                                 return;
742                                                 // fall through
743                                                 case '[' :
744                                                         if (!fCloseBracketsHTML)
745                                                                 return;
746                                                         if (hasIdentifierToTheRight(document, offset
747                                                                         + length))
748                                                                 return;
749                                                 // fall through
750                                                 case '"' :
751                                                         if (event.character == '"') {
752                                                                 if (!fCloseStringsHTML)
753                                                                         return;
754                                                                 if (hasIdentifierToTheLeft(document, offset)
755                                                                                 || hasIdentifierToTheRight(document,
756                                                                                                 offset + length))
757                                                                         return;
758                                                         }
759                                                         //     ITypedRegion partition=
760                                                         // document.getPartition(offset);
761                                                         //       if (!
762                                                         // IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
763                                                         // &&
764                                                         // (partition.getOffset() != offset))
765                                                         //         return;
766                                                         final char character = event.character;
767                                                         final char closingCharacter = getPeerCharacter(character);
768                                                         final StringBuffer buffer = new StringBuffer();
769                                                         buffer.append(character);
770                                                         buffer.append(closingCharacter);
771                                                         document.replace(offset, length, buffer.toString());
772                                                         LinkedPositionManager manager = new LinkedPositionManager(
773                                                                         document);
774                                                         manager.addPosition(offset + 1, 0);
775                                                         fOffset = offset;
776                                                         fLength = 2;
777                                                         LinkedPositionUI editor = new LinkedPositionUI(
778                                                                         sourceViewer, manager);
779                                                         editor.setCancelListener(this);
780                                                         editor.setExitPolicy(new ExitPolicy(
781                                                                         closingCharacter));
782                                                         editor.setFinalCaretOffset(offset + 2);
783                                                         editor.enter();
784                                                         IRegion newSelection = editor.getSelectedRegion();
785                                                         sourceViewer.setSelectedRange(newSelection
786                                                                         .getOffset(), newSelection.getLength());
787                                                         event.doit = false;
788                                         }
789                                 }
790                         } catch (BadLocationException e) {
791                         }
792                 }
793                 /*
794                  * @see org.phpeclipse.phpdt.internal.ui.text.link.LinkedPositionUI.ExitListener#exit(boolean)
795                  */
796                 public void exit(boolean accept) {
797                         if (accept)
798                                 return;
799                         // remove brackets
800                         try {
801                                 final ISourceViewer sourceViewer = getSourceViewer();
802                                 IDocument document = sourceViewer.getDocument();
803                                 document.replace(fOffset, fLength, null);
804                         } catch (BadLocationException e) {
805                         }
806                 }
807         }
808         /** The editor's save policy */
809         protected ISavePolicy fSavePolicy;
810         /**
811          * Listener to annotation model changes that updates the error tick in the
812          * tab image
813          */
814         private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
815         /** The editor's paint manager */
816         //  private PaintManager fPaintManager;
817         /** The editor's bracket painter */
818         private BracketPainter fBracketPainter;
819         /** The editor's bracket matcher */
820         private PHPPairMatcher fBracketMatcher;
821         /** The editor's line painter */
822         private LinePainter fLinePainter;
823         /** The editor's print margin ruler painter */
824         private PrintMarginPainter fPrintMarginPainter;
825         /** The editor's problem painter */
826         //  private ProblemPainter fProblemPainter;
827         /** The editor's tab converter */
828         private TabConverter fTabConverter;
829         /** History for structure select action */
830         //private SelectionHistory fSelectionHistory;
831         /** The preference property change listener for php core. */
832         //  private IPropertyChangeListener fPropertyChangeListener = new
833         // PropertyChangeListener();
834         /** The remembered java element */
835         private IJavaElement fRememberedElement;
836         /** The remembered selection */
837         private ITextSelection fRememberedSelection;
838         /** The remembered php element offset */
839         private int fRememberedElementOffset;
840         /** The bracket inserter. */
841         private BracketInserter fBracketInserter = new BracketInserter();
842
843         /** The standard action groups added to the menu */
844         private GenerateActionGroup fGenerateActionGroup;
845         private CompositeActionGroup fContextMenuGroup;
846         //  private class PropertyChangeListener implements IPropertyChangeListener {
847         //    /*
848         //     * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
849         //     */
850         //    public void
851         // propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
852         // event) {
853         //      handlePreferencePropertyChanged(event);
854         //    }
855         //  }
856         /* Preference key for code formatter tab size */
857         private final static String CODE_FORMATTER_TAB_SIZE = JavaCore.FORMATTER_TAB_SIZE;
858         /** Preference key for matching brackets */
859         private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
860         /** Preference key for matching brackets color */
861         private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
862         /** Preference key for highlighting current line */
863         private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
864         /** Preference key for highlight color of current line */
865         private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
866         /** Preference key for showing print marging ruler */
867         private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
868         /** Preference key for print margin ruler color */
869         private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
870         /** Preference key for print margin ruler column */
871         private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
872         /** Preference key for inserting spaces rather than tabs */
873         private final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
874         /** Preference key for error indication */
875         //  private final static String ERROR_INDICATION =
876         // PreferenceConstants.EDITOR_PROBLEM_INDICATION;
877         /** Preference key for error color */
878         //  private final static String ERROR_INDICATION_COLOR =
879         // PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
880         /** Preference key for warning indication */
881         //  private final static String WARNING_INDICATION =
882         // PreferenceConstants.EDITOR_WARNING_INDICATION;
883         /** Preference key for warning color */
884         //  private final static String WARNING_INDICATION_COLOR =
885         // PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
886         /** Preference key for task indication */
887         private final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
888         /** Preference key for task color */
889         private final static String TASK_INDICATION_COLOR = PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
890         /** Preference key for bookmark indication */
891         private final static String BOOKMARK_INDICATION = PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
892         /** Preference key for bookmark color */
893         private final static String BOOKMARK_INDICATION_COLOR = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
894         /** Preference key for search result indication */
895         private final static String SEARCH_RESULT_INDICATION = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
896         /** Preference key for search result color */
897         private final static String SEARCH_RESULT_INDICATION_COLOR = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
898         /** Preference key for unknown annotation indication */
899         private final static String UNKNOWN_INDICATION = PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
900         /** Preference key for unknown annotation color */
901         private final static String UNKNOWN_INDICATION_COLOR = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
902         /** Preference key for linked position color */
903         private final static String LINKED_POSITION_COLOR = PreferenceConstants.EDITOR_LINKED_POSITION_COLOR;
904         /** Preference key for shwoing the overview ruler */
905         private final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
906         /** Preference key for error indication in overview ruler */
907         private final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
908         /** Preference key for warning indication in overview ruler */
909         private final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
910         /** Preference key for task indication in overview ruler */
911         private final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
912         /** Preference key for bookmark indication in overview ruler */
913         private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
914         /** Preference key for search result indication in overview ruler */
915         private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
916         /** Preference key for unknown annotation indication in overview ruler */
917         private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
918         /** Preference key for automatically closing strings */
919         private final static String CLOSE_STRINGS_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP;
920         /** Preference key for automatically wrapping Java strings */
921         private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS;
922         /** Preference key for automatically closing brackets and parenthesis */
923         private final static String CLOSE_BRACKETS_PHP = PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP;
924         /** Preference key for automatically closing phpdocs and comments */
925         private final static String CLOSE_JAVADOCS = PreferenceConstants.EDITOR_CLOSE_JAVADOCS;
926         /** Preference key for automatically adding phpdoc tags */
927         private final static String ADD_JAVADOC_TAGS = PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
928         /** Preference key for automatically formatting phpdocs */
929         private final static String FORMAT_JAVADOCS = PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
930         /** Preference key for automatically closing strings */
931         private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
932         /** Preference key for automatically closing brackets and parenthesis */
933         private final static String CLOSE_BRACKETS_HTML = PreferenceConstants.EDITOR_CLOSE_BRACKETS_HTML;
934         /** Preference key for smart paste */
935         private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
936         //  private final static class AnnotationInfo {
937         //    public String fColorPreference;
938         //    public String fOverviewRulerPreference;
939         //    public String fEditorPreference;
940         //  };
941         //  private final static Map ANNOTATION_MAP;
942         //  static {
943         //
944         //    AnnotationInfo info;
945         //    ANNOTATION_MAP = new HashMap();
946         //
947         //    info = new AnnotationInfo();
948         //    info.fColorPreference = TASK_INDICATION_COLOR;
949         //    info.fOverviewRulerPreference = TASK_INDICATION_IN_OVERVIEW_RULER;
950         //    info.fEditorPreference = TASK_INDICATION;
951         //    ANNOTATION_MAP.put(AnnotationType.TASK, info);
952         //
953         //    info = new AnnotationInfo();
954         //    info.fColorPreference = ERROR_INDICATION_COLOR;
955         //    info.fOverviewRulerPreference = ERROR_INDICATION_IN_OVERVIEW_RULER;
956         //    info.fEditorPreference = ERROR_INDICATION;
957         //    ANNOTATION_MAP.put(AnnotationType.ERROR, info);
958         //
959         //    info = new AnnotationInfo();
960         //    info.fColorPreference = WARNING_INDICATION_COLOR;
961         //    info.fOverviewRulerPreference = WARNING_INDICATION_IN_OVERVIEW_RULER;
962         //    info.fEditorPreference = WARNING_INDICATION;
963         //    ANNOTATION_MAP.put(AnnotationType.WARNING, info);
964         //
965         //    info = new AnnotationInfo();
966         //    info.fColorPreference = BOOKMARK_INDICATION_COLOR;
967         //    info.fOverviewRulerPreference = BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
968         //    info.fEditorPreference = BOOKMARK_INDICATION;
969         //    ANNOTATION_MAP.put(AnnotationType.BOOKMARK, info);
970         //
971         //    info = new AnnotationInfo();
972         //    info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
973         //    info.fOverviewRulerPreference =
974         // SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
975         //    info.fEditorPreference = SEARCH_RESULT_INDICATION;
976         //    ANNOTATION_MAP.put(AnnotationType.SEARCH, info);
977         //
978         //    info = new AnnotationInfo();
979         //    info.fColorPreference = UNKNOWN_INDICATION_COLOR;
980         //    info.fOverviewRulerPreference = UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
981         //    info.fEditorPreference = UNKNOWN_INDICATION;
982         //    ANNOTATION_MAP.put(AnnotationType.UNKNOWN, info);
983         //  };
984         //
985         //  private final static AnnotationType[] ANNOTATION_LAYERS =
986         //    new AnnotationType[] {
987         //      AnnotationType.UNKNOWN,
988         //      AnnotationType.BOOKMARK,
989         //      AnnotationType.TASK,
990         //      AnnotationType.SEARCH,
991         //      AnnotationType.WARNING,
992         //      AnnotationType.ERROR };
993         /**
994          * Creates a new php unit editor.
995          */
996         public PHPUnitEditor() {
997                 super();
998                 setDocumentProvider(PHPeclipsePlugin.getDefault()
999                                 .getCompilationUnitDocumentProvider());
1000                 setEditorContextMenuId("#PHPEditorContext"); //$NON-NLS-1$
1001                 setRulerContextMenuId("#PHPRulerContext"); //$NON-NLS-1$
1002                 setOutlinerContextMenuId("#PHPOutlinerContext"); //$NON-NLS-1$
1003                 // don't set help contextId, we install our own help context
1004                 fSavePolicy = null;
1005                 fJavaEditorErrorTickUpdater = new JavaEditorErrorTickUpdater(this);
1006         }
1007         /*
1008          * @see AbstractTextEditor#createActions()
1009          */
1010         protected void createActions() {
1011                 super.createActions();
1012                 Action action;
1013                 //              Action action= new
1014                 // TextOperationAction(PHPEditorMessages.getResourceBundle(),
1015                 // "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS);
1016                 // //$NON-NLS-1$
1017                 //              action.setActionDefinitionId(PHPEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
1018                 //              setAction("CorrectionAssistProposal", action); //$NON-NLS-1$
1019                 //              markAsStateDependentAction("CorrectionAssistProposal", true);
1020                 // //$NON-NLS-1$
1021                 //// WorkbenchHelp.setHelp(action,
1022                 // IJavaHelpContextIds.QUICK_FIX_ACTION);
1023                 action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(),
1024                                 "ContentAssistProposal.", this); //$NON-NLS-1$
1025                 action
1026                                 .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
1027                 setAction("ContentAssistProposal", action); //$NON-NLS-1$
1028                 markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
1029                 //              WorkbenchHelp.setHelp(action,
1030                 // IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
1031                 action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
1032                                 "ContentAssistContextInformation.", this,
1033                                 ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
1034                 action
1035                                 .setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
1036                 setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
1037                 markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
1038                 //              WorkbenchHelp.setHelp(action,
1039                 // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
1040                 //              action= new
1041                 // TextOperationAction(PHPEditorMessages.getResourceBundle(),
1042                 // "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX);
1043                 // //$NON-NLS-1$
1044                 //              action.setActionDefinitionId(PHPEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX);
1045                 //              setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$
1046                 //              markAsStateDependentAction("ContentAssistCompletePrefix", true);
1047                 // //$NON-NLS-1$
1048                 //// WorkbenchHelp.setHelp(action,
1049                 // IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
1050                 action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
1051                                 "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
1052                 action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
1053                 setAction("Comment", action); //$NON-NLS-1$
1054                 markAsStateDependentAction("Comment", true); //$NON-NLS-1$
1055                 //              WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
1056                 action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
1057                                 "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
1058                 action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
1059                 setAction("Uncomment", action); //$NON-NLS-1$
1060                 markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
1061                 //              WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
1062
1063                 action = new ToggleCommentAction(PHPEditorMessages.getResourceBundle(),
1064                                 "ToggleComment.", this); //$NON-NLS-1$
1065                 action
1066                                 .setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT);
1067                 setAction("ToggleComment", action); //$NON-NLS-1$
1068                 markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
1069                 //WorkbenchHelp.setHelp(action,
1070                 // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
1071                 configureToggleCommentAction();
1072
1073                 //    action = new
1074                 // ToggleCommentAction(PHPEditorMessages.getResourceBundle(),
1075                 //        "ToggleComment.", this, getSourceViewerConfiguration()
1076                 //            .getDefaultPrefixes(getSourceViewer(), "")); //$NON-NLS-1$
1077                 // //$NON-NLS-2$
1078                 //    action.setActionDefinitionId(PHPEditorActionDefinitionIds.TOGGLE_COMMENT);
1079                 //    setAction("ToggleComment", action); //$NON-NLS-1$
1080                 //    markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
1081                 //    // WorkbenchHelp.setHelp(action,
1082                 //    // IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
1083
1084                 action = new TextOperationAction(PHPEditorMessages.getResourceBundle(),
1085                                 "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
1086                 action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
1087                 setAction("Format", action); //$NON-NLS-1$
1088                 markAsStateDependentAction("Format", true); //$NON-NLS-1$
1089                 markAsSelectionDependentAction("Format", true); //$NON-NLS-1$           
1090                 //              WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
1091
1092                 action = new AddBlockCommentAction(PHPEditorMessages
1093                                 .getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$
1094                 action
1095                                 .setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
1096                 setAction("AddBlockComment", action); //$NON-NLS-1$
1097                 markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
1098                 markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$          
1099                 //              WorkbenchHelp.setHelp(action,
1100                 // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
1101                 action = new RemoveBlockCommentAction(PHPEditorMessages
1102                                 .getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
1103                 action
1104                                 .setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
1105                 setAction("RemoveBlockComment", action); //$NON-NLS-1$
1106                 markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
1107                 markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$               
1108                 //              WorkbenchHelp.setHelp(action,
1109                 // IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
1110                 //              action= new IndentAction(PHPEditorMessages.getResourceBundle(),
1111                 // "Indent.", this, false); //$NON-NLS-1$
1112                 //              action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT);
1113                 //              setAction("Indent", action); //$NON-NLS-1$
1114                 //              markAsStateDependentAction("Indent", true); //$NON-NLS-1$
1115                 //              markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
1116                 //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
1117                 //              
1118                 //              action= new IndentAction(PHPEditorMessages.getResourceBundle(),
1119                 // "Indent.", this, true); //$NON-NLS-1$
1120                 //              setAction("IndentOnTab", action); //$NON-NLS-1$
1121                 //              markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
1122                 //              markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
1123                 //              
1124                 if (getPreferenceStore().getBoolean(
1125                                 PreferenceConstants.EDITOR_SMART_TAB)) {
1126                         // don't replace Shift Right - have to make sure their enablement is
1127                         // mutually exclusive
1128                         //                      removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
1129                         setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
1130                 }
1131                 fGenerateActionGroup = new GenerateActionGroup(this,
1132                                 ITextEditorActionConstants.GROUP_EDIT);
1133                 fActionGroups = new CompositeActionGroup(
1134                                 new ActionGroup[]{fGenerateActionGroup});
1135                 //        We have to keep the context menu group separate to have better
1136                 // control
1137                 // over positioning
1138                 fContextMenuGroup = new CompositeActionGroup(
1139                                 new ActionGroup[]{fGenerateActionGroup});
1140                 //      rg,
1141                 //      new LocalHistoryActionGroup(this,
1142                 // ITextEditorActionConstants.GROUP_EDIT)});
1143
1144         }
1145         /*
1146          * @see JavaEditor#getElementAt(int)
1147          */
1148         protected IJavaElement getElementAt(int offset) {
1149                 return getElementAt(offset, true);
1150         }
1151         /**
1152          * Returns the most narrow element including the given offset. If
1153          * <code>reconcile</code> is <code>true</code> the editor's input
1154          * element is reconciled in advance. If it is <code>false</code> this
1155          * method only returns a result if the editor's input element does not need
1156          * to be reconciled.
1157          * 
1158          * @param offset
1159          *            the offset included by the retrieved element
1160          * @param reconcile
1161          *            <code>true</code> if working copy should be reconciled
1162          */
1163         protected IJavaElement getElementAt(int offset, boolean reconcile) {
1164                 IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
1165                                 .getWorkingCopyManager();
1166                 ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
1167                 if (unit != null) {
1168                         try {
1169                                 if (reconcile) {
1170                                         synchronized (unit) {
1171                                                 unit.reconcile();
1172                                         }
1173                                         return unit.getElementAt(offset);
1174                                 } else if (unit.isConsistent())
1175                                         return unit.getElementAt(offset);
1176                         } catch (JavaModelException x) {
1177                                 PHPeclipsePlugin.log(x.getStatus());
1178                                 // nothing found, be tolerant and go on
1179                         }
1180                 }
1181                 return null;
1182         }
1183         /*
1184          * @see JavaEditor#getCorrespondingElement(IJavaElement)
1185          */
1186         protected IJavaElement getCorrespondingElement(IJavaElement element) {
1187                 try {
1188                         return EditorUtility.getWorkingCopy(element, true);
1189                 } catch (JavaModelException x) {
1190                         PHPeclipsePlugin.log(x.getStatus());
1191                         // nothing found, be tolerant and go on
1192                 }
1193                 return null;
1194         }
1195         public void createPartControl(Composite parent) {
1196                 super.createPartControl(parent);
1197                 //    fPaintManager = new PaintManager(getSourceViewer());
1198                 LinePainter linePainter;
1199                 linePainter = new LinePainter(getSourceViewer());
1200                 linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235,
1201                                 224));
1202                 //    fPaintManager.addPainter(linePainter);
1203                 if (isBracketHighlightingEnabled())
1204                         startBracketHighlighting();
1205                 if (isLineHighlightingEnabled())
1206                         startLineHighlighting();
1207                 if (isPrintMarginVisible())
1208                         showPrintMargin();
1209                 //    Iterator e = ANNOTATION_MAP.keySet().iterator();
1210                 //    while (e.hasNext()) {
1211                 //      AnnotationType type = (AnnotationType) e.next();
1212                 //      if (isAnnotationIndicationEnabled(type))
1213                 //        startAnnotationIndication(type);
1214                 //    }
1215                 if (isTabConversionEnabled())
1216                         startTabConversion();
1217                 //    if (isOverviewRulerVisible())
1218                 //      showOverviewRuler();
1219                 //
1220                 //    Preferences preferences =
1221                 // PHPeclipsePlugin.getDefault().getPluginPreferences();
1222                 //    preferences.addPropertyChangeListener(fPropertyChangeListener);
1223                 IPreferenceStore preferenceStore = getPreferenceStore();
1224                 boolean closeBracketsPHP = preferenceStore
1225                                 .getBoolean(CLOSE_BRACKETS_PHP);
1226                 boolean closeStringsPHP = preferenceStore.getBoolean(CLOSE_STRINGS_PHP);
1227                 boolean closeBracketsHTML = preferenceStore
1228                                 .getBoolean(CLOSE_BRACKETS_HTML);
1229                 boolean closeStringsHTML = preferenceStore
1230                                 .getBoolean(CLOSE_STRINGS_HTML);
1231                 fBracketInserter.setCloseBracketsPHPEnabled(closeBracketsPHP);
1232                 fBracketInserter.setCloseStringsPHPEnabled(closeStringsPHP);
1233                 fBracketInserter.setCloseBracketsHTMLEnabled(closeBracketsHTML);
1234                 fBracketInserter.setCloseStringsHTMLEnabled(closeStringsHTML);
1235                 ISourceViewer sourceViewer = getSourceViewer();
1236                 if (sourceViewer instanceof ITextViewerExtension)
1237                         ((ITextViewerExtension) sourceViewer)
1238                                         .prependVerifyKeyListener(fBracketInserter);
1239         }
1240         private static char getPeerCharacter(char character) {
1241                 switch (character) {
1242                         case '(' :
1243                                 return ')';
1244                         case ')' :
1245                                 return '(';
1246                         case '[' :
1247                                 return ']';
1248                         case ']' :
1249                                 return '[';
1250                         case '"' :
1251                                 return character;
1252                         default :
1253                                 throw new IllegalArgumentException();
1254                 }
1255         }
1256
1257         private void startBracketHighlighting() {
1258                 if (fBracketPainter == null) {
1259                         ISourceViewer sourceViewer = getSourceViewer();
1260                         fBracketPainter = new BracketPainter(sourceViewer);
1261                         fBracketPainter
1262                                         .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
1263                         //      fPaintManager.addPainter(fBracketPainter);
1264                 }
1265         }
1266         private void stopBracketHighlighting() {
1267                 if (fBracketPainter != null) {
1268                         //      fPaintManager.removePainter(fBracketPainter);
1269                         fBracketPainter.deactivate(true);
1270                         fBracketPainter.dispose();
1271                         fBracketPainter = null;
1272                 }
1273         }
1274         private boolean isBracketHighlightingEnabled() {
1275                 IPreferenceStore store = getPreferenceStore();
1276                 return store.getBoolean(MATCHING_BRACKETS);
1277         }
1278         private void startLineHighlighting() {
1279                 if (fLinePainter == null) {
1280                         ISourceViewer sourceViewer = getSourceViewer();
1281                         fLinePainter = new LinePainter(sourceViewer);
1282                         fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
1283                         //      fPaintManager.addPainter(fLinePainter);
1284                 }
1285         }
1286         private void stopLineHighlighting() {
1287                 if (fLinePainter != null) {
1288                         //      fPaintManager.removePainter(fLinePainter);
1289                         fLinePainter.deactivate(true);
1290                         fLinePainter.dispose();
1291                         fLinePainter = null;
1292                 }
1293         }
1294         private boolean isLineHighlightingEnabled() {
1295                 IPreferenceStore store = getPreferenceStore();
1296                 return store.getBoolean(CURRENT_LINE);
1297         }
1298         private void showPrintMargin() {
1299                 if (fPrintMarginPainter == null) {
1300                         fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
1301                         fPrintMarginPainter
1302                                         .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
1303                         fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore()
1304                                         .getInt(PRINT_MARGIN_COLUMN));
1305                         //      fPaintManager.addPainter(fPrintMarginPainter);
1306                 }
1307         }
1308         private void hidePrintMargin() {
1309                 if (fPrintMarginPainter != null) {
1310                         //      fPaintManager.removePainter(fPrintMarginPainter);
1311                         fPrintMarginPainter.deactivate(true);
1312                         fPrintMarginPainter.dispose();
1313                         fPrintMarginPainter = null;
1314                 }
1315         }
1316         private boolean isPrintMarginVisible() {
1317                 IPreferenceStore store = getPreferenceStore();
1318                 return store.getBoolean(PRINT_MARGIN);
1319         }
1320         //  private void startAnnotationIndication(AnnotationType annotationType) {
1321         //    if (fProblemPainter == null) {
1322         //      fProblemPainter = new ProblemPainter(this, getSourceViewer());
1323         //// fPaintManager.addPainter(fProblemPainter);
1324         //    }
1325         //    fProblemPainter.setColor(annotationType, getColor(annotationType));
1326         //    fProblemPainter.paintAnnotations(annotationType, true);
1327         //    fProblemPainter.paint(IPainter.CONFIGURATION);
1328         //  }
1329         //
1330         //  private void shutdownAnnotationIndication() {
1331         //    if (fProblemPainter != null) {
1332         //
1333         //      if (!fProblemPainter.isPaintingAnnotations()) {
1334         //// fPaintManager.removePainter(fProblemPainter);
1335         //        fProblemPainter.deactivate(true);
1336         //        fProblemPainter.dispose();
1337         //        fProblemPainter = null;
1338         //      } else {
1339         //        fProblemPainter.paint(IPainter.CONFIGURATION);
1340         //      }
1341         //    }
1342         //  }
1343         //
1344         //  private void stopAnnotationIndication(AnnotationType annotationType) {
1345         //    if (fProblemPainter != null) {
1346         //      fProblemPainter.paintAnnotations(annotationType, false);
1347         //      shutdownAnnotationIndication();
1348         //    }
1349         //  }
1350         //
1351         //  private boolean isAnnotationIndicationEnabled(AnnotationType
1352         // annotationType) {
1353         //    IPreferenceStore store = getPreferenceStore();
1354         //    AnnotationInfo info = (AnnotationInfo)
1355         // ANNOTATION_MAP.get(annotationType);
1356         //    if (info != null)
1357         //      return store.getBoolean(info.fEditorPreference);
1358         //    return false;
1359         //  }
1360         //
1361         //  private boolean
1362         // isAnnotationIndicationInOverviewRulerEnabled(AnnotationType
1363         // annotationType) {
1364         //    IPreferenceStore store = getPreferenceStore();
1365         //    AnnotationInfo info = (AnnotationInfo)
1366         // ANNOTATION_MAP.get(annotationType);
1367         //    if (info != null)
1368         //      return store.getBoolean(info.fOverviewRulerPreference);
1369         //    return false;
1370         //  }
1371         //
1372         //  private void showAnnotationIndicationInOverviewRuler(AnnotationType
1373         // annotationType, boolean show) {
1374         //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1375         //    OverviewRuler ruler = asv.getOverviewRuler();
1376         //    if (ruler != null) {
1377         //      ruler.setColor(annotationType, getColor(annotationType));
1378         //      ruler.showAnnotation(annotationType, show);
1379         //      ruler.update();
1380         //    }
1381         //  }
1382         //
1383         //  private void setColorInOverviewRuler(AnnotationType annotationType, Color
1384         // color) {
1385         //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1386         //    OverviewRuler ruler = asv.getOverviewRuler();
1387         //    if (ruler != null) {
1388         //      ruler.setColor(annotationType, color);
1389         //      ruler.update();
1390         //    }
1391         //  }
1392
1393         private int getTabSize() {
1394                 Preferences preferences = PHPeclipsePlugin.getDefault()
1395                                 .getPluginPreferences();
1396                 return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
1397         }
1398
1399         private boolean isTabConversionEnabled() {
1400                 IPreferenceStore store = getPreferenceStore();
1401                 return store.getBoolean(SPACES_FOR_TABS);
1402         }
1403         //  private void showOverviewRuler() {
1404         //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1405         //    asv.showOverviewRuler();
1406         //
1407         //    OverviewRuler overviewRuler = asv.getOverviewRuler();
1408         //    if (overviewRuler != null) {
1409         //      for (int i = 0; i < ANNOTATION_LAYERS.length; i++) {
1410         //        AnnotationType type = ANNOTATION_LAYERS[i];
1411         //        overviewRuler.setLayer(type, i);
1412         //        if (isAnnotationIndicationInOverviewRulerEnabled(type))
1413         //          showAnnotationIndicationInOverviewRuler(type, true);
1414         //      }
1415         //    }
1416         //  }
1417         //
1418         //  private void hideOverviewRuler() {
1419         //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1420         //    asv.hideOverviewRuler();
1421         //  }
1422         //
1423         //  private boolean isOverviewRulerVisible() {
1424         //    IPreferenceStore store = getPreferenceStore();
1425         //    return store.getBoolean(OVERVIEW_RULER);
1426         //  }
1427         private Color getColor(String key) {
1428                 RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
1429                 return getColor(rgb);
1430         }
1431         private Color getColor(RGB rgb) {
1432                 JavaTextTools textTools = PHPeclipsePlugin.getDefault()
1433                                 .getJavaTextTools();
1434                 return textTools.getColorManager().getColor(rgb);
1435         }
1436         //  private Color getColor(AnnotationType annotationType) {
1437         //    AnnotationInfo info = (AnnotationInfo)
1438         // ANNOTATION_MAP.get(annotationType);
1439         //    if (info != null)
1440         //      return getColor(info.fColorPreference);
1441         //    return null;
1442         //  }
1443         public void dispose() {
1444                 ISourceViewer sourceViewer = getSourceViewer();
1445                 if (sourceViewer instanceof ITextViewerExtension)
1446                         ((ITextViewerExtension) sourceViewer)
1447                                         .removeVerifyKeyListener(fBracketInserter);
1448                 //    if (fPropertyChangeListener != null) {
1449                 //      Preferences preferences =
1450                 // PHPeclipsePlugin.getDefault().getPluginPreferences();
1451                 //      preferences.removePropertyChangeListener(fPropertyChangeListener);
1452                 //      fPropertyChangeListener = null;
1453                 //    }
1454                 if (fJavaEditorErrorTickUpdater != null) {
1455                         fJavaEditorErrorTickUpdater.dispose();
1456                         fJavaEditorErrorTickUpdater = null;
1457                 }
1458                 //    if (fSelectionHistory != null)
1459                 //      fSelectionHistory.dispose();
1460                 //    if (fPaintManager != null) {
1461                 //      fPaintManager.dispose();
1462                 //      fPaintManager = null;
1463                 //    }
1464                 if (fActionGroups != null) {
1465                         fActionGroups.dispose();
1466                         fActionGroups = null;
1467                 }
1468                 super.dispose();
1469         }
1470         //  protected AnnotationType getAnnotationType(String preferenceKey) {
1471         //    Iterator e = ANNOTATION_MAP.keySet().iterator();
1472         //    while (e.hasNext()) {
1473         //      AnnotationType type = (AnnotationType) e.next();
1474         //      AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
1475         //      if (info != null) {
1476         //        if (preferenceKey.equals(info.fColorPreference)
1477         //          || preferenceKey.equals(info.fEditorPreference)
1478         //          || preferenceKey.equals(info.fOverviewRulerPreference))
1479         //          return type;
1480         //      }
1481         //    }
1482         //    return null;
1483         //  }
1484         /*
1485          * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
1486          */
1487         protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
1488                 try {
1489                         AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1490                         if (asv != null) {
1491                                 String p = event.getProperty();
1492                                 if (CLOSE_BRACKETS_PHP.equals(p)) {
1493                                         fBracketInserter
1494                                                         .setCloseBracketsPHPEnabled(getPreferenceStore()
1495                                                                         .getBoolean(p));
1496                                         return;
1497                                 }
1498                                 if (CLOSE_STRINGS_PHP.equals(p)) {
1499                                         fBracketInserter
1500                                                         .setCloseStringsPHPEnabled(getPreferenceStore()
1501                                                                         .getBoolean(p));
1502                                         return;
1503                                 }
1504                                 if (CLOSE_BRACKETS_HTML.equals(p)) {
1505                                         fBracketInserter
1506                                                         .setCloseBracketsHTMLEnabled(getPreferenceStore()
1507                                                                         .getBoolean(p));
1508                                         return;
1509                                 }
1510                                 if (CLOSE_STRINGS_HTML.equals(p)) {
1511                                         fBracketInserter
1512                                                         .setCloseStringsHTMLEnabled(getPreferenceStore()
1513                                                                         .getBoolean(p));
1514                                         return;
1515                                 }
1516                                 if (SPACES_FOR_TABS.equals(p)) {
1517                                         if (isTabConversionEnabled())
1518                                                 startTabConversion();
1519                                         else
1520                                                 stopTabConversion();
1521                                         return;
1522                                 }
1523                                 if (MATCHING_BRACKETS.equals(p)) {
1524                                         if (isBracketHighlightingEnabled())
1525                                                 startBracketHighlighting();
1526                                         else
1527                                                 stopBracketHighlighting();
1528                                         return;
1529                                 }
1530                                 if (MATCHING_BRACKETS_COLOR.equals(p)) {
1531                                         if (fBracketPainter != null)
1532                                                 fBracketPainter
1533                                                                 .setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
1534                                         return;
1535                                 }
1536                                 if (CURRENT_LINE.equals(p)) {
1537                                         if (isLineHighlightingEnabled())
1538                                                 startLineHighlighting();
1539                                         else
1540                                                 stopLineHighlighting();
1541                                         return;
1542                                 }
1543                                 if (CURRENT_LINE_COLOR.equals(p)) {
1544                                         if (fLinePainter != null) {
1545                                                 stopLineHighlighting();
1546                                                 startLineHighlighting();
1547                                         }
1548                                         return;
1549                                 }
1550                                 if (PRINT_MARGIN.equals(p)) {
1551                                         if (isPrintMarginVisible())
1552                                                 showPrintMargin();
1553                                         else
1554                                                 hidePrintMargin();
1555                                         return;
1556                                 }
1557                                 if (PRINT_MARGIN_COLOR.equals(p)) {
1558                                         if (fPrintMarginPainter != null)
1559                                                 fPrintMarginPainter
1560                                                                 .setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
1561                                         return;
1562                                 }
1563                                 if (PRINT_MARGIN_COLUMN.equals(p)) {
1564                                         if (fPrintMarginPainter != null)
1565                                                 fPrintMarginPainter
1566                                                                 .setMarginRulerColumn(getPreferenceStore()
1567                                                                                 .getInt(PRINT_MARGIN_COLUMN));
1568                                         return;
1569                                 }
1570                                 //        if (OVERVIEW_RULER.equals(p)) {
1571                                 //          if (isOverviewRulerVisible())
1572                                 //            showOverviewRuler();
1573                                 //          else
1574                                 //            hideOverviewRuler();
1575                                 //          return;
1576                                 //        }
1577                                 //        AnnotationType type = getAnnotationType(p);
1578                                 //        if (type != null) {
1579                                 //
1580                                 //          AnnotationInfo info = (AnnotationInfo)
1581                                 // ANNOTATION_MAP.get(type);
1582                                 //          if (info.fColorPreference.equals(p)) {
1583                                 //            Color color = getColor(type);
1584                                 //            if (fProblemPainter != null) {
1585                                 //              fProblemPainter.setColor(type, color);
1586                                 //              fProblemPainter.paint(IPainter.CONFIGURATION);
1587                                 //            }
1588                                 //            setColorInOverviewRuler(type, color);
1589                                 //            return;
1590                                 //          }
1591                                 //
1592                                 //          if (info.fEditorPreference.equals(p)) {
1593                                 //            if (isAnnotationIndicationEnabled(type))
1594                                 //              startAnnotationIndication(type);
1595                                 //            else
1596                                 //              stopAnnotationIndication(type);
1597                                 //            return;
1598                                 //          }
1599                                 //
1600                                 //          if (info.fOverviewRulerPreference.equals(p)) {
1601                                 //            if (isAnnotationIndicationInOverviewRulerEnabled(type))
1602                                 //              showAnnotationIndicationInOverviewRuler(type, true);
1603                                 //            else
1604                                 //              showAnnotationIndicationInOverviewRuler(type, false);
1605                                 //            return;
1606                                 //          }
1607                                 //        }
1608                                 IContentAssistant c = asv.getContentAssistant();
1609                                 if (c instanceof ContentAssistant)
1610                                         ContentAssistPreference.changeConfiguration(
1611                                                         (ContentAssistant) c, getPreferenceStore(), event);
1612                         }
1613                 } finally {
1614                         super.handlePreferenceStoreChanged(event);
1615                 }
1616         }
1617         /*
1618          * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
1619          */
1620         protected void handlePreferencePropertyChanged(
1621                         org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
1622                 AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1623                 if (asv != null) {
1624                         String p = event.getProperty();
1625                         if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
1626                                 asv.updateIndentationPrefixes();
1627                                 if (fTabConverter != null)
1628                                         fTabConverter.setNumberOfSpacesPerTab(getTabSize());
1629                         }
1630                 }
1631                 super.handlePreferencePropertyChanged(event);
1632         }
1633         /**
1634          * Handles a property change event describing a change of the php core's
1635          * preferences and updates the preference related editor properties.
1636          * 
1637          * @param event
1638          *            the property change event
1639          */
1640         //  protected void
1641         // handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent
1642         // event) {
1643         //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1644         //    if (asv != null) {
1645         //      String p = event.getProperty();
1646         //      if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
1647         //        asv.updateIndentationPrefixes();
1648         //        if (fTabConverter != null)
1649         //          fTabConverter.setNumberOfSpacesPerTab(getTabSize());
1650         //      }
1651         //    }
1652         //  }
1653
1654         /*
1655          * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
1656          */
1657         protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
1658                 return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store);
1659         }
1660         //  protected ISourceViewer createJavaSourceViewer(Composite parent,
1661         // IVerticalRuler ruler, int styles) {
1662         //    return new AdaptedSourceViewer(parent, ruler, styles);
1663         //  }
1664         private boolean isValidSelection(int offset, int length) {
1665                 IDocumentProvider provider = getDocumentProvider();
1666                 if (provider != null) {
1667                         IDocument document = provider.getDocument(getEditorInput());
1668                         if (document != null) {
1669                                 int end = offset + length;
1670                                 int documentLength = document.getLength();
1671                                 return 0 <= offset && offset <= documentLength && 0 <= end
1672                                                 && end <= documentLength;
1673                         }
1674                 }
1675                 return false;
1676         }
1677         /*
1678          * @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
1679          */
1680         protected boolean canHandleMove(IEditorInput originalElement,
1681                         IEditorInput movedElement) {
1682                 String oldExtension = ""; //$NON-NLS-1$
1683                 if (originalElement instanceof IFileEditorInput) {
1684                         IFile file = ((IFileEditorInput) originalElement).getFile();
1685                         if (file != null) {
1686                                 String ext = file.getFileExtension();
1687                                 if (ext != null)
1688                                         oldExtension = ext;
1689                         }
1690                 }
1691                 String newExtension = ""; //$NON-NLS-1$
1692                 if (movedElement instanceof IFileEditorInput) {
1693                         IFile file = ((IFileEditorInput) movedElement).getFile();
1694                         if (file != null)
1695                                 newExtension = file.getFileExtension();
1696                 }
1697                 return oldExtension.equals(newExtension);
1698         }
1699         /*
1700          * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
1701          */
1702         public void editorContextMenuAboutToShow(IMenuManager menu) {
1703                 super.editorContextMenuAboutToShow(menu);
1704                 ActionContext context = new ActionContext(getSelectionProvider()
1705                                 .getSelection());
1706                 fContextMenuGroup.setContext(context);
1707                 fContextMenuGroup.fillContextMenu(menu);
1708                 fContextMenuGroup.setContext(null);
1709         }
1710         /*
1711          * @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput)
1712          */
1713         protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
1714                 if (page != null) {
1715                         IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
1716                                         .getWorkingCopyManager();
1717                         page.setInput(manager.getWorkingCopy(input));
1718                 }
1719         }
1720         /*
1721          * @see AbstractTextEditor#performSaveOperation(WorkspaceModifyOperation,
1722          *      IProgressMonitor)
1723          */
1724         //  protected void performSaveOperation(WorkspaceModifyOperation operation,
1725         // IProgressMonitor progressMonitor) {
1726         //    IDocumentProvider p = getDocumentProvider();
1727         //    if (p instanceof PHPDocumentProvider) {
1728         //      PHPDocumentProvider cp = (PHPDocumentProvider) p;
1729         //      cp.setSavePolicy(fSavePolicy);
1730         //    }
1731         //
1732         //    try {
1733         //      super.performSaveOperation(operation, progressMonitor);
1734         //    } finally {
1735         //      if (p instanceof PHPDocumentProvider) {
1736         //        PHPDocumentProvider cp = (PHPDocumentProvider) p;
1737         //        cp.setSavePolicy(null);
1738         //      }
1739         //    }
1740         //  }
1741         /*
1742          * @see AbstractTextEditor#doSave(IProgressMonitor)
1743          */
1744         public void doSave(IProgressMonitor progressMonitor) {
1745
1746                 IDocumentProvider p = getDocumentProvider();
1747                 if (p == null) {
1748                         // editor has been closed
1749                         return;
1750                 }
1751
1752                 if (p.isDeleted(getEditorInput())) {
1753
1754                         if (isSaveAsAllowed()) {
1755
1756                                 /*
1757                                  * 1GEUSSR: ITPUI:ALL - User should never loose changes made in
1758                                  * the editors. Changed Behavior to make sure that if called
1759                                  * inside a regular save (because of deletion of input element)
1760                                  * there is a way to report back to the caller.
1761                                  */
1762                                 performSaveAs(progressMonitor);
1763
1764                         } else {
1765
1766                                 /*
1767                                  * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still
1768                                  * there Missing resources.
1769                                  */
1770                                 Shell shell = getSite().getShell();
1771                                 MessageDialog
1772                                                 .openError(
1773                                                                 shell,
1774                                                                 PHPEditorMessages
1775                                                                                 .getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
1776                         }
1777
1778                 } else {
1779
1780                         setStatusLineErrorMessage(null);
1781
1782                         IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
1783                                         .getWorkingCopyManager();
1784                         ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
1785
1786                         if (unit != null) {
1787                                 synchronized (unit) {
1788                                         performSave(false, progressMonitor);
1789                                 }
1790                         } else
1791                                 performSave(false, progressMonitor);
1792                 }
1793         }
1794
1795         public boolean isSaveAsAllowed() {
1796                 return true;
1797         }
1798
1799         /**
1800          * The compilation unit editor implementation of this
1801          * <code>AbstractTextEditor</code> method asks the user for the workspace
1802          * path of a file resource and saves the document there. See
1803          * http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
1804          * 
1805          * @param progressMonitor
1806          *            the progress monitor
1807          */
1808         protected void performSaveAs(IProgressMonitor progressMonitor) {
1809
1810                 Shell shell = getSite().getShell();
1811                 IEditorInput input = getEditorInput();
1812
1813                 SaveAsDialog dialog = new SaveAsDialog(shell);
1814
1815                 IFile original = (input instanceof IFileEditorInput)
1816                                 ? ((IFileEditorInput) input).getFile()
1817                                 : null;
1818                 if (original != null)
1819                         dialog.setOriginalFile(original);
1820
1821                 dialog.create();
1822
1823                 IDocumentProvider provider = getDocumentProvider();
1824                 if (provider == null) {
1825                         // editor has been programmatically closed while the dialog was open
1826                         return;
1827                 }
1828
1829                 if (provider.isDeleted(input) && original != null) {
1830                         String message = PHPEditorMessages
1831                                         .getFormattedString(
1832                                                         "CompilationUnitEditor.warning.save.delete", new Object[]{original.getName()}); //$NON-NLS-1$
1833                         dialog.setErrorMessage(null);
1834                         dialog.setMessage(message, IMessageProvider.WARNING);
1835                 }
1836
1837                 if (dialog.open() == Window.CANCEL) {
1838                         if (progressMonitor != null)
1839                                 progressMonitor.setCanceled(true);
1840                         return;
1841                 }
1842
1843                 IPath filePath = dialog.getResult();
1844                 if (filePath == null) {
1845                         if (progressMonitor != null)
1846                                 progressMonitor.setCanceled(true);
1847                         return;
1848                 }
1849
1850                 IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1851                 IFile file = workspaceRoot.getFile(filePath);
1852                 final IEditorInput newInput = new FileEditorInput(file);
1853
1854                 boolean success = false;
1855                 try {
1856
1857                         provider.aboutToChange(newInput);
1858                         getDocumentProvider().saveDocument(progressMonitor, newInput,
1859                                         getDocumentProvider().getDocument(getEditorInput()), true);
1860                         success = true;
1861
1862                 } catch (CoreException x) {
1863                         IStatus status = x.getStatus();
1864                         if (status == null || status.getSeverity() != IStatus.CANCEL)
1865                                 ErrorDialog
1866                                                 .openError(
1867                                                                 shell,
1868                                                                 PHPEditorMessages
1869                                                                                 .getString("CompilationUnitEditor.error.saving.title2"), PHPEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
1870                 } finally {
1871                         provider.changed(newInput);
1872                         if (success)
1873                                 setInput(newInput);
1874                 }
1875
1876                 if (progressMonitor != null)
1877                         progressMonitor.setCanceled(!success);
1878         }
1879
1880         /*
1881          * @see AbstractTextEditor#doSetInput(IEditorInput)
1882          */
1883         protected void doSetInput(IEditorInput input) throws CoreException {
1884                 super.doSetInput(input);
1885                 configureTabConverter();
1886                 configureToggleCommentAction();
1887         }
1888
1889         //      /*
1890         //       * @see
1891         // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
1892         //       * @since 3.0
1893         //       */
1894         //      protected void installOverrideIndicator(boolean waitForReconcilation) {
1895         //              IAnnotationModel model=
1896         // getDocumentProvider().getAnnotationModel(getEditorInput());
1897         //              if (!waitForReconcilation)
1898         //                      super.installOverrideIndicator(false);
1899         //              else {
1900         //                      uninstallOverrideIndicator();
1901         //                      IJavaElement inputElement= getInputJavaElement();
1902         //                      if (model == null || inputElement == null)
1903         //                              return;
1904         //                      
1905         //                      fOverrideIndicatorManager= new OverrideIndicatorManager(model,
1906         // inputElement, null);
1907         //                      addReconcileListener(fOverrideIndicatorManager);
1908         //              }
1909         //      }
1910         //      
1911         //      /*
1912         //       * @see
1913         // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
1914         //       * @since 3.0
1915         //       */
1916         //      protected void uninstallOverrideIndicator() {
1917         //              if (fOverrideIndicatorManager != null)
1918         //                      removeReconcileListener(fOverrideIndicatorManager);
1919         //              super.uninstallOverrideIndicator();
1920         //      }
1921
1922         /**
1923          * Configures the toggle comment action
1924          * 
1925          * @since 3.0
1926          */
1927         private void configureToggleCommentAction() {
1928                 IAction action = getAction("ToggleComment"); //$NON-NLS-1$
1929                 if (action instanceof ToggleCommentAction) {
1930                         ISourceViewer sourceViewer = getSourceViewer();
1931                         SourceViewerConfiguration configuration = getSourceViewerConfiguration();
1932                         ((ToggleCommentAction) action).configure(sourceViewer,
1933                                         configuration);
1934                 }
1935         }
1936
1937         private void configureTabConverter() {
1938                 if (fTabConverter != null) {
1939                         IDocumentProvider provider = getDocumentProvider();
1940                         if (provider instanceof PHPDocumentProvider) {
1941                                 PHPDocumentProvider cup = (PHPDocumentProvider) provider;
1942                                 fTabConverter.setLineTracker(cup
1943                                                 .createLineTracker(getEditorInput()));
1944                         }
1945                 }
1946         }
1947
1948         private void startTabConversion() {
1949                 if (fTabConverter == null) {
1950                         fTabConverter = new TabConverter();
1951                         configureTabConverter();
1952                         fTabConverter.setNumberOfSpacesPerTab(getTabSize());
1953                         AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1954                         asv.addTextConverter(fTabConverter);
1955                         // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
1956                         asv.updateIndentationPrefixes();
1957                 }
1958         }
1959
1960         private void stopTabConversion() {
1961                 if (fTabConverter != null) {
1962                         AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1963                         asv.removeTextConverter(fTabConverter);
1964                         // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
1965                         asv.updateIndentationPrefixes();
1966                         fTabConverter = null;
1967                 }
1968         }
1969
1970         /*
1971          * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean,
1972          *      org.eclipse.core.runtime.IProgressMonitor)
1973          */
1974         protected void performSave(boolean overwrite,
1975                         IProgressMonitor progressMonitor) {
1976                 IDocumentProvider p = getDocumentProvider();
1977                 if (p instanceof PHPDocumentProvider) {
1978                         PHPDocumentProvider cp = (PHPDocumentProvider) p;
1979                         cp.setSavePolicy(fSavePolicy);
1980                 }
1981                 try {
1982                         super.performSave(overwrite, progressMonitor);
1983                 } finally {
1984                         if (p instanceof PHPDocumentProvider) {
1985                                 PHPDocumentProvider cp = (PHPDocumentProvider) p;
1986                                 cp.setSavePolicy(null);
1987                         }
1988                 }
1989         }
1990         /*
1991          * @see AbstractTextEditor#doSaveAs
1992          */
1993         public void doSaveAs() {
1994                 if (askIfNonWorkbenchEncodingIsOk()) {
1995                         super.doSaveAs();
1996                 }
1997         }
1998
1999         /**
2000          * Asks the user if it is ok to store in non-workbench encoding.
2001          * 
2002          * @return <true>if the user wants to continue
2003          */
2004         private boolean askIfNonWorkbenchEncodingIsOk() {
2005                 IDocumentProvider provider = getDocumentProvider();
2006                 if (provider instanceof IStorageDocumentProvider) {
2007                         IEditorInput input = getEditorInput();
2008                         IStorageDocumentProvider storageProvider = (IStorageDocumentProvider) provider;
2009                         String encoding = storageProvider.getEncoding(input);
2010                         String defaultEncoding = storageProvider.getDefaultEncoding();
2011                         if (encoding != null && !encoding.equals(defaultEncoding)) {
2012                                 Shell shell = getSite().getShell();
2013                                 String title = PHPEditorMessages
2014                                                 .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
2015                                 String msg;
2016                                 if (input != null)
2017                                         msg = MessageFormat
2018                                                         .format(
2019                                                                         PHPEditorMessages
2020                                                                                         .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"),
2021                                                                         new String[]{input.getName(), encoding}); //$NON-NLS-1$
2022                                 else
2023                                         msg = MessageFormat
2024                                                         .format(
2025                                                                         PHPEditorMessages
2026                                                                                         .getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"),
2027                                                                         new String[]{encoding}); //$NON-NLS-1$
2028                                 return MessageDialog.openQuestion(shell, title, msg);
2029                         }
2030                 }
2031                 return true;
2032         }
2033         /*
2034          * @see IReconcilingParticipant#reconciled()
2035          */
2036         public void reconciled() {
2037                 if (synchronizeOutlineOnCursorMove()) {
2038                         Shell shell = getSite().getShell();
2039                         if (shell != null && !shell.isDisposed()) {
2040                                 shell.getDisplay().asyncExec(new Runnable() {
2041                                         public void run() {
2042                                                 synchronizeOutlinePageSelection();
2043                                         }
2044                                 });
2045                         }
2046                 }
2047         }
2048
2049         protected void updateStateDependentActions() {
2050                 super.updateStateDependentActions();
2051                 fGenerateActionGroup.editorStateChanged();
2052         }
2053
2054         private boolean synchronizeOutlineOnCursorMove() {
2055                 return PreferenceConstants.getPreferenceStore().getBoolean(
2056                                 PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
2057         }
2058
2059         /**
2060          * Returns the updated java element for the old java element.
2061          */
2062         private IJavaElement findElement(IJavaElement element) {
2063                 if (element == null)
2064                         return null;
2065                 IWorkingCopyManager manager = PHPeclipsePlugin.getDefault()
2066                                 .getWorkingCopyManager();
2067                 ICompilationUnit unit = manager.getWorkingCopy(getEditorInput());
2068                 if (unit != null) {
2069                         try {
2070                                 synchronized (unit) {
2071                                         unit.reconcile();
2072                                 }
2073                                 IJavaElement[] findings = unit.findElements(element);
2074                                 if (findings != null && findings.length > 0)
2075                                         return findings[0];
2076                         } catch (JavaModelException x) {
2077                                 PHPeclipsePlugin.log(x.getStatus());
2078                                 // nothing found, be tolerant and go on
2079                         }
2080                 }
2081                 return null;
2082         }
2083         /**
2084          * Returns the offset of the given Java element.
2085          */
2086         private int getOffset(IJavaElement element) {
2087                 if (element instanceof ISourceReference) {
2088                         ISourceReference sr = (ISourceReference) element;
2089                         try {
2090                                 ISourceRange srcRange = sr.getSourceRange();
2091                                 if (srcRange != null)
2092                                         return srcRange.getOffset();
2093                         } catch (JavaModelException e) {
2094                         }
2095                 }
2096                 return -1;
2097         }
2098         /*
2099          * @see AbstractTextEditor#rememberSelection()
2100          */
2101         protected void rememberSelection() {
2102                 ISelectionProvider sp = getSelectionProvider();
2103                 fRememberedSelection = (sp == null ? null : (ITextSelection) sp
2104                                 .getSelection());
2105                 if (fRememberedSelection != null) {
2106                         fRememberedElement = getElementAt(fRememberedSelection.getOffset(),
2107                                         true);
2108                         fRememberedElementOffset = getOffset(fRememberedElement);
2109                 }
2110         }
2111         /*
2112          * @see AbstractTextEditor#restoreSelection()
2113          */
2114         protected void restoreSelection() {
2115                 try {
2116                         if (getSourceViewer() == null || fRememberedSelection == null)
2117                                 return;
2118                         IJavaElement newElement = findElement(fRememberedElement);
2119                         int newOffset = getOffset(newElement);
2120                         int delta = (newOffset > -1 && fRememberedElementOffset > -1)
2121                                         ? newOffset - fRememberedElementOffset
2122                                         : 0;
2123                         if (isValidSelection(delta + fRememberedSelection.getOffset(),
2124                                         fRememberedSelection.getLength()))
2125                                 selectAndReveal(delta + fRememberedSelection.getOffset(),
2126                                                 fRememberedSelection.getLength());
2127                 } finally {
2128                         fRememberedSelection = null;
2129                         fRememberedElement = null;
2130                         fRememberedElementOffset = -1;
2131                 }
2132         }
2133         
2134 //      /*
2135 //       * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
2136 //       * @since 3.0
2137 //       */
2138 //      public void aboutToBeReconciled() {
2139 //
2140 //              // Notify AST provider
2141 //              PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement());
2142 //              
2143 //              // Notify listeners
2144 //              Object[] listeners = fReconcilingListeners.getListeners();
2145 //              for (int i = 0, length= listeners.length; i < length; ++i)
2146 //                      ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled();
2147 //      }
2148 //      
2149 //      /*
2150 //       * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, boolean, IProgressMonitor)
2151 //       * @since 3.0
2152 //       */
2153 //      public void reconciled(net.sourceforge.phpdt.core.dom.CompilationUnit ast, boolean forced, IProgressMonitor progressMonitor) {
2154 //
2155 //              // Always notify AST provider
2156 //              PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast, getInputJavaElement());
2157 //              
2158 //              // Notify listeners
2159 //              Object[] listeners = fReconcilingListeners.getListeners();
2160 //              for (int i = 0, length= listeners.length; i < length; ++i)
2161 //                      ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, progressMonitor);
2162 //
2163 //              // Update Java Outline page selection
2164 //              if (!forced && !progressMonitor.isCanceled()) {
2165 //                      Shell shell= getSite().getShell();
2166 //                      if (shell != null && !shell.isDisposed()) {
2167 //                              shell.getDisplay().asyncExec(new Runnable() {
2168 //                                      public void run() {
2169 //                                              selectionChanged();
2170 //                                      }
2171 //                              });
2172 //                      }
2173 //              }
2174 //      }
2175 }