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;
28 * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
30 public class HTMLConfiguration extends XMLConfiguration {
31 private SmartyTagScanner smartyTagScanner;
32 public HTMLConfiguration(XMLTextTools tools) {
36 public HTMLConfiguration(XMLTextTools tools, ITextEditor editor) {
38 Map tokens = tools.getTokens();
39 smartyTagScanner = new SmartyTagScanner(tokens);
42 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
43 ContentAssistant assistant = new ContentAssistant();
44 assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
46 IContentAssistProcessor processor = new HTMLCompletionProcessor();
47 assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
48 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_TAG);
49 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_PI);
50 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_COMMENT);
51 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_DECL);
52 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_TAG);
53 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_ATTRIBUTE);
54 assistant.setContentAssistProcessor(processor, XMLPartitionScanner.XML_CDATA);
56 assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
57 assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
62 * Returns a scanner which is configured to scan XML text.
64 * @return an XML text scanner
66 public SmartyTagScanner getSmartyScanner() {
67 return smartyTagScanner;
70 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
72 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
73 PresentationReconciler reconciler = new PresentationReconciler();
75 DefaultDamagerRepairer dr;
77 dr = new DefaultDamagerRepairer(getSmartyScanner());
78 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
79 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
81 dr = new DefaultDamagerRepairer(xmlTextTools.getDTDTextScanner());
82 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL);
83 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL);
85 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLPIScanner());
87 reconciler.setDamager(dr, XMLPartitionScanner.XML_PI);
88 reconciler.setRepairer(dr, XMLPartitionScanner.XML_PI);
89 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_PI);
90 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_PI);
92 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCommentScanner());
94 reconciler.setDamager(dr, XMLPartitionScanner.XML_COMMENT);
95 reconciler.setRepairer(dr, XMLPartitionScanner.XML_COMMENT);
96 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_COMMENT);
97 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_COMMENT);
99 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLDeclScanner());
101 reconciler.setDamager(dr, XMLPartitionScanner.XML_DECL);
102 reconciler.setRepairer(dr, XMLPartitionScanner.XML_DECL);
103 reconciler.setDamager(dr, XMLPartitionScanner.DTD_INTERNAL_DECL);
104 reconciler.setRepairer(dr, XMLPartitionScanner.DTD_INTERNAL_DECL);
106 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLTagScanner());
108 reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
109 reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
111 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLAttributeScanner());
113 reconciler.setDamager(dr, XMLPartitionScanner.XML_ATTRIBUTE);
114 reconciler.setRepairer(dr, XMLPartitionScanner.XML_ATTRIBUTE);
116 dr = new DefaultDamagerRepairer(xmlTextTools.getXMLCDATAScanner());
118 reconciler.setDamager(dr, XMLPartitionScanner.XML_CDATA);
119 reconciler.setRepairer(dr, XMLPartitionScanner.XML_CDATA);