2 * Created on 25.08.2004
4 * TODO To change the template for this generated file go to
5 * Window - Preferences - Java - Code Style - Code Templates
7 package net.sourceforge.phpdt.smarty.ui.internal.text;
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;
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;
25 public class SmartyConfiguration extends XMLConfiguration {
26 private SmartyTagScanner smartyTagScanner;
27 public SmartyConfiguration(XMLTextTools tools) {
31 public SmartyConfiguration(XMLTextTools tools, ITextEditor editor) {
33 Map tokens = tools.getTokens();
34 smartyTagScanner = new SmartyTagScanner(tokens);
37 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
38 ContentAssistant assistant = new ContentAssistant();
39 assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
41 IContentAssistProcessor processor = new SmartyCompletionProcessor();
42 assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
43 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_TAG);
44 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_PI);
45 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_COMMENT);
46 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_DECL);
47 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_TAG);
48 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_ATTRIBUTE);
49 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_CDATA);
51 assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
52 assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
57 * Returns a scanner which is configured to scan XML text.
59 * @return an XML text scanner
61 public SmartyTagScanner getSmartyScanner() {
62 return smartyTagScanner;
65 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
67 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
68 PresentationReconciler reconciler = new PresentationReconciler();
70 DefaultDamagerRepairer dr;
72 dr = new DefaultDamagerRepairer(getSmartyScanner());
73 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
74 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
76 dr = new DefaultDamagerRepairer(xmlTextTools.getDTDTextScanner());
77 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL);
78 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL);
80 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLPIScanner());
82 reconciler.setDamager(dr, XMLPartitionScanner.XML_PI);
83 reconciler.setRepairer(dr, XMLPartitionScanner.XML_PI);
84 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_PI);
85 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_PI);
87 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCommentScanner());
89 reconciler.setDamager(dr, XMLPartitionScanner.XML_COMMENT);
90 reconciler.setRepairer(dr, XMLPartitionScanner.XML_COMMENT);
91 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_COMMENT);
92 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_COMMENT);
94 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLDeclScanner());
96 reconciler.setDamager(dr, XMLPartitionScanner.XML_DECL);
97 reconciler.setRepairer(dr, XMLPartitionScanner.XML_DECL);
98 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_DECL);
99 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_DECL);
101 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLTagScanner());
103 reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
104 reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
106 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLAttributeScanner());
108 reconciler.setDamager(dr, XMLPartitionScanner.XML_ATTRIBUTE);
109 reconciler.setRepairer(dr, XMLPartitionScanner.XML_ATTRIBUTE);
111 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCDATAScanner());
113 reconciler.setDamager(dr, XMLPartitionScanner.XML_CDATA);
114 reconciler.setRepairer(dr, XMLPartitionScanner.XML_CDATA);