2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.corext.template.php;
7 import java.util.Collection;
9 import org.eclipse.jdt.core.ICompilationUnit;
10 import org.eclipse.jdt.core.IJavaElement;
11 import org.eclipse.jdt.core.IMethod;
12 import org.eclipse.jdt.core.JavaModelException;
13 import org.eclipse.jdt.core.Signature;
15 import net.sourceforge.phpdt.internal.corext.template.ContextType;
16 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
17 import net.sourceforge.phpdt.internal.corext.template.TemplateVariable;
20 * A context type for java code.
22 public class PHPContextType extends CompilationUnitContextType {
24 protected static class Array extends TemplateVariable {
26 super(JavaTemplateMessages.getString("JavaContextType.variable.name.array"), JavaTemplateMessages.getString("JavaContextType.variable.description.array")); //$NON-NLS-1$ //$NON-NLS-2$
28 public String evaluate(TemplateContext context) {
29 return ((JavaContext) context).guessArray();
33 protected static class ArrayType extends TemplateVariable {
35 super(JavaTemplateMessages.getString("JavaContextType.variable.name.array.type"), JavaTemplateMessages.getString("JavaContextType.variable.description.array.type")); //$NON-NLS-1$ //$NON-NLS-2$
37 public String evaluate(TemplateContext context) {
38 return ((JavaContext) context).guessArrayType();
42 protected static class ArrayElement extends TemplateVariable {
43 public ArrayElement() {
44 super(JavaTemplateMessages.getString("JavaContextType.variable.name.array.element"), JavaTemplateMessages.getString("JavaContextType.variable.description.array.element")); //$NON-NLS-1$ //$NON-NLS-2$
46 public String evaluate(TemplateContext context) {
47 return ((JavaContext) context).guessArrayElement();
51 protected static class Index extends TemplateVariable {
53 super(JavaTemplateMessages.getString("JavaContextType.variable.name.index"), JavaTemplateMessages.getString("JavaContextType.variable.description.index")); //$NON-NLS-1$ //$NON-NLS-2$
55 public String evaluate(TemplateContext context) {
56 return ((JavaContext) context).getIndex();
60 protected static class Collection extends TemplateVariable {
62 super(JavaTemplateMessages.getString("JavaContextType.variable.name.collection"), JavaTemplateMessages.getString("JavaContextType.variable.description.collection")); //$NON-NLS-1$ //$NON-NLS-2$
64 public String evaluate(TemplateContext context) {
65 return ((JavaContext) context).guessCollection();
69 protected static class Iterator extends TemplateVariable {
71 super(JavaTemplateMessages.getString("JavaContextType.variable.name.iterator"), JavaTemplateMessages.getString("JavaContextType.variable.description.iterator")); //$NON-NLS-1$ //$NON-NLS-2$
73 public String evaluate(TemplateContext context) {
74 return ((JavaContext) context).getIterator();
82 * Creates a java context type.
84 public PHPContextType() {
85 super("php"); //$NON-NLS-1$
88 addVariable(new GlobalVariables.Cursor());
89 addVariable(new GlobalVariables.Dollar());
90 addVariable(new GlobalVariables.Date());
91 addVariable(new GlobalVariables.Time());
92 addVariable(new GlobalVariables.User());
95 /* addVariable(new File());
96 addVariable(new ReturnType());
97 addVariable(new Method());
98 addVariable(new Type());
99 addVariable(new Package());
100 addVariable(new Project());
101 addVariable(new Arguments());
104 addVariable(new Array());
105 addVariable(new ArrayType());
106 addVariable(new ArrayElement());
107 addVariable(new Index());
108 addVariable(new Iterator());
109 addVariable(new Collection());*/
113 * @see ContextType#createContext()
115 public TemplateContext createContext() {
116 return new PHPUnitContext(this, fDocument, fPosition); //, fCompilationUnit);