//import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType.File;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
/**
* A context type for javadoc.
super("html"); //$NON-NLS-1$
// global
-// addVariable(new GlobalVariables.Cursor());
-// addVariable(new GlobalVariables.Dollar());
-// addVariable(new GlobalVariables.Date());
-// addVariable(new GlobalVariables.Year());
-// addVariable(new GlobalVariables.Time());
-// addVariable(new GlobalVariables.User());
+ addResolver(new GlobalTemplateVariables.Cursor());
+ addResolver(new GlobalTemplateVariables.WordSelection());
+ addResolver(new GlobalTemplateVariables.LineSelection());
+ addResolver(new GlobalTemplateVariables.Dollar());
+ addResolver(new GlobalTemplateVariables.Date());
+ addResolver(new GlobalTemplateVariables.Year());
+ addResolver(new GlobalTemplateVariables.Time());
+ addResolver(new GlobalTemplateVariables.User());
- // compilation unit
- /* addVariable(new File());
- addVariable(new Method());
- addVariable(new ReturnType());
- addVariable(new Arguments());
- addVariable(new Type());
- addVariable(new Package());
- addVariable(new Project());*/
+ addResolver(new File());
}
/*
// public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
// return new JavaDocContext(this, document, offset, length, compilationUnit);
// }
+ /* (non-Javadoc)
+ * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
+ */
+ protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
+ // check for multiple cursor variables
+ for (int i= 0; i < variables.length; i++) {
+ TemplateVariable var= variables[i];
+ if (var.getType().equals(GlobalTemplateVariables.Cursor.NAME)) {
+ if (var.getOffsets().length > 1) {
+ throw new TemplateException(JavaTemplateMessages.getString("ContextType.error.multiple.cursor.variables")); //$NON-NLS-1$
+ }
+ }
+ }
+ }
}