1 package net.sourceforge.phpeclipse.editors;
3 import org.eclipse.jface.text.IDocument;
4 import org.eclipse.jface.text.ITextDoubleClickStrategy;
5 import org.eclipse.jface.text.TextAttribute;
6 import org.eclipse.jface.text.presentation.IPresentationReconciler;
7 import org.eclipse.jface.text.presentation.PresentationReconciler;
8 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
9 import org.eclipse.jface.text.rules.Token;
10 import org.eclipse.jface.text.source.ISourceViewer;
11 import org.eclipse.jface.text.source.SourceViewerConfiguration;
13 public class PHPConfiguration extends SourceViewerConfiguration {
14 private PHPDoubleClickStrategy doubleClickStrategy;
15 private PHPTagScanner tagScanner;
16 private PHPScanner scanner;
17 private ColorManager colorManager;
19 public PHPConfiguration(ColorManager colorManager) {
20 this.colorManager = colorManager;
22 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
24 IDocument.DEFAULT_CONTENT_TYPE,
25 PHPPartitionScanner.HTML_COMMENT,
26 PHPPartitionScanner.HTML_TAG };
28 public ITextDoubleClickStrategy getDoubleClickStrategy(
29 ISourceViewer sourceViewer,
31 if (doubleClickStrategy == null)
32 doubleClickStrategy = new PHPDoubleClickStrategy();
33 return doubleClickStrategy;
36 protected PHPScanner getXMLScanner() {
37 if (scanner == null) {
38 scanner = new PHPScanner(colorManager);
39 scanner.setDefaultReturnToken(
42 colorManager.getColor(IPHPColorConstants.DEFAULT))));
48 protected PHPTagScanner getXMLTagScanner() {
49 if (tagScanner == null) {
50 tagScanner = new PHPTagScanner(colorManager);
51 tagScanner.setDefaultReturnToken(
54 colorManager.getColor(IPHPColorConstants.PHP_TAG))));
59 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
60 PresentationReconciler reconciler = new PresentationReconciler();
62 DefaultDamagerRepairer dr =
63 new DefaultDamagerRepairer(getXMLTagScanner());
64 reconciler.setDamager(dr, PHPPartitionScanner.HTML_TAG);
65 reconciler.setRepairer(dr, PHPPartitionScanner.HTML_TAG);
67 dr = new DefaultDamagerRepairer(getXMLScanner());
68 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
69 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
71 NonRuleBasedDamagerRepairer ndr =
72 new NonRuleBasedDamagerRepairer(
74 colorManager.getColor(IPHPColorConstants.XML_COMMENT)));
75 reconciler.setDamager(ndr, PHPPartitionScanner.HTML_COMMENT);
76 reconciler.setRepairer(ndr, PHPPartitionScanner.HTML_COMMENT);