Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.smarty.ui / src / net / sourceforge / phpdt / smarty / ui / internal / text / SmartyConfiguration.java
1 /*
2  * Created on 25.08.2004
3  *
4  * TODO To change the template for this generated file go to
5  * Window - Preferences - Java - Code Style - Code Templates
6  */
7 package net.sourceforge.phpdt.smarty.ui.internal.text;
8
9 import java.util.Map;
10
11 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
12 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
13 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
14
15 import org.eclipse.jface.text.IDocument;
16 import org.eclipse.jface.text.contentassist.ContentAssistant;
17 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
18 import org.eclipse.jface.text.contentassist.IContentAssistant;
19 import org.eclipse.jface.text.presentation.IPresentationReconciler;
20 import org.eclipse.jface.text.presentation.PresentationReconciler;
21 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
22 import org.eclipse.jface.text.source.ISourceViewer;
23 import org.eclipse.ui.texteditor.ITextEditor;
24
25 public class SmartyConfiguration extends XMLConfiguration {
26         private SmartyTagScanner smartyTagScanner;
27
28 //      public SmartyConfiguration(XMLTextTools tools) {
29 //              this(tools, null);
30 //      }
31
32         public SmartyConfiguration(XMLTextTools tools, ITextEditor editor) {
33                 super(tools, editor);
34                 Map tokens = tools.getTokens();
35                 smartyTagScanner = new SmartyTagScanner(tokens);
36         }
37
38         public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
39                 ContentAssistant assistant = new ContentAssistant();
40                 assistant
41                                 .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
42
43                 IContentAssistProcessor processor = new SmartyCompletionProcessor();
44                 assistant.setContentAssistProcessor(processor,
45                                 IDocument.DEFAULT_CONTENT_TYPE);
46                 assistant.setContentAssistProcessor(processor,
47                                 XMLPartitionScanner.XML_TAG);
48                 assistant.setContentAssistProcessor(processor,
49                                 XMLPartitionScanner.XML_PI);
50                 assistant.setContentAssistProcessor(processor,
51                                 XMLPartitionScanner.XML_COMMENT);
52                 assistant.setContentAssistProcessor(processor,
53                                 XMLPartitionScanner.XML_DECL);
54                 assistant.setContentAssistProcessor(processor,
55                                 XMLPartitionScanner.XML_TAG);
56                 assistant.setContentAssistProcessor(processor,
57                                 XMLPartitionScanner.XML_ATTRIBUTE);
58                 assistant.setContentAssistProcessor(processor,
59                                 XMLPartitionScanner.XML_CDATA);
60
61                 assistant
62                                 .setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
63                 assistant
64                                 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
65
66                 return assistant;
67         }
68
69         /**
70          * Returns a scanner which is configured to scan XML text.
71          * 
72          * @return an XML text scanner
73          */
74         public SmartyTagScanner getSmartyScanner() {
75                 return smartyTagScanner;
76         }
77
78         /*
79          * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
80          */
81         public IPresentationReconciler getPresentationReconciler(
82                         ISourceViewer sourceViewer) {
83                 PresentationReconciler reconciler = new PresentationReconciler();
84
85                 DefaultDamagerRepairer dr;
86
87                 dr = new DefaultDamagerRepairer(getSmartyScanner());
88                 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
89                 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
90
91                 dr = new DefaultDamagerRepairer(xmlTextTools.getDTDTextScanner());
92                 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL);
93                 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL);
94
95                 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLPIScanner());
96
97                 reconciler.setDamager(dr, XMLPartitionScanner.XML_PI);
98                 reconciler.setRepairer(dr, XMLPartitionScanner.XML_PI);
99                 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_PI);
100                 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_PI);
101
102                 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCommentScanner());
103
104                 reconciler.setDamager(dr, XMLPartitionScanner.XML_COMMENT);
105                 reconciler.setRepairer(dr, XMLPartitionScanner.XML_COMMENT);
106                 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_COMMENT);
107                 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_COMMENT);
108
109                 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLDeclScanner());
110
111                 reconciler.setDamager(dr, XMLPartitionScanner.XML_DECL);
112                 reconciler.setRepairer(dr, XMLPartitionScanner.XML_DECL);
113                 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_DECL);
114                 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_DECL);
115
116                 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLTagScanner());
117
118                 reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
119                 reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
120
121                 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLAttributeScanner());
122
123                 reconciler.setDamager(dr, XMLPartitionScanner.XML_ATTRIBUTE);
124                 reconciler.setRepairer(dr, XMLPartitionScanner.XML_ATTRIBUTE);
125
126                 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCDATAScanner());
127
128                 reconciler.setDamager(dr, XMLPartitionScanner.XML_CDATA);
129                 reconciler.setRepairer(dr, XMLPartitionScanner.XML_CDATA);
130
131                 return reconciler;
132         }
133 }