2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template.php;
7 //import net.sourceforge.phpdt.core.ICompilationUnit;
9 import net.sourceforge.phpdt.core.ICompilationUnit;
10 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType.File;
12 import org.eclipse.jface.text.IDocument;
13 import org.eclipse.jface.text.templates.GlobalTemplateVariables;
14 import org.eclipse.jface.text.templates.TemplateException;
15 import org.eclipse.jface.text.templates.TemplateVariable;
18 * A context type for javadoc.
20 public class HTMLContextType extends CompilationUnitContextType {
23 * Creates a java context type.
25 public HTMLContextType() {
26 super("html"); //$NON-NLS-1$
29 addResolver(new GlobalTemplateVariables.Cursor());
30 addResolver(new GlobalTemplateVariables.WordSelection());
31 addResolver(new GlobalTemplateVariables.LineSelection());
32 addResolver(new GlobalTemplateVariables.Dollar());
33 addResolver(new GlobalTemplateVariables.Date());
34 addResolver(new GlobalTemplateVariables.Year());
35 addResolver(new GlobalTemplateVariables.Time());
36 addResolver(new GlobalTemplateVariables.User());
38 addResolver(new File());
42 * @see ContextType#createContext()
44 public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
45 return new HTMLUnitContext(this, document, offset, length, compilationUnit);
48 * @see net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, net.sourceforge.phpdt.core.ICompilationUnit)
50 // public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
51 // return new JavaDocContext(this, document, offset, length, compilationUnit);
54 * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
56 protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
57 // check for multiple cursor variables
58 for (int i= 0; i < variables.length; i++) {
59 TemplateVariable var= variables[i];
60 if (var.getType().equals(GlobalTemplateVariables.Cursor.NAME)) {
61 if (var.getOffsets().length > 1) {
62 throw new TemplateException(JavaTemplateMessages.getString("ContextType.error.multiple.cursor.variables")); //$NON-NLS-1$