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;
11 import org.eclipse.jface.text.IDocument;
12 import org.eclipse.jface.text.templates.GlobalTemplateVariables;
13 import org.eclipse.jface.text.templates.TemplateException;
14 import org.eclipse.jface.text.templates.TemplateVariable;
17 * A context type for javadoc.
19 public class HTMLContextType extends CompilationUnitContextType {
22 * Creates a java context type.
24 public HTMLContextType() {
25 super("html"); //$NON-NLS-1$
28 addResolver(new GlobalTemplateVariables.Cursor());
29 addResolver(new GlobalTemplateVariables.WordSelection());
30 addResolver(new GlobalTemplateVariables.LineSelection());
31 addResolver(new GlobalTemplateVariables.Dollar());
32 addResolver(new GlobalTemplateVariables.Date());
33 addResolver(new GlobalTemplateVariables.Year());
34 addResolver(new GlobalTemplateVariables.Time());
35 addResolver(new GlobalTemplateVariables.User());
37 addResolver(new File());
41 * @see ContextType#createContext()
43 public CompilationUnitContext createContext(IDocument document, int offset,
44 int length, ICompilationUnit compilationUnit) {
45 return new HTMLUnitContext(this, document, offset, length,
52 * @see net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType#createContext(org.eclipse.jface.text.IDocument,
53 * int, int, net.sourceforge.phpdt.core.ICompilationUnit)
55 // public CompilationUnitContext createContext(IDocument document, int
56 // offset, int length, ICompilationUnit compilationUnit) {
57 // return new JavaDocContext(this, document, offset, length,
63 * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
65 protected void validateVariables(TemplateVariable[] variables)
66 throws TemplateException {
67 // check for multiple cursor variables
68 for (int i = 0; i < variables.length; i++) {
69 TemplateVariable var = variables[i];
70 if (var.getType().equals(GlobalTemplateVariables.Cursor.NAME)) {
71 if (var.getOffsets().length > 1) {
72 throw new TemplateException(
74 .getString("ContextType.error.multiple.cursor.variables")); //$NON-NLS-1$