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;
28 public SmartyConfiguration(XMLTextTools tools) {
32 public SmartyConfiguration(XMLTextTools tools, ITextEditor editor) {
34 Map tokens = tools.getTokens();
35 smartyTagScanner = new SmartyTagScanner(tokens);
38 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
39 ContentAssistant assistant = new ContentAssistant();
41 .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
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);
62 .setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
64 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
70 * Returns a scanner which is configured to scan XML text.
72 * @return an XML text scanner
74 public SmartyTagScanner getSmartyScanner() {
75 return smartyTagScanner;
79 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
81 public IPresentationReconciler getPresentationReconciler(
82 ISourceViewer sourceViewer) {
83 PresentationReconciler reconciler = new PresentationReconciler();
85 DefaultDamagerRepairer dr;
87 dr = new DefaultDamagerRepairer(getSmartyScanner());
88 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
89 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
91 dr = new DefaultDamagerRepairer(xmlTextTools.getDTDTextScanner());
92 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL);
93 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL);
95 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLPIScanner());
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);
102 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCommentScanner());
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);
109 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLDeclScanner());
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);
116 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLTagScanner());
118 reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
119 reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
121 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLAttributeScanner());
123 reconciler.setDamager(dr, XMLPartitionScanner.XML_ATTRIBUTE);
124 reconciler.setRepairer(dr, XMLPartitionScanner.XML_ATTRIBUTE);
126 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCDATAScanner());
128 reconciler.setDamager(dr, XMLPartitionScanner.XML_CDATA);
129 reconciler.setRepairer(dr, XMLPartitionScanner.XML_CDATA);