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.Time());
82 addVariable(new GlobalVariables.User());
85 /* addVariable(new File());
86 addVariable(new ReturnType());
87 addVariable(new Method());
88 addVariable(new Type());
89 addVariable(new Package());
90 addVariable(new Project());
91 addVariable(new Arguments());
94 addVariable(new Array());
95 addVariable(new ArrayType());
96 addVariable(new ArrayElement());
97 addVariable(new Index());
98 addVariable(new Iterator());
99 addVariable(new Collection());*/
103 * @see ContextType#createContext()
105 public TemplateContext createContext() {
106 return new PHPUnitContext(this, fDocument, fPosition); //, fCompilationUnit);