2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template.php;
7 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
10 * A context type for java code.
12 public class PHPContextType extends CompilationUnitContextType {
14 protected static class Array extends TemplateVariable {
16 super(JavaTemplateMessages.getString("JavaContextType.variable.name.array"), JavaTemplateMessages.getString("JavaContextType.variable.description.array")); //$NON-NLS-1$ //$NON-NLS-2$
18 public String evaluate(TemplateContext context) {
19 return ((JavaContext) context).guessArray();
23 protected static class ArrayType extends TemplateVariable {
25 super(JavaTemplateMessages.getString("JavaContextType.variable.name.array.type"), JavaTemplateMessages.getString("JavaContextType.variable.description.array.type")); //$NON-NLS-1$ //$NON-NLS-2$
27 public String evaluate(TemplateContext context) {
28 return ((JavaContext) context).guessArrayType();
32 protected static class ArrayElement extends TemplateVariable {
33 public ArrayElement() {
34 super(JavaTemplateMessages.getString("JavaContextType.variable.name.array.element"), JavaTemplateMessages.getString("JavaContextType.variable.description.array.element")); //$NON-NLS-1$ //$NON-NLS-2$
36 public String evaluate(TemplateContext context) {
37 return ((JavaContext) context).guessArrayElement();
41 protected static class Index extends TemplateVariable {
43 super(JavaTemplateMessages.getString("JavaContextType.variable.name.index"), JavaTemplateMessages.getString("JavaContextType.variable.description.index")); //$NON-NLS-1$ //$NON-NLS-2$
45 public String evaluate(TemplateContext context) {
46 return ((JavaContext) context).getIndex();
50 protected static class Collection extends TemplateVariable {
52 super(JavaTemplateMessages.getString("JavaContextType.variable.name.collection"), JavaTemplateMessages.getString("JavaContextType.variable.description.collection")); //$NON-NLS-1$ //$NON-NLS-2$
54 public String evaluate(TemplateContext context) {
55 return ((JavaContext) context).guessCollection();
59 protected static class Iterator extends TemplateVariable {
61 super(JavaTemplateMessages.getString("JavaContextType.variable.name.iterator"), JavaTemplateMessages.getString("JavaContextType.variable.description.iterator")); //$NON-NLS-1$ //$NON-NLS-2$
63 public String evaluate(TemplateContext context) {
64 return ((JavaContext) context).getIterator();
72 * Creates a java context type.
74 public PHPContextType() {
75 super("php"); //$NON-NLS-1$
78 addVariable(new GlobalVariables.Cursor());
79 addVariable(new GlobalVariables.Dollar());
80 addVariable(new GlobalVariables.Date());
81 addVariable(new GlobalVariables.Year());
82 addVariable(new GlobalVariables.Time());
83 addVariable(new GlobalVariables.User());
86 /* addVariable(new File());
87 addVariable(new ReturnType());
88 addVariable(new Method());
89 addVariable(new Type());
90 addVariable(new Package());
91 addVariable(new Project());
92 addVariable(new Arguments());
95 addVariable(new Array());
96 addVariable(new ArrayType());
97 addVariable(new ArrayElement());
98 addVariable(new Index());
99 addVariable(new Iterator());
100 addVariable(new Collection());*/
104 * @see ContextType#createContext()
106 public TemplateContext createContext() {
107 return new PHPUnitContext(this, fDocument, fOffset); //, fCompilationUnit);