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