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;
14 import java.util.Vector;
16 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
17 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
18 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
19 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
20 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
21 import net.sourceforge.phpdt.internal.ui.text.PHPAnnotationHover;
22 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
23 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
24 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
25 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
26 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
27 import net.sourceforge.phpdt.ui.PreferenceConstants;
28 import net.sourceforge.phpdt.ui.text.JavaTextTools;
29 import net.sourceforge.phpeclipse.PHPCore;
30 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
31 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
32 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
33 import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
34 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
35 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
36 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
37 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
39 import org.eclipse.core.resources.IFile;
40 import org.eclipse.core.runtime.NullProgressMonitor;
41 import org.eclipse.jface.preference.IPreferenceStore;
42 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
43 import org.eclipse.jface.text.DefaultInformationControl;
44 import org.eclipse.jface.text.IAutoIndentStrategy;
45 import org.eclipse.jface.text.IDocument;
46 import org.eclipse.jface.text.IInformationControl;
47 import org.eclipse.jface.text.IInformationControlCreator;
48 import org.eclipse.jface.text.ITextDoubleClickStrategy;
49 import org.eclipse.jface.text.ITextHover;
50 import org.eclipse.jface.text.ITextViewerExtension2;
51 import org.eclipse.jface.text.TextAttribute;
52 import org.eclipse.jface.text.contentassist.ContentAssistant;
53 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
54 import org.eclipse.jface.text.contentassist.IContentAssistant;
55 import org.eclipse.jface.text.formatter.ContentFormatter;
56 import org.eclipse.jface.text.formatter.IContentFormatter;
57 import org.eclipse.jface.text.formatter.IFormattingStrategy;
58 import org.eclipse.jface.text.information.IInformationPresenter;
59 import org.eclipse.jface.text.information.IInformationProvider;
60 import org.eclipse.jface.text.information.InformationPresenter;
61 import org.eclipse.jface.text.presentation.IPresentationReconciler;
62 import org.eclipse.jface.text.presentation.PresentationReconciler;
63 import org.eclipse.jface.text.reconciler.IReconciler;
64 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
65 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
66 import org.eclipse.jface.text.rules.DefaultPartitioner;
67 import org.eclipse.jface.text.rules.RuleBasedScanner;
68 import org.eclipse.jface.text.rules.Token;
69 import org.eclipse.jface.text.source.IAnnotationHover;
70 import org.eclipse.jface.text.source.ISourceViewer;
71 import org.eclipse.jface.text.source.SourceViewerConfiguration;
72 import org.eclipse.swt.SWT;
73 import org.eclipse.swt.widgets.Shell;
74 import org.eclipse.ui.IEditorInput;
75 import org.eclipse.ui.IFileEditorInput;
78 * Configuration for an <code>SourceViewer</code> which shows PHP code.
80 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
83 * Preference key used to look up display tab width.
87 public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
89 * Preference key for inserting spaces rather than tabs.
93 public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
95 // public static final String HTML_DEFAULT = IPHPPartitionScannerConstants.HTML;
96 //IDocument.DEFAULT_CONTENT_TYPE;
98 private JavaTextTools fJavaTextTools;
99 private PHPEditor fEditor;
101 private ContentFormatter fFormatter;
102 private HTMLFormattingStrategy fFormattingStrategy;
104 * Single token scanner.
106 static class SingleTokenScanner extends BufferedRuleBasedScanner {
107 public SingleTokenScanner(TextAttribute attribute) {
108 setDefaultReturnToken(new Token(attribute));
113 * Default constructor.
115 public PHPSourceViewerConfiguration(JavaTextTools textTools, PHPEditor editor) {
116 fJavaTextTools = textTools;
121 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
123 public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
124 // if (fFormatter == null) {
125 // fFormatter = new ContentFormatter();
126 // fFormattingStrategy = new HTMLFormattingStrategy(this, sourceViewer);
127 // fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
128 // fFormatter.enablePartitionAwareFormatting(false);
129 // fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
131 // return fFormatter;
133 if (fFormatter == null) {
135 fFormatter = new ContentFormatter();
136 IFormattingStrategy strategy = new JavaFormattingStrategy(sourceViewer);
138 fFormatter.setFormattingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE);
139 fFormatter.enablePartitionAwareFormatting(false);
140 fFormatter.setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
146 * Returns the names of the document position categories used by the document
147 * partitioners created by this object to manage their partition information.
148 * If the partitioners don't use document position categories, the returned
149 * result is <code>null</code>.
151 * @return the partition managing position categories or <code>null</code>
154 public String[] getPartitionManagingPositionCategories() {
155 return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
158 // * Returns the names of the document position categories used by the document
159 // * partitioners created by this object to manage their partition information.
160 // * If the partitioners don't use document position categories, the returned
161 // * result is <code>null</code>.
163 // * @return the partition managing position categories or <code>null</code>
164 // * if there is none
166 // private String[] getPartitionManagingPositionCategories() {
167 // return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
170 public PHPEditor getEditor() {
175 * Returns the preference store used by this configuration to initialize
176 * the individual bits and pieces.
178 * @return the preference store used to initialize this configuration
182 protected IPreferenceStore getPreferenceStore() {
183 return PHPeclipsePlugin.getDefault().getPreferenceStore();
187 // * Method declared on SourceViewerConfiguration
189 // public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
190 // return new PHPAnnotationHover();
193 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
195 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
196 return new PHPAnnotationHover();
200 * Method declared on SourceViewerConfiguration
202 public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
203 return (IPHPPartitionScannerConstants.PHP.equals(contentType) ? new PHPAutoIndentStrategy() : new DefaultAutoIndentStrategy());
207 * Returns the PHP source code scanner for this configuration.
209 * @return the PHP source code scanner
211 protected RuleBasedScanner getCodeScanner() {
212 return fJavaTextTools.getCodeScanner();
216 * Returns the HTML source code scanner for this configuration.
218 * @return the HTML source code scanner
220 protected RuleBasedScanner getHTMLScanner() {
221 return fJavaTextTools.getHTMLScanner();
225 * Returns the Smarty source code scanner for this configuration.
227 * @return the Smarty source code scanner
229 protected RuleBasedScanner getSmartyScanner() {
230 return fJavaTextTools.getSmartyScanner();
234 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
236 public IReconciler getReconciler(ISourceViewer sourceViewer) {
238 if (getEditor() != null && getEditor().isEditable()) {
239 JavaReconciler reconciler = new JavaReconciler(getEditor(), new JavaReconcilingStrategy(getEditor()), false);
240 reconciler.setProgressMonitor(new NullProgressMonitor());
241 reconciler.setDelay(500);
249 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
252 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
253 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin.getDefault().getJavaEditorTextHoverDescriptors();
254 int stateMasks[] = new int[hoverDescs.length];
255 int stateMasksLength = 0;
256 for (int i = 0; i < hoverDescs.length; i++) {
257 if (hoverDescs[i].isEnabled()) {
259 int stateMask = hoverDescs[i].getStateMask();
260 while (j < stateMasksLength) {
261 if (stateMasks[j] == stateMask)
265 if (j == stateMasksLength)
266 stateMasks[stateMasksLength++] = stateMask;
269 if (stateMasksLength == hoverDescs.length)
272 int[] shortenedStateMasks = new int[stateMasksLength];
273 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength);
274 return shortenedStateMasks;
278 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
281 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
282 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin.getDefault().getJavaEditorTextHoverDescriptors();
284 while (i < hoverDescs.length) {
285 if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask)
286 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
290 if (fEditor != null) {
291 IEditorInput editorInput = fEditor.getEditorInput();
292 if (editorInput instanceof IFileEditorInput) {
294 IFile f = ((IFileEditorInput) editorInput).getFile();
295 return new PHPTextHover(f.getProject());
296 } catch (NullPointerException e) {
297 // this exception occurs, if getTextHover is called by preference pages !
301 return new PHPTextHover(null);
305 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
307 public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
308 return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
312 * Returns the SmartyDoc source code scanner for this configuration.
314 * @return the SmartyDoc source code scanner
316 protected RuleBasedScanner getSmartyDocScanner() {
317 return fJavaTextTools.getSmartyDocScanner();
321 * Returns the PHPDoc source code scanner for this configuration.
323 * @return the PHPDoc source code scanner
325 protected RuleBasedScanner getPHPDocScanner() {
326 return fJavaTextTools.getJavaDocScanner();
330 * Method declared on SourceViewerConfiguration
332 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
333 return new String[] {
334 IPHPPartitionScannerConstants.HTML,
335 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
336 IPHPPartitionScannerConstants.PHP,
337 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
338 IPHPPartitionScannerConstants.CSS,
339 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
340 IPHPPartitionScannerConstants.JAVASCRIPT,
341 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT,
342 IPHPPartitionScannerConstants.SMARTY,
343 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
344 IDocument.DEFAULT_CONTENT_TYPE };
348 * Method declared on SourceViewerConfiguration
350 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
352 ContentAssistant assistant = new ContentAssistant();
353 IContentAssistProcessor processor = new HTMLCompletionProcessor();
354 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.HTML);
355 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
356 assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
357 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.CSS);
358 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
359 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.JAVASCRIPT);
360 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
361 // TODO define special smarty partition content assist
362 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.SMARTY);
363 assistant.setContentAssistProcessor(processor, IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
365 assistant.setContentAssistProcessor(new PHPCompletionProcessor(), IPHPPartitionScannerConstants.PHP);
367 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(), IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
369 // assistant.enableAutoActivation(true);
370 // assistant.setAutoActivationDelay(500);
371 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
372 // ContentAssistPreference.configure(assistant, getPreferenceStore());
373 // assistant.setContextInformationPopupOrientation(
374 // ContentAssistant.CONTEXT_INFO_ABOVE);
375 // assistant.setContextInformationPopupBackground(
376 // PHPEditorEnvironment.getPHPColorProvider().getColor(
377 // new RGB(150, 150, 0)));
378 ContentAssistPreference.configure(assistant, getPreferenceStore());
380 assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
381 assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
387 * Method declared on SourceViewerConfiguration
389 // public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
390 // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null); //$NON-NLS-1$
391 // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$
395 * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
398 public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
399 return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$
403 * Method declared on SourceViewerConfiguration
405 public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
406 return new PHPDoubleClickSelector();
410 * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
412 public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
414 Vector vector = new Vector();
416 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
418 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault().getPreferenceStore();
419 int tabWidth = preferences.getInt(PHPCore.FORMATTER_TAB_SIZE);
420 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
422 for (int i = 0; i <= tabWidth; i++) {
423 StringBuffer prefix = new StringBuffer();
426 for (int j = 0; j + i < tabWidth; j++)
432 for (int j = 0; j < i; j++)
439 vector.add(prefix.toString());
442 vector.add(""); //$NON-NLS-1$
444 return (String[]) vector.toArray(new String[vector.size()]);
447 * Method declared on SourceViewerConfiguration
449 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
450 // PHPColorProvider provider = PHPEditorEnvironment.getPHPColorProvider();
451 // JavaColorManager provider = PHPEditorEnvironment.getPHPColorProvider();
452 PresentationReconciler reconciler = new PresentationReconciler();
454 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
455 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
456 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
458 dr = new DefaultDamagerRepairer(getHTMLScanner());
459 reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
460 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
461 dr = new DefaultDamagerRepairer(getHTMLScanner());
462 reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS);
463 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS);
464 dr = new DefaultDamagerRepairer(getHTMLScanner());
465 reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
466 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
467 dr = new DefaultDamagerRepairer(getHTMLScanner());
468 reconciler.setDamager(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
469 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
470 dr = new DefaultDamagerRepairer(getHTMLScanner());
471 reconciler.setDamager(dr, IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
472 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
474 dr = new DefaultDamagerRepairer(getSmartyScanner());
475 reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY);
476 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY);
478 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
479 reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
480 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
483 new DefaultDamagerRepairer(
484 new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(PHPColorProvider.MULTI_LINE_COMMENT))));
485 reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
486 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
488 dr = new DefaultDamagerRepairer(getCodeScanner());
489 reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
490 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
492 dr = new DefaultDamagerRepairer(getPHPDocScanner());
493 reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
494 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
500 * Method declared on SourceViewerConfiguration
502 public int getTabWidth(ISourceViewer sourceViewer) {
503 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
507 * Method declared on SourceViewerConfiguration
509 // public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
510 // if (fEditor != null) {
511 // IEditorInput editorInput = fEditor.getEditorInput();
512 // if (editorInput instanceof IFileEditorInput) {
514 // IFile f = ((IFileEditorInput) editorInput).getFile();
515 // return new PHPTextHover(f.getProject());
516 // } catch (NullPointerException e) {
517 // // this exception occurs, if getTextHover is called by preference pages !
521 // return new PHPTextHover(null);
525 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
528 public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
529 return new IInformationControlCreator() {
530 public IInformationControl createInformationControl(Shell parent) {
531 return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
532 // return new HoverBrowserControl(parent);
538 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
541 // public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
542 // InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
543 // IInformationProvider provider= new JavaInformationProvider(getEditor());
544 // presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
545 // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
546 // presenter.setSizeConstraints(60, 10, true, true);
551 * Returns the information presenter control creator. The creator is a factory creating the
552 * presenter controls for the given source viewer. This implementation always returns a creator
553 * for <code>DefaultInformationControl</code> instances.
555 * @param sourceViewer the source viewer to be configured by this configuration
556 * @return an information control creator
559 private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
560 return new IInformationControlCreator() {
561 public IInformationControl createInformationControl(Shell parent) {
562 int shellStyle = SWT.RESIZE;
563 int style = SWT.V_SCROLL | SWT.H_SCROLL;
564 return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
565 // return new HoverBrowserControl(parent);
570 * Returns the outline presenter control creator. The creator is a factory creating outline
571 * presenter controls for the given source viewer. This implementation always returns a creator
572 * for <code>JavaOutlineInformationControl</code> instances.
574 * @param sourceViewer the source viewer to be configured by this configuration
575 * @return an information control creator
578 private IInformationControlCreator getOutlinePresenterControlCreator(ISourceViewer sourceViewer) {
579 return new IInformationControlCreator() {
580 public IInformationControl createInformationControl(Shell parent) {
581 int shellStyle = SWT.RESIZE;
582 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
583 return new JavaOutlineInformationControl(parent, shellStyle, treeStyle);
588 * Returns the outline presenter which will determine and shown
589 * information requested for the current cursor position.
591 * @param sourceViewer the source viewer to be configured by this configuration
592 * @param doCodeResolve a boolean which specifies whether code resolve should be used to compute the Java element
593 * @return an information presenter
596 public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
597 InformationPresenter presenter = new InformationPresenter(getOutlinePresenterControlCreator(sourceViewer));
598 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
599 IInformationProvider provider = new JavaElementProvider(getEditor(), doCodeResolve);
600 presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
601 presenter.setInformationProvider(provider, IPHPPartitionScannerConstants.PHP);
602 presenter.setInformationProvider(provider, IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
603 presenter.setInformationProvider(provider, IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
604 presenter.setInformationProvider(provider, IPHPPartitionScannerConstants.HTML);
605 presenter.setInformationProvider(provider, IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
606 presenter.setSizeConstraints(40, 20, true, false);