1 /**********************************************************************
 
   2  Copyright (c) 2000, 2002 IBM Corp. and others.
 
   3  All rights reserved. This program and the accompanying materials
 
   4  are made available under the terms of the Common Public License v1.0
 
   5  which accompanies this distribution, and is available at
 
   6  http://www.eclipse.org/legal/cpl-v10.html
 
   9  IBM Corporation - Initial implementation
 
  10  Klaus Hartlage - www.eclipseproject.de
 
  11  **********************************************************************/
 
  12 package net.sourceforge.phpeclipse.phpeditor;
 
  13 import java.util.Vector;
 
  15 import net.sourceforge.phpdt.core.JavaCore;
 
  16 import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
 
  17 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 
  18 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
 
  19 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 
  20 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
 
  21 import net.sourceforge.phpdt.internal.ui.text.JavaCompositeReconcilingStrategy;
 
  22 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
 
  23 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
 
  24 import net.sourceforge.phpdt.internal.ui.text.JavaPresentationReconciler;
 
  25 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
 
  26 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
 
  27 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
 
  28 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
 
  29 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
 
  30 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
 
  31 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
 
  32 import net.sourceforge.phpdt.ui.PreferenceConstants;
 
  33 import net.sourceforge.phpdt.ui.text.IColorManager;
 
  34 import net.sourceforge.phpdt.ui.text.JavaTextTools;
 
  35 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
  36 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
 
  37 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
 
  38 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
 
  39 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
 
  40 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
 
  41 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
 
  43 import org.eclipse.core.runtime.NullProgressMonitor;
 
  44 import org.eclipse.jface.preference.IPreferenceStore;
 
  45 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
 
  46 import org.eclipse.jface.text.DefaultInformationControl;
 
  47 import org.eclipse.jface.text.IAutoIndentStrategy;
 
  48 import org.eclipse.jface.text.IDocument;
 
  49 import org.eclipse.jface.text.IInformationControl;
 
  50 import org.eclipse.jface.text.IInformationControlCreator;
 
  51 import org.eclipse.jface.text.ITextDoubleClickStrategy;
 
  52 import org.eclipse.jface.text.ITextHover;
 
  53 import org.eclipse.jface.text.ITextViewerExtension2;
 
  54 import org.eclipse.jface.text.TextAttribute;
 
  55 import org.eclipse.jface.text.contentassist.ContentAssistant;
 
  56 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
 
  57 import org.eclipse.jface.text.contentassist.IContentAssistant;
 
  58 import org.eclipse.jface.text.formatter.ContentFormatter;
 
  59 import org.eclipse.jface.text.formatter.IContentFormatter;
 
  60 import org.eclipse.jface.text.formatter.IFormattingStrategy;
 
  61 import org.eclipse.jface.text.information.IInformationPresenter;
 
  62 import org.eclipse.jface.text.information.IInformationProvider;
 
  63 import org.eclipse.jface.text.information.InformationPresenter;
 
  64 import org.eclipse.jface.text.presentation.IPresentationReconciler;
 
  65 import org.eclipse.jface.text.presentation.PresentationReconciler;
 
  66 import org.eclipse.jface.text.reconciler.IReconciler;
 
  67 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
 
  68 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
 
  69 import org.eclipse.jface.text.rules.DefaultPartitioner;
 
  70 import org.eclipse.jface.text.rules.RuleBasedScanner;
 
  71 import org.eclipse.jface.text.rules.Token;
 
  72 import org.eclipse.jface.text.source.IAnnotationHover;
 
  73 import org.eclipse.jface.text.source.ISourceViewer;
 
  74 import org.eclipse.jface.text.source.SourceViewerConfiguration;
 
  75 import org.eclipse.jface.util.PropertyChangeEvent;
 
  76 import org.eclipse.swt.SWT;
 
  77 import org.eclipse.swt.widgets.Shell;
 
  78 import org.eclipse.ui.texteditor.ITextEditor;
 
  80  * Configuration for an <code>SourceViewer</code> which shows PHP code.
 
  82 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
 
  84          * Preference key used to look up display tab width.
 
  88         public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
 
  90          * Preference key for inserting spaces rather than tabs.
 
  94         public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
 
  95         //  public static final String HTML_DEFAULT =
 
  96         // IPHPPartitionScannerConstants.HTML;
 
  97         //IDocument.DEFAULT_CONTENT_TYPE;
 
  98         private JavaTextTools fJavaTextTools;
 
  99         private ITextEditor fTextEditor;
 
 100         private ContentFormatter fFormatter;
 
 101         private HTMLFormattingStrategy fFormattingStrategy;
 
 103          * Single token scanner.
 
 105         static class SingleTokenScanner extends BufferedRuleBasedScanner {
 
 106                 public SingleTokenScanner(TextAttribute attribute) {
 
 107                         setDefaultReturnToken(new Token(attribute));
 
 111          * The document partitioning.
 
 114         private String fDocumentPartitioning;
 
 116          * The Java source code scanner
 
 119         private AbstractJavaScanner fCodeScanner;
 
 121          * The Java multi-line comment scanner 
 
 124         private AbstractJavaScanner fMultilineCommentScanner;
 
 126          * The Java single-line comment scanner
 
 129         private AbstractJavaScanner fSinglelineCommentScanner;
 
 131          * The Java string scanner
 
 134         private AbstractJavaScanner fStringScanner;
 
 136          * The Javadoc scanner
 
 139         private AbstractJavaScanner fJavaDocScanner;
 
 141          * The preference store, can be read-only
 
 144         private IPreferenceStore fPreferenceStore;
 
 149         private IColorManager fColorManager;
 
 152          * Creates a new Java source viewer configuration for viewers in the given editor 
 
 153          * using the given preference store, the color manager and the specified document partitioning.
 
 155          * Creates a Java source viewer configuration in the new setup without text tools. Clients are
 
 156          * allowed to call {@link JavaSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}
 
 157          * and disallowed to call {@link JavaSourceViewerConfiguration#getPreferenceStore()} on the resulting
 
 158          * Java source viewer configuration.
 
 161          * @param colorManager the color manager
 
 162          * @param preferenceStore the preference store, can be read-only
 
 163          * @param editor the editor in which the configured viewer(s) will reside
 
 164          * @param partitioning the document partitioning for this configuration
 
 167         public PHPSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
 
 168                 fColorManager= colorManager;
 
 169                 fPreferenceStore= preferenceStore;
 
 171                 fDocumentPartitioning= partitioning;
 
 172                 fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
 
 173 //              initializeScanners();
 
 177          * Default constructor.
 
 179         public PHPSourceViewerConfiguration(JavaTextTools textTools,
 
 181                 fJavaTextTools = textTools;
 
 182                 fTextEditor = editor;
 
 185          * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
 
 187         public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
 
 188                 //    if (fFormatter == null) {
 
 189                 //      fFormatter = new ContentFormatter();
 
 190                 //      fFormattingStrategy = new HTMLFormattingStrategy(this,
 
 192                 //      fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
 
 193                 //      fFormatter.enablePartitionAwareFormatting(false);
 
 194                 //      fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
 
 196                 //    return fFormatter;
 
 197                 if (fFormatter == null) {
 
 199                         fFormatter = new ContentFormatter();
 
 200                         IFormattingStrategy strategy = new JavaFormattingStrategy(
 
 202                         fFormatter.setFormattingStrategy(strategy,
 
 203                                         IDocument.DEFAULT_CONTENT_TYPE);
 
 204                         fFormatter.enablePartitionAwareFormatting(false);
 
 206                                         .setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
 
 211          * Returns the names of the document position categories used by the
 
 212          * document partitioners created by this object to manage their partition
 
 213          * information. If the partitioners don't use document position categories,
 
 214          * the returned result is <code>null</code>.
 
 216          * @return the partition managing position categories or <code>null</code>
 
 219         public String[] getPartitionManagingPositionCategories() {
 
 220                 return new String[]{DefaultPartitioner.CONTENT_TYPES_CATEGORY};
 
 223         //   * Returns the names of the document position categories used by the
 
 225         //   * partitioners created by this object to manage their partition
 
 227         //   * If the partitioners don't use document position categories, the
 
 229         //   * result is <code>null</code>.
 
 231         //   * @return the partition managing position categories or
 
 233         //   * if there is none
 
 235         //  private String[] getPartitionManagingPositionCategories() {
 
 236         //    return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
 
 238         public ITextEditor getEditor() {
 
 242          * Returns the preference store used by this configuration to initialize
 
 243          * the individual bits and pieces.
 
 245          * @return the preference store used to initialize this configuration
 
 249         protected IPreferenceStore getPreferenceStore() {
 
 250                 return PHPeclipsePlugin.getDefault().getPreferenceStore();
 
 253         //   * Method declared on SourceViewerConfiguration
 
 255         //  public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
 
 256         //    return new PHPAnnotationHover();
 
 259          * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
 
 261         public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
 
 262                 return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
 
 265          * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
 
 268         public IAnnotationHover getOverviewRulerAnnotationHover(
 
 269                         ISourceViewer sourceViewer) {
 
 270                 return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
 
 273          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 275         public IAutoIndentStrategy getAutoIndentStrategy(
 
 276                         ISourceViewer sourceViewer, String contentType) {
 
 277                 if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
 
 278                         return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
 
 280                 return (IPHPPartitions.PHP_PARTITIONING.equals(contentType)
 
 281                                 ? new PHPAutoIndentStrategy()
 
 282                                 : new DefaultAutoIndentStrategy());
 
 285          * Returns the PHP source code scanner for this configuration.
 
 287          * @return the PHP source code scanner
 
 289         protected RuleBasedScanner getCodeScanner() {
 
 290                 return fJavaTextTools.getCodeScanner();
 
 293          * Returns the HTML source code scanner for this configuration.
 
 295          * @return the HTML source code scanner
 
 297         protected RuleBasedScanner getHTMLScanner() {
 
 298                 return fJavaTextTools.getHTMLScanner();
 
 301          * Returns the Smarty source code scanner for this configuration.
 
 303          * @return the Smarty source code scanner
 
 305         protected RuleBasedScanner getSmartyScanner() {
 
 306                 return fJavaTextTools.getSmartyScanner();
 
 309          * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
 
 312          * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
 
 314         public IReconciler getReconciler(ISourceViewer sourceViewer) {
 
 316                 final ITextEditor editor= getEditor();
 
 317                 if (editor != null && editor.isEditable()) {
 
 319                         JavaCompositeReconcilingStrategy strategy= new JavaCompositeReconcilingStrategy(editor, getConfiguredDocumentPartitioning(sourceViewer));
 
 320                         JavaReconciler reconciler= new JavaReconciler(editor, strategy, false);
 
 321                         reconciler.setIsIncrementalReconciler(false);
 
 322                         reconciler.setProgressMonitor(new NullProgressMonitor());
 
 323                         reconciler.setDelay(500);
 
 329 //      public IReconciler getReconciler(ISourceViewer sourceViewer) {
 
 330 //              if (getEditor() != null && getEditor().isEditable()) {
 
 331 //                      JavaReconciler reconciler = new JavaReconciler(getEditor(),
 
 332 //                                      new JavaReconcilingStrategy(getEditor()), false);
 
 333 //                      reconciler.setProgressMonitor(new NullProgressMonitor());
 
 334 //                      reconciler.setDelay(500);
 
 335 //                      return reconciler;
 
 340          * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer,
 
 344         public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer,
 
 345                         String contentType) {
 
 346                 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
 
 347                                 .getDefault().getJavaEditorTextHoverDescriptors();
 
 348                 int stateMasks[] = new int[hoverDescs.length];
 
 349                 int stateMasksLength = 0;
 
 350                 for (int i = 0; i < hoverDescs.length; i++) {
 
 351                         if (hoverDescs[i].isEnabled()) {
 
 353                                 int stateMask = hoverDescs[i].getStateMask();
 
 354                                 while (j < stateMasksLength) {
 
 355                                         if (stateMasks[j] == stateMask)
 
 359                                 if (j == stateMasksLength)
 
 360                                         stateMasks[stateMasksLength++] = stateMask;
 
 363                 if (stateMasksLength == hoverDescs.length)
 
 365                 int[] shortenedStateMasks = new int[stateMasksLength];
 
 366                 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0,
 
 368                 return shortenedStateMasks;
 
 371          * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
 
 374         public ITextHover getTextHover(ISourceViewer sourceViewer,
 
 375                         String contentType, int stateMask) {
 
 376                 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
 
 377                                 .getDefault().getJavaEditorTextHoverDescriptors();
 
 379                 while (i < hoverDescs.length) {
 
 380                         if (hoverDescs[i].isEnabled()
 
 381                                         && hoverDescs[i].getStateMask() == stateMask)
 
 382                                 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
 
 386 //              if (fEditor != null) {
 
 387 //                      IEditorInput editorInput = fEditor.getEditorInput();
 
 388 //                      if (editorInput instanceof IFileEditorInput) {
 
 390 //                                      IFile f = ((IFileEditorInput) editorInput).getFile();
 
 391 //                                      return new PHPTextHover(f.getProject());
 
 392 //                              } catch (NullPointerException e) {
 
 393 //                                      // this exception occurs, if getTextHover is called by
 
 394 //                                      // preference pages !
 
 398 //              return new PHPTextHover(null);
 
 401          * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
 
 403         public ITextHover getTextHover(ISourceViewer sourceViewer,
 
 404                         String contentType) {
 
 405                 return getTextHover(sourceViewer, contentType,
 
 406                                 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
 
 409          * Returns the SmartyDoc source code scanner for this configuration.
 
 411          * @return the SmartyDoc source code scanner
 
 413         protected RuleBasedScanner getSmartyDocScanner() {
 
 414                 return fJavaTextTools.getSmartyDocScanner();
 
 417          * Returns the PHPDoc source code scanner for this configuration.
 
 419          * @return the PHPDoc source code scanner
 
 421         protected RuleBasedScanner getPHPDocScanner() {
 
 422                 return fJavaTextTools.getJavaDocScanner();
 
 425          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 427         public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
 
 428                 return new String[]{IPHPPartitions.HTML,
 
 429                                 IPHPPartitions.HTML_MULTILINE_COMMENT,
 
 430                                 IPHPPartitions.PHP_PARTITIONING,
 
 431                                 IPHPPartitions.PHP_PHPDOC_COMMENT,
 
 433                                 IPHPPartitions.CSS_MULTILINE_COMMENT,
 
 434                                 IPHPPartitions.JAVASCRIPT,
 
 435                                 IPHPPartitions.JS_MULTILINE_COMMENT,
 
 436                                 IPHPPartitions.SMARTY,
 
 437                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT,
 
 438                                 IDocument.DEFAULT_CONTENT_TYPE};
 
 441          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 443         public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
 
 444                 ContentAssistant assistant = new ContentAssistant();
 
 445                 IContentAssistProcessor processor = new HTMLCompletionProcessor();
 
 446                 assistant.setContentAssistProcessor(processor,
 
 447                                 IPHPPartitions.HTML);
 
 448                 assistant.setContentAssistProcessor(processor,
 
 449                                 IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 450                 assistant.setContentAssistProcessor(processor,
 
 451                                 IDocument.DEFAULT_CONTENT_TYPE);
 
 452                 assistant.setContentAssistProcessor(processor,
 
 454                 assistant.setContentAssistProcessor(processor,
 
 455                                 IPHPPartitions.CSS_MULTILINE_COMMENT);
 
 456                 assistant.setContentAssistProcessor(processor,
 
 457                                 IPHPPartitions.JAVASCRIPT);
 
 458                 assistant.setContentAssistProcessor(processor,
 
 459                                 IPHPPartitions.JS_MULTILINE_COMMENT);
 
 460                 // TODO define special smarty partition content assist
 
 461                 assistant.setContentAssistProcessor(processor,
 
 462                                 IPHPPartitions.SMARTY);
 
 463                 assistant.setContentAssistProcessor(processor,
 
 464                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 465                 assistant.setContentAssistProcessor(new PHPCompletionProcessor(getEditor()),
 
 466                                 IPHPPartitions.PHP_PARTITIONING);
 
 467                 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
 
 468                                 IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 469                 //    assistant.enableAutoActivation(true);
 
 470                 //    assistant.setAutoActivationDelay(500);
 
 471                 //    assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
 
 472                 //    ContentAssistPreference.configure(assistant, getPreferenceStore());
 
 473                 //    assistant.setContextInformationPopupOrientation(
 
 474                 //      ContentAssistant.CONTEXT_INFO_ABOVE);
 
 475                 //    assistant.setContextInformationPopupBackground(
 
 476                 //      PHPEditorEnvironment.getPHPColorProvider().getColor(
 
 477                 //        new RGB(150, 150, 0)));
 
 478                 ContentAssistPreference.configure(assistant, getPreferenceStore());
 
 480                                 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
 
 482                                 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
 
 486          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 488         //  public String getDefaultPrefix(ISourceViewer sourceViewer, String
 
 490         //    return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
 
 492         //    // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
 
 493         // null); //$NON-NLS-1$
 
 496          * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
 
 499         public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
 
 500                         String contentType) {
 
 501                 return new String[]{"//", ""}; //$NON-NLS-1$ //$NON-NLS-2$
 
 504          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 506         public ITextDoubleClickStrategy getDoubleClickStrategy(
 
 507                         ISourceViewer sourceViewer, String contentType) {
 
 508                 return new PHPDoubleClickSelector();
 
 511          * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
 
 513         public String[] getIndentPrefixes(ISourceViewer sourceViewer,
 
 514                         String contentType) {
 
 515                 Vector vector = new Vector();
 
 516                 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
 
 517                 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
 
 518                                 .getPreferenceStore();
 
 519                 int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
 
 520                 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
 
 521                 for (int i = 0; i <= tabWidth; i++) {
 
 522                         StringBuffer prefix = new StringBuffer();
 
 524                                 for (int j = 0; j + i < tabWidth; j++)
 
 529                                 for (int j = 0; j < i; j++)
 
 534                         vector.add(prefix.toString());
 
 536                 vector.add(""); //$NON-NLS-1$
 
 537                 return (String[]) vector.toArray(new String[vector.size()]);
 
 540          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 542         public IPresentationReconciler getPresentationReconciler(
 
 543                         ISourceViewer sourceViewer) {
 
 544                 //  PHPColorProvider provider =
 
 545                 // PHPEditorEnvironment.getPHPColorProvider();
 
 546                 //    JavaColorManager provider =
 
 547                 // PHPEditorEnvironment.getPHPColorProvider();
 
 548                 PresentationReconciler reconciler= new JavaPresentationReconciler();
 
 549                 reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
 
 551                 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 552                 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
 
 553                 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
 
 554                 dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 555                 reconciler.setDamager(dr, IPHPPartitions.HTML);
 
 556                 reconciler.setRepairer(dr, IPHPPartitions.HTML);
 
 557                 dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 558                 reconciler.setDamager(dr, IPHPPartitions.CSS);
 
 559                 reconciler.setRepairer(dr, IPHPPartitions.CSS);
 
 560                 dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 561                 reconciler.setDamager(dr,
 
 562                                 IPHPPartitions.CSS_MULTILINE_COMMENT);
 
 563                 reconciler.setRepairer(dr,
 
 564                                 IPHPPartitions.CSS_MULTILINE_COMMENT);
 
 565                 dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 566                 reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
 
 567                 reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
 
 568                 dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 569                 reconciler.setDamager(dr,
 
 570                                 IPHPPartitions.JS_MULTILINE_COMMENT);
 
 571                 reconciler.setRepairer(dr,
 
 572                                 IPHPPartitions.JS_MULTILINE_COMMENT);
 
 573                 dr = new DefaultDamagerRepairer(getSmartyScanner());
 
 574                 reconciler.setDamager(dr, IPHPPartitions.SMARTY);
 
 575                 reconciler.setRepairer(dr, IPHPPartitions.SMARTY);
 
 576                 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
 
 577                 reconciler.setDamager(dr,
 
 578                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 579                 reconciler.setRepairer(dr,
 
 580                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 581                 dr = new DefaultDamagerRepairer(new SingleTokenScanner(
 
 582                                 new TextAttribute(fJavaTextTools.getColorManager().getColor(
 
 583                                                 PHPColorProvider.MULTI_LINE_COMMENT))));
 
 584                 reconciler.setDamager(dr,
 
 585                                 IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 586                 reconciler.setRepairer(dr,
 
 587                                 IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 588                 dr = new DefaultDamagerRepairer(getCodeScanner());
 
 589                 reconciler.setDamager(dr, IPHPPartitions.PHP_PARTITIONING);
 
 590                 reconciler.setRepairer(dr, IPHPPartitions.PHP_PARTITIONING);
 
 591                 dr = new DefaultDamagerRepairer(getPHPDocScanner());
 
 592                 reconciler.setDamager(dr,
 
 593                                 IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 594                 reconciler.setRepairer(dr,
 
 595                                 IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 599          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 601         public int getTabWidth(ISourceViewer sourceViewer) {
 
 602                 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
 
 605          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 607         //  public ITextHover getTextHover(ISourceViewer sourceViewer, String
 
 609         //    if (fEditor != null) {
 
 610         //      IEditorInput editorInput = fEditor.getEditorInput();
 
 611         //      if (editorInput instanceof IFileEditorInput) {
 
 613         //          IFile f = ((IFileEditorInput) editorInput).getFile();
 
 614         //          return new PHPTextHover(f.getProject());
 
 615         //        } catch (NullPointerException e) {
 
 616         //          // this exception occurs, if getTextHover is called by preference pages
 
 621         //    return new PHPTextHover(null);
 
 624          * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
 
 627         public IInformationControlCreator getInformationControlCreator(
 
 628                         ISourceViewer sourceViewer) {
 
 629                 return new IInformationControlCreator() {
 
 630                         public IInformationControl createInformationControl(Shell parent) {
 
 631                                 return new DefaultInformationControl(parent, SWT.NONE,
 
 632                                                 new HTMLTextPresenter(true));
 
 633                                 // return new HoverBrowserControl(parent);
 
 638          * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
 
 641         //      public IInformationPresenter getInformationPresenter(ISourceViewer
 
 643         //              InformationPresenter presenter= new
 
 644         // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
 
 645         //              IInformationProvider provider= new JavaInformationProvider(getEditor());
 
 646         //              presenter.setInformationProvider(provider,
 
 647         // IDocument.DEFAULT_CONTENT_TYPE);
 
 648         //              presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
 
 649         //              presenter.setSizeConstraints(60, 10, true, true);
 
 653          * Returns the information presenter control creator. The creator is a
 
 654          * factory creating the presenter controls for the given source viewer.
 
 655          * This implementation always returns a creator for <code>DefaultInformationControl</code>
 
 658          * @param sourceViewer
 
 659          *            the source viewer to be configured by this configuration
 
 660          * @return an information control creator
 
 663         private IInformationControlCreator getInformationPresenterControlCreator(
 
 664                         ISourceViewer sourceViewer) {
 
 665                 return new IInformationControlCreator() {
 
 666                         public IInformationControl createInformationControl(Shell parent) {
 
 667                                 int shellStyle = SWT.RESIZE;
 
 668                                 int style = SWT.V_SCROLL | SWT.H_SCROLL;
 
 669                                 return new DefaultInformationControl(parent, shellStyle, style,
 
 670                                                 new HTMLTextPresenter(false));
 
 671                                 // return new HoverBrowserControl(parent);
 
 676          * Returns the outline presenter control creator. The creator is a factory
 
 677          * creating outline presenter controls for the given source viewer. This
 
 678          * implementation always returns a creator for <code>JavaOutlineInformationControl</code>
 
 681          * @param sourceViewer
 
 682          *            the source viewer to be configured by this configuration
 
 683          * @return an information control creator
 
 686         private IInformationControlCreator getOutlinePresenterControlCreator(
 
 687                         ISourceViewer sourceViewer) {
 
 688                 return new IInformationControlCreator() {
 
 689                         public IInformationControl createInformationControl(Shell parent) {
 
 690                                 int shellStyle = SWT.RESIZE;
 
 691                                 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
 
 692                                 return new JavaOutlineInformationControl(parent, shellStyle,
 
 698          * Returns the outline presenter which will determine and shown information
 
 699          * requested for the current cursor position.
 
 701          * @param sourceViewer
 
 702          *            the source viewer to be configured by this configuration
 
 703          * @param doCodeResolve
 
 704          *            a boolean which specifies whether code resolve should be used
 
 705          *            to compute the Java element
 
 706          * @return an information presenter
 
 709         public IInformationPresenter getOutlinePresenter(
 
 710                         ISourceViewer sourceViewer, boolean doCodeResolve) {
 
 711                 InformationPresenter presenter = new InformationPresenter(
 
 712                                 getOutlinePresenterControlCreator(sourceViewer));
 
 713                 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
 
 714                 IInformationProvider provider = new JavaElementProvider(getEditor(),
 
 716                 presenter.setInformationProvider(provider,
 
 717                                 IDocument.DEFAULT_CONTENT_TYPE);
 
 718                 presenter.setInformationProvider(provider,
 
 719                                 IPHPPartitions.PHP_PARTITIONING);
 
 720                 presenter.setInformationProvider(provider,
 
 721                                 IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 722                 presenter.setInformationProvider(provider,
 
 723                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 724                 presenter.setInformationProvider(provider,
 
 725                                 IPHPPartitions.HTML);
 
 726                 presenter.setInformationProvider(provider,
 
 727                                 IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 728                 presenter.setSizeConstraints(40, 20, true, false);